Browse Source

ktree - before end case reversed

master
kanoi 11 years ago
parent
commit
6cf839db3e
  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. 2
      src/ktree.c

20
pool/base.php

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

14
pool/db.php

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

6
pool/page.php

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

6
pool/page_help.php

@ -1,13 +1,13 @@
<?php <?php
# #
function dohelp($data) function dohelp($data, $user)
{ {
return '<h1>Helpless</h1>Helpless'; 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 <?php
# #
function doindex($data) function doindex($data, $user)
{ {
$pg = ' $pg = '
<h1>CKPool</h1> <h1>CKPool</h1>
@ -9,9 +9,9 @@ Welcome to CKPool the bestest mostest gnarliest poolest in the ...... south.
return $pg; 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 <?php
# #
function dopayments($data) function dopayments($data, $user)
{ {
$pg = '<h1>Payments</h1>'; $pg = '<h1>Payments</h1>';
$rep = getPayments(); $rep = getPayments($user);
$ans = repDecode($rep); $ans = repDecode($rep);
$pg .= "<table callpadding=0 cellspacing=0 border=0>\n"; $pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
@ -35,9 +35,9 @@ function dopayments($data)
return $pg; 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'); include_once('socket.php');
# #
function doreg($data) function doreg($data, $u)
{ {
if (isset($data['user'])) if (isset($data['user']))
$user = htmlspecialchars($data['user']); $user = htmlspecialchars($data['user']);
@ -72,7 +72,7 @@ function safepass($pass)
return true; return true;
} }
# #
function show_reg($menu, $name) function show_reg($menu, $name, $u)
{ {
$user = getparam('user', false); $user = getparam('user', false);
$mail = getparam('mail', false); $mail = getparam('mail', false);
@ -117,12 +117,12 @@ function show_reg($menu, $name)
$ans = repDecode($rep); $ans = repDecode($rep);
if ($ans['STATUS'] == 'ok') if ($ans['STATUS'] == 'ok')
gopage($data, 'doreg2', $menu, $name, true, true, false); gopage($data, 'doreg2', $menu, $name, $u, true, true, false);
else else
$data['error'] = "Invalid details"; $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('param.php');
include_once('base.php'); include_once('base.php');
# #
function process($p) function process($p, $user)
{ {
$menu = array( $menu = array(
'Home' => array( 'Home' => array(
@ -34,26 +34,26 @@ function process($p)
} }
if ($page === '') if ($page === '')
showPage('index', $menu, ''); showPage('index', $menu, '', $user);
else else
showPage($page, $menu, $n); showPage($page, $menu, $n, $user);
} }
# #
function check() function check()
{ {
tryLogInOut(); tryLogInOut();
$in = loggedIn(); $who = loggedIn();
if ($in == false) if ($who === false)
{ {
if (requestRegister() == true) if (requestRegister() == true)
showPage('reg', NULL, ''); showPage('reg', NULL, '', $who);
else else
showIndex(); showIndex();
} }
else else
{ {
$p = getparam('k', true); $p = getparam('k', true);
process($p); process($p, $who);
} }
} }
# #

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 (old)
{ {
if (oldcmp > 0.0) if (oldcmp < 0.0)
{ {
*ctx = old; *ctx = old;
return(old->data); return(old->data);

Loading…
Cancel
Save