'; die('Error ' . mysql_errno() . ' : ' . mysql_error() . ' Query= ' . $val); } /** * Displays mysql error messages and sends error details in email. * @param string $val Val is a optional param * @param string $mysqli mysqli is a optional param */ function showierror($val = null, $mysqli = null) { if ($mysqli == null) global $mysqli; $message = getErrorMessage($mysqli->errno, $mysqli->error, $val); sendMail($message); echo ''; die('Error ' . $mysqli->errno . ' : ' . $mysqli->error . ' Query= ' . $val); } /** * Displays mysql error messages and sends error details in email. * @param string $val Val is a optional param * @param PDOStatement $pdo_stmt mysqli is a optional param */ function show_pdo_error($val = null, $pdo_stmt = null, $show_error = true) { $message = getErrorMessage($pdo_stmt->errorCode(), print_r($pdo_stmt->errorInfo(), true), $val); sendMail($message); if ($show_error) { echo ''; die('There was an error. Please try again after sometime.'); } } /** * Sends mysql errors in email through SES. * @param string $message message is a required param */ function sendMail($message) { $subject = 'MySQL Error: ' . $_SERVER['APPLICATION_ENV']; $sesClient = AWSManager::getService('ses'); $configs = getConfigData(); $emailList = $configs['notification']['email']['addresses']; foreach ($emailList as $email => $name) { $to[] = $email; } Web_Mail::sesRawDispatch($sesClient, $to, $subject, $message); } /** * Returns formatted error message. * @param string $errno errno is a optional param * @param string $error error is a optional param * @param string $val Val is a optional param * @return string */ function getErrorMessage($errno = null, $error = null, $val = null) { $message = ' MySQL Error ' . date("Y-m-d H:i:s") . '

' . $_SERVER['REQUEST_URI'] . ' encountered the following MySQL Error:

Error number: ' . $errno . '.

Error info: ' . $error . '.

Query Failed: ' . $val . '.

HOST NAME: ' . $_SERVER['HOSTNAME'] . '

Remote Address: ' . $_SERVER['REMOTE_ADDR'] . '

Server Address: ' . $_SERVER['SERVER_ADDR'] . '

HTTP Referrer: ' . $_SERVER['HTTP_REFERER'] . '

HTTP Request sent:
'; foreach ($_REQUEST as $key => $value) { if (is_array($value)) { $value = implode('; ', $value); } $message .= $key . ':' . $value . '.
'; } $message .= 'SESSION variables:
'; $keys_to_skip = array('auth0__access_token', 'auth0AccessToken', 'auth0__refresh_token', 'csrfp_token', 'auth0__webauth_state'); foreach ($_SESSION as $key => $value) { if (in_array($key, $keys_to_skip)) { continue; } if (is_array($value)) { $value = implode('; ', $value); } $message .= $key . ':' . $value . '.
'; } $message .= ' '; return $message; } function clean($input, $maxlength) { $input = substr($input, 0, $maxlength); $input = EscapeShellCmd($input); return ($input); } function sendErrorPage($mesg) { header("Content-type: text/vnd.wap.wml"); printf(""); printf("\n"); printf("\n"); printf("

\n"); printf("%s", $mesg); printf("

\n"); printf("
\n"); printf("
\n"); }