Browse Source

Merge branch 'master' of bitbucket.org:ckolivas/ckpool

master
Con Kolivas 11 years ago
parent
commit
16b108f503
  1. 20
      pool/base.php
  2. 14
      pool/db.php
  3. 6
      pool/page.php
  4. 6
      pool/page_help.php
  5. 6
      pool/page_index.php
  6. 8
      pool/page_payments.php
  7. 8
      pool/page_reg.php
  8. 44
      pool/page_worker.php
  9. 14
      pool/prime.php
  10. 6
      src/ckdb.c
  11. 2
      src/ktree.c

20
pool/base.php

@ -102,14 +102,14 @@ function safetext($txt, $len = 1024)
return $res;
}
#
function dbd($data)
function dbd($data, $user)
{
return "<font color=red size=+10><br>Web site is currently down</font>";
}
#
function dbdown()
{
gopage(NULL, 'dbd', NULL, '', true, false);
gopage(NULL, 'dbd', NULL, '', false, true, false);
}
#
function f404($data)
@ -119,10 +119,10 @@ function f404($data)
#
function do404()
{
gopage(NULL, 'f404', NULL, '', true, false);
gopage(NULL, 'f404', NULL, '', false, true, false);
}
#
function showPage($page, $menu, $name)
function showPage($page, $menu, $name, $user)
{
# If you are doing development, use without '@'
# Then switch to '@' when finished
@ -131,14 +131,14 @@ function showPage($page, $menu, $name)
$fun = 'show_' . $page;
if (function_exists($fun))
$fun($menu, $name);
$fun($menu, $name, $user);
else
do404();
}
#
function showIndex()
{
showPage('index', NULL, '');
showPage('index', NULL, '', false);
}
#
function offline()
@ -147,7 +147,7 @@ function offline()
{
$ip = $_SERVER['REMOTE_ADDR'];
if ($ip != '192.168.7.74')
gopage(NULL, file_get_contents('./maintenance.txt'), NULL, '', false, false);
gopage(NULL, file_get_contents('./maintenance.txt'), NULL, '', false, false, false, false);
}
}
#
@ -260,10 +260,8 @@ function validate()
function loggedIn()
{
list($who, $whoid) = validate();
if ($who == false)
return false;
return true;
// false if not logged in
return $who;
}
#
?>

14
pool/db.php

