Ejemplo n.º 1
0
Archivo: Log.php Proyecto: shupp/openid
 /**
  * Logs the event
  * 
  * @param array $event Array containing 'name' and 'data' keys
  * 
  * @return void
  */
 public function update(array $event)
 {
     if (!in_array($event['name'], $this->events)) {
         return;
     }
     $this->log->log($event['name'] . ":\n");
     $this->log->log($event['data']);
 }
Ejemplo n.º 2
0
function phpErrorHandler($severity, $message, $filename, $lineno)
{
    switch ($severity) {
        case E_ERROR:
        case E_WARNING:
        case E_PARSE:
        case E_CORE_ERROR:
        case E_COMPILE_WARNING:
        case E_USER_WARNING:
            if (LOGGING) {
                Log::logException(LoggingConstants::ERROR, "Unexpected error", ErrorException($message, 0, $severity, $filename, $lineno));
            }
            break;
        case E_RECOVERABLE_ERROR:
        case E_USER_ERROR:
            $exception = new ErrorException($message, 0, $severity, $filename, $lineno);
            if (LOGGING) {
                Log::logException(LoggingConstants::ERROR, "Unexpected error", $exception);
            }
            throw $exception;
            break;
        case E_USER_NOTICE:
        case E_NOTICE:
            if (LOGGING) {
                Log::log(LoggingConstants::INFO, "PHP notice: {$message}, file:{$filename}, line:{$lineno}");
            }
            break;
        default:
            if (LOGGING) {
                Log::log(LoggingConstants::DEBUG, "PHP notice: {$message}, file:{$filename}, line:{$lineno}");
            }
    }
}
 public static function loadClass($class, $dirs = null)
 {
     // make a recursive directoryiterator
     $config = Zend_Registry::getInstance()->configuration;
     $from_path = $config->webapp ? $config->webapp->modules ? realpath($config->webapp->modules->path) : null : null;
     if ($from_path) {
         $i = new RecursiveIteratorIterator(new FilenameFilterIterator($from_path, array('.svn', '.hc', '.cvs')));
         // Scan the modules folder and attempt to find the class
         Log::log("ModuleLoader ; Scanning for {$class} in directory \"{$from_path}\".", Log::DEBUG);
         foreach ($i as $key => $value) {
             // If we try to find Foo module, look for ModuleFoo.class.php
             $match = "Module{$class}.class.php";
             if (substr($value, -strlen($match)) == $match) {
                 Log::log("ModuleLoader ; Found class {$class} in file \"{$value}\".", Log::INFO);
                 include_once $key;
                 break 1;
                 // exit foreach
             } else {
                 Log::log("ModuleLoader ; Skipping file \"{$value}\".", Log::DEBUG);
             }
         }
         return $class;
     } else {
         return false;
     }
 }
Ejemplo n.º 4
0
 public static function curlFetch($url)
 {
     $numTries = 0;
     do {
         global $baseAddr;
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_USERAGENT, "Crest Fetcher for https://{$baseAddr}");
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
         curl_setopt($ch, CURLOPT_TIMEOUT, 5);
         //timeout in seconds
         $body = curl_exec($ch);
         $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
         if ($httpCode == 200) {
             return $body;
         }
         if ($httpCode == 403) {
             return;
         }
         if ($httpCode == 500) {
             return 500;
         }
         if ($httpCode == 415) {
             return 415;
         }
         ++$numTries;
         sleep(1);
     } while ($httpCode != 200 && $numTries <= 3);
     Log::log("Gave up on {$url}");
     return;
 }
