Browse Source

php - match new consistent message format

master
kanoi 11 years ago
parent
commit
d895674df9
  1. 24
      pool/db.php
  2. 4
      pool/page_reg.php

24
pool/db.php

@ -46,11 +46,11 @@ function repDecode($rep)
return $ans;
}
#
function msgEncode($id, $cmd, $fields)
function msgEncode($cmd, $id, $fields)
{
global $send_sep, $fld_sep, $val_sep;
$msg = $id . $send_sep . $cmd;
$msg = $cmd . $send_sep . $id;
$first = true;
foreach ($fields as $name => $value)
{
@ -105,23 +105,37 @@ function checkpass($user, $pass)
{
$passhash = myhash($pass);
$flds = array('username' => $user, 'passwordhash' => $passhash);
$msg = msgEncode('log', 'chkpass', $flds);
$msg = msgEncode('chkpass', 'log', $flds);
$rep = sendsockreply('checkpass', $msg);
if (!$rep)
dbdown();
return $rep;
}
#
function getpayments()
function getWorkers()
{
list($who, $whoid) = validate();
if ($who == false)
showIndex();
$flds = array('username' => $who);
$msg = msgEncode('pay', 'payments', $flds);
$msg = msgEncode('workers', 'work', $flds);
$rep = sendsockreply('getworkers', $msg);
if (!$rep)
dbdown();
return $rep;
}
#
function getPayments()
{
list($who, $whoid) = validate();
if ($who == false)
showIndex();
$flds = array('username' => $who);
$msg = msgEncode('payments', 'pay', $flds);
$rep = sendsockreply('getpayments', $msg);
if (!$rep)
dbdown();
return $rep;
}
#
?>

4
pool/page_reg.php

@ -110,13 +110,13 @@ function show_reg($menu, $name)
$flds = array('username' => $user,
'emailaddress' => $mail,
'passwordhash' => $passhash);
$msg = msgEncode('reg', 'adduser', $flds);
$msg = msgEncode('adduser', 'reg', $flds);
$rep = sendsockreply('show_reg', $msg);
if (!$rep)
dbdown();
$ans = repDecode($rep);
if ($ans['STATUS'] == 'added')
if ($ans['STATUS'] == 'ok')
gopage($data, 'doreg2', $menu, $name, true, true, false);
else
$data['error'] = "Invalid details";

Loading…
Cancel
Save