Browse Source

php - add web information to ckdb requests

master
kanoi 10 years ago
parent
commit
3e041c8bae
  1. 40
      pool/db.php
  2. 2
      pool/page_ckp.php
  3. 3
      pool/page_pplns.php

40
pool/db.php

@ -65,34 +65,26 @@ function repDecode($rep)
return $ans;
}
#
function msgEncode($cmd, $id, $fields)
function msgEncode($cmd, $id, $fields, $user)
{
global $send_sep, $fld_sep, $val_sep;
$t = time() % 10000;
$msg = $cmd . $send_sep . $id.$t;
$first = true;
$msg = $cmd . $send_sep . $id.$t . $send_sep;
foreach ($fields as $name => $value)
{
if ($first === true)
{
$msg .= $send_sep;
$first = false;
}
else
$msg .= $fld_sep;
$msg .= $name . $val_sep . $value;
}
$msg .= $name . $val_sep . $value . $fld_sep;
$msg .= 'createcode' . $val_sep . 'php' . $fld_sep;
$msg .= 'createby' . $val_sep . $user . $fld_sep;
$msg .= 'createinet' . $val_sep . $_SERVER['REMOTE_ADDR'];
return $msg;
}
#
function getStats($user)
{
if ($user === null)
$msg = msgEncode('homepage', 'home', array());
$msg = msgEncode('homepage', 'home', array(), $user);
else
$msg = msgEncode('homepage', 'home', array('username'=>$user));
$msg = msgEncode('homepage', 'home', array('username'=>$user), $user);
return $msg;
}
#
@ -120,7 +112,7 @@ function checkPass($user, $pass)
{
$passhash = myhash($pass);
$flds = array('username' => $user, 'passwordhash' => $passhash);
$msg = msgEncode('chkpass', 'log', $flds);
$msg = msgEncode('chkpass', 'log', $flds, $user);
$rep = sendsockreply('checkPass', $msg);
if (!$rep)
dbdown();
@ -132,7 +124,7 @@ function setPass($user, $oldpass, $newpass)
$oldhash = myhash($oldpass);
$newhash = myhash($newpass);
$flds = array('username' => $user, 'oldhash' => $oldhash, 'newhash' => $newhash);
$msg = msgEncode('newpass', 'log', $flds);
$msg = msgEncode('newpass', 'log', $flds, $user);
$rep = sendsockreply('setPass', $msg);
if (!$rep)
dbdown();
@ -143,7 +135,7 @@ function userReg($user, $email, $pass)
{
$passhash = myhash($pass);
$flds = array('username' => $user, 'emailaddress' => $email, 'passwordhash' => $passhash);
$msg = msgEncode('adduser', 'reg', $flds);
$msg = msgEncode('adduser', 'reg', $flds, $user);
$rep = sendsockreply('userReg', $msg);
if (!$rep)
dbdown();
@ -159,7 +151,7 @@ function userSettings($user, $email = null, $addr = null, $pass = null)
$flds['address'] = $addr;
if ($pass != null)
$flds['passwordhash'] = myhash($pass);
$msg = msgEncode('usersettings', 'userset', $flds);
$msg = msgEncode('usersettings', 'userset', $flds, $user);
$rep = sendsockreply('userSettings', $msg);
if (!$rep)
dbdown();
@ -169,7 +161,7 @@ function userSettings($user, $email = null, $addr = null, $pass = null)
function getAllUsers($user)
{
$flds = array();
$msg = msgEncode('allusers', 'all', $flds);
$msg = msgEncode('allusers', 'all', $flds, $user);
$rep = sendsockreply('getAllUsers', $msg);
if (!$rep)
dbdown();
@ -181,7 +173,7 @@ function getWorkers($user)
if ($user == false)
showIndex();
$flds = array('username' => $user, 'stats' => 'Y');
$msg = msgEncode('workers', 'work', $flds);
$msg = msgEncode('workers', 'work', $flds, $user);
$rep = sendsockreply('getWorkers', $msg);
if (!$rep)
dbdown();
@ -193,7 +185,7 @@ function getPayments($user)
if ($user == false)
showIndex();
$flds = array('username' => $user);
$msg = msgEncode('payments', 'pay', $flds);
$msg = msgEncode('payments', 'pay', $flds, $user);
$rep = sendsockreply('getPayments', $msg);
if (!$rep)
dbdown();
@ -205,7 +197,7 @@ function getBlocks($user)
if ($user == false)
showIndex();
$flds = array();
$msg = msgEncode('blocklist', 'blk', $flds);
$msg = msgEncode('blocklist', 'blk', $flds, $user);
$rep = sendsockreply('getBlocks', $msg);
if (!$rep)
dbdown();

2
pool/page_ckp.php

@ -18,7 +18,7 @@ function dockp($data, $user)
{
$pg = '<h1>CKPool</h1>';
$msg = msgEncode('stats', 'stats', array());
$msg = msgEncode('stats', 'stats', array(), $user);
$rep = sendsockreply('stats', $msg);
if ($rep == false)
$ans = array();

3
pool/page_pplns.php

@ -30,7 +30,8 @@ Block: <input type=text name=blk size=10 value=''>
}
else
{
$msg = msgEncode('pplns', 'pplns', array('height' => $blk, 'allow_aged' => 'Y'));
$flds = array('height' => $blk, 'allow_aged' => 'Y');
$msg = msgEncode('pplns', 'pplns', $flds, $user);
$rep = sendsockreply('pplns', $msg);
if ($rep == false)
$ans = array();

Loading…
Cancel
Save