Ejemplo n.º 5
0
 private function processAMFResponse($streamResponse, AsyncStreamSetInfo $asyncStreamSetInfo)
 {
     /*MessageDataReader*/
     $parser = new MessageDataReader();
     /*Message*/
     $responseObject = $parser->readMessage($streamResponse);
     /*Object[]*/
     $responseData = $responseObject->getRequestBodyData();
     /*V3Message*/
     $v3 = $responseData[0]->defaultAdapt();
     if ($v3->isError()) {
         /*ErrMessage*/
         $errorMessage = $v3;
         /*Fault*/
         $fault = new Fault($errorMessage->faultString, $errorMessage->faultDetail);
         $asyncStreamSetInfo->responder->errorHandler($fault);
     } else {
         /*Object[]*/
         $returnValue = $v3->body->body;
         /*Object[]*/
         $adaptedObject = array();
         for ($i = 0; $i < count($returnValue); $i++) {
             $adaptedObject[$i] = $returnValue[$i]->defaultAdapt();
         }
         var_dump($adaptedObject);
         Log::log(LoggingConstants::MYDEBUG, ob_get_contents());
         $asyncStreamSetInfo->responder->responseHandler($adaptedObject);
     }
 }
Ejemplo n.º 6
0
 public function inspect($targetObject)
 {
     if (LOGGING) {
         Log::log(LoggingConstants::DEBUG, "WebServiceHandler.inspect, targetObject: " . $targetObject);
     }
     if (strripos($targetObject, "wsdl") != strlen($targetObject) - 4) {
         return null;
     }
     $proxyhost = '';
     $proxyport = '';
     $proxyusername = '';
     $proxypassword = '';
     $client = new soapclient($targetObject, true, $proxyhost, $proxyport, $proxyusername, $proxypassword);
     $err = $client->getError();
     if ($err) {
         throw new Exception($err);
     }
     $proxy = $client->getProxy();
     //			$webInsp = new WebServiceInspector();
     //			$webInsp->inspect($targetObject);
     //
     //			$serviceDescriptor = $webInsp->serviceDescriptor;
     ////			if( LOGGING )
     ////				Log::log( LoggingConstants::MYDEBUG, ob_get_contents());
     //			$_SESSION['wsdl'][$targetObject] = serialize($serviceDescriptor);
     $proxyName = get_class($proxy);
     $proxyReflection = new ReflectionClass($proxyName);
     $serviceDescriptor = ClassInspector::inspectClass($proxyReflection);
     if (LOGGING) {
         Log::log(LoggingConstants::DEBUG, "web service handler has successfully inspected target service");
     }
     return $serviceDescriptor;
 }
 /**
  * calls main kd-config backend to retrieve user-specific vars
  */
 protected function initConfigFromKabelDeutschland()
 {
     $url = $this->base_config['config_url'] . '?';
     foreach ($this->base_config['params'] as $name => $value) {
         $url .= urlencode($name) . '=' . urlencode($value) . '&';
     }
     $url = substr($url, 0, strlen($url) - 1);
     $arr_config = $this->get($url, array(), true);
     $this->base_url = $arr_config['params']['Gateways'][0]['JsonGW'];
     // init obj has wrong format
     $arr_init = $arr_config['params']['InitObj'];
     foreach ($arr_init as $element) {
         foreach ($element as $key => $value) {
             if (!is_array($value)) {
                 $this->init_object['initObj'][$key] = $value;
             } else {
                 foreach ($value as $sub_element) {
                     foreach ($sub_element as $sub_key => $sub_value) {
                         $this->init_object['initObj'][$key][$sub_key] = $sub_value;
                     }
                 }
             }
         }
     }
     // set hardcoded values
     $this->init_object['initObj']['UDID'] = $this->api['udid'];
     $this->obj_log->log('initConfig', json_encode($this->init_object));
 }
