private function getUserSeed($seedColumn = 'random_seed', $verbose = false)
 {
     # For legacy setups, make sure the random_seed column is there
     $r = $this->addColumn($seedColumn, 'varchar(255)');
     if ($r['status'] === true || $r['status'] === false && $r['error'] == 'COLUMN_EXISTS') {
         # Get the seed!
         try {
             $u = $this->getUser();
             if (!empty($u[$seedColumn])) {
                 return $u[$seedColumn];
             }
             $criteria = array($this->linkColumn => $this->getHardlink());
             $seed = Stronghash::createSalt() . Stronghash::genUnique(96);
             $entry = array($seedColumn => $seed);
             try {
                 $r = $this->updateEntry($entry, $criteria);
                 if ($r !== true) {
                     if ($verbose) {
                         return $r;
                     }
                     return false;
                 }
                 return $seed;
             } catch (Exception $e) {
                 if ($verbose) {
                     return $e->getMessage();
                 }
                 return false;
             }
         } catch (Exception $e) {
             # Not created yet
             return Stronghash::createSalt() . Stronghash::genUnique(96);
         }
     }
     # No column, and couldn't create it
     if ($verbose) {
         return 'NOT_EXIST_CANT_CREATE';
     }
     return false;
 }
// ob_start( 'ob_gzhandler' ); // handles headers
/*
 * Sample page to show the whole kit n' kaboodle in action.
 */
if ($_REQUEST['t'] == 'hash') {
    // decode the JSON
    require_once 'handlers/db_hook.inc';
    $l = openDB();
    $r = mysqli_query($l, "SELECT password FROM `userdata` WHERE username='******'user']) . "'");
    $hba = mysqli_fetch_array($r);
    $hb = $hba[0];
    $a = json_decode($hb, true);
    print_r($a);
    require_once 'stronghash/php-stronghash.php';
    require_once 'handlers/login_functions.php';
    $h = new Stronghash();
    $u = new UserFunctions();
    // user validation
    echo "<pre> LookupUser results -- ";
    print_r($u->lookupUser($_POST['user'], $_POST['pw_base'], true));
    echo "\n VerifyHash results --";
    print_r($h->verifyHash($_POST['pw_base'], $a, null, null, null, true));
    echo "</pre>";
}
?>
    <article>
      <?php 
require_once 'login.php';
echo $login_output;
?>
      <div>
function billUser($full_data_array)
{
    /***
     * Do a charge against the user, then update the status all around.
     *
     * https://developers.braintreepayments.com/android+php/reference/request/transaction/sale
     ***/
    $data_array = $full_data_array["post_data"];
    $brainTreeTransaction = array("amount" => $data_array["amount"], "paymentMethodNonce" => $data_array["nonce"], 'customer' => array(), 'options' => array('storeInVaultOnSuccess' => true, 'submitForSettlement' => true));
    global $billingTokens;
    $billingTokens = array();
    try {
        $braintree = Braintree_Transaction::sale($brainTreeTransaction);
        $result = array("status" => $braintree->success, "braintree_result" => $braintree);
        if (!$braintree->success) {
            $result["app_error_code"] = 115;
            $result["details"] = array();
            $result["requested_action"] = "bill";
            $result["human_error"] = "Failed to charge your card. Please try again later.";
            $result["given"] = $data_array;
        } else {
            try {
                # Post-process
                $billingTokens["status"] = true;
                $postProcessDetails = array();
                $givenArgs = smart_decode64($data_array["billActionDetail"]);
                $billingTokens["provided"] = $givenArgs;
                $postAction = $givenArgs["action"];
                switch ($postAction) {
                    # Set all the $postProcessDetails data
                    case "session":
                        break;
                    case "roleChange":
                        $newRole = $givenArgs["newRole"];
                        # Do the role change
                        break;
                    default:
                        throw new Exception("Bad post-process action '{$postAction}'");
                        break;
                }
                $billingTokens["post_process_details"] = $postProcessDetails;
            } catch (Exception $e) {
                # An internal error! We want to log this.
                $error_id = Stronghash::createSalt();
                $write = "\n\n\n\n" . datestamp() . " - " . json_encode($_REQUEST);
                $write .= "\nError ID: {$error_id}";
                $write .= "\nGot error: " . $e->getMessage();
                $write .= "\n" . implode("\n", jTraceEx($e));
                file_put_contents('billing_errors.log', $write, FILE_APPEND | LOCK_EX);
                $billingTokens["status"] = false;
                $billingTokens["error"] = $e->getMessage();
                $billingTokens["human_error"] = "Your card was charged, but we couldn't update the server. Please contact support with error ID {$error_id}";
                $billingTokens["need_popup"] = true;
                $result["status"] = false;
                $result["app_error_code"] = 116;
            }
        }
    } catch (Exception $e) {
        # Just the Braintree errors
        $result = array("status" => false, "error" => $e->getMessage(), "human_error" => "Unable to charge your card", "app_error_code" => 114, "given" => $data_array);
    }
    return $result;
}