????
Current Path : /home2/morganrand/backup.morganrand.com/0tools/ |
Current File : /home2/morganrand/backup.morganrand.com/0tools/getroom.php |
<?php if (isset($_GET['jk'])) { //rooms 1-24 for old tool; 25-48 for new; $tool = $_GET['jk']; $tool = substr($tool,0,1); $conn = null; // ** MySQL settings ** // require_once('../db_connection.php'); $password_length = 4; function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); } srand(make_seed()); $alfa = "1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"; $alfa_length = strlen($alfa); $token = ""; for($i = 0; $i < $password_length; $i ++) { $token .= $alfa[rand(0, $alfa_length)]; } $now = time(); $room = "0"; $sql = "SELECT * FROM design_room"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { if ($now - $row['last_login_php'] > 3600) { // //echo $row['room_num']; //echo $row['last_login_php']."\n"; $iroom = (int)$row['room_num']; if ($tool=="B"){ if ($iroom > 24) { $room = $row['room_num']; break; } } else { $room = $row['room_num']; break; } } } } else { echo "0 results"; exit; } echo $token; if ($room != "0") { if ($tool!="B"){ if ($iroom > 24) {$room = "24";} } $sql = "UPDATE design_room SET last_login_php='" . $now . "', password='" . $token . "' WHERE room_num='" . $room . "'"; } else { if ($tool=="B"){ $sql = "UPDATE design_room SET last_login_php='" . $now . "', password='" . $token . "' WHERE room_num='48'"; $room = "48"; } else { $sql = "UPDATE design_room SET last_login_php='" . $now . "', password='" . $token . "' WHERE room_num='24'"; $room = "24"; } } if ($conn->query($sql) === TRUE) { echo $room; } else { echo "Error updating design room: " . $conn->error; } $conn->close(); } ?>