Ejemplo n.º 8
0
 public function execute(Request $message)
 {
     /*String*/
     $dsId = $this->headers["DSId"];
     /*String*/
     $woId = $this->headers["WebORBClientId"];
     /*IDestination*/
     $destObj = ORBConfig::getInstance()->getDataServices()->getDestinationManager()->getDestination($this->destination);
     if ($destObj == null) {
         /*String*/
         $error = "Unknown destination - " . $destination . ". Make sure the destination is properly configured.";
         if (LOGGING) {
             Log::log(LoggingConstants::ERROR, $error);
         }
         return new ErrMessage($this->messageId, new Exception($error));
     }
     /*Object[]*/
     $bodyParts = $this->body->body;
     if ($bodyParts != null && count($bodyParts) > 0) {
         for ($i = 0, $len = count($bodyParts); $i < $len; $i++) {
             $this->body->body[$i] = $bodyParts[$i]->defaultAdapt();
         }
         $destObj->messagePublished($woId, $bodyParts[0]);
         $destObj->getServiceHandler()->addMessage($this->headers, $this);
     }
     return new AckMessage($this->messageId, $this->clientId, null, array());
 }
 private static function updateCorporations($db)
 {
     $db->execute("delete from zz_corporations where corporationID = 0");
     $db->execute("insert ignore into zz_corporations (corporationID) select executorCorpID from zz_alliances where executorCorpID > 0");
     $result = $db->query("select corporationID, name, memberCount, ticker from zz_corporations where lastUpdated < date_sub(now(), interval 1 week) and corporationID >= 1000001 order by lastUpdated limit 100", array(), 0);
     foreach ($result as $row) {
         $id = $row["corporationID"];
         $pheal = Util::getPheal();
         $pheal->scope = "corp";
         try {
             $corpInfo = $pheal->CorporationSheet(array("corporationID" => $id));
             $name = $corpInfo->corporationName;
             $ticker = $corpInfo->ticker;
             $memberCount = $corpInfo->memberCount;
             $ceoID = $corpInfo->ceoID;
             if ($ceoID == 1) {
                 $ceoID = 0;
             }
             $dscr = $corpInfo->description;
             //CLI::out("|g|$id|n| $name");
             if ($name != "") {
                 $db->execute("update zz_corporations set name = :name, ticker = :ticker, memberCount = :memberCount, ceoID = :ceoID, description = :dscr, lastUpdated = now() where corporationID = :id", array(":id" => $id, ":name" => $name, ":ticker" => $ticker, ":memberCount" => $memberCount, ":ceoID" => $ceoID, ":dscr" => $dscr));
             }
         } catch (Exception $ex) {
             $db->execute("update zz_corporations set lastUpdated = now(), name = :name where corporationID = :id", array(":id" => $id, ":name" => "Corporation {$id}"));
             if ($ex->getCode() != 503) {
                 Log::log("ERROR Validating Corp {$id}: " . $ex->getMessage());
             }
         }
         usleep(100000);
         // Try not to spam the API servers (pauses 1/10th of a second)
     }
 }
Ejemplo n.º 10
0
 public function dispatch(Request &$request)
 {
     $config = ORBConfig::getInstance();
     for ($i = 0, $max = $request->getBodyCount(); $i < $max; $i++) {
         $request->setCurrentBody($i);
         $requestURI = $request->getRequestURI();
         if (LOGGING) {
             Log::log(LoggingConstants::INFO, "requestURI = {$requestURI}");
         }
         $serviceId = substr($requestURI, 0, strrpos($requestURI, "."));
         $methodName = substr($requestURI, strlen($serviceId) + 1);
         $arg = $request->getRequestBodyData();
         if (!is_array($arg)) {
             $arg = array($request->getRequestBodyData());
         }
         try {
             $value = self::handleInvoke($request, $serviceId, $methodName, $arg);
             $namedObject = $arg[0];
             $correlationId = $namedObject->defaultAdapt()->messageId;
             $ackMessage = new AckMessage($correlationId, null, $value);
             $request->setResponseBodyPart($ackMessage);
             $request->setResponseURI("/onResult");
         } catch (Exception $e) {
             $request->setResponseBodyPart($e);
             $request->setResponseURI("/onStatus");
         }
     }
     return true;
 }
Ejemplo n.º 11
0
 static function save($type = '', $destination = '', $extra = '')
 {
     if (empty(self::$log)) {
         return;
     }
     $type = $type ? $type : C('LOG_TYPE');
     if (self::FILE == $type) {
         // 文件方式记录日志信息
         if (empty($destination)) {
             $destination = C('LOG_PATH') . date('y_m_d') . '.log';
         }
         //检测日志文件大小,超过配置大小则备份日志文件重新生成
         if (is_file($destination) && floor(C('LOG_FILE_SIZE')) <= filesize($destination)) {
             rename($destination, dirname($destination) . '/' . time() . '-' . basename($destination));
         }
     } else {
         $destination = $destination ? $destination : C('LOG_DEST');
         $extra = $extra ? $extra : C('LOG_EXTRA');
     }
     $now = date(self::$format);
     error_log($now . ' ' . get_client_ip() . ' ' . $_SERVER['REQUEST_URI'] . "\r\n" . implode('', self::$log) . "\r\n", $type, $destination, $extra);
     // 保存后清空日志缓存
     self::$log = array();
     //clearstatcache();
 }
