This commit is contained in:
Adrien MALINGREY 2025-05-09 16:10:54 +02:00
parent 203e5a7edc
commit 21741e394e
10 changed files with 51 additions and 17 deletions

View File

@ -3,14 +3,12 @@ include_once "Trie.php";
const CASE_NOIRE = " "; const CASE_NOIRE = " ";
const MIN_PREMIER_MOT = 1;
const MIN_MOTS_SUIVANTS = 1;
function dico($longueur_max) { function dico($longueur_max) {
$transliterator = Transliterator::createFromRules(':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: Upper(); :: NFC;', Transliterator::FORWARD); $transliterator = Transliterator::createFromRules(':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: Upper(); :: NFC;', Transliterator::FORWARD);
$dico = [[""]]; $dico = [[new Trie()]];
for ($longueur = 0; $longueur <= $longueur_max; $longueur++) { for ($longueur = 0; $longueur <= $longueur_max; $longueur++) {
$dico[] = new Trie(); $dico[] = new Trie();
} }
@ -48,7 +46,7 @@ function dico($longueur_max) {
function mots_espaces($longueur_max) { function mots_espaces($longueur_max) {
$dico = dico($longueur_max); $dico = dico($longueur_max);
for ($longueur = 1; $longueur <= $longueur_max; $longueur++) { for ($longueur = 1; $longueur <= $longueur_max; $longueur++) {
for ($position_espace = MIN_PREMIER_MOT; $position_espace + MIN_MOTS_SUIVANTS < $longueur; $position_espace++) { for ($position_espace = 1; $position_espace + 1 < $longueur; $position_espace++) {
$mots_suivants = $dico[$longueur - $position_espace - 1]; $mots_suivants = $dico[$longueur - $position_espace - 1];
foreach ($dico[$position_espace]->arrayIterator() as $premier_mot => $definition) { foreach ($dico[$position_espace]->arrayIterator() as $premier_mot => $definition) {
$premier_mot[] = CASE_NOIRE; $premier_mot[] = CASE_NOIRE;

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
favicons/favicon-96x96.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -27,17 +27,42 @@ $largeur = filter_input(INPUT_GET, 'colonnes', FILTER_VALIDATE_INT, [
]); ]);
$grille = new Grille($hauteur, $largeur); $grille = new Grille($hauteur, $largeur);
$basedir = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"].dirname($_SERVER["DOCUMENT_URI"]);
if (!isset($_GET["grille"]) || $_GET["grille"] == "") { if (!isset($_GET["grille"]) || $_GET["grille"] == "") {
do { do {
$id = uniqid(); $id = uniqid();
} while (!$grille->genere($id)); } while (!$grille->genere($id));
$_GET["grille"] = $id; $_GET["grille"] = $id;
header("Location: " . dirname($_SERVER['DOCUMENT_URI']) . "?" . http_build_query($_GET)); header("Location: $basedir/?" . http_build_query($_GET));
exit; exit;
} }
?>
<!DOCTYPE HTML>
<html lang="fr-FR" dir="ltr" prefix="og: https://ogp.me/ns#">
<head>
<meta charset="utf-8">
<title>🄼🄾🅃🅂▣🄲🅁🄾🄸🅂🄴🅂</title>
<link rel="stylesheet" href="style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="favicon.ico" />
<link rel="icon" type="image/svg+xml" href="favicons/favicon.svg">
<link rel="icon" type="image/png" href="favicons/favicon-96x96.png" sizes="96x96" />
<link rel="apple-touch-icon" sizes="180x180" href="favicons/apple-touch-icon.png" />
<meta name="apple-mobile-web-app-title" content="🄼🄾🅃🅂 🄲🅁🄾🄸🅂🄴🅂" />
<link rel="manifest" href="site.webmanifest" />
<meta property="og:title" content="🄼🄾🅃🅂 🄲🅁🄾🄸🅂🄴🅂"/>
<meta property="og:type" content="game"/>
<meta property="og:url" content="<?=$basedir?>"/>
<meta property="og:image" content="<?=$basedir?>/thumbnail.png"/>
<meta property="og:image:width" content="192"/>
<meta property="og:image:height" content="192"/>
<meta property="og:locale" content="fr_FR"/>
<meta property="og:site_name" content="<?=$_SERVER["HTTP_HOST"]?>"/>
</head>
<?php
$id = htmlspecialchars($_GET["grille"]); $id = htmlspecialchars($_GET["grille"]);
$grille_valide = $grille->load($id) || $grille->genere($id); $grille_valide = $grille->load($id) || $grille->genere($id);
@ -92,16 +117,6 @@ if ($grille_valide) {
} }
} }
?> ?>
<!DOCTYPE HTML>
<html lang="fr-FR">
<head>
<meta charset="utf-8">
<title>🄼□□🅂■🄲□□□🅂□🄴🅂</title>
<link rel="stylesheet" href="style.css">
<link rel="icon" href="favicon.svg">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body> <body>
<form id="grilleForm" method="get" location="."> <form id="grilleForm" method="get" location=".">
@ -210,7 +225,7 @@ if ($grille_valide) {
</div> </div>
<div class="nouvelle-grille"> <div class="nouvelle-grille">
<img src="favicon.svg" width="16" height="16"> <img src="favicons/favicon.svg" width="16" height="16">
<button type="submit">Nouvelle grille</button> <button type="submit">Nouvelle grille</button>
de de
<input type="number" id="lignes"<?= isset($_GET["lignes"])? ' name="lignes"': "" ?> value="<?= $hauteur ?>" min="<?=HAUTEUR_MIN?>" max="<?=HAUTEUR_MAX?>"/> <input type="number" id="lignes"<?= isset($_GET["lignes"])? ' name="lignes"': "" ?> value="<?= $hauteur ?>" min="<?=HAUTEUR_MIN?>" max="<?=HAUTEUR_MAX?>"/>

21
site.webmanifest Normal file
View File

@ -0,0 +1,21 @@
{
"name": "🄼🄾🅃🅂 🄲🅁🄾🄸🅂🄴🅂",
"short_name": "Mots croisés",
"icons": [
{
"src": "favicons/web-app-manifest-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "favicons/web-app-manifest-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB