View Source: /source/dbwrapper.php

Click here for the source, OR
Other files that you may wish to view the source of:

Source of: /source/dbwrapper.php

<?
//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);
if (!
get_magic_quotes_gpc()){
    
set_magic_quotes($_GET);
    
set_magic_quotes($_POST);
    
set_magic_quotes($_SESSION);
    
set_magic_quotes($_COOKIE);
    
set_magic_quotes($HTTP_GET_VARS);
    
set_magic_quotes($HTTP_POST_VARS);
    
set_magic_quotes($HTTP_COOKIE_VARS);
    
ini_set("magic_quotes_gpc",1);
}
set_magic_quotes_runtime(0);

function 
set_magic_quotes(&$vars) {
    
//eval("\$vars_val =& \$GLOBALS[$vars]$suffix;");
    
if (is_array($vars)) {
        
reset($vars);
        while (list(
$key,$val) = each($vars))
            
set_magic_quotes($vars[$key]);
    }else{
        
$vars addslashes($vars);
        
//eval("\$GLOBALS$suffix = \$vars_val;");
    
}
}

define('DBTYPE',"mysql");

function 
db_query($sql){
    global 
$session;
    
$fname DBTYPE."_query";
    
$r $fname($sql) or die(($session[user][superuser]>=|| 1?"<pre>".HTMLEntities($sql)."</pre>":"").db_error(LINK));
    return 
$r;
}

function 
db_error($link){
    
$fname DBTYPE."_error";
    
$r $fname($link);
    return 
$r;
}

function 
db_fetch_assoc($result){
    
$fname DBTYPE."_fetch_assoc";
    
$r $fname($result);
    return 
$r;
}

function 
db_num_rows($result){
    
$fname DBTYPE."_num_rows";
    
$r $fname($result);
    return 
$r;
}

function 
db_affected_rows($link=false){
    
$fname DBTYPE."_affected_rows";
    if (
$link===false) {
        
$r $fname();
    }else{
        
$r $fname($link);
    }
    return 
$r;
}

function 
db_pconnect($host,$user,$pass){
    
$fname DBTYPE."_pconnect";
    
$r $fname($host,$user,$pass);
    return 
$r;
}

function 
db_select_db($dbname){
    
$fname DBTYPE."_select_db";
    
$r $fname($dbname);
    return 
$r;
}
?>