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

2
pool/page_ckp.php

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

3
pool/page_pplns.php

@ -30,7 +30,8 @@ Block: <input type=text name=blk size=10 value=''>
} }
else 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); $rep = sendsockreply('pplns', $msg);
if ($rep == false) if ($rep == false)
$ans = array(); $ans = array();

Loading…
Cancel
Save