0){ //Use the special path instead. $rootPath = trim(file_get_contents("root.inf")); } $databasePath = $rootPath . "whitelist.config"; $content = ""; $regexists = false; /* if (file_exists($databasePath)){ include_once("auth.php"); //If the user is able to continues to proceed, that means the user has right to use this system $content = file_get_contents($databasePath); $regexists = true; }else{ //There is no user registration yet. Create one } */ //See if this page is requested for command. $errormsg = ""; if (isset($_POST['act']) && $_POST['act'] != ""){ $action = $_POST['act']; if ($action == "newuser"){ if (isset($_POST['username']) && isset($_POST['secretecode'])){ $newusername = $_POST['username']; $password = $_POST['secretecode']; if ($password == ""){ showerror("Password cannot be empty!"); } $encodedpw = hash('sha512',$password); $content = trim($content); $users = explode(PHP_EOL,$content); $usernameexists = false; foreach ($users as $userdata){ $username = explode(",",$userdata)[0]; if (strtolower($username) == strtolower($newusername)){ $usernameexists = true; } } if ($usernameexists){ $errormsg = "Username already exists."; showerror($errormsg); }else{ $encodedpw = strtoupper($encodedpw); file_put_contents($databasePath,$newusername . "," . $encodedpw . PHP_EOL,FILE_APPEND); header("Location: regi.php?msg=New user added."); exit(0); } } }else if ($action == "rmvuser"){ if (isset($_POST['username'])){ $targetusername = $_POST['username']; $content = trim($content); $users = explode(PHP_EOL,$content); $allowedusers = []; foreach ($users as $userdata){ $username = explode(",",$userdata)[0]; if (strtolower($username) == strtolower($targetusername)){ }else{ array_push($allowedusers,$userdata); } } $newcontent = implode(PHP_EOL,$allowedusers); $newcontent .= PHP_EOL; if (count($allowedusers) == 0){ unlink($databasePath); }else{ file_put_contents($databasePath,$newcontent); } die("DONE"); }else{ die("ERROR. username not defined for act=rmvuser"); } } exit(0); } ?>
'.$_GET['msg'].'
List of registered users for this system