[
        "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_valide = false;
$grille = new Grille($hauteur, $largeur);
$basedir = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"].dirname($_SERVER["DOCUMENT_URI"]);
if (isset($_GET["grille"]) || $_GET["grille"] == "") {
    $id = htmlspecialchars($_GET["grille"]);
} else {
    do {
        $id = uniqid();
    } while (!$grille->genere($id));
    $grille_valide = true;
    $_GET["grille"] = $id;
    header("Location: $basedir/?" . http_build_query($_GET));
}
?>
    
    πΌπΎπ
π
β£π²π
πΎπΈπ
π΄π
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    "/>
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;
            }
        }
    }
}
?>