LoGD Standardrelease steht hier zum Download zur Verfügung!
<?php
/*
2021-06-02 aragon php8 -- magic quotes have been removed
2021-06-05 aragon bugfix php8
2021-06-06 aragon force utf8 on db-connection to avoid charset-mismatch. Data is stored as utf8, files are utf8.
2024-05-04 aragon code-style
*/
//do some cleanup here to make sure magic_quotes_gpc is ON, and magic_quotes_runtime is OFF, and error reporting is all but notice.
error_reporting(E_ALL ^ E_NOTICE);
function set_magic_quotes(&$vars)
{
//eval("\$vars_val =& \$GLOBALS[$vars]$suffix;");
if (is_array($vars)) {
reset($vars);
foreach ($vars as $key => $val)
set_magic_quotes($vars[$key]);
} else {
$vars = addslashes($vars);
//eval("\$GLOBALS$suffix = \$vars_val;");
}
}
define('DBTYPE', "mysqli");
$dbqueriesthishit = 0;
$dbtimethishit = 0;
$mysqli;
function db_query($sql)
{
global $session, $dbqueriesthishit, $dbtimethishit, $link;
global $mysqli;
$superUser = $session['user']['superuser'] ?? 0;
$dbqueriesthishit++;
$dbtimethishit -= getmicrotime();
$fname = DBTYPE . "_query";
$r = $fname($mysqli, $sql) or die(($superUser >= 3 || 1 ? "<pre>" . HTMLEntities($sql) . "</pre>" : "") . db_error($link));
$dbtimethishit += getmicrotime();
//$x = strpos($sql,"WHERE");
//if ($x!==false) {
// $where = substr($sql,$x+6);
// $x = strpos($where,"ORDER BY");
// if ($x!==false) $where = substr($where,0,$x);
// $x = strpos($where,"LIMIT");
// if ($x!==false) $where = substr($where,0,$x);
// $where = preg_replace("/'[^']*'/","",$where);
// $where = preg_replace('/"[^"]*"/',"",$where);
// $where = preg_replace("/[^a-zA-Z ]/","",$where);
// mysql_query("INSERT DELAYED INTO queryanalysis VALUES (0,\"".addslashes($where)."\",0)");
//}
return $r;
}
function db_insert_id($link = false)
{
global $dbtimethishit;
$dbtimethishit -= getmicrotime();
$fname = DBTYPE . "_insert_id";
if ($link === false) {
$r = $fname();
} else {
$r = $fname($link);
}
$dbtimethishit += getmicrotime();
return $r;
}
function db_error($link)
{
$fname = DBTYPE . "_error";
$r = $fname($link);
return $r;
}
function db_fetch_assoc($result)
{
global $dbtimethishit, $mysqli;
$dbtimethishit -= getmicrotime();
$fname = DBTYPE . "_fetch_assoc";
$r = $fname($result);
$dbtimethishit += getmicrotime();
return $r;
}
function db_num_rows($result)
{
global $dbtimethishit, $mysqli;
$dbtimethishit -= getmicrotime();
$fname = DBTYPE . "_num_rows";
$r = $fname($result);
$dbtimethishit += getmicrotime();
return $r;
}
function db_affected_rows($link = false)
{
global $dbtimethishit, $mysqli;
$dbtimethishit -= getmicrotime();
$fname = DBTYPE . "_affected_rows";
if ($link === false) {
$r = $fname($mysqli,);
} else {
$r = $fname($mysqli, $link);
}
$dbtimethishit += getmicrotime();
return $r;
}
function db_pconnect($host, $user, $pass, $name)
{
global $dbtimethishit, $mysqli;
$dbtimethishit -= getmicrotime();
$fname = DBTYPE . "_connect";
$r = $fname($host, $user, $pass, $name);
//$r = new DBTYPE($host, $user, $pass, $name);
$dbtimethishit += getmicrotime();
$mysqli = $r;
if (!$mysqli->set_charset("utf8")) {
printf("Error loading character set utf8: %s\n", $mysqli->error);
exit();
} else {
// printf("Current character set: %s\n", $mysqli->character_set_name());
}
return $r;
}
function db_select_db($dbname)
{
global $mysqli;
global $dbtimethishit;
$dbtimethishit -= getmicrotime();
$fname = DBTYPE . "_select_db";
$r = $fname($mysqli, $dbname);
$dbtimethishit += getmicrotime();
return $r;
}
function db_free_result($result)
{
global $dbtimethishit, $mysqli;
$dbtimethishit -= getmicrotime();
$fname = DBTYPE . "_free_result";
$r = $fname($result);
$dbtimethishit += getmicrotime();
return $r;
}