????

Your IP : 3.145.85.123


Current Path : /home2/morganrand/backup.morganrand.com/0tools/parts/
Upload File :
Current File : /home2/morganrand/backup.morganrand.com/0tools/parts/getroom.php

<?php
// ** MySQL settings ** //
// mediatemple
//define('DB_NAME', 'db11634_common');    // The name of the database
//define('DB_USER', 'db11634_common');     // Your MySQL username
//define('DB_PASSWORD', 'Xeno20_jKmol');	 // ...and password
//define('DB_HOST', 'internal-db.s11634.gridserver.com');    // 99% chance you won't need to change this value
//define('DB_CHARSET', 'utf8');
//define('DB_COLLATE', '');

// godaddy
define('DB_NAME', 'weddingf_old');    // The name of the database
define('DB_USER', 'weddingf_old');     // Your MySQL username
define('DB_PASSWORD', '671811go');	 // ...and password
define('DB_HOST', 'localhost');    // 99% chance you won't need to change this value
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
$password_length = 4;

function make_seed() {
  list($usec, $sec) = explode(' ', microtime());
  return (float) $sec + ((float) $usec * 100000);
}

srand(make_seed());

$alfa = "1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
$token = "";
for($i = 0; $i < $password_length; $i ++) {
  $token .= $alfa[rand(0, strlen($alfa))];
}   

mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die(mysql_error());
// echo "Connected to MySQL<br />";

mysql_select_db(DB_NAME) or die(mysql_error());
// echo "Connected to Database<br />";

//rooms 1-24 for old tool; 25-48 for new;
$tool = $_GET['jk'];
$tool = substr($tool,0,1);

$now = time();
$room = "0";

$result = mysql_query("SELECT * FROM design_room") or die(mysql_error());

while ($row = mysql_fetch_array($result, MYSQL_ASSOC) ) {
	if ($now - $row['last_login_php'] > 3600) {
		//echo $row['room_num'];
		//echo $row['last_login_php']."\n";
		//$room = $row['room_num'];
		if ($tool="B"){
			if (int($room) > 24) {
				$room = $row['room_num'];
				break;
			}	
		} else {
			$room = $row['room_num'];
			break;
		}
	}
}
mysql_free_result($result);
if ($room != "0") {
	$result = mysql_query("UPDATE design_room SET last_login_php='" . $now . "', password='" . $token . "' WHERE room_num='" . $room . "'") or die(mysql_error());
	echo $token;
} else {
	if ($tool="B"){
		$result = mysql_query("UPDATE design_room SET last_login_php='" . $now . "', password='" . $token . "' WHERE room_num='48'") or die(mysql_error());
		echo $token;
		$room = "48"
	} else {
		$result = mysql_query("UPDATE design_room SET last_login_php='" . $now . "', password='" . $token . "' WHERE room_num='24'") or die(mysql_error());
		echo $token;
		$room = "24";
	}
}
echo $room;
?>