function logoutall($force = false) { global $con; $query = "SELECT * FROM students WHERE ACTIVE = '1'"; $result = mysqli_query($con, $query); if (!$result) { fancydie('Could not fetch user data from database, ' . mysqli_error($con)); } $count = 0; while ($row = mysqli_fetch_array($result)) { logout($row["id"], $row["FULLNAME"], 1, false); $count++; } if ($force) { message("Successfully force logged out " . $count . " student(s)"); } else { message("Successfully logged out " . $count . " student(s)"); } }
<?php include_once '../includes/tools.php'; //authentication stuff if ($_SESSION['adminpass'] == null) { redirect('admin/login'); } if (md5($_SESSION['adminpass']) != $adminpassword) { redirect('login.php?error=wp'); } // Verify connection with database if (mysqli_connect_errno()) { fancydie("Couldn't connect to the database. Reason: " . mysqli_connect_error()); } $user = urldecode($_GET['user']); $result = mysqli_query($con, "SELECT * FROM students WHERE fullname = '{$user}'"); $row = mysqli_fetch_array($result); $ID = $row['id']; $active = $row['active']; $totaltime = $row['totaltime']; $name = $row['name']; if (isset($_POST['action'])) { switch ($_POST['action']) { case 'login': signIn($ID); die; case 'logout': signOut($ID); die; case 'flogout': select();
include_once 'includes/tools.php'; /* * Process the posted variables / check if they are valid */ //assign and cleanup the id $ID = trim(strtolower($_POST['id'])); //did the user even type an id? if ($ID == null) { //numeric and nonzero fancydie('You did not enter an ID.'); } //get id if (strpos($ID, 'drop') !== false) { fancydie('Stop trying to hack my website!'); } if (!is_numeric($ID)) { //numeric and >0 fancydie('"' . $ID . '" is an invalid ID.'); } //check what the last page told this page to do if ($_POST["login"]) { login($ID); } else { if ($_POST["logout"]) { logout($ID); } else { fancydie('This page was told neither to login nor logout the user' . mysqli_error($query)); } } $action = $_POST["login"] ? "in" : "out"; redirect("confirmation.php?a=" . $action . "&u=" . getName($ID));