Ejemplo n.º 12
0
 public static function dump($data, $label = '')
 {
     if (!self::hasDebug()) {
         return;
     }
     Log::log(self::CLASSNAME, $data, $label);
 }
Ejemplo n.º 13
0
 public function dispatch(Request &$request)
 {
     if (!$this->isV3Request($request)) {
         return false;
     }
     $authError = false;
     for ($i = 0, $max = $request->getBodyCount(); $i < $max; $i++) {
         $request->setCurrentBody($i);
         $array = $request->getRequestBodyData();
         $class = new ReflectionClass("V3Message");
         if ($array[0] instanceof NamedObject && $array[0]->canAdaptTo($class)) {
             /*NamedObject*/
             $namedObject = $array[0];
             /*V3Message*/
             $v3message = $namedObject->defaultAdapt();
             $v3message = $v3message->execute($request);
             $request->setResponseBodyPart($v3message);
             if ($v3message->IsError()) {
                 $request->setResponseURI(ORBConstants::ONSTATUS);
             } else {
                 $request->setResponseURI(ORBConstants::ONRESULT);
             }
         } else {
             if (LOGGING) {
                 Log::log(LoggingConstants::DEBUG, "cannot be adapted to V3Message");
             }
             return false;
         }
     }
     return true;
 }
 public function pass()
 {
     $remoteHost = $this->getRemoteHostName();
     if ($remoteHost == null) {
         if (LOGGING) {
             Log::log(LoggingConstants::ERROR, "unable to resolve the host name for " . Network::getUserHostAddress());
         }
         return false;
     }
     if ($this->m_isLocalHost) {
         return $this->localHostCheck($remoteHost);
     }
     foreach ($this->m_comparators as $comparator) {
         $needToBreak = false;
         $index = strrpos($remoteHost, ".");
         $token = $remoteHost;
         if ($index === false) {
             $needToBreak = true;
         } else {
             $token = substr($remoteHost, index + 1);
         }
         if (!$comparator->match($token)) {
             return false;
         }
         if ($needToBreak) {
             break;
         }
         $remoteHost = substr($remoteHost, 0, $index);
     }
     return true;
 }
Ejemplo n.º 15
0
 /**
  * Automatik logging.
  * Selects if to log as json string or as plain string depending if
  * message is object or string.
  * @param string $level
  * @param mixed $message
  */
 private static function autolog($level, $message)
 {
     if (is_string($message)) {
         Log::log($level, $message);
     } else {
         Log::jlog($level, $message);
     }
 }
Ejemplo n.º 16
0
 public function quitConsoleAction()
 {
     $this->application->get('session')->delete("desktop");
     // Journal de log
     $logger = new Log("db");
     $logger->log("{$this->getUser()->getIdentity()} quitte la console d'administration.", Log::INFO);
     $this->redirect('intranet/index');
 }
Ejemplo n.º 17
0
 public function __construct()
 {
     if (Core::$oSession->authUserData !== null) {
         self::$userData = Core::$oSession->authUserData;
         $this->isLogged = true;
         Log::log(self::CLASSNAME, Core::$oSession->authUserData);
     }
 }
Ejemplo n.º 18
0
 public static function log()
 {
     if (file_exists(Settings::$errorLog)) {
         Log::log(self::CLASSNAME, File::tail(Settings::$errorLog, 50));
     } else {
         Log::log(self::CLASSNAME, "Error file not exist!");
     }
 }
Ejemplo n.º 19
0
 public static function findMethod(ReflectionClass $class, $methodName)
 {
     if (LOGGING) {
         Log::log(LoggingConstants::INFO, "methodName = {$methodName}");
     }
     $method = $class->getMethod($methodName);
     return $method;
 }
