Browse Source

php - move repDecode to db.php for most calls

master
kanoi 10 years ago
parent
commit
bded8227fc
  1. 7
      pool/base.php
  2. 23
      pool/db.php
  3. 3
      pool/page_blocks.php
  4. 3
      pool/page_payments.php
  5. 13
      pool/page_reg.php
  6. 3
      pool/page_stats.php
  7. 3
      pool/page_workers.php

7
pool/base.php

@ -192,10 +192,11 @@ include_once('db.php');
# #
function validUserPass($user, $pass) function validUserPass($user, $pass)
{ {
$rep = checkpass($user, $pass); $rep = checkPass($user, $pass);
$ans = repDecode($rep); if ($rep != null)
$ans = repDecode($rep);
usleep(100000); // Max 10x per second usleep(100000); // Max 10x per second
if ($ans['STATUS'] == 'ok') if ($rep != null && $ans['STATUS'] == 'ok')
{ {
$key = 'ckp'.rand(1000000,9999999); $key = 'ckp'.rand(1000000,9999999);
$_SESSION['ckpkey'] = $key; $_SESSION['ckpkey'] = $key;

23
pool/db.php

@ -116,7 +116,7 @@ function homeInfo($user)
return $ans; return $ans;
} }
# #
function checkpass($user, $pass) function checkPass($user, $pass)
{ {
$passhash = myhash($pass); $passhash = myhash($pass);
$flds = array('username' => $user, 'passwordhash' => $passhash); $flds = array('username' => $user, 'passwordhash' => $passhash);
@ -124,7 +124,18 @@ function checkpass($user, $pass)
$rep = sendsockreply('checkpass', $msg); $rep = sendsockreply('checkpass', $msg);
if (!$rep) if (!$rep)
dbdown(); dbdown();
return $rep; return repDecode($rep);
}
#
function userReg($user, $email, $pass)
{
$passhash = myhash($pass);
$flds = array('username' => $user, 'emailaddress' => $email, 'passwordhash' => $passhash);
$msg = msgEncode('adduser', 'reg', $flds);
$rep = sendsockreply('adduser', $msg);
if (!$rep)
dbdown();
return repDecode($rep);
} }
# #
function getAllUsers() function getAllUsers()
@ -134,7 +145,7 @@ function getAllUsers()
$rep = sendsockreply('getAllUsers', $msg); $rep = sendsockreply('getAllUsers', $msg);
if (!$rep) if (!$rep)
dbdown(); dbdown();
return $rep; return repDecode($rep);
} }
# #
function getWorkers($user) function getWorkers($user)
@ -146,7 +157,7 @@ function getWorkers($user)
$rep = sendsockreply('getWorkers', $msg); $rep = sendsockreply('getWorkers', $msg);
if (!$rep) if (!$rep)
dbdown(); dbdown();
return $rep; return repDecode($rep);
} }
# #
function getPayments($user) function getPayments($user)
@ -158,7 +169,7 @@ function getPayments($user)
$rep = sendsockreply('getPayments', $msg); $rep = sendsockreply('getPayments', $msg);
if (!$rep) if (!$rep)
dbdown(); dbdown();
return $rep; return repDecode($rep);
} }
# #
function getBlocks($user) function getBlocks($user)
@ -170,7 +181,7 @@ function getBlocks($user)
$rep = sendsockreply('getBlocks', $msg); $rep = sendsockreply('getBlocks', $msg);
if (!$rep) if (!$rep)
dbdown(); dbdown();
return $rep; return repDecode($rep);
} }
# #
?> ?>

3
pool/page_blocks.php

@ -4,8 +4,7 @@ function doblocks($data, $user)
{ {
$pg = '<h1>Blocks</h1>'; $pg = '<h1>Blocks</h1>';
$rep = getBlocks($user); $ans = getBlocks($user);
$ans = repDecode($rep);
$pg .= "<table callpadding=0 cellspacing=0 border=0>\n"; $pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
$pg .= "<tr class=title>"; $pg .= "<tr class=title>";

3
pool/page_payments.php

@ -4,8 +4,7 @@ function dopayments($data, $user)
{ {
$pg = '<h1>Payments</h1>'; $pg = '<h1>Payments</h1>';
$rep = getPayments($user); $ans = getPayments($user);
$ans = repDecode($rep);
$pg .= "<table callpadding=0 cellspacing=0 border=0>\n"; $pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
$pg .= "<tr class=title>"; $pg .= "<tr class=title>";

13
pool/page_reg.php

@ -129,20 +129,11 @@ function show_reg($menu, $name, $u)
if ($ok === true) if ($ok === true)
{ {
$passhash = myhash($pass); $ans = userReg($user, $mail, $pass);
$flds = array('username' => $user,
'emailaddress' => $mail,
'passwordhash' => $passhash);
$msg = msgEncode('adduser', 'reg', $flds);
$rep = sendsockreply('show_reg', $msg);
if (!$rep)
dbdown();
$ans = repDecode($rep);
if ($ans['STATUS'] == 'ok') if ($ans['STATUS'] == 'ok')
gopage($data, 'doreg2', $menu, $name, $u, true, true, false); gopage($data, 'doreg2', $menu, $name, $u, true, true, false);
else else
$data['error'] = "Invalid details"; $data['error'] = "Invalid username, password or email address";
} }
gopage($data, 'doreg', $menu, $name, $u, true, true, false); gopage($data, 'doreg', $menu, $name, $u, true, true, false);

3
pool/page_stats.php

@ -12,8 +12,7 @@ function dostats($data, $user)
{ {
$pg = '<h1>Pool Stats</h1>'; $pg = '<h1>Pool Stats</h1>';
$rep = getAllUsers(); $ans = getAllUsers();
$ans = repDecode($rep);
$pg .= "<table callpadding=0 cellspacing=0 border=0>\n"; $pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
$pg .= "<tr class=title>"; $pg .= "<tr class=title>";

3
pool/page_workers.php

@ -4,8 +4,7 @@ function doworker($data, $user)
{ {
$pg = '<h1>Workers</h1>'; $pg = '<h1>Workers</h1>';
$rep = getWorkers($user); $ans = getWorkers($user);
$ans = repDecode($rep);
$pg .= "<table callpadding=0 cellspacing=0 border=0>\n"; $pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
$pg .= "<tr class=title>"; $pg .= "<tr class=title>";

Loading…
Cancel
Save