function __construct($e, $code = 'DBError') { global $db, $skip_db_error; if (isset($skip_db_error_exception) and $skip_db_error_exception === TRUE) { //Used by system_check script. return TRUE; } $db->FailTrans(); //print_r($e); //adodb_pr($e); Debug::Text('Begin Exception...', __FILE__, __LINE__, __METHOD__, 10); Debug::Arr(Debug::backTrace(), ' BackTrace: ', __FILE__, __LINE__, __METHOD__, 10); //Log database error if (isset($e->message)) { if (stristr($e->message, 'statement timeout') !== FALSE) { $code = 'DBTimeout'; } Debug::Text($e->message, __FILE__, __LINE__, __METHOD__, 10); } if (isset($e->trace)) { $e = strip_tags(adodb_backtrace($e->trace)); Debug::Arr($e, 'Exception...', __FILE__, __LINE__, __METHOD__, 10); } Debug::Text('End Exception...', __FILE__, __LINE__, __METHOD__, 10); //Dump debug buffer. Debug::Display(); Debug::writeToLog(); Debug::emailLog(); Redirect::Page(URLBuilder::getURL(array('exception' => $code), Environment::getBaseURL() . 'DownForMaintenance.php')); ob_flush(); ob_clean(); exit; }
function testdb(&$db, $createtab = "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)") { global $ADODB_version, $ADODB_FETCH_MODE; adodb_backtrace(); $max = 100; $sql = 'select * from ADOXYZ'; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; //print "<h3>ADODB Version: $ADODB_version Host: <i>$db->host</i> Database: <i>$db->database</i></h3>"; // perform query once to cache results so we are only testing throughput $rs = $db->Execute($sql); if (!$rs) { print "Error in recordset<p>"; return; } $arr = $rs->GetArray(); //$db->debug = true; global $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; $start = microtime(); for ($i = 0; $i < $max; $i++) { $rs =& $db->Execute($sql); $arr =& $rs->GetArray(); // print $arr[0][1]; } $end = microtime(); $start = explode(' ', $start); $end = explode(' ', $end); //print_r($start); //print_r($end); // print_r($arr); $total = $end[0] + trim($end[1]) - $start[0] - trim($start[1]); printf("<p>seconds = %8.2f for %d iterations each with %d records</p>", $total, $max, sizeof($arr)); flush(); //$db->Close(); }
function connect() { global $conf_db; try { $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $mode ="mysql"; if ($conf_db) $mode = $conf_db['db_type']; $this->db= ADONewConnection($mode); if ($conf_db) $this->db->Connect($conf_db['db_host'],$conf_db['db_user'],$conf_db['db_pwd'],$conf_db['db_name']) or die("COULD NOT SELECT DATABASE.<br>"); else $this->db->Connect(HOST,USER,PASS,DB) or die("COULD NOT SELECT DATABASE.<br>"); return 0; } catch (exception $e) { var_dump($e); adodb_backtrace($e->gettrace()); $this->message = $e." -> ".$this->db->ErrorMsg(); return 1; } }
function __construct($e) { global $db; $db->FailTrans(); //print_r($e); //adodb_pr($e); //Log database error if (isset($e->message)) { Debug::Text($e->message, __FILE__, __LINE__, __METHOD__, 10); } if (isset($e->trace)) { $e = strip_tags(adodb_backtrace($e->trace)); Debug::Arr($e, 'Exception...', __FILE__, __LINE__, __METHOD__, 10); } Debug::Arr(Debug::backTrace(), ' BackTrace: ', __FILE__, __LINE__, __METHOD__, 10); //Dump debug buffer. Debug::Display(); Debug::writeToLog(); Debug::emailLog(); Redirect::Page(URLBuilder::getURL(array('exception' => 'DBError'), Environment::getBaseURL() . 'DownForMaintenance.php')); ob_flush(); ob_clean(); exit; }
/** * @param $table string name of the table, not needed by all databases (eg. mysql), default '' * @param $column string name of the column, not needed by all databases (eg. mysql), default '' * @return the last inserted ID. Not all databases support this. */ function Insert_ID($table = '', $column = '') { if ($this->_logsql && $this->lastInsID) { return $this->lastInsID; } if ($this->hasInsertID) { return $this->_insertid($table, $column); } if ($this->debug) { ADOConnection::outp('<p>Insert_ID error</p>'); adodb_backtrace(); } return false; }
/** * Execute SQL, caching recordsets. * * @param [secs2cache] seconds to cache data, set to 0 to force query. * This is an optional parameter. * @param sql SQL statement to execute * @param [inputarr] holds the input data to bind to * @return RecordSet or false */ function CacheExecute($secs2cache, $sql = false, $inputarr = false) { global $ADODB_CACHE; if (empty($ADODB_CACHE)) { $this->_CreateCache(); } if (!is_numeric($secs2cache)) { $inputarr = $sql; $sql = $secs2cache; $secs2cache = $this->cacheSecs; } if (is_array($sql)) { $sqlparam = $sql; $sql = $sql[0]; } else { $sqlparam = $sql; } $md5file = $this->_gencachename($sql . serialize($inputarr), true); $err = ''; if ($secs2cache > 0) { $rs = $ADODB_CACHE->readcache($md5file, $err, $secs2cache, $this->arrayClass); $this->numCacheHits += 1; } else { $err = 'Timeout 1'; $rs = false; $this->numCacheMisses += 1; } if (!$rs) { // no cached rs found if ($this->debug) { if (get_magic_quotes_runtime() && !$this->memCache) { ADOConnection::outp("Please disable magic_quotes_runtime - it corrupts cache files :("); } if ($this->debug !== -1) { ADOConnection::outp(" {$md5file} cache failure: {$err} (this is a notice and not an error)"); } } $rs = $this->Execute($sqlparam, $inputarr); if ($rs) { $eof = $rs->EOF; $rs = $this->_rs2rs($rs); // read entire recordset into memory immediately $rs->timeCreated = time(); // used by caching $txt = _rs2serialize($rs, false, $sql); // serialize $ok = $ADODB_CACHE->writecache($md5file, $txt, $this->debug, $secs2cache); if (!$ok) { if ($ok === false) { $em = 'Cache write error'; $en = -32000; if ($fn = $this->raiseErrorFn) { $fn($this->databaseType, 'CacheExecute', $en, $em, $md5file, $sql, $this); } } else { $em = 'Cache file locked warning'; $en = -32001; // do not call error handling for just a warning } if ($this->debug) { ADOConnection::outp(" " . $em); } } if ($rs->EOF && !$eof) { $rs->MoveFirst(); //$rs = csv2rs($md5file,$err); $rs->connection = $this; // Pablo suggestion } } else { if (!$this->memCache) { $ADODB_CACHE->flushcache($md5file); } } } else { $this->_errorMsg = ''; $this->_errorCode = 0; if ($this->fnCacheExecute) { $fn = $this->fnCacheExecute; $fn($this, $secs2cache, $sql, $inputarr); } // ok, set cached object found $rs->connection = $this; // Pablo suggestion if ($this->debug) { if ($this->debug == 99) { adodb_backtrace(); } $inBrowser = isset($_SERVER['HTTP_USER_AGENT']); $ttl = $rs->timeCreated + $secs2cache - time(); $s = is_array($sql) ? $sql[0] : $sql; if ($inBrowser) { $s = '<i>' . htmlspecialchars($s) . '</i>'; } ADOConnection::outp(" {$md5file} reloaded, ttl={$ttl} [ {$s} ]"); } } return $rs; }
function _fetch($ignore_fields = false) { if ($this->connection->debug) { error_log("_fetch()"); } if ($this->fetchMode & ADODB_FETCH_ASSOC) { if ($this->fetchMode & ADODB_FETCH_NUM) { if ($this->connection->debug) { error_log("fetch mode: both"); } $this->fields = @sqlsrv_fetch_array($this->_queryID, SQLSRV_FETCH_BOTH); } else { if ($this->connection->debug) { error_log("fetch mode: assoc"); } $this->fields = @sqlsrv_fetch_array($this->_queryID, SQLSRV_FETCH_ASSOC); } if (ADODB_ASSOC_CASE == 0) { foreach ($this->fields as $k => $v) { $this->fields[strtolower($k)] = $v; } } else { if (ADODB_ASSOC_CASE == 1) { foreach ($this->fields as $k => $v) { $this->fields[strtoupper($k)] = $v; } } } } else { if ($this->connection->debug) { error_log("fetch mode: num"); } $this->fields = @sqlsrv_fetch_array($this->_queryID, SQLSRV_FETCH_NUMERIC); } if (is_array($this->fields) && array_key_exists(1, $this->fields) && !array_key_exists(0, $this->fields)) { //fix fetch numeric keys since they're not 0 based $arrFixed = array(); foreach ($this->fields as $key => $value) { if (is_numeric($key)) { $arrFixed[$key - 1] = $value; } else { $arrFixed[$key] = $value; } } //if($this->connection->debug) error_log("<hr>fixing non 0 based return array, old: ".print_r($this->fields,true)." new: ".print_r($arrFixed,true)); $this->fields = $arrFixed; } if (is_array($this->fields)) { foreach ($this->fields as $key => $value) { if (is_object($value) && method_exists($value, 'format')) { //is DateTime object $this->fields[$key] = $value->format("Y-m-d\\TH:i:s\\Z"); } } } if ($this->fields === null) { $this->fields = false; } if ($this->connection->debug) { error_log("<hr>after _fetch, fields: <pre>" . print_r($this->fields, true) . " backtrace: " . adodb_backtrace(false)); } return $this->fields; }
} $rs = new ADORecordSet_empty(); foreach ($rs as $v) { echo "<p>empty "; var_dump($v); } if ($i != $cnt) { die("actual cnt is {$i}, cnt should be {$cnt}\n"); } else { echo "Count {$i} is correct<br>"; } $rs = $db->Execute("select bad from badder"); } catch (exception $e) { adodb_pr($e); echo "<h3>adodb_backtrace:</h3>\n"; $e = adodb_backtrace($e->gettrace()); } $rs = $db->Execute("select distinct id, firstname,lastname from adoxyz order by id"); echo "Result=\n", $rs, "</p>"; echo "<h3>Active Record</h3>"; include_once "../adodb-active-record.inc.php"; ADOdb_Active_Record::SetDatabaseAdapter($db); try { class City extends ADOdb_Active_Record { } $a = new City(); } catch (exception $e) { echo $e->getMessage(); } try {
V4.80 8 Mar 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, the BSD license will take precedence. Set tabs to 8. */ error_reporting(E_ALL); $path = dirname(__FILE__); include "{$path}/../adodb-exceptions.inc.php"; include "{$path}/../adodb.inc.php"; try { $db = NewADOConnection("oci8"); $db->Connect('', 'scott', 'natsoft'); $db->debug = 1; $cnt = $db->GetOne("select count(*) from adoxyz"); $rs = $db->Execute("select * from adoxyz order by id"); $i = 0; foreach ($rs as $k => $v) { $i += 1; echo $k; adodb_pr($v); flush(); } if ($i != $cnt) { die("actual cnt is {$i}, cnt should be {$cnt}\n"); } $rs = $db->Execute("select bad from badder"); } catch (exception $e) { adodb_pr($e); $e = adodb_backtrace($e->trace); }
/** * Quotes a string. * An example is $db->qstr("Don't bother",magic_quotes_runtime()); * * @param s the string to quote * @param [magic_quotes] if $s is GET/POST var, set to get_magic_quotes_gpc(). * This undoes the stupidity of magic quotes for GPC. * * @return quoted string to be sent back to database */ function qstr($s, $magic_quotes = false) { $nofixquotes = false; if (is_array($s)) { adodb_backtrace(); } if ($this->noNullStrings && strlen($s) == 0) { $s = ' '; } if (!$magic_quotes) { if ($this->replaceQuote[0] == '\\') { $s = str_replace('\\', '\\\\', $s); } return "'" . str_replace("'", $this->replaceQuote, $s) . "'"; } // undo magic quotes for " $s = str_replace('\\"', '"', $s); if ($this->replaceQuote == "\\'") { // ' already quoted, no need to change anything return "'{$s}'"; } else { // change \' to '' for sybase/mssql $s = str_replace('\\\\', '\\', $s); return "'" . str_replace("\\'", $this->replaceQuote, $s) . "'"; } }
function &_Execute($sql, $inputarr = false) { // debug version of query if ($this->debug) { global $HTTP_SERVER_VARS; $ss = ''; if ($inputarr) { foreach ($inputarr as $kk => $vv) { if (is_string($vv) && strlen($vv) > 64) { $vv = substr($vv, 0, 64) . '...'; } $ss .= "({$kk}=>'{$vv}') "; } $ss = "[ {$ss} ]"; } $sqlTxt = str_replace(',', ', ', is_array($sql) ? $sql[0] : $sql); // check if running from browser or command-line $inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']); if ($inBrowser) { if ($this->debug === -1) { ADOConnection::outp("<br>\n({$this->databaseType}): " . htmlspecialchars($sqlTxt) . " <code>{$ss}</code>\n<br>\n", false); } else { ADOConnection::outp("<hr />\n({$this->databaseType}): " . htmlspecialchars($sqlTxt) . " <code>{$ss}</code>\n<hr />\n", false); } } else { ADOConnection::outp("=----\n({$this->databaseType}): " . $sqlTxt . " \n-----\n", false); } flush(); $this->_queryID = $this->_query($sql, $inputarr); /* Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql because ErrorNo() calls Execute('SELECT @ERROR'), causing recure */ if ($this->databaseType == 'mssql') { // ErrorNo is a slow function call in mssql, and not reliable // in PHP 4.0.6 if ($emsg = $this->ErrorMsg()) { $err = $this->ErrorNo(); if ($err) { ADOConnection::outp($err . ': ' . $emsg); flush(); } } } else { if (!$this->_queryID) { $e = $this->ErrorNo(); $m = $this->ErrorMsg(); ADOConnection::outp($e . ': ' . $m); flush(); } } } else { // non-debug version of query $this->_queryID = @$this->_query($sql, $inputarr); } /************************ OK, query executed *************************/ // error handling if query fails if ($this->_queryID === false) { if ($this->debug == 99) { adodb_backtrace(true, 5); } $fn = $this->raiseErrorFn; if ($fn) { $fn($this->databaseType, 'EXECUTE', $this->ErrorNo(), $this->ErrorMsg(), $sql, $inputarr, $this); } return false; } else { if ($this->_queryID === true) { // return simplified empty recordset for inserts/updates/deletes with lower overhead $rs =& new ADORecordSet_empty(); return $rs; } } // return real recordset from select statement $rsclass = $this->rsPrefix . $this->databaseType; $rs =& new $rsclass($this->_queryID, $this->fetchMode); // &new not supported by older PHP versions $rs->connection =& $this; // Pablo suggestion $rs->Init(); if (is_array($sql)) { $rs->sql = $sql[0]; } else { $rs->sql = $sql; } if ($rs->_numOfRows <= 0) { global $ADODB_COUNTRECS; if ($ADODB_COUNTRECS) { if (!$rs->EOF) { $rs =& $this->_rs2rs($rs, -1, -1, !is_array($sql)); $rs->_queryID = $this->_queryID; } else { $rs->_numOfRows = 0; } } } return $rs; }
/** * @return the last inserted ID. Not all databases support this. */ function Insert_ID() { if ($this->_logsql && $this->lastInsID) return $this->lastInsID; if ($this->hasInsertID) return $this->_insertid(); if ($this->debug) { ADOConnection::outp( '<p>Insert_ID error</p>'); adodb_backtrace(); } return false; }
function error_handler($errno, $errmsg, $filename, $linenum, $vars) { // Custom error-handling function. // Sends an email to BUGSLIST. global $PAGE; // define an assoc array of error string // in reality the only entries we should // consider are E_WARNING, E_NOTICE, E_USER_ERROR, // E_USER_WARNING and E_USER_NOTICE $errortype = array(E_ERROR => "Error", E_WARNING => "Warning", E_PARSE => "Parsing Error", E_NOTICE => "Notice", E_CORE_ERROR => "Core Error", E_CORE_WARNING => "Core Warning", E_COMPILE_ERROR => "Compile Error", E_COMPILE_WARNING => "Compile Warning", E_USER_ERROR => "User Error", E_USER_WARNING => "User Warning", E_USER_NOTICE => "User Notice", 2048 => "Runtime Notice"); $err = ''; if (isset($_SERVER['REQUEST_URI'])) { $err .= "URL:\t\thttp://" . DOMAIN . $_SERVER['REQUEST_URI'] . "\n"; } else { $err .= "URL:\t\tNone - running from command line?\n"; } if (isset($_SERVER['HTTP_REFERER'])) { $err .= "Referer:\t" . $_SERVER['HTTP_REFERER'] . "\n"; } else { $err .= "Referer:\tNone\n"; } if (isset($_SERVER['HTTP_USER_AGENT'])) { $err .= "User-Agent:\t" . $_SERVER['HTTP_USER_AGENT'] . "\n"; } else { $err .= "User-Agent:\tNone\n"; } $err .= "Number:\t\t{$errno}\n"; $err .= "Type:\t\t" . $errortype[$errno] . "\n"; $err .= "Message:\t{$errmsg}\n"; $err .= "File:\t\t{$filename}\n"; $err .= "Line:\t\t{$linenum}\n"; if (count($_POST)) { $err .= "_POST:"; foreach ($_POST as $k => $v) { $err .= "\t\t{$k} => {$v}\n"; } } // I'm not sure this bit is actually any use! // set of errors for which a var trace will be saved. // $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE); // if (in_array($errno, $user_errors)) { // $err .= "Variables:\t" . serialize($vars) . "\n"; // } // Add the problematic line if possible. if (is_readable($filename)) { $source = file($filename); $err .= "\nSource:\n\n"; // Show the line, plus prev and next, with line numbers. $err .= $linenum - 2 . " " . $source[$linenum - 3]; $err .= $linenum - 1 . " " . $source[$linenum - 2]; $err .= $linenum . " " . $source[$linenum - 1]; $err .= $linenum + 1 . " " . $source[$linenum]; $err .= $linenum + 2 . " " . $source[$linenum + 1]; } // Will we need to exit after this error? $fatal_errors = array(E_ERROR, E_USER_ERROR); if (in_array($errno, $fatal_errors)) { $fatal = true; } else { $fatal = false; } // Finally, display errors and stuff... if (DEVSITE) { // On a devsite we just display the problem. $message = array('title' => "Error", 'text' => "{$err}\n"); if (is_object($PAGE)) { $PAGE->error_message($message, $fatal); vardump(adodb_backtrace()); } else { vardump($message); vardump(adodb_backtrace()); } } else { // On live sites we display a nice message and email the problem. $message = array('title' => "Sorry, an error has occurred", 'text' => "We've been notified by email and will try to fix the problem soon!"); if (is_object($PAGE)) { $PAGE->error_message($message, $fatal); } else { header('HTTP/1.0 500 Internal Server Error'); print "<p>Oops, sorry, an error has occurred!</p>\n"; } if (!($errno & E_USER_NOTICE)) { mail(BUGSLIST, "[TWFYBUG]: {$errmsg}", $err, "From: Bug <" . CONTACTEMAIL . ">\n" . "X-Mailer: PHP/" . phpversion()); } } // Do we need to exit? if ($fatal) { exit(1); } }
function error_handler($errno, $errmsg, $filename, $linenum, $vars) { $errortype = array(E_ERROR => "Error", E_WARNING => "Warning", E_PARSE => "Parsing Error", E_NOTICE => "Notice", E_CORE_ERROR => "Core Error", E_CORE_WARNING => "Core Warning", E_COMPILE_ERROR => "Compile Error", E_COMPILE_WARNING => "Compile Warning", E_USER_ERROR => "User Error", E_USER_WARNING => "User Warning", E_USER_NOTICE => "User Notice", E_STRICT => "PHP 5 Strict Notice", E_RECOVERABLE_ERROR => 'PHP 5.2 Recoverable Error'); //check error is of an appropriate level $errors_to_report = bit_compactor(ini_get('error_reporting')); if (!in_array($errno, $errors_to_report)) { // There's nothing to report here return; } //get the back trace $backtrace = debug_backtrace(); $backtrace = array_slice($backtrace, 1); //make the message $fatal_errors = array(E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR); $err = ''; if (isset($_SERVER['REQUEST_URI'])) { $err .= "URL:\t\thttp://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . "\n"; } else { $err .= "URL:\t\tNone - running from command line?\n"; } if (isset($_SERVER['HTTP_REFERER'])) { $err .= "Referer:\t" . $_SERVER['HTTP_REFERER'] . "\n"; } else { $err .= "Referer:\tNone\n"; } if (isset($_SERVER['REMOTE_ADDR'])) { $err .= "REMOTE IP:\t" . $_SERVER['REMOTE_ADDR'] . "\n"; } else { $err .= "REMOTE IP:\tNone\n"; } if (isset($_SERVER['SERVER_ADDR'])) { $err .= "SERVER ADDR:\t" . $_SERVER['SERVER_ADDR'] . "\n"; } else { $err .= "SERVER_ADDR:\tNone\n"; } if (isset($_SERVER['REQUEST_METHOD'])) { $err .= "REQUEST METHOD:\t" . $_SERVER['REQUEST_METHOD'] . "\n"; } else { $err .= "REQUEST METHOD:\tNone\n"; } if (isset($_SERVER['HTTP_USER_AGENT'])) { $err .= "User-Agent:\t" . $_SERVER['HTTP_USER_AGENT'] . "\n"; } else { $err .= "User-Agent:\tNone\n"; } $err .= "Number:\t\t{$errno}\n"; $err .= "Type:\t\t" . $errortype[$errno] . "\n"; $err .= "Message:\t{$errmsg}\n"; $err .= "File:\t\t{$filename}\n"; $err .= "Line:\t\t{$linenum}\n"; // Add in the suplimentry data if (isset($GLOBALS['_REPORT_ERROR_MESSAGE']) && !empty($GLOBALS['_REPORT_ERROR_MESSAGE'])) { $err .= "Info:\t\t" . $GLOBALS['_REPORT_ERROR_MESSAGE'] . "\n"; unset($GLOBALS['_REPORT_ERROR_MESSAGE']); } // get the details of where the error is if (is_readable($filename)) { $source = file($filename); $err .= "\nSource:\n\n"; // show the line, plus prev and next, with line numbers. $err .= $linenum - 2 . " " . $source[$linenum - 3]; $err .= $linenum - 1 . " " . $source[$linenum - 2]; $err .= "<b>" . $linenum . " " . $source[$linenum - 1] . "</b>"; $err .= $linenum + 1 . " " . $source[$linenum]; $err .= $linenum + 2 . " " . $source[$linenum + 1]; } // add in the back trace $err .= "\nBacktrace:\n " . adodb_backtrace(false, $backtrace); // Now we want to add in the session, request and suplimentry data if (isset($_REQUEST) && is_array($_REQUEST) && count($_REQUEST) > 0) { $err .= "\nREQUEST Data:\n\n"; $err .= print_r($_REQUEST, true); } if (isset($GLOBALS['_REPORT_ERROR_DATA'])) { $err .= "\nADDITIONAL Data:\n\n"; $err .= print_r($GLOBALS['_REPORT_ERROR_DATA'], true); unset($GLOBALS['_REPORT_ERROR_DATA']); } //anything useful in the session if (isset($_SESSION) && is_array($_SESSION) && count($_SESSION) > 0) { $session = $_SESSION; $err .= "\nSESSION Data:\n\n"; $err .= print_r($session, true); } //either display the message on screen or email it (if on the live site) $fatal = false; if (DEVSITE) { print '<pre>' . $err . '</pre>'; } else { //send the email $subject = BUG_EMAIL_PREFIX . ' ' . ($errno != E_USER_WARNING ? 'FATAL ' : 'WARNING ') . (defined('APP_NAME') ? '(' . APP_NAME . ') ' : '') . $errmsg; send_text_email(BUG_TO_EMAIL, BUG_EMAIL_PREFIX, BUG_FROM_EMAIL, $subject, $err); if ($errno != E_USER_WARNING) { //tell people something bad happened print '<div style="text-align:center;">'; print '<h1>Sorry, something went wrong</h1>'; print '<h3>An email has been sent to the geeks!</h3>'; print '<p><a href="http://www.thestraightchoice.org">click here to go back to the homepage</a></p>'; print '</div>'; $fatal = true; } } //Copy error to the error log error_log($errortype[$errno] . ' : ' . $errmsg . ' ( ' . $filename . ' [' . $linenum . '] )'); //if fatal then die() if ($fatal || in_array($errno, $fatal_errors)) { die; } }
/** * Open a database connection * * @return boolean success */ function openConnection() { $success = true; // No need to open a connection if it is // already open - just use the existing one! if ($this->_conn == null) { try { $this->_conn = ADONewConnection(FT_DB_DSN); } catch (exception $e) { $success = false; $this->setErrorMsg($this->_conn->ErrorMsg()); if (FT_DEBUG) { var_dump($e); adodb_backtrace($e->gettrace()); } } } $this->_conn->debug = FT_DEBUG; $this->_conn->SetFetchMode($this->getOutput()); return $success; }