3 require_once("../lib/lib.php");
5 $ga = new GoogleAuthenticator("/tmp/gaexpage.db");
8 <h1>Example Page for GA4PHP</h1>
11 if(isset($_REQUEST["action"])) {
12 switch($_REQUEST["action"]) {
14 $username = $_REQUEST["username"];
15 $pr = preg_match('/^[a-zA-Z0-9@\.]+$/',"$username");
17 if(strlen($username)<3) {
18 echo "<font color=\"red\">Sorry, username must be at least 3 chars</font>";
20 echo "<font color=\"red\">Sorry, username can only contain a-z, A-Z, 0-9 @ and .</font>";
22 $url = $ga->setupUser($username);
23 echo "QRCode for user \"$username\" is <img src=\"http://chart.apis.google.com/chart?cht=qr&chl=$url&chs=120x120\">";
28 $username = $_REQUEST["username"];
29 $code = $_REQUEST["code"];
30 if($ga->authenticateUser($username, $code)) {
31 echo "<font color=\"green\">Passed!</font>";
33 echo "<font color=\"red\">Failed!</font>";
44 <form method="post" action="index.php?action=createuser">
45 Username: <input type="text" name="username"><br>
46 Type (ignored for now): <select name="ttype"><option value="HOTP">HOTP</option><option value="TOTP">TOTP</option></select><br>
47 <input type="submit" name="go" value="go"><br>
50 <form method="post" action="index.php?action=authuser">
51 Username: <input type="text" name="username"><br>
52 Code: <input type="text" name="code"><br>
53 <input type="submit" name="go" value="go"><br>