From 6cf839db3ef49b2c60941dba8f0e6b43e21f53da Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 19 Jun 2014 22:41:36 +1000 Subject: [PATCH] ktree - before end case reversed --- pool/base.php | 20 +++++++++---------- pool/db.php | 14 ++++++-------- pool/page.php | 6 +++--- pool/page_help.php | 6 +++--- pool/page_index.php | 6 +++--- pool/page_payments.php | 8 ++++---- pool/page_reg.php | 8 ++++---- pool/page_worker.php | 44 ++++++++++++++++++++++++++++++++++++++++++ pool/prime.php | 14 +++++++------- src/ktree.c | 2 +- 10 files changed, 84 insertions(+), 44 deletions(-) create mode 100644 pool/page_worker.php diff --git a/pool/base.php b/pool/base.php index 01a60961..8903293d 100644 --- a/pool/base.php +++ b/pool/base.php @@ -102,14 +102,14 @@ function safetext($txt, $len = 1024) return $res; } # -function dbd($data) +function dbd($data, $user) { return "
Web site is currently down
"; } # 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; } # ?> diff --git a/pool/db.php b/pool/db.php index d9339206..ae30369d 100644 --- a/pool/db.php +++ b/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) diff --git a/pool/page.php b/pool/page.php index dec1ba05..02258977 100644 --- a/pool/page.php +++ b/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) diff --git a/pool/page_help.php b/pool/page_help.php index 63b2c3d0..85a0c605 100644 --- a/pool/page_help.php +++ b/pool/page_help.php @@ -1,13 +1,13 @@ HelplessHelpless'; } # -function show_help($menu, $name) +function show_help($menu, $name, $user) { - gopage(NULL, 'dohelp', $menu, $name); + gopage(NULL, 'dohelp', $menu, $name, $user); } # ?> diff --git a/pool/page_index.php b/pool/page_index.php index c6b4aaf9..e39ad7d9 100644 --- a/pool/page_index.php +++ b/pool/page_index.php @@ -1,6 +1,6 @@ CKPool @@ -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); } # ?> diff --git a/pool/page_payments.php b/pool/page_payments.php index 0b9df450..2fa4c847 100644 --- a/pool/page_payments.php +++ b/pool/page_payments.php @@ -1,10 +1,10 @@ Payments'; - $rep = getPayments(); + $rep = getPayments($user); $ans = repDecode($rep); $pg .= "\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); } # ?> diff --git a/pool/page_reg.php b/pool/page_reg.php index 81dbf196..5a97f3a4 100644 --- a/pool/page_reg.php +++ b/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); } # ?> diff --git a/pool/page_worker.php b/pool/page_worker.php new file mode 100644 index 00000000..4a730a27 --- /dev/null +++ b/pool/page_worker.php @@ -0,0 +1,44 @@ +Workers'; + + $rep = getWorkers($user); + $ans = repDecode($rep); + + $pg .= "
\n"; + $pg .= ""; + $pg .= ""; + $pg .= ""; + $pg .= ""; + $pg .= ""; + $pg .= "\n"; + if ($ans['STATUS'] == 'ok') + { + $count = $ans['rows']; + for ($i = 0; $i < $count; $i++) + { + if (($i % 2) == 0) + $row = 'even'; + else + $row = 'odd'; + + $pg .= ""; + $pg .= ''; + $pg .= ''; + $pg .= ''; + $pg .= "\n"; + } + } + $pg .= "
NameDifficultyIdle NotificationsIdle Notification Time
'.$ans['paydate'.$i].''.$ans['payaddress'.$i].''.btcfmt($ans['amount'.$i]).'
\n"; + + return $pg; +} +# +function show_workers($menu, $name, $user) +{ + gopage(NULL, 'doworkers', $menu, $name, $user); +} +# +?> diff --git a/pool/prime.php b/pool/prime.php index a3418fe4..7066cc99 100644 --- a/pool/prime.php +++ b/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); } } # diff --git a/src/ktree.c b/src/ktree.c index ccb723f1..f899e2a8 100644 --- a/src/ktree.c +++ b/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);