2 require_once("../lib/authClient.php");
4 $myAC = new GAAuthClient();
8 if(isset($_SESSION["loggedin"])) if($_SESSION["loggedin"]) $loggedin = true;
9 else $loggedin = false;
11 if(isset($_REQUEST["action"])) {
12 switch($_REQUEST["action"]) {
13 case "deleteradclient":
14 $clientname = $_REQUEST["clientname"];
15 $ret = $myAC->deleteRadiusClient($clientname);
16 header("Location: ?message=".urlencode("Client Deleted"));
20 $clientname = $_REQUEST["clientname"];
21 $clientip = $_REQUEST["clientip"];
22 $clientsecret = $_REQUEST["clientsecret"];
23 $clientdesc = $_REQUEST["clientdesc"];
24 $ret = $myAC->addRadiusClient($clientname, $clientip, $clientsecret, $clientdesc);
26 header("Location: ?message=".urlencode("Client Added"));
27 } else if ($ret == "name") {
28 header("Location: ?error=".urlencode("Client Name Already Existed"));
29 } else if ($ret == "ip") {
30 header("Location: ?error=".urlencode("Client IP Already Existed"));
35 $ttype = $_REQUEST["tokentype"];
36 $tkey = $_REQUEST["tokenkey"];
37 $username = $_REQUEST["username"];
38 $ret1 = $myAC->setUserTokenType($username, $ttype);
39 $ret2 = $myAC->setUserToken($username, $tkey);
40 error_log("got, $ret1, $ret2...");
43 $username = $_REQUEST["username"];
44 $tokenone = $_REQUEST["tokenone"];
45 $tokentwo = $_REQUEST["tokentwo"];
46 $retval = $myAC->syncUserToken($username, $tokenone, $tokentwo);
47 error_log("retval: $retval");
49 header("Location: ?message=".urlencode("token synced"));
52 header("Location: ?error=".urlencode("token not synced"));
57 case "recreatehotptoken":
58 $username = $_REQUEST["username"];
59 $myAC->addUser($username, "HOTP");
60 header("Location: ?message=".urlencode("seemed to work?"));
62 case "recreatetotptoken":
63 $username = $_REQUEST["username"];
64 $myAC->addUser($username, "TOTP");
65 header("Location: ?message=".urlencode("seemed to work?"));
68 $username = $_REQUEST["username"];
69 $myAC->deleteUserToken($username);
70 header("Location: ?message=".urlencode("seemed to work?"));
73 $username = $_REQUEST["username"];
74 if($_REQUEST["original_real"] != $_REQUEST["realname"]) {
75 $myAC->setUserRealName($username, $_REQUEST["realname"]);
77 if($_REQUEST["password"] != "") {
78 if($_REQUEST["password"]!=$_REQUEST["password_conf"]) {
79 header("Location: ?message=confirmfalse");
81 $myAC->setUserPass($username, $_REQUEST["password"]);
86 $username = $_REQUEST["username"];
87 $password = $_REQUEST["password"];
89 if($myAC->authUserPass($username, $password)) {
90 $_SESSION["loggedin"] = true;
91 $_SESSION["username"] = $username;
92 header("Location: admin.php");
94 header("Location: admin.php?error=".urlencode("Login Failed"));
100 $_SESSION["loggedin"] = false;
101 $_SESSION["username"] = "";
102 header("Location: admin.php");
106 $username = $_REQUEST["username"];
107 $users = explode(",",$username);
108 foreach($users as $user) {
110 error_log("createing, $user\n");
111 if($user != "" && strlen($user)>2) $myAC->addUser($user);
113 header("Location: admin.php");
117 error_log("would update");
118 $err = print_r($_REQUEST, true);
119 error_log("req: $err\n");
120 $username = $_REQUEST["username"];
121 if($_REQUEST["realname"]!="") {
122 $myAC->setUserRealName($username, $_REQUEST["realname"]);
124 if($_REQUEST["password"]!= "") {
125 $myAC->setUserPass($username, $_REQUEST["password"]);
129 $username = $_REQUEST["username"];
130 $myAC->deleteUser($username);
133 $username = $_REQUEST["username"];
134 $myAC->setUserPass($username, "");
137 $otk = $_REQUEST["otk"];
138 $username = $_REQUEST["username"];
139 error_log("requesting otk, $otk");
140 $otk_img = $myAC->getOtkPng($username,$otk);
141 header("Content-type: image/png");