Select difficulty level:



Select game image:



Or upload your own image:





Your statistics will not be saved since you are not logged in. Login or register if you like.You are logged in as . Logout. View High Scores.
LANGDON X DOT COM - Image Puzzle
= $intWidth) { $intTop = $intTop + $intPieceHeight; $intLeft = $intLeft - $intWidth; } ?>
153600) { unlink($strTempFile); throw_exception('The file must be smaller than 150 kilobytes.'); } // if it doesn't meet size requirements if (!((($a_image_size[0] <= 640) && ($a_image_size[0] >= 160)) && (($a_image_size[1] <= 640) && ($a_image_size[1] >= 160)))) { unlink($strTempFile); throw_exception('The image must be no greater than 640 pixels and no smaller than 100 pixels on any side.'); } $i = 0; $strNewFile = $strPath . $_FILES['UPLOAD']['name']; $strNewFileName = $_FILES['UPLOAD']['name']; // if a file w/ the same name exists while (file_exists($strNewFile)) { $i++; $strNewFile = $strPath . $i . $_FILES['UPLOAD']['name']; $strNewFileName = $i . $_FILES['UPLOAD']['name']; } // move file to intended destination move_uploaded_file($strTempFile, $strNewFile) or die('failed to move file.'); chmod($strNewFile, 7660); require('../include/database.php'); // insert a new record for this file $query = 'INSERT INTO PUZZLE_FILE (fkPUZZLE_USER_ID, FILENAME) VALUES (' . ((isLoggedIn()) ? $_SESSION['USER_ID'] : 'NULL') . ', \'' . $strNewFileName . '\')'; mysql_query($query) or die('puzzle insert failed'); mysql_close($connection); // redirect header('location: ' . $_SERVER['PHP_SELF'] . '?p=' . $_POST['PARTS'] . '&f=' . $strNewFileName); } } function handleWinner() { if ($_SERVER['QUERY_STRING'] == 'winner') { print 'Congratulations. Try another?'; if (isLoggedIn()) { if ($_POST['hash'] == md5($_SESSION['USER_ID'] . ' plays dis puzzle ' . $_POST['id'] . ' @ dis parts ' . $_POST['parts'])) { require('../include/database.php'); $query = "UPDATE PUZZLE_USER_STATISTIC SET DATE_LAST_UPDATED = NOW(), MOVES = {$_POST['txtAttempt']}, SECONDS = {$_POST['txtTime']} WHERE pkPUZZLE_USER_STATISTIC_ID = {$_POST['id']}"; mysql_query($query) or die('stat update failed..'); mysql_close($connection); // say if they made a new record or something } } else { print '

If you were logged in, you might have been able to obtain a high score.'; } exit; } } function jumbleArray($p_array) { $a_array = $p_array; $intIndex = count($p_array) - 1; $intMaxMoves = count($p_array) * count($p_array) * 10; $intWidth = sqrt(count($p_array)); for ($i = 0; $i < ($intMaxMoves + 6); $i++) { $a_intIndexes = array(); // can move up if (($intIndex - $intWidth) >= 0) $a_intIndexes[] = ($intIndex - $intWidth); // can move down if (($intIndex + $intWidth) < count($p_array)) $a_intIndexes[] = ($intIndex + $intWidth); // can move left if ( (($intIndex - 1) > 0) && ((($intIndex) % $intWidth) != 0)) $a_intIndexes[] = ($intIndex - 1); // can move right if ( (($intIndex + 1) < count($p_array)) && ((($intIndex + 1) % $intWidth) != 0)) $a_intIndexes[] = ($intIndex + 1); if ($intMaxMoves < $i) { sort($a_intIndexes); $intNewIndex = $a_intIndexes[count($a_intIndexes) - 1]; if ((count($a_intIndexes) - 1) == $intNewIndex) return $a_array; } else { // pick a direction at random $intNewIndex = $a_intIndexes[rand(0, (count($a_intIndexes) - 1))]; } // swap the pieces $temp = $a_array[$intIndex]; $a_array[$intIndex] = $a_array[$intNewIndex]; $a_array[$intNewIndex] = $temp; $intIndex = $intNewIndex; } return $a_array; } function makeFit($p_size, $p_divider) { while ($p_size % $p_divider != 0) $p_size--; return $p_size; } function throw_exception($p_text) { $_SESSION['exception'] = $p_text; header('location: ' . $_SERVER['PHP_SELF']); exit; } function verifyInput() { // verify that the parts input is valid if (isset($_GET['p'])) if (($_GET['p'] == 9) | ($_GET['p'] == 16) | ($_GET['p'] == 25) | ($_GET['p'] == 36) | ($_GET['p'] == 49)) $intParts = $_GET['p']; else $intParts = ''; // verify that the filename specified is valid if (isset($_GET['f'])) if (!file_exists($_GET['f'])) { header('location: ' . $_GET['PHP_SELF']); exit; } return $intParts; } ?>