Ejemplo n.º 20
0
 /**
  * Private function that logs message using specified logger (if provided).
  * @param string $msg Message to log.
  */
 private function log($msg)
 {
     if (self::$logger) {
         // message on one line
         $msg = preg_replace("/\r?\n/", ' ', $msg);
         self::$logger->log($msg);
     }
 }
 /**
  * Private function that logs message using specified logger (if provided).
  * @param string $msg Message to log.
  */
 protected function log($msg, $boolQueryLog = false)
 {
     if (self::$logger) {
         // message on one line
         $msg = preg_replace("/\r?\n/", ' ', $msg);
         self::$logger->log($msg);
     }
 }
Ejemplo n.º 22
0
 public function setEmployee(Employee $emp)
 {
     Log::log(LoggingConstants::DEBUG, var_export($emp, TRUE));
     Log::log(LoggingConstants::DEBUG, count($emp));
     Log::log(LoggingConstants::DEBUG, $emp->getEmployeeName());
     $emp->setEmployeeName("Joe Orbman");
     return $emp;
 }
Ejemplo n.º 23
0
 public function write()
 {
     Log::log(LoggingConstants::MYDEBUG, "Write Page");
     foreach ($this->content as $child) {
         if ($child != null && get_class($child) != "" && !$child->onEachPage) {
             $child->write();
         }
     }
 }
 public function __construct()
 {
     if (class_exists('finfo', false)) {
         $mimefile = realpath(dirname(__FILE__)) . '/magic';
         $this->_finfo = new finfo(FILEINFO_MIME, $mimefile);
     } else {
         Log::log("Fileinfo class not found, using fallback mime type detecting.", Log::NOTICE);
     }
 }
 public function processDestination(ORBConfig $orbConfig, $destinationId, $destinationNode)
 {
     if (LOGGING) {
         Log::log(LoggingConstants::INFO, "Registered Flex Messaging destination - " . $destinationId);
     }
     /*MessagingDestination*/
     $destination = new MessagingDestination($destinationId);
     return $destination;
 }
Ejemplo n.º 26
0
 public function addItem($itemName)
 {
     $_SESSION['shopping_cart_items'][] = $itemName;
     var_dump($_SESSION['shopping_cart_items']);
     if (LOGGING) {
         Log::log(LoggingConstants::MYDEBUG, ob_get_contents());
     }
     return $itemName;
 }
 /**
  * risolutoErrorLog($loglevel, $msg)
  *
  * エラーログを出力する
  *
  * @access    private
  *
  * @param     string $loglevel 出力するメッセージのログレベル
  * @param     string $msg 出力するメッセージ
  *
  * @return    boolean 常にTrue
  */
 private function risolutoErrorLog($loglevel, $msg)
 {
     // ログ出力しエラーメッセージを返却
     $conf = new Conf();
     $conf->parse(RISOLUTO_CONF . 'risoluto.ini');
     $log = new Log();
     $log->setCurrentLogLevel($conf->getIni('LOGGING', 'loglevel'));
     $log->log($loglevel, $msg);
 }
Ejemplo n.º 28
0
 public function __construct($message, $code = 0, Exception $previous = null)
 {
     $di = new Di();
     $config = new Config($di);
     $di->register($config);
     $log = new Log($config);
     $log->log($message);
     parent::__construct($message, $code, $previous);
 }
Ejemplo n.º 29
0
 public function load($className)
 {
     $path = $this->pathes[$className];
     if (file_exists($path)) {
         require_once $path;
     } else {
         Log::log(LoggingConstants::EXCEPTION, "Cannot load file: " . $path);
     }
 }
Ejemplo n.º 30
0
 /**
  * Actually download file(s)
  *
  * @throws \Exception
  */
 public function download()
 {
     $fileIds = $this->getFinalFileIds();
     foreach ($fileIds as $fileId) {
         $downloadRequest = new DownloadRequest($this->accessToken, $fileId);
         $url = $downloadRequest->getDownloadUrl();
         Log::log("Attempting to download URL '{$url}'.");
         $this->downloadCallback->__invoke($url, $fileId, $this->fileId);
     }
 }