/**
  * Notifies site administrators of the error condition
  *
  * @param  string $notify_msg The formatted error message
  * @param  string $notify_from Sender of the email
  * @param  string $notify_list Email addresses to whom send the error report.
  */
 private static function _notify(&$notify_msg, $notify_from, $notify_list)
 {
     $backtrace = debug_backtrace();
     array_splice($backtrace, 0, 2);
     foreach ($backtrace as $frame) {
         // avoid recursion?
         if (isset($frame['class']) && $frame['class'] == __CLASS__) {
             return;
         }
     }
     $time = time();
     $date = date('Y-m-d H:i:s', $time);
     $msg = "Hello,\n\n";
     $msg .= $notify_msg;
     // this checks that we're not running from commandline (cron for example)
     if (isset($_SERVER['REMOTE_ADDR'])) {
         $proto = 'http';
         if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === 'on' || $_SERVER['HTTPS'] == 1)) {
             $proto .= 's';
         }
         $url = "{$proto}://{$_SERVER['HTTP_HOST']}{$_SERVER['SCRIPT_NAME']}";
         if (isset($_SERVER['QUERY_STRING'])) {
             $url .= "?{$_SERVER['QUERY_STRING']}";
         }
         $msg .= "URL: {$url}\n";
         $msg .= "IP: {$_SERVER['REMOTE_ADDR']}\n";
         $login = Auth::getUserLogin();
         if ($login) {
             $msg .= "User: {$login}\n";
         }
         if (!empty($_SERVER['HTTP_REFERER'])) {
             $msg .= "Referer: {$_SERVER['HTTP_REFERER']}\n";
         }
         if (!empty($_SERVER['HTTP_USER_AGENT'])) {
             $msg .= "User-Agent: {$_SERVER['HTTP_USER_AGENT']}\n";
         }
         $msg .= "\n";
     }
     $msg .= "-- \nSincerely yours,\nAutomated Error_Handler Class";
     $max_allowed_packet = DB_Helper::getMaxAllowedPacket();
     // skip error details of an email notification about a query that
     // was bigger than max_allowed_packet + 1024
     if (strlen($msg) > $max_allowed_packet + 1024) {
         return;
     }
     $notify_list = str_replace(';', ',', $notify_list);
     $notify_list = explode(',', $notify_list);
     $subject = APP_SITE_NAME . ' - Error found! - ' . $date;
     foreach ($notify_list as $notify_email) {
         $mail = new Mail_Helper();
         $mail->setTextBody($msg);
         $mail->send($notify_from, $notify_email, $subject, 0, false, 'error');
     }
 }