Browse Source

php - make the share age function reusable

master
kanoi 10 years ago
parent
commit
23f0b77f33
  1. 37
      pool/base.php
  2. 32
      pool/page_workers.php

37
pool/base.php

@ -18,6 +18,41 @@ function adddbg($str)
} }
} }
# #
function howlongago($sec)
{
if ($sec < 60)
$des = $sec.'s';
else
{
$sec = round($sec/60);
if ($sec < 60)
$des = $sec.'min';
else
{
$sec = round($sec/60);
if ($sec < 24)
{
$des = $sec.'hr';
if ($sec != 1)
$des .= 's';
}
else
{
$sec = round($sec/24);
if ($sec < 9999)
{
$des = $sec.'day';
if ($sec != 1)
$des .= 's';
}
else
$des = 'never';
}
}
}
return $des;
}
#
function btcfmt($amt) function btcfmt($amt)
{ {
$amt /= 100000000; $amt /= 100000000;
@ -240,7 +275,7 @@ function validUserPass($user, $pass)
{ {
$rep = checkPass($user, $pass); $rep = checkPass($user, $pass);
if ($rep != null) if ($rep != null)
$ans = repDecode($rep); $ans = repDecode($rep);
usleep(100000); // Max 10x per second usleep(100000); // Max 10x per second
if ($rep != null && $ans['STATUS'] == 'ok') if ($rep != null && $ans['STATUS'] == 'ok')
{ {

32
pool/page_workers.php

@ -42,37 +42,7 @@ function workuser($data, $user, &$offset, &$totshare, &$totdiff,
$ld = '&nbsp;'; $ld = '&nbsp;';
$pg .= "<td class=dr>$ld</td>"; $pg .= "<td class=dr>$ld</td>";
if ($lst < 60) $pg .= '<td class=dr>'.howlongago($lst).'</td>';
$lstdes = $lst.'s';
else
{
$lst = round($lst/60);
if ($lst < 60)
$lstdes = $lst.'min';
else
{
$lst = round($lst/60);
if ($lst < 24)
{
$lstdes = $lst.'hr';
if ($lst != 1)
$lstdes .= 's';
}
else
{
$lst = round($lst/24);
if ($lst < 9999)
{
$lstdes = $lst.'day';
if ($lst != 1)
$lstdes .= 's';
}
else
$lstdes = 'never';
}
}
}
$pg .= "<td class=dr>$lstdes</td>";
$shareacc = number_format($ans['w_shareacc:'.$i], 0); $shareacc = number_format($ans['w_shareacc:'.$i], 0);
$totshare += $ans['w_shareacc:'.$i]; $totshare += $ans['w_shareacc:'.$i];

Loading…
Cancel
Save