$_SESSION["sudokuGridSolutions"]
This commit is contained in:
parent
ba07a531d0
commit
39c564fb89
12
index.php
12
index.php
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
require("classes.php");
|
||||
session_start();
|
||||
if (!array_key_exists("nbSolutions", $_SESSION)) {
|
||||
$_SESSION["nbSolutions"] = array();
|
||||
if (!array_key_exists("sudokuGridSolutions", $_SESSION)) {
|
||||
$_SESSION["sudokuGridSolutions"] = array();
|
||||
}
|
||||
|
||||
$fullUrl = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"].$_SERVER["DOCUMENT_URI"];
|
||||
@ -10,12 +10,12 @@
|
||||
$currentGrid = strip_tags($_SERVER['QUERY_STRING']);
|
||||
|
||||
if (preg_match("/^[1-9.]{81}$/", $currentGrid)) {
|
||||
if (!array_key_exists($currentGrid, $_SESSION["nbSolutions"])) {
|
||||
if (!array_key_exists($currentGrid, $_SESSION["sudokuGridSolutions"])) {
|
||||
$grid = new Grid();
|
||||
$grid->import($currentGrid);
|
||||
$_SESSION["nbSolutions"][$currentGrid] = $grid->containsDuplicates() ? -1 : $grid->countSolutions(2);
|
||||
$_SESSION["sudokuGridSolutions"][$currentGrid] = $grid->containsDuplicates() ? -1 : $grid->countSolutions(2);
|
||||
}
|
||||
switch($_SESSION["nbSolutions"][$currentGrid]) {
|
||||
switch($_SESSION["sudokuGridSolutions"][$currentGrid]) {
|
||||
case -1:
|
||||
$warning = "Cette grille contient des doublons.";
|
||||
break;
|
||||
@ -33,7 +33,7 @@
|
||||
$grid->generate();
|
||||
$gridAsString = $grid->toString();
|
||||
$newGridUrl = "$dirUrl/?$gridAsString";
|
||||
$_SESSION["nbSolutions"][$gridAsString] = 1;
|
||||
$_SESSION["sudokuGridSolutions"][$gridAsString] = 1;
|
||||
if ($currentGrid) {
|
||||
require("400.php");
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user