function __construct($q = null, $makearray = false) { global $db; if (!is_object($db)) { $db = my_connect(); } if ($makearray) { $q = explode(';', $q); foreach ($q as $k => $v) { if (trim($v) == '') { unset($q[$k]); } else { $q[$k] = trim($v); } } } if (is_null($q)) { return true; } else { return $this->set_query($q); } }
//get all the spatial data associated with this mesh $spatialResult = $db->query("SELECT \n\t\t\torientX, \n\t\t\torientY, \n\t\t\torientZ, \n\t\t\tposX,\n\t\t\tposY,\n\t\t\tposZ\n\t\t\tfrom `Spatial Data`\n\t\t\twhere meshId=" . $row["meshId"]); //compact it into a separate array then append this array to the end of the current mesh array while ($spatialRow = $spatialResult->fetch_array(MYSQL_ASSOC)) { $curSpatial = array(); foreach ($spatialRow as $spaceData) { $curSpatial[] = $spaceData; } $spatialData[] = $curSpatial; } $meshes[] = array($curMesh, $spatialData); } echo json_encode($meshes); $db->close(); } else { if ($_GET["getLights"]) { $db = my_connect(); $result = $db->query("SELECT * FROM lights"); $lights = array(); while ($row = $result->fetch_array(MYSQL_ASSOC)) { $curLight = array(); foreach ($row as $lightField) { $curLight[] = $lightField; } $lights[] = $curLight; } echo json_encode($lights); $db->close(); } } }
<HTML> <BODY> <?php $password = $_POST['pswd']; $username = $_POST['name']; echo "<BR>Checking authentication of user {$username} ... <P>"; if ($username == "" || $password == "") { echo "<H3>Sorry, you must supply both username and password.</H3>\n"; die("<A HREF=\"./index.php\"><BUTTON TYPE=button> Try again or create new account? </BUTTON></A>\n"); } my_connect(); $sessionid = session_id(); decho("You have authenticated as user '{$username}'. Your sessionid is '{$sessionid}'.<BR>"); my_disconnect(); $sessionid = session_id(); $_SESSION['username'] = $username; $_SESSION['password'] = $password; $_SESSION['debug'] = $debug; ?> <P> <H3>You have logged in successfully.</H3> <A HREF="./mainpage.php"><BUTTON TYPE=button> Proceed to the main page </BUTTON></A><P> <A HREF="./logout.php"><BUTTON TYPE=button> Logout </BUTTON></A> </BODY> </HTML>
if ($port) { $host = sprintf("%s:%s", $host, $port); } } $link = mysql_connect($host, $user, $passwd, true); if (!$link) { printf("[%03d] Cannot connect using host '%s', user '%s', password '****', [%d] %s\n", $offset, $host, $user, $passwd, mysql_errno(), mysql_error()); return false; } return $link; } $links = array(); // try to open 3 links $links[0] = my_connect(10, $host, $user, $passwd, $db, $port, $socket); $links[1] = my_connect(20, $host, $user, $passwd, $db, $port, $socket); $links[2] = my_connect(30, $host, $user, $passwd, $db, $port, $socket); if (false !== $links[2]) { printf("[040] Last connection should not have been allowed!\n"); } // free some links but let index 1 remain unset($links[2]); mysql_close($links[0]); unset($links[0]); // should be allowed -> second open connection $links[0] = my_connect(50, $host, $user, $passwd, $db, $port, $socket); $links[2] = my_connect(60, $host, $user, $passwd, $db, $port, $socket); ksort($links); var_dump($links); mysql_close($links[0]); mysql_close($links[1]); print "done!\n";