From 947463ac32986cf65a5cf5823d28874285913669 Mon Sep 17 00:00:00 2001 From: Adrien Gallou Date: Sat, 1 Mar 2025 10:56:30 +0100 Subject: [PATCH] =?UTF-8?q?suppression=20code=20non=20utilis=C3=A9=20dans?= =?UTF-8?q?=20Base=5FDe=5FDonnees?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cela n'était pas utilisé, on le supprime. --- sources/Afup/Utils/Base_De_Donnees.php | 129 ------------------------- 1 file changed, 129 deletions(-) diff --git a/sources/Afup/Utils/Base_De_Donnees.php b/sources/Afup/Utils/Base_De_Donnees.php index 329c878e4..bc2ee6a87 100644 --- a/sources/Afup/Utils/Base_De_Donnees.php +++ b/sources/Afup/Utils/Base_De_Donnees.php @@ -48,112 +48,6 @@ public function getDbLink() return $this->link; } - /** - * Scinde un ensemble de requètes SQL en un tableau regroupant ces requètes - * - * ATTENTION : Fonction importée depuis phpMyAdmin. - * Nom original : PMA_splitSqlFile(). - * - * @param string $sql Requetes SQL à scinder - * @return array Tableau contenant les requètes SQL - */ - public function _scinderRequetesSql($sql): array - { - // do not trim, see bug #1030644 - //$sql = trim($sql); - $sql = rtrim($sql, "\n\r"); - $sql_len = strlen($sql); - $char = ''; - $string_start = ''; - $in_string = false; - $nothing = true; - $time0 = time(); - $ret = []; - - for ($i = 0; $i < $sql_len; ++$i) { - $char = $sql[$i]; - - // We are in a string, check for not escaped end of strings except for - // backquotes that can't be escaped - if ($in_string) { - for (; ;) { - $i = strpos($sql, $string_start, $i); - // No end of string found -> add the current substring to the - // returned array - if (!$i) { - $ret[] = ['query' => $sql, 'empty' => $nothing]; - return $ret; - } elseif ($string_start === '`' || $sql[$i - 1] !== '\\') { - $string_start = ''; - $in_string = false; - break; - } else { - // ... first checks for escaped backslashes - $j = 2; - $escaped_backslash = false; - while ($i - $j > 0 && $sql[$i - $j] === '\\') { - $escaped_backslash = !$escaped_backslash; - $j++; - } - // ... if escaped backslashes: it's really the end of the - // string -> exit the loop - if ($escaped_backslash) { - $string_start = ''; - $in_string = false; - break; - } // ... else loop - else { - $i++; - } - } // end if...elseif...else - } - // end for - } elseif (($char === '-' && $sql_len > $i + 2 && $sql[$i + 1] === '-' && $sql[$i + 2] <= ' ') || $char === '#' || ($char === '/' && $sql_len > $i + 1 && $sql[$i + 1] === '*')) { - $i = strpos($sql, $char === '/' ? '*/' : "\n", $i); - // didn't we hit end of string? - if ($i === false) { - break; - } - if ($char === '/') { - $i++; - } - } elseif ($char === ';') { - // if delimiter found, add the parsed part to the returned array - $ret[] = ['query' => substr($sql, 0, $i), 'empty' => $nothing]; - $nothing = true; - $sql = ltrim(substr($sql, min($i + 1, $sql_len))); - $sql_len = strlen($sql); - if ($sql_len !== 0) { - $i = -1; - } else { - // The submited statement(s) end(s) here - return $ret; - } - } elseif (($char === '"') || ($char === '\'') || ($char === '`')) { - $in_string = true; - $nothing = false; - $string_start = $char; - } elseif ($nothing) { - $nothing = false; - } - - // loic1: send a fake header each 30 sec. to bypass browser timeout - $time1 = time(); - if ($time1 >= $time0 + 30) { - $time0 = $time1; - header('X-pmaPing: Pong'); - } // end if - } // end for - - // add any rest to the returned array - if ($sql !== '' && $sql !== '0' && preg_match('@[^[:space:]]+@', $sql)) { - $ret[] = ['query' => $sql, 'empty' => $nothing]; - } - - return $ret; - } - - /** * Sélectionne la base de données indiquée * @@ -227,29 +121,6 @@ public function executer($requete) return $result; } - - /** - * Exécute les requêtes SQL d'un fichier - * - * @param string $fichier Nom du fichier avec les requêtes à exécuter - */ - public function executerFichier($fichier): bool - { - if (!file_exists($fichier)) { - return false; - } - - $requetes = $this->_scinderRequetesSql(file_get_contents($fichier)); - foreach ($requetes as $requete) { - if (!$this->executer($requete['query'])) { - return false; - } - } - - return true; - } - - /** * Exécute une requête SQL et retourne le premier champ du premier enregistrement *