"; $s.= "
\nERROR " . date("M d, Y h:i:s A") ."
\n"; $s.= "Sorry, we encountered an error while processing your request.
"; $s.= "The details of this error will be sent to the technical support department for analysis.
"; $s.= "Again, sorry for the inconvenience.
"; $s.= "
\n"; echo $s; $s = ""; } $s = "\n
\nERROR " . date("M d, Y h:i:s A") ."
\n"; if ($bSilent) $s.= "This is a SILENT error (the user has no knowlege of it)
\n"; $s.= "The details of this error will be sent to the technical support department for analysis.
\n"; //assemble the current URL //note that appending the $QUERY_STRING is optional - in some cases the $REQUEST_URI already has the $QUERY_STRING baked into it (depends if we are truly submitting a form, or if's a URL with the form fields baked into it) $strURL = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; if ($_SERVER['QUERY_STRING'] && (strpos($strURL, $_SERVER['QUERY_STRING'])===false)) $strURL .= $_SERVER['QUERY_STRING']; $s.= "$strSourceFile line $intSourceLineNumber
\n". "REMOTE_ADDR: $_SERVER[REMOTE_ADDR]
\n" . "$strTitle
\n". "$strDescription
\n" . "session[userName] = $_SESSION[userName]
\n" . "URL: $strURL
\n" . "Referrer: $_SERVER[HTTP_REFERER]
\n" . "Request Method: $_SERVER[REQUEST_METHOD]
\n" . "Client: $_SERVER[REMOTE_ADDR]
\n" . "Server: $_SERVER[SERVER_ADDR]
\n" . "User Agent: $_SERVER[HTTP_USER_AGENT]
\n" . "PHP Status: $php_errormsg
\n"; if(function_exists("mysqli_error") and $db) $s .= "SQL Status: ". mysqli_error($db) . "
\n"; $s.= "\n"; $s.= "
\n"; $s.= "SESSION VARIABLES:
\n"; if(is_array($_SESSION)){ foreach($_SESSION as $key=>$val){ if(is_array($val)) $val2 = print_r($val,true); else $val2 = $val; $s.="   $key=$val2
\n"; } } $s.= "
\n"; $s.= "CGI POST VARIABLES:
\n"; if(is_array($_POST)){ foreach($_POST as $key=>$val){ if(is_array($val)) $val2 = print_r($val,true); else $val2 = $val; $s.="   $key=$val2
\n"; } } $s.= "
\n"; $s.= "CGI GET VARIABLES:
\n"; if(is_array($_GET)){ foreach($_GET as $key=>$val){ if(is_array($val)) $val2 = print_r($val,true); else $val2 = $val; $s.="   $key=$val2
\n"; } } $s.= "
\n"; $s.= "COOKIES:
\n"; if(is_array($_COOKIE)){ foreach($_COOKIE as $key=>$val){ if(is_array($val)) $val2 = print_r($val,true); else $val2 = $val; $s.="   $key=$val2
\n"; } } if(function_exists("debug_print_backtrace")){ ob_start(); debug_print_backtrace(); $trace = ob_get_contents(); ob_end_clean(); $s.= "
\n"; $s .= "STACK TRACE:
\n"; $s .= str_replace("\n", "
\n", $trace); } if ($bShowTechnicalMessage && !$bSilent) echo $s; if ($bAlwaysEmailTechSupport) { $s = str_replace("
","",$s); //strip out the html, so that it's email friendly $s = str_replace("
","",$s); $s = str_replace(" "," ",$s); mail($strDestEmail,"$_SERVER[HTTP_HOST] Error", $s); } if ($boolFatal) exit(); } ////////////////////////////////////////////////////////////////////////////////////// function strVarDump($var){ ob_start(); var_dump($var); $s=ob_get_contents(); ob_end_clean(); return($s); } ////////////////////////////////////////////////////////////////////////////////////// function logger($strFilename, $strContent){ return; //disabled static $strTime, $strDate; if(!$strDate) $strDate = date("Ymd"); if(!$strTime) $strTime = date("His"); //date("Ymd_His"); $strDir = $_SERVER['DOCUMENT_ROOT'] . "/../logger/" . $strDate; if(!is_dir($strDir)){ mkdir($strDir, 0777); if(!is_dir($strDir)){ logSilentError("logger", "could not create directory $strDir", false, __FILE__, __LINE__); return; } } $strPathname = $strDir . "/" . $strDate . "_" . $strTime . "_" . $strFilename.".txt"; $fp = fopen($strPathname, "a"); if(!$fp){ logSilentError("logger", "could not open $strPathname for append", false, __FILE__, __LINE__); return; } fwrite($fp, $strContent . "\n"); fclose($fp); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// ?>\n"; $result = mysqli_query($db,$sql); if(!$result) logError("cloneDatabase() failed", "sql failed: $sql", true, __FILE__, __LINE__); while($row=mysqli_fetch_array($result)){ $arDatabases[] = $row[0]; } mysqli_free_result($result); while($intTries<100){ $strDestDatabaseName = $strSourceDatabaseName . "_" . date("Ymd"); if($intTries) $strDestDatabaseName .= "_" . $intTries; $bSuccess = !in_array($strDestDatabaseName,$arDatabases); if($bSuccess) break; $intTries++; } if(!$bSuccess) logError("cloneDatabase() failed", "could not come up with an available name for the dest database", true, __FILE__, __LINE__); $sql = "create database $strDestDatabaseName"; if($_SESSION[debugMode]) print "$sql
\n"; $bSuccess = mysqli_query($db,$sql); if(!$bSuccess) logError("cloneDatabase() failed", "sql failed: $sql", true, __FILE__, __LINE__); } //get a list of tables $sql ="SHOW TABLES IN $strSourceDatabaseName"; if($_SESSION[debugMode]) print "$sql
\n"; $result = mysqli_query($db,$sql); if(!$result) logError("cloneDatabase() failed", "sql failed: $sql", true, __FILE__, __LINE__); while($row=mysqli_fetch_array($result)){ $arTables[] = $row[0]; } mysqli_free_result($result); foreach($arTables as $strTable){ $sql = "CREATE TABLE $strDestDatabaseName.$strTable LIKE $strSourceDatabaseName.$strTable"; if($_SESSION[debugMode]) print "$sql
\n"; $bSuccess = mysqli_query($db,$sql); if(!$bSuccess) logError("cloneDatabase() failed", "sql failed: $sql", true, __FILE__, __LINE__); $sql = "INSERT INTO $strDestDatabaseName.$strTable SELECT * FROM $strSourceDatabaseName.$strTable"; if($_SESSION[debugMode]) print "$sql
\n"; $bSuccess = mysqli_query($db,$sql); if(!$bSuccess) logError("cloneDatabase() failed", "sql failed: $sql", true, __FILE__, __LINE__); } } ?>