本文整理汇总了PHP中server::unpack_bankmsg方法的典型用法代码示例。如果您正苦于以下问题:PHP server::unpack_bankmsg方法的具体用法?PHP server::unpack_bankmsg怎么用?PHP server::unpack_bankmsg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类server
的用法示例。
在下文中一共展示了server::unpack_bankmsg方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getbanktran
}
$msg = custmsg2('gettime', $bankid, $req);
$msg = $server->process($msg);
$args = $u->match_message($msg);
if (is_string($args)) {
return false;
}
return $args['time'];
}
// Spend tokens from bank to $id to give him an account
if (!$db->contents($server->inboxkey($id)) && !$db->contents($server->balancekey($id))) {
$tran = getbanktran();
$amt = 50;
$spend = bankmsg('spend', $bankid, $tran, $id, $tokenid, $amt, "Welcome to Trubanc!");
$msg = $db->get($server->assetbalancekey($bankid, $tokenid));
$bal = $server->unpack_bankmsg($msg, $t->ATBALANCE, $t->BALANCE, $t->AMOUNT);
echo "bal: {$bal}\n";
$bal = bankmsg('balance', $bankid, $tran, $tokenid, $bal - $amt);
process("{$spend}.{$bal}");
}
// Register $id, if not yet registered
if (!$server->pubkeydb->get($id)) {
// Get the bankid. This command does not require an acount
process(custmsg('bankid', $pubkey));
process(custmsg("register", $bankid, $pubkey, "George Jetson"));
process(custmsg('id', $bankid, $id));
}
//process(custmsg2("register",$bankid,$pubkey2,"Jane Jetson"));
$trans = $db->get($server->accttimekey($id));
// getinbox
$inbox = $db->contents($server->inboxkey($id));
示例2: doit
function doit()
{
global $dbdir, $bank_name, $bankurl;
global $template_file;
$init = mqreq('init');
$initadmin = mqreq('initadmin');
$drawadmin = mqreq('drawadmin');
$passphrase = mqreq('passphrase');
$verification = mqreq('verification');
$bankpass = mqreq('bankpass');
$name = mqreq('name');
$random = mqreq('random');
$sig = mqreq('sig');
require_once "lib/fsdb.php";
require_once "lib/ssl.php";
require_once "lib/server.php";
$ssl = new ssl();
$db = new fsdb($dbdir);
if ($init) {
if (!$passphrase) {
$error = "Passphrase must be entered";
} elseif ($passphrase != $verification) {
$error = "Passphrase doesn't match verification. Try again.";
} else {
$server = new server($db, $ssl, false, $bank_name, $bankurl);
$t = $server->t;
$bankid = $server->bankid;
$tokenid = $server->tokenid;
$msg = "(0,bankid,0):0";
$res = $server->process($msg);
$args = $server->unpack_bankmsg($res, $t->BANKID);
if (is_string($args)) {
$error = "Error testing server: {$args}";
} else {
$bal = $db->get("account/{$bankid}/balance/main/{$tokenid}");
if (!$bal) {
$error = "Bank has no token balance";
} else {
$args = $server->unpack_bankmsg($bal, $t->ATBALANCE, $t->BALANCE);
if (is_string($args)) {
$error = "On parsing bank token balance: {$args}";
}
}
}
}
// Initialize client
if (!$error) {
$dbdir = '';
if (file_exists('client/settings.php')) {
require_once "client/settings.php";
}
$dbdir = "client/{$dbdir}";
$template_file = "client/{$template_file}";
$error = die_unless_client_properly_configured(true);
if (!$error) {
require_once "lib/client.php";
$clientdb = new fsdb("{$dbdir}");
$client = new client($clientdb, $ssl);
if ($enabledebug) {
$client->showprocess = 'appenddebug';
}
$hash = $client->passphrasehash($passphrase);
if ($clientdb->get("privkey/{$hash}") || $clientdb->get("account/{$bankid}/bank/{$bankid}/req")) {
$error = $client->login($passphrase);
if ($error || $bankid != $client->id) {
$error = "Passphrase not for bank account";
}
} else {
$privkey = $db->get('privkey');
$pk = $ssl->load_private_key($privkey);
if (!$pk) {
$error = "Can't load bank private key";
} else {
openssl_pkey_export($pk, $privkey, $passphrase);
openssl_free_key($pk);
$error = $client->verifybank($bankurl, $bankid);
if (!$error) {
$error = $client->newuser($passphrase, $privkey);
}
}
}
}
}
if (!$error) {
$drawadmin = true;
$bankpass = $passphrase;
require_once "lib/LoomRandom.php";
$random = new LoomRandom();
$random = $random->random_id();
$sig = trimsig($ssl->sign($random, $db->get('privkey')));
}
} elseif ($initadmin) {
if (!$passphrase) {
$error = "Passphrase must be entered";
} elseif ($passphrase != $verification) {
$error = "Passphrase doesn't match verification. Try again.";
} else {
// This requires you to get here by knowing the bank passphrase
$sig = trimsig($sig);
$newsig = trimsig($ssl->sign($random, $db->get('privkey')));
//.........这里部分代码省略.........