Esempio n. 1
0
// and the ability to create new ones. This isnt really in the scope of the
// GA4PHP, but for this example, we need to be able to create users, so heres where
// you do it.
$db = getDatabase();
$result = $db->query("select * from users");
foreach ($result as $row) {
    if ($myga->hasToken($row["users_username"])) {
        $hastoken = "Yes";
        $type = $myga->getTokenType($row["users_username"]);
        if ($type == "HOTP") {
            $type = "- Counter Based";
        } else {
            $type = "- Time Based";
        }
        $hexkey = $myga->getKey($row["users_username"]);
        $b32key = $myga->helperhex2b32($hexkey);
        $url = urlencode($myga->createURL($row["users_username"]));
        $keyurl = "<img src=\"http://chart.apis.google.com/chart?cht=qr&chl={$url}&chs=100x100\">";
    } else {
        $b32key = "";
        $hexkey = "";
        $type = "";
        $hastoken = "no";
        $keyurl = "";
    }
    // now we generate the qrcode for the user
    echo "<tr><td>" . $row["users_username"] . "</td><td>" . $row["users_fullname"] . "</td><td>{$hastoken} {$type}</td><td>{$keyurl}</td><td>{$b32key}</td><td>{$hexkey}</td></tr>";
}
closeDatabase($db);
?>
</table>