function err_callback($errno, $errmsg, $filename, $linenum, $vars) { $logFile = new CWwwLog(); $logFile->logStr("PHP ERROR/{$errno} {$errmsg} ({$filename}:{$linenum})"); // Never die after an error }
function err_callback($errno, $errmsg, $filename, $linenum, $vars) { $logFile = new CWwwLog(); $logFile->logStr("PHP ERROR/{$errno} {$errmsg} ({$filename}:{$linenum})"); $logFile->logStr("PHP CALLSTACK/" . print_r(debug_backtrace(), TRUE)); // Never die after an error }
/** * Find the specified error message, and return the first found with the following precedence: * 1. Current language(s) set by setMsgLangage() * 2. English message * 3. Debug message * 4. Generic error * Each language can be found through ['lnk'] if needed * Tags (%1..%n) in the message are replaced by mixed arguments specified after $errNum. * Ex: errorMsg(55, $domainName) * if 'dbg' is found in ['add'] or $DisplayDbg is true, the 'dbg' version is appended to the found version. */ function errorMsg($errNum = GENERIC_ERROR_NUM) { // Find specified message using precedence rules global $MsgLanguages; $precedence = array(array($errNum, $MsgLanguages == 'all' ? array('en', 'fr', 'de') : $MsgLanguages), array($errNum, array('en')), array($errNum, array('dbg')), array(GENERIC_ERROR_NUM, $MsgLanguages), array(GENERIC_ERROR_NUM, array('en'))); global $ErrMsgs; $args = func_get_args(); $msg = ''; foreach ($precedence as $rule) { // Find message list($actualErrNum, $languages) = $rule; foreach ($languages as $lg) { if (isset($ErrMsgs[$actualErrNum][$lg]) && $ErrMsgs[$actualErrNum][$lg] != 'TODO') { appendToMsg($msg, $errNum, $ErrMsgs[$actualErrNum][$lg], $args); } else { if (isset($ErrMsgs[$actualErrNum]['lnk']) && isset($ErrMsgs[$actualErrNum]['lnk'][$lg]) && $ErrMsgs[$actualErrNum]['lnk'][$lg] != 'TODO') { appendToMsg($msg, $errNum, $ErrMsgs[$actualErrNum]['lnk'][$lg], $args); } } } // Try next rule only if not found if (!empty($msg)) { break; } } // Add debug version if needed global $DisplayDbg; $msgHasDebug = in_array('dbg', $languages); $logExtMsg = ''; if (!$msgHasDebug && isset($ErrMsgs[$actualErrNum]['dbg'])) { if ($DisplayDbg || isset($ErrMsgs[$actualErrNum]['add']) && $ErrMsgs[$actualErrNum]['add'] == 'dbg') { $msg .= '[' . $ErrMsgs[$actualErrNum]['dbg'] . "]\n"; } else { $logExtMsg .= '[' . $ErrMsgs[$actualErrNum]['dbg'] . ']'; } // to log message } // Get mail data if specified $mailData = isset($ErrMsgs[$actualErrNum]['mail']) ? $ErrMsgs[$actualErrNum]['mail'] : (isset($ErrMsgs[$actualErrNum]['lnk']['mail']) ? $ErrMsgs[$actualErrNum]['lnk']['mail'] : array()); // Apply params if applicable $numArgs = func_num_args(); if ($numArgs > 1) { for ($i = 0; $i != $numArgs; ++$i) { $msg = str_replace("%{$i}", $args[$i], $msg); $logExtMsg = str_replace("%{$i}", $args[$i], $logExtMsg); $mIdx = 0; foreach ($mailData as $field) { $mailData[$mIdx] = str_replace("%{$i}", $args[$i], $field); ++$mIdx; } } } // Log technical errors if possible $logMode = isset($ErrMsgs[$actualErrNum]['log']) ? $ErrMsgs[$actualErrNum]['log'] : (isset($ErrMsgs[$actualErrNum]['lnk']['log']) ? $ErrMsgs[$actualErrNum]['lnk']['log'] : true); if ($logMode && class_exists('CWwwLog')) { $logFile = new CWwwLog(); $logFile->logStr($logExtMsg); // message is already logged by ob_callback_r2login() } // Send email if specified if (!empty($mailData) && count($mailData) >= 3) { include_once 'email/htmlMimeMail.php'; $mail = new htmlMimeMail(); $mail->setFrom('*****@*****.**'); $mail->setSubject($mailData[1]); $mail->setText('Application: ' . $_GET['clientApplication'] . ' - Login: '******'login'] . "\n" . $mailData[2]); $result = $mail->send(array($mailData[0])); } return $msg; }