/** * Send an email about a possible hack to the admin * * @param string $where - where the event happened */ function writeLog($where) { $ip = getRealIp(); // Get the IP from superglobal $host = gethostbyaddr($ip); // Try to locate the host of the attack // create a logging message with php heredoc syntax $logging = <<<LOGMSGG \tThere was a hacking attempt,. \tIP-Adress: {$ip} \tHost of Attacker: {$host} \tPoint of Attack: {$where} LOGMSGG; // Awkward but LOG must be flush left // log the message echLog('hack', $logging); }
public function __construct($error, $errno) { // get sent vars $this->ex_error = $error; $this->ex_errno = $errno; // get exception information from parent class $traces = parent::getTraceAsString(); // find error message and code $code = $this->ex_errno; $message = $this->ex_error; // log error message $log_success = echLog('mysql', $message, $code, $traces); if (!$log_success) { die('Could not log fatal error'); } // call parent constructor parent::__construct($message, $code); }