[ "default" => HAUTEUR_DEFAUT, "min_range" => HAUTEUR_MIN, "max_range" => HAUTEUR_MAX ] ]); $largeur = filter_input(INPUT_GET, 'colonnes', FILTER_VALIDATE_INT, [ "options" => [ "default" => LARGEUR_DEFAUT, "min_range" => LARGEUR_MIN, "max_range" => LARGEUR_MAX ] ]); $grille = new Grille($hauteur, $largeur); $basedir = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"].dirname($_SERVER["DOCUMENT_URI"]); if (!isset($_GET["grille"]) || $_GET["grille"] == "") { do { $id = uniqid(); $grille_valide = $grille->genere($id); } while (!$grille_valide); $_GET["grille"] = $id; header("Location: $basedir/?" . http_build_query($_GET)); } else { $id = htmlspecialchars($_GET["grille"]); $grille_valide = $grille->load($id) || $grille->genere($id); } mt_srand(crc32($id)); if ($grille_valide) { $definitions_horizontales = []; for ($y = 0; $y < $hauteur; $y++) { $definitions_horizontales[$y] = []; foreach ($grille->lignes[$y] as $mot) { $definitions = $grille->dico[strlen($mot)][$mot]; if (count($definitions)) { $definition = $definitions[mt_rand(0, count($definitions) - 1)]; if (strpos($definition, "#") !== false) { [$definition, $nb_mots] = explode("#", $definition); $nb_mots = " ($nb_mots mots)"; } else { $nb_mots = ""; } if (strpos($definition, "@") !== false) { [$definition, $auteur] = explode("@", $definition); $auteur = " $auteur"; } else { $auteur = ""; } $definitions_horizontales[$y][] = $definition; } } } $definitions_verticales = []; for ($x = 0 ; $x < $largeur; $x++) { $definitions_verticales[$x] = []; foreach ($grille->colonnes[$x] as $mot) { $definitions = $grille->dico[strlen($mot)][$mot]; if (count($definitions)) { $definition = $definitions[mt_rand(0, count($definitions) - 1)]; if (strpos($definition, "#") !== false) { [$definition, $nb_mots] = explode("#", $definition); $nb_mots = " ($nb_mots mots)"; } else { $nb_mots = ""; } if (strpos($definition, "@") !== false) { [$definition, $auteur] = explode("@", $definition); $auteur = " $auteur"; } else { $auteur = ""; } $definitions_verticales[$x][] = $definition . $nb_mots . $auteur; } } } } ?>