@ -102,12 +102,11 @@ function checkpass($user, $pass)
return $rep;
}
#
function getWorkers()
function getWorkers($user)
{
list($who, $whoid) = validate();
if ($who == false)
if ($user == false)
showIndex();
$flds = array('username' => $who);
$flds = array('username' => $user);
$msg = msgEncode('workers', 'work', $flds);
$rep = sendsockreply('getworkers', $msg);
if (!$rep)
@ -115,12 +114,11 @@ function getWorkers()
return $rep;
}
#
function getPayments()
function getPayments($user)
{
list($who, $whoid) = validate();
if ($who == false)
if ($user == false)
showIndex();
$flds = array('username' => $who);
$flds = array('username' => $user);
$msg = msgEncode('payments', 'pay', $flds);
$rep = sendsockreply('getpayments', $msg);
if (!$rep)

6
pool/page.php

@ -333,7 +333,7 @@ function pgfoot()
return $foot;
}
#
function gopage($data, $page, $menu, $name, $ispage = true, $dotop = true, $douser = true)
function gopage($data, $page, $menu, $name, $user, $ispage = true, $dotop = true, $douser = true)
{
global $dbg;
global $page_scripts;
@ -347,7 +347,7 @@ function gopage($data, $page, $menu, $name, $ispage = true, $dotop = true, $dous
$pg = '';
if ($ispage == true)
$pg .= $page($data);
$pg .= $page($data, $user);
else
$pg .= $page;
@ -355,7 +355,7 @@ function gopage($data, $page, $menu, $name, $ispage = true, $dotop = true, $dous
// unset($_SESSION['logkey']);
$head = pghead($script_marker, $name);
$body = pgbody($menu, $dotop, $name, $douser);
$body = pgbody($menu, $dotop, $user, $douser);
$foot = pgfoot();
if ($dbg === true)

6
pool/page_help.php

@ -1,13 +1,13 @@
<?php
#
function dohelp($data)
function dohelp($data, $user)
{
return '<h1>Helpless</h1>Helpless';
}
#
function show_help($menu, $name)
function show_help($menu, $name, $user)
{
gopage(NULL, 'dohelp', $menu, $name);
gopage(NULL, 'dohelp', $menu, $name, $user);
}
#
?>

6
pool/page_index.php

@ -1,6 +1,6 @@
<?php
#
function doindex($data)
function doindex($data, $user)
{
$pg = '
<h1>CKPool</h1>
@ -9,9 +9,9 @@ Welcome to CKPool the bestest mostest gnarliest poolest in the ...... south.
return $pg;
}
#
function show_index($menu, $name)
function show_index($menu, $name, $user)
{
gopage(NULL, 'doindex', $menu, $name);
gopage(NULL, 'doindex', $menu, $name, $user);
}
#
?>

8
pool/page_payments.php

@ -1,10 +1,10 @@
<?php
#
function dopayments($data)
function dopayments($data, $user)
{
$pg = '<h1>Payments</h1>';
$rep = getPayments();
$rep = getPayments($user);
$ans = repDecode($rep);
$pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
@ -35,9 +35,9 @@ function dopayments($data)
return $pg;
}
#
function show_payments($menu, $name)
function show_payments($menu, $name, $user)
{
gopage(NULL, 'dopayments', $menu, $name);
gopage(NULL, 'dopayments', $menu, $name, $user);
}
#
?>

8
pool/page_reg.php

@ -2,7 +2,7 @@
#
include_once('socket.php');
#
function doreg($data)
function doreg($data, $u)
{
if (isset($data['user']))
$user = htmlspecialchars($data['user']);
@ -72,7 +72,7 @@ function safepass($pass)
return true;
}
#
function show_reg($menu, $name)
function show_reg($menu, $name, $u)
{
$user = getparam('user', false);
$mail = getparam('mail', false);
@ -117,12 +117,12 @@ function show_reg($menu, $name)
$ans = repDecode($rep);
if ($ans['STATUS'] == 'ok')
gopage($data, 'doreg2', $menu, $name, true, true, false);
gopage($data, 'doreg2', $menu, $name, $u, true, true, false);
else
$data['error'] = "Invalid details";
}
gopage($data, 'doreg', $menu, $name, true, true, false);
gopage($data, 'doreg', $menu, $name, $u, true, true, false);
}
#
?>

44
pool/page_worker.php

@ -0,0 +1,44 @@
<?php
#
function doworkers($data, $user)
{
$pg = '<h1>Workers</h1>';
$rep = getWorkers($user);
$ans = repDecode($rep);
$pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
$pg .= "<tr class=title>";
$pg .= "<td class=dl>Name</td>";
$pg .= "<td class=dl>Difficulty</td>";
$pg .= "<td class=dr>Idle Notifications</td>";
$pg .= "<td class=dr>Idle Notification Time</td>";
$pg .= "</tr>\n";
if ($ans['STATUS'] == 'ok')
{
$count = $ans['rows'];
for ($i = 0; $i < $count; $i++)
{
if (($i % 2) == 0)
$row = 'even';
else
$row = 'odd';
$pg .= "<tr class=$row>";
$pg .= '<td class=dl>'.$ans['paydate'.$i].'</td>';
$pg .= '<td class=dl>'.$ans['payaddress'.$i].'</td>';
$pg .= '<td class=dr>'.btcfmt($ans['amount'.$i]).'</td>';
$pg .= "</tr>\n";
}
}
$pg .= "</table>\n";
return $pg;
}
#
function show_workers($menu, $name, $user)
{
gopage(NULL, 'doworkers', $menu, $name, $user);
}
#
?>

14
pool/prime.php

@ -3,7 +3,7 @@
include_once('param.php');
include_once('base.php');
#
function process($p)
function process($p, $user)
{
$menu = array(
'Home' => array(
@ -34,26 +34,26 @@ function process($p)
}
if ($page === '')
showPage('index', $menu, '');
showPage('index', $menu, '', $user);
else
showPage($page, $menu, $n);
showPage($page, $menu, $n, $user);
}
#
function check()
{
tryLogInOut();
$in = loggedIn();
if ($in == false)
$who = loggedIn();
if ($who === false)
{
if (requestRegister() == true)
showPage('reg', NULL, '');
showPage('reg', NULL, '', $who);
else
showIndex();
}
else
{
$p = getparam('k', true);
process($p);
process($p, $who);
}
}
#

6
src/ckdb.c

@ -4089,7 +4089,7 @@ static enum cmd_values breakdown(char *buf, int *which_cmds, char *cmd, char *id
}
next = data;
if (strncmp(next, JSON_TRANSFER, JSON_TRANSFER_LEN) == 0) {
if (next && strncmp(next, JSON_TRANSFER, JSON_TRANSFER_LEN) == 0) {
json_t *json_data;
json_error_t err_val;
void *json_iter;
@ -4182,7 +4182,7 @@ static enum cmd_values breakdown(char *buf, int *which_cmds, char *cmd, char *id
K_WLOCK(transfer_list);
while (next && *next) {
data = next;
next = strchr(data, 0x02);
next = strchr(data, FLDSEP);
if (next)
*(next++) = '\0';
@ -4208,7 +4208,7 @@ static enum cmd_values breakdown(char *buf, int *which_cmds, char *cmd, char *id
}
K_WUNLOCK(transfer_list);
}
matane:
free(cmdptr);
return cmds[*which_cmds].cmd_val;
}

2
src/ktree.c

@ -607,7 +607,7 @@ K_ITEM *find_before_in_ktree(K_TREE *ktree, K_ITEM *data, double (*cmp_funct)(K_
{
if (old)
{
if (oldcmp > 0.0)
if (oldcmp < 0.0)
{
*ctx = old;
return(old->data);

Loading…
Cancel
Save