function issueTo($com, $amount, $username, $title = '', $notify = '', $reference = '') { global $thisEntity; if (!$title) { $title = $thisEntity['Name'] . ' Deposit'; } // Issue that much: issue($com, $amount); // Build the transfer data: $transferData = array('Commodity' => $com, 'Amount' => $amount, 'ItemInformation' => '{"products":[{"opn":"com://' . $com . '","volume":' . $amount . ',"total":0}],"notify":"' . escape($notify, false) . '"}', 'Reference' => $reference, 'Username' => $username, 'Title' => $title, 'Name' => $thisEntity['Name'], 'FromUsername' => $thisEntity['Username']); // Transfer now, from the issuer itself: transfer($transferData, false); }
} elseif ($action == 'registerEmail') { $message = registerEmail(); echo $message; } elseif ($action == 'registerPwd') { $message = registerPwd(); echo $message; } elseif ($action == 'confirmPwd') { $message = confirmPwd(); echo $message; } else { } if ($action == 'register') { echo register(); } if ($action == 'issue') { echo issue(); } if ($action == 'userInfo') { echo userInfo(); } if ($action == 'login') { echo login(); } if ($action == 'logout') { logout(); } if ($action == 'active') { echo active(); } if ($action == 'forget') { $toMail = $_POST['email'];
Warning: Some code contains mistakes or deliberately incorrect coding for the purpose of serving as an example for the book. Please read the book carefully to determine which code is suitable for reuse in your own applications. Copyright 2013 Marc J. Rochkind. All rights reserved. May be copied and used under the BSD-type license at http://basepath.com/aup/copyright.htm. */ define("DB_USER", "rochkind_hesk"); define("DB_PASSWORD", "..."); $pdo = new PDO('mysql:host=localhost;dbname=rochkind_hesk', DB_USER, DB_PASSWORD); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $s = file_get_contents("CWA-requirements.txt"); $s = str_replace("\n", "<br>", $s); while (preg_match('/^(.*)\\{(\\w+) (\\d+)}(.*)$/s', $s, $m)) { $s = $m[1] . issue($m[2], $m[3]) . $m[4]; } echo $s; function issue($cmd, $n) { global $pdo; $stmt = $pdo->prepare("select id, subject, message from\n hesk_tickets where id = :id"); $stmt->execute(array('id' => $n)); if ($row = $stmt->fetch()) { if ($cmd == "Issue") { return "\n <table border=1 cellspacing=0 cellpadding=10>\n <tr><td>\n <p><b>Issue {$row['id']}: {$row['subject']}</b>\n <p>{$row['message']}\n </table>\n "; } else { return "<br>Issue {$row['id']}: {$row['subject']}"; } } else { return "<b>[Can't locate Issue {$n}]</b>";