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

4
pool/page_reg.php

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

Loading…
Cancel
Save