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)
{
$rep = checkpass($user, $pass);
$ans = repDecode($rep);
$rep = checkPass($user, $pass);
if ($rep != null)
$ans = repDecode($rep);
usleep(100000); // Max 10x per second
if ($ans['STATUS'] == 'ok')
if ($rep != null && $ans['STATUS'] == 'ok')
{
$key = 'ckp'.rand(1000000,9999999);
$_SESSION['ckpkey'] = $key;

23
pool/db.php

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

3
pool/page_blocks.php

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

3
pool/page_payments.php

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

13
pool/page_reg.php

@ -129,20 +129,11 @@ function show_reg($menu, $name, $u)
if ($ok === true)
{
$passhash = myhash($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);
$ans = userReg($user, $mail, $pass);
if ($ans['STATUS'] == 'ok')
gopage($data, 'doreg2', $menu, $name, $u, true, true, false);
else
$data['error'] = "Invalid details";
$data['error'] = "Invalid username, password or email address";
}
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>';
$rep = getAllUsers();
$ans = repDecode($rep);
$ans = getAllUsers();
$pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
$pg .= "<tr class=title>";

3
pool/page_workers.php

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

Loading…
Cancel
Save