Skip to content

Commit

Permalink
suppression code non utilisé dans Base_De_Donnees
Browse files Browse the repository at this point in the history
Cela n'était pas utilisé, on le supprime.
  • Loading branch information
agallou committed Mar 1, 2025
1 parent 4ac8773 commit 947463a
Showing 1 changed file with 0 additions and 129 deletions.
129 changes: 0 additions & 129 deletions sources/Afup/Utils/Base_De_Donnees.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit 947463a

Please sign in to comment.