public function __construct()
 {
     parent::__construct();
     $this->preserved = array();
     // static vars come from the parent class
     $this->latest = array("pid" => self::$pid, "ip" => Request::GetRemoteAddr(), "user" => self::$user, "start" => $_SERVER['REQUEST_TIME'], "devtype" => Request::GetDeviceType(), "devid" => self::$devid, "devagent" => Request::GetUserAgent(), "command" => Request::GetCommandCode(), "ended" => 0, "push" => false);
     $this->key = self::PREFIX . self::$devid . '|' . self::$user . '|' . self::$pid;
     $this->AnnounceInformation("initializing");
 }
 /**
  * Constructor
  *
  * @access public
  */
 public function TopCollector()
 {
     // initialize super parameters
     $this->allocate = 2097152;
     // 2 MB
     $this->type = 20;
     parent::__construct();
     // initialize params
     $this->InitializeParams();
     $this->preserved = array();
     // static vars come from the parent class
     $this->latest = array("pid" => self::$pid, "ip" => Request::GetRemoteAddr(), "user" => self::$user, "start" => self::$start, "devtype" => Request::GetDeviceType(), "devid" => self::$devid, "devagent" => Request::GetUserAgent(), "command" => Request::GetCommandCode(), "ended" => 0, "push" => false);
     $this->AnnounceInformation("initializing");
 }
Example #3
0
     if ($ex instanceof ZPushException) {
         header('HTTP/1.1 ' . $ex->getHTTPCodeString());
         foreach ($ex->getHTTPHeaders() as $h) {
             header($h);
         }
     } else {
         header('HTTP/1.1 500 Internal Server Error');
     }
 } else {
     ZLog::Write(LOGLEVEL_FATAL, "Exception: ({$exclass}) - headers were already sent. Message: " . $ex->getMessage());
 }
 if ($ex instanceof AuthenticationRequiredException) {
     ZPush::PrintZPushLegal($exclass, sprintf('<pre>%s</pre>', $ex->getMessage()));
     // log the failed login attemt e.g. for fail2ban
     if (defined('LOGAUTHFAIL') && LOGAUTHFAIL != false) {
         ZLog::Write(LOGLEVEL_WARN, sprintf("IP: %s failed to authenticate user '%s'", Request::GetRemoteAddr(), Request::GetAuthUser() ? Request::GetAuthUser() : Request::GetGETUser()));
     }
 } else {
     if ($ex instanceof WBXMLException) {
         ZLog::Write(LOGLEVEL_FATAL, "Request could not be processed correctly due to a WBXMLException. Please report this.");
     } else {
         if (!$ex instanceof ZPushException || $ex->showLegalNotice()) {
             $cmdinfo = Request::GetCommand() ? sprintf(" processing command <i>%s</i>", Request::GetCommand()) : "";
             $extrace = $ex->getTrace();
             $trace = !empty($extrace) ? "\n\nTrace:\n" . print_r($extrace, 1) : "";
             ZPush::PrintZPushLegal($exclass . $cmdinfo, sprintf('<pre>%s</pre>', $ex->getMessage() . $trace));
         }
     }
 }
 // Announce exception to process loop detection
 if (ZPush::GetDeviceManager(false)) {
Example #4
0
        ZPush::PrintZPushLegal($exclass, sprintf('<pre>%s</pre>', $ex->getMessage()));
        // log the failed login attemt e.g. for fail2ban
        if (defined('LOGAUTHFAIL') && LOGAUTHFAIL != false) {
            ZLog::Write(LOGLEVEL_WARN, sprintf("IP: %s failed to authenticate user '%s'", Request::GetRemoteAddr(), Request::GetAuthUser() ? Request::GetAuthUser() : Request::GetGETUser()));
        }
    } else {
        if ($ex instanceof WBXMLException) {
            ZLog::Write(LOGLEVEL_FATAL, "Request could not be processed correctly due to a WBXMLException. Please report this including the 'WBXML debug data' logged. Be aware that the debug data could contain confidential information.");
        } else {
            if (!$ex instanceof ZPushException || $ex->showLegalNotice()) {
                $cmdinfo = Request::GetCommand() ? sprintf(" processing command <i>%s</i>", Request::GetCommand()) : "";
                $extrace = $ex->getTrace();
                $trace = !empty($extrace) ? "\n\nTrace:\n" . print_r($extrace, 1) : "";
                ZPush::PrintZPushLegal($exclass . $cmdinfo, sprintf('<pre>%s</pre>', $ex->getMessage() . $trace));
            }
        }
    }
    // Announce exception to process loop detection
    if (ZPush::GetDeviceManager(false)) {
        ZPush::GetDeviceManager()->AnnounceProcessException($ex);
    }
    // Announce exception if the TopCollector if available
    ZPush::GetTopCollector()->AnnounceInformation(get_class($ex), true);
}
// save device data if the DeviceManager is available
if (ZPush::GetDeviceManager(false)) {
    ZPush::GetDeviceManager()->Save();
}
// end gracefully
ZLog::Write(LOGLEVEL_INFO, sprintf("cmd='%s' memory='%s/%s' time='%ss' devType='%s' devId='%s' getUser='******' from='%s' version='%s' method='%s' httpcode='%s'", Request::GetCommand(), Utils::FormatBytes(memory_get_peak_usage(false)), Utils::FormatBytes(memory_get_peak_usage(true)), number_format(microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"], 2), Request::GetDeviceType(), Request::GetDeviceID(), Request::GetGETUser(), Request::GetRemoteAddr(), @constant('ZPUSH_VERSION'), Request::GetMethod(), http_response_code()));
ZLog::Write(LOGLEVEL_DEBUG, "-------- End");
Example #5
0
 /**
  * Write request header to log
  */
 protected static function RequestHeader()
 {
     self::Write(LOGLEVEL_DEBUG, "-------- Start");
     self::Write(LOGLEVEL_DEBUG, sprintf("cmd='%s' devType='%s' devId='%s' getUser='******' from='%s' version='%s' method='%s'", Request::GetCommand(), Request::GetDeviceType(), Request::GetDeviceID(), Request::GetGETUser(), Request::GetRemoteAddr(), @constant('ZPUSH_VERSION'), Request::GetMethod()));
 }