Browse Source

php - add an admin events page

master
kanoi 9 years ago
parent
commit
d85e0bafec
  1. 8
      pool/base.php
  2. 5
      pool/db.php
  3. 153
      pool/page_events.php
  4. 4
      pool/page_ips.php
  5. 1
      pool/prime.php

8
pool/base.php

@ -343,6 +343,14 @@ function safetext($txt, $len = 1024)
return $res;
}
#
function isans($ans, $fld)
{
if (isset($ans[$fld]))
return $ans[$fld];
else
return ' ';
}
#
function dbd($data, $user)
{
return "<span class=alert><br>Database is reloading, mining is all OK</span>";

5
pool/db.php

@ -496,13 +496,12 @@ function getOpts($user, $optlist)
return repDecode($rep);
}
#
function eventIPs($user)
function eventCmd($user, $flds)
{
if ($user == false)
showIndex();
$flds = array('action' => 'ips');
$msg = msgEncode('events', 'events', $flds, $user);
$rep = sendsockreply('eventIPs', $msg);
$rep = sendsockreply('eventCmd', $msg);
if (!$rep)
dbdown();
return repDecode($rep);

153
pool/page_events.php

@ -0,0 +1,153 @@
<?php
#
function doevents($data, $user)
{
$pg = '<h1>Event Information</h1>';
$wh = getparam('what', false);
if (nuem($wh))
$wh = '';
$pg = '<br>'.makeForm('events')."
What: <input type=text name=what size=10 value='$wh'>
&nbsp;<input type=submit name=Get value=Get>
</form>";
if ($wh == 'settings')
{
$ans = eventCmd($user, array('action' => 'settings'));
$other = array('event_limits_hash_lifetime',
'ovent_limits_ipc_factor');
$pg .= "<br><br><table callpadding=0 cellspacing=0 border=0>\n";
$pg .= '<thead><tr class=title>';
$pg .= '<td class=dr>#</td>';
$pg .= '<td class=dl>Name</td>';
$pg .= '<td class=dr>Value</td>';
$pg .= "</tr></thead>\n";
if ($ans['STATUS'] == 'ok')
{
$pg .= '<tbody>';
$i = 0;
foreach ($other as $name)
{
if (($i % 2) == 0)
$row = 'even';
else
$row = 'odd';
$i++;
$pg .= "<tr class=$row>";
$pg .= "<td class=dr>$i</td>";
$pg .= "<td class=dl>$name</td>";
$pg .= '<td class=dr>'.$ans[$name].'</td>';
$pg .= "</tr>\n";
}
$pg .= '</tbody>';
}
$pg .= "</table>\n";
$flds = array('enabled' => 'Ena',
'user_low_time' => 'UserLo',
'user_low_time_limit' => 'UserLoLim',
'user_hi_time' => 'UserHi',
'user_hi_time_limit' => 'UserHiLim',
'ip_low_time' => 'IPLo',
'ip_low_time_limit' => 'IPLoLim',
'ip_hi_time' => 'IPHi',
'ip_hi_time_limit' => 'IPHiLim',
'lifetime' => 'Life');
$pg .= "<br><br><table callpadding=0 cellspacing=0 border=0>\n";
$pg .= '<thead><tr class=title>';
$pg .= '<td class=dr>#</td>';
$pg .= '<td class=dl>Name</td>';
foreach ($flds as $row => $nam)
$pg .= "<td class=dr>$nam</td>";
$pg .= "</tr></thead>\n";
if ($ans['STATUS'] == 'ok')
{
$pg .= '<tbody>';
$names = array();
foreach ($ans as $name => $value)
{
$ex = explode('_', $name, 2);
if (count($ex) == 2 && isset($flds[$ex[1]]))
$names[$ex[0]] = 1;
}
$i = 0;
foreach ($names as $name => $one)
{
if (($i % 2) == 0)
$row = 'even';
else
$row = 'odd';
$i++;
$pg .= "<tr class=$row>";
$pg .= "<td class=dr>$i</td>";
$pg .= "<td class=dl>$name</td>";
foreach ($flds as $fld => $nam)
$pg .= '<td class=dr>'.$ans[$name.'_'.$fld].'</td>';
$pg .= "</tr>\n";
}
$pg .= '</tbody>';
}
$pg .= "</table>\n";
}
if ($wh == 'all' || $wh == 'user' || $wh == 'ip' || $wh == 'ipc' || $wh == 'hash')
{
$ans = eventCmd($user, array('action' => 'events', 'list' => $wh));
$pg .= "<br><br><table callpadding=0 cellspacing=0 border=0>\n";
$pg .= '<thead><tr class=title>';
$pg .= '<td class=dr>#</td>';
$pg .= '<td class=dl>List</td>';
$pg .= '<td class=dr>ID</td>';
$pg .= '<td class=dr>User</td>';
$pg .= '<td class=dr>IP</td>';
$pg .= '<td class=dr>IPc</td>';
$pg .= '<td class=dr>Hash</td>';
$pg .= '<td class=dr>UTC</td>';
$pg .= "</tr></thead>\n";
if ($ans['STATUS'] == 'ok')
{
$pg .= '<tbody>';
$count = $ans['rows'];
for ($i = 0; $i < $count; $i++)
{
if (($i % 2) == 0)
$row = 'even';
else
$row = 'odd';
$j = $i+1;
$pg .= "<tr class=$row>";
$pg .= "<td class=dr>$j</td>";
$pg .= '<td class=dl>'.$ans['list:'.$i].'</td>';
$pg .= '<td class=dr>'.$ans['id:'.$i].'</td>';
$pg .= '<td class=dr>'.$ans['user:'.$i].'</td>';
$pg .= '<td class=dr>'.isans($ans, 'ip:'.$i).'</td>';
$pg .= '<td class=dr>'.isans($ans, 'ipc:'.$i).'</td>';
$pg .= '<td class=dr>'.isans($ans, 'hash:'.$i).'</td>';
$pg .= '<td class=dr>'.gmdate('j/M H:i:s',$ans['createdate:'.$i]).'</td>';
$pg .= "</tr>\n";
}
$pg .= '</tbody>';
}
}
return $pg;
}
#
function show_events($info, $page, $menu, $name, $user)
{
gopage($info, NULL, 'doevents', $page, $menu, $name, $user);
}
#
?>

4
pool/page_ips.php

@ -4,7 +4,7 @@ function doips($data, $user)
{
$pg = '<h1>Event IP Information</h1>';
$ans = eventIPs($user);
$ans = eventCmd($user, array('action' => 'ips'));
$pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
$pg .= '<thead><tr class=title>';
@ -16,7 +16,7 @@ function doips($data, $user)
$pg .= '<td class=dr>Lifetime</td>';
$pg .= '<td class=dr>Log</td>';
$pg .= '<td class=dl>Desc</td>';
$pg .= '<td class=dr>CreateDate</td>';
$pg .= '<td class=dr>UTC</td>';
$pg .= "</tr></thead>\n";
if ($ans['STATUS'] == 'ok')
{

1
pool/prime.php

@ -26,6 +26,7 @@ function process($p, $user, $menu)
$menu['Admin']['PPLNS'] = 'pplns';
$menu['Admin']['AllWork'] = 'allwork';
$menu['Admin']['IPS'] = 'ips';
$menu['Admin']['Events'] = 'events';
}
bp:
$page = '';

Loading…
Cancel
Save