$stateSolver = new StateSolver($sudoku); $stateSolver->findSolution(); return $stateSolver->sudoku; } if (isset($_GET['vakje']) && isset($_GET['graad']) && isset($_GET['goforplay'])) { $sql = "INSERT INTO sudoku (graad,inhoud,time) VALUES ('".$_GET['graad']."','".serialize($_GET['vakje'])."','".time()."')"; if (mysql_result(mysql_query("SELECT COUNT(*) AS a FROM sudoku WHERE inhoud='".serialize($_GET['vakje'])."';"),0,'a') == 0) mysql_query($sql) or die(mysql_error()); } if (isset($_POST['oplossen']) && isset($_POST['vakje']) && isset($_POST['sudoku_id'])) { $inhoud = explode(".",implode(".",unserialize(mysql_result(mysql_query("SELECT inhoud FROM sudoku WHERE id='".$_POST['sudoku_id']."';"),0,'inhoud')))); $goede_oplossing = implode(",",De_Oplossing_In_Array($inhoud)); for ($i=0;$i<81;$i++) { if (isset($_POST['vakje'][$i]) && strlen($_POST['vakje'][$i])==1) $van_gebruiker[$i] = $_POST['vakje'][$i]; else $van_gebruiker[$i] = $inhoud[$i]; } $speler_oplossing = implode(",",$van_gebruiker); if ($goede_oplossing == $speler_oplossing) { // Goede oplossing... echo " JE HEBT M!!!<br><br>"; } else {
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; } </style> </head> <body> <?php if (isset($_GET['play'])) { $inhoud = $db->select_one('sudoku', 'inhoud', array('type' => 9, 'id' => $_GET['play'])); $arrSudoku = explode(',', $inhoud); if (!empty($_GET['solution'])) { $arrSudoku = De_Oplossing_In_Array($arrSudoku); } printSudokuField($arrSudoku); } else { printSudokuField(); } ?> <br /> <table border="1" cellpadding="4"> <tr><th colspan="3">Play existing Sudoku:</td></tr> <?php $q = $db->fetch("SELECT * FROM sudoku WHERE 0 < oplosbaar AND 9 = type ORDER BY graad ASC, time DESC"); foreach ($q as $r) { echo '<tr>'; echo '<td align="right">' . $r['id'] . '</td>';
if (isset($_POST['sudoku'], $_POST['level'])) { if ('easy' !== $_POST['level'] && 'medium' !== $_POST['level'] && 'hard' !== $_POST['level']) { exit('Invalid level! Only "easy", "medium" and "hard" are allowed!'); } if (mysql_query("INSERT INTO sudoku (graad, inhoud, time, type) VALUES ('" . $_POST['level'] . "', '" . $_POST['sudoku'] . "', " . time() . ", 4);")) { exit('OK' . mysql_insert_id()); } exit(mysql_error()); } else { if (isset($_POST['id'], $_POST['sudoku'])) { $q = mysql_query("SELECT inhoud FROM sudoku WHERE type = 4 AND id = " . (int) $_POST['id'] . ";"); if (!$q || !mysql_num_rows($q)) { exit('Is no puzzle!'); } $arrDbSudoku = explode(',', mysql_result($q, 0)); $szSolution = implode(',', De_Oplossing_In_Array($arrDbSudoku)); if ($szSolution === $_POST['sudoku']) { exit(strtoupper('You got it!')); } exit('Sorry, it\'s not correct!'); } } ?> <html> <head> <title>SUDOKU</title> <script type="text/javascript" src="/js/mootools_1_11.js"></script> <script type="text/javascript"> <!--// var g_max = 3;