Example #1
0
 /**
  * @param array $conf Configurations for reaching Gerrit server
  */
 public function __construct()
 {
     /** @var \Bart\Configuration\GerritConfig $config */
     $config = Diesel::create('Bart\\Configuration\\GerritConfig');
     /** @var \Bart\SshWrapper $ssh */
     $ssh = Diesel::create('Bart\\SshWrapper', $config->host(), $config->sshPort());
     $ssh->setCredentials($config->sshUser(), $config->sshKeyFile());
     $this->ssh = $ssh;
     $this->config = $config;
     $this->logger = Log4PHP::getLogger(__CLASS__);
     $this->logger->trace("Configured Gerrit API using ssh {$ssh}");
 }
Example #2
0
 /**
  * 上传图片
  * @throws Exception
  */
 function post_upload_action()
 {
     $redirect = false;
     if (empty($_FILES['image']['tmp_name'])) {
         if (!isset($_POST['image'])) {
             throw new Exception('hapn.u_notfound');
         }
         $content = $_POST['image'];
     } else {
         $content = file_get_contents($_FILES['image']['tmp_name']);
         $redirect = true;
     }
     if (!getimagesizefromstring($content)) {
         throw new Exception('image.u_fileIllegal');
     }
     $start = microtime(true);
     $imgApi = new StorageExport();
     $info = $imgApi->save($content);
     ksort($info);
     Logger::trace(sprintf('upload cost:%.3fms', (microtime(true) - $start) * 1000));
     if ($redirect) {
         $this->response->redirect('/image/upload?img=' . $info['img_id'] . '.' . $info['img_ext']);
     } else {
         $this->request->of = 'json';
         $this->response->setRaw(json_encode($info));
     }
 }
Example #3
0
 /**
  * Запуск периодических задач.
  *
  * Проверяется время последнего запуска, чаще установленного администратором
  * времени запуск производиться не будет (по умолчанию 15 минут).
  */
 public static function on_rpc(Context $ctx)
 {
     $status = "DELAYED";
     $lastrun = $ctx->config->get('modules/cron/lastrun');
     $delay = $ctx->config->get('modules/cron/delay', 15) * 60;
     if (time() >= $lastrun + $delay) {
         $ctx->config->set('modules/cron/lastrun', time());
         $ctx->config->save();
         @set_time_limit(0);
         ob_start();
         try {
             $ctx->registry->broadcast('ru.molinos.cms.cron', array($ctx));
             $status = "OK";
         } catch (Exception $e) {
             Logger::trace($e);
             $status = "ERROR: " . get_class($e) . '; ' . trim($e->getMessage(), '.') . '.';
         }
         ob_end_clean();
     }
     if ($ctx->get('destination')) {
         return $ctx->getRedirect();
     }
     if (!MCMS_CONSOLE) {
         header('Content-Type: text/plain; charset=utf-8');
         die($status);
     }
     die;
 }
 public function login()
 {
     vendor("Logger.Logger", LIB_PATH . '../Extend/Vendor');
     $logger = new Logger();
     $logger->trace('The stacktrace is ');
     $domain = $_SERVER['SERVER_NAME'];
     if (preg_match("/^([A-Za-z0-9]+)\\.weixin\\.[A-Za-z0-9]+\\.com\$/i", $domain, $matches)) {
         //是oem客户
         $oem_name = $matches[1];
         if (!empty($oem_name)) {
             $login_pic = session('oem_logo');
             if (empty($login_pic)) {
                 $sql = "select ac.cfg_data, u.role from  tp_user as u LEFT JOIN tp_oem_cfg as ac on u.id = ac.agent_id where u.domain_prefix = '{$oem_name}'; ";
                 $Model = new Model();
                 $user = $Model->query($sql);
                 if ($user != false) {
                     $this->agent_cfg = $this->getAgentCfg($user[0]['cfg_data']);
                     $login_pic = $this->agent_cfg['company_logo'];
                     if (!empty($login_pic)) {
                         session('oem_logo', $login_pic);
                     }
                 }
             }
         }
         $this->assign('is_oem', 1);
     } else {
         //不是oem用户
         $login_pic = '/images/login_logo.png';
     }
     $this->assign('login_pic', $login_pic);
     $this->display();
 }
Example #5
0
 /**
  * @param string|\Exception $msg
  * @param array $context
  * @throws \RuntimeException
  */
 public static function trace($msg, array $context = array())
 {
     if (empty(static::$instance)) {
         throw new \RuntimeException('Logger instance not added to proxy yet');
     }
     static::$instance->trace($msg, $context);
 }
Example #6
0
 /**
  * @param bool $returnOutputAsString [Optional] By default, command output is returned as an array
  * @return array|string Output of command
  * @throws CommandException if command fails
  */
 public function run($returnOutputAsString = false)
 {
     $output = array();
     $returnVar = 0;
     $this->logger->trace('Executing ' . $this->safeCommandStr);
     exec($this->safeCommandStr, $output, $returnVar);
     if ($returnVar !== 0) {
         $this->logger->error('Non-zero exit status ' . $returnVar);
         throw new CommandException("Got bad status {$returnVar} for {$this->safeCommandStr}. Output: " . implode("\n", $output));
     }
     return $returnOutputAsString ? implode("\n", $output) : $output;
 }
 public function testLogLevel()
 {
     $rootAppender = new LoggerAppenderTest();
     $root = new Logger('root');
     $root->addAppender($rootAppender);
     $logger = new Logger('logger', $root);
     $logger->trace('trace');
     $logger->debug('debug');
     $logger->info('info');
     $logger->warn('warn');
     $logger->error('error');
     $logger->fatal('fatal');
     $this->assertEquals(array(array(Logger::TRACE, 'trace'), array(Logger::DEBUG, 'debug'), array(Logger::INFO, 'info'), array(Logger::WARN, 'warn'), array(Logger::ERROR, 'error'), array(Logger::FATAL, 'fatal')), $rootAppender->logs);
 }
 public function handle($headers, $body, $outputClass = null)
 {
     if ($outputClass !== null) {
         $this->getUnmarshaller()->setOutputClass($outputClass);
     }
     Logger::info('Handling callback');
     Logger::trace('Headers: {0}', $headers);
     Logger::trace('Body: {0}', $body);
     if (!$this->isSignatureCheckDisabled()) {
         $securityHelper = new SecurityHelper($this->apiKey, $this->signatureKey, $this->partnerApiKey, $this->partnerSignatureKey);
         $signature = $securityHelper->getSignature($headers);
         //var_dump($headers);
         $securityHelper->checkSignature($signature, $body);
     }
     return $this->getUnmarshaller()->unmarshall($body);
 }
Example #9
0
 /**
  * Вывод административной страницы. Вызывает обработчик, указанный в next,
  * предварительно проверив права пользователя.
  */
 public static function serve(Context $ctx, $path, array $pathinfo)
 {
     if (class_exists('APIStream')) {
         APIStream::init($ctx);
     }
     try {
         self::checkperm($ctx, $pathinfo);
         if (!$ctx->user->id and empty($pathinfo['anonymous'])) {
             throw new UnauthorizedException();
         }
         if (empty($pathinfo['next'])) {
             if (!empty($pathinfo['xsl'])) {
                 $pathinfo['next'] = 'AdminPage::xsltonly';
             } else {
                 throw new RuntimeException(t('Не указан обработчик для страницы %path (параметр <tt>next</tt>).', array('%path' => $path)));
             }
         }
         if (!is_callable($pathinfo['next'])) {
             throw new RuntimeException(t('Неверный обработчик для страницы %path (<tt>%next()</tt>).', array('%path' => $path, '%next' => $pathinfo['next'])));
         }
         $args = func_get_args();
         $output = call_user_func_array($pathinfo['next'], $args);
         if (!$output instanceof Response) {
             $xsl = empty($pathinfo['xsl']) ? null : implode(DIRECTORY_SEPARATOR, explode('/', $pathinfo['xsl']));
             $tmp = new AdminPage($output, $xsl);
             $output = $tmp->getResponse($ctx);
         }
         return $output;
     } catch (NotConnectedException $e) {
         Logger::trace($e);
         if (is_dir(os::path('lib', 'modules', 'install'))) {
             $ctx->redirect('install?destination=' . urlencode(MCMS_REQUEST_URI));
         } else {
             throw new RuntimeException('Система не проинсталлирована и модуля install нет.');
         }
     } catch (Exception $e) {
         Logger::trace($e);
         $data = array('status' => 500, 'error' => get_class($e), 'message' => $e->getMessage(), 'version' => MCMS_VERSION, 'release' => MCMS_RELEASE, 'base' => $ctx->url()->getBase($ctx), 'prefix' => MCMS_SITE_FOLDER . '/themes', 'back' => urlencode(MCMS_REQUEST_URI), 'next' => urlencode($ctx->get('destination')), 'clean' => !empty($_GET['__cleanurls']));
         if ($e instanceof UserErrorException) {
             $data['status'] = $e->getCode();
         }
         $xsl = os::path('lib', 'modules', 'admin', 'template.xsl');
         xslt::transform(html::em('page', $data), $xsl)->send();
     }
 }
 private function _createCustomerEntry(RecordCustomer $rec)
 {
     $nameFirst = $rec->nameFirst;
     $nameLast = $rec->nameLast;
     $email = $rec->email;
     /* save customer and update customer group */
     /** @var  $customer Mage_Customer_Model_Customer */
     $customer = Mage::getModel('customer/customer');
     $customer->setFirstname($nameFirst);
     $customer->setLastname($nameLast);
     $customer->setEmail($email);
     $customer->setWebsiteId(1);
     try {
         $customer->save();
         $this->_log->trace("New customer '{$nameFirst} {$nameLast} <{$email}>' is saved.");
     } catch (Exception $e) {
         $this->_log->error("Cannot save customer '{$nameFirst} {$nameLast} <{$email}>'.", $e);
     }
 }
 /**
  * Дополнительная обработка текстовых полей.
  * 
  * @param Context $ctx 
  * @param string $fieldName
  * @param string $text 
  * @static
  * @access public
  * @return string
  * @mcms_message ru.molinos.cms.format.text
  */
 public static function on_format_text(Context $ctx, $fieldName, &$text)
 {
     $fields = $ctx->config->get('modules/pridetypograph/fields', array());
     /*
     if (!in_array($fieldName, $fields))
       return;
     */
     if (strlen(trim($text))) {
         try {
             $typo = self::getTypo();
             if (mb_check_encoding($text2 = $typo->parse($text), 'utf-8')) {
                 $text = $text2;
             } else {
                 Logger::log('Waring: PrideTypograph failed to process this text: ' . $text);
             }
         } catch (Exception $e) {
             Logger::trace($e);
         }
     }
 }
 public static function send($from, $to, $subject, $body, array $attachments = null, array $headers = null)
 {
     if (empty($to)) {
         Logger::trace("mail not sent: no recipients: {$subject}");
         return;
     }
     $config = Context::last()->config;
     if (empty($from)) {
         if (!($from = $config->get('modules/mail/from'))) {
             $from = "Molinos.CMS <no-reply@" . MCMS_HOST_NAME . ">";
         }
     }
     if (strstr($body, '<html>') === false) {
         $body = '<html><head><title>' . html::plain($subject) . '</title></head><body>' . $body . '</body></html>';
     }
     if (!is_array($to)) {
         $to = preg_split('/, */', $to, -1, PREG_SPLIT_NO_EMPTY);
     }
     Logger::log(sprintf('to=%s, subject=%s', join(',', $to), $subject), 'mail');
     $mail = new htmlMimeMail();
     if ('smtp' == ($transport = ($server = $config->get('modules/mail/server')) ? 'smtp' : 'mail')) {
         $mail->setSMTPParams($server);
     }
     $mail->setFrom($from);
     $mail->setSubject($subject);
     $mail->setHtml(self::fixhtml($body));
     $mail->setTextCharset('UTF-8');
     $mail->setTextEncoding('base64');
     $mail->setHTMLCharset('UTF-8');
     $mail->setHTMLEncoding('UTF-8');
     $mail->setHeadCharset('UTF-8');
     foreach ((array) $attachments as $file) {
         $mail->addAttachment($file['data'], $file['name'], $file['type']);
     }
     foreach ((array) $headers as $k => $v) {
         if (!empty($v)) {
             $mail->setHeader($k, $v);
         }
     }
     return $mail->send($to, $transport);
 }
Example #13
0
function route()
{
    foreach (include_paths() as $path) {
        $base = $path['base'];
        $action = $path['action'];
        $controller = load_controller($base, $action);
        if ($controller) {
            if (strpos($base, '/index') === strlen($base) - 6) {
                $base = substr($base, 0, strlen($base) - 6);
            }
            $controller->module = $base == 'index' ? '' : $base;
            break;
        }
    }
    if (!$controller) {
        $path = base_path();
        Logger::trace("No route for {$path}!");
        throw new App404Exception("Not found!", 404);
    }
    return array($base, $controller, $action);
}
Example #14
0
File: Task.php Project: hihus/newpi
 public function run()
 {
     //初始化pipe
     $default_pipe = array('TaskProcessPipe' => 'default');
     $pipes = Conf::get('global.pipes', array());
     if (empty($pipes)) {
         $pipes = $default_pipe;
     }
     $this->pipeLoadContainer = $pipes;
     //后台脚本方便日志记录,把所有输出全部定位到日志目录
     ob_start();
     echo "\n---------------------" . date("Y-m-d H:i:s") . "--------------------\n";
     echo "\nrun result:\n";
     $this->timer->begin('task_run');
     parent::run();
     $this->timer->end('task_run');
     $time = $this->timer->getResult();
     echo "\nrun time : " . $time[0]['1'] / 1000 . " s \n";
     echo "\n---------------------" . date("Y-m-d H:i:s") . "--------------------\n";
     $res = ob_get_clean();
     Logger::trace("%s", var_export($res, true));
 }
Example #15
0
 private static function log($type, $msg, $errorNo, $params)
 {
     if (class_exists('Xiaoju\\Beatles\\Utils\\Logger')) {
         switch ($type) {
             case 'debug':
                 Logger::debug($msg, $errorNo, $params);
                 break;
             case 'trace':
                 Logger::trace($msg, $errorNo, $params);
                 break;
             case 'notice':
                 Logger::notice($msg, $errorNo, $params);
                 break;
             case 'warning':
                 Logger::warning($msg, $errorNo, $params);
                 break;
             case 'fatal':
                 Logger::fatal($msg, $errorNo, $params);
                 break;
         }
     }
 }
Example #16
0
 public static function run()
 {
     try {
         self::setup();
         $ctx = Context::last();
         if ('admin/install' != $ctx->query() and !$ctx->config->isOk()) {
             $ctx->redirect('admin/install');
         }
         $router = new Router();
         $result = $router->poll($ctx)->dispatch($ctx);
         if ($result instanceof Response) {
             $result->send();
         } elseif (false === $result) {
             header('HTTP/1.1 404 Not Found');
             header('Content-Type: text/plain; charset=utf-8');
             die('Route Not Found.');
         } else {
             list($handler, $args) = $router->find($ctx);
             if (false === $handler) {
                 $method = '?unknown?';
             } elseif (is_array($handler['call'])) {
                 $method = implode('::', $handler['call']);
             } else {
                 $method = $handler['call'];
             }
             $message = t('<h1>Внутренняя ошибка</h1><p>Обработчик пути <tt>%path</tt> (<tt>%func</tt>) должен был вернуть объект класса <a href="@class">Response</a>, а вернул %type.</p><hr/><a href="@home">Molinos CMS v%version</a>', array('%path' => $ctx->query(), '%type' => gettype($result), '%func' => $method, '@class' => 'http://code.google.com/p/molinos-cms/wiki/Response_Class', '%version' => MCMS_VERSION, '@home' => 'http://molinos-cms.googlecode.com/'));
             header('HTTP/1.1 500 Internal Server Error');
             header('Content-Type: text/html; charset=utf-8');
             die($message);
         }
     } catch (Exception $e) {
         Logger::trace($e);
         header('HTTP/1.1 500 FUBAR');
         header('Content-Type: text/plain; charset=utf-8');
         die(sprintf('%s: %s.', get_class($e), rtrim($e->getMessage(), '.')));
     }
 }
Example #17
0
 public function get($name)
 {
     if (array_key_exists($name, $this->_params)) {
         $value = $this->_params[$name];
         // log parameters
         $this->_divParams[$name] = $value;
         Logger::trace("get paramter %s => %s", $name, $value);
         return $value;
     }
     if (array_key_exists($name, $this->_baseParams)) {
         return $this->_baseParams[$name];
     }
     return null;
 }
Example #18
0
 static function _run()
 {
     $code = 1;
     $msg = '';
     $data = null;
     App::init();
     try {
         $data = self::execute();
     } catch (AppBreakException $e) {
         return;
     } catch (Exception $e) {
         if (App::$controller && App::$controller->is_ajax) {
             $code = $e->getCode();
             $msg = $e->getMessage();
             if (!strlen($msg)) {
                 $msg = 'error';
             }
         } else {
             return self::error_handle($e);
         }
     }
     if (App::$controller && App::$controller->is_ajax) {
         $resp = array('code' => $code, 'message' => $msg, 'data' => $data);
         if (defined('JSON_UNESCAPED_UNICODE')) {
             $json = json_encode($resp, JSON_UNESCAPED_UNICODE);
         } else {
             $json = json_encode($resp);
         }
         $jp = App::$controller->jp;
         if (!preg_match('/^[a-z0-9_]+$/i', $jp)) {
             $jp = false;
         }
         if ($jp) {
             echo "{$jp}({$json});";
         } else {
             echo $json;
         }
     } else {
         #var_dump(find_view_and_layout());
         list($__view, $__layout) = find_view_and_layout();
         if (!$__view) {
             Logger::trace("No view for " . base_path());
         } else {
             Logger::trace("View {$__view}");
             $params = App::$context->as_array();
             extract($params);
             ob_start();
             include $__view;
             self::$view_content = ob_get_clean();
         }
         if ($__layout) {
             Logger::trace("Layout {$__layout}");
             $params = App::$context->as_array();
             extract($params);
             include $__layout;
         } else {
             if (App::$controller->layout !== false) {
                 Logger::error("No layout for " . base_path());
             }
             _view();
         }
     }
 }
Example #19
0
 /**
  * @param Logger $logger
  * @param $startQuery
  * @param PDOStatement $stmt
  * @param array $parameters
  */
 protected function traceQuery($logger, $startQuery, PDOStatement $stmt, array $parameters)
 {
     if ($logger->isTraceEnabled()) {
         $logger->trace("Query :\n" . self::parms($stmt->queryString, $parameters) . "\ntook: " . (self::getTimestamp() - $startQuery));
     }
 }
Example #20
0
 /**
  * Отправляет сообщение об ошибке куда следует.
  */
 private static function send_error($message = "undefined", $extra = null)
 {
     Logger::trace($message);
     if (class_exists('BebopMimeMail')) {
         $message = wordwrap(strip_tags($message), 75, "\n         ");
         $referer = empty($_SERVER['HTTP_REFERER']) ? null : "Referer: {$_SERVER['HTTP_REFERER']}\n";
         $subject = "Error at " . MCMS_HOST_NAME;
         $content = "<pre>Message: {$message}\nMethod:  {$_SERVER['REQUEST_METHOD']}\n" . "URL:     http://" . MCMS_HOST_NAME . MCMS_REQUEST_URI . "\n{$extra}\n{$referer}" . "Backtrace follows.\n\n" . Logger::backtrace() . '</pre>';
         BebopMimeMail::send(null, Context::last()->config->get('main/errors/mail'), $subject, $content);
     }
 }
Example #21
0
File: App.php Project: xtzlyp/newpi
 function errorHandler()
 {
     restore_error_handler();
     $error = func_get_args();
     $res = false;
     if (!($error[0] & error_reporting())) {
         Logger::debug('error info, errno:%d,errmsg:%s,file:%s,line:%d', $error[0], $error[1], $error[2], $error[3]);
     } elseif ($error[0] === E_USER_NOTICE) {
         Logger::trace('error trace, errno:%d,errmsg:%s,file:%s,line:%d', $error[0], $error[1], $error[2], $error[3]);
     } elseif ($error[0] === E_USER_WARNING) {
         Logger::warning('error warning, errno:%d,errmsg:%s,file:%s,line:%d', $error[0], $error[1], $error[2], $error[3]);
     } elseif ($error[0] === E_USER_ERROR) {
         Logger::fatal('error error, errno:%d,errmsg:%s,file:%s,line:%d', $error[0], $error[1], $error[2], $error[3]);
     } else {
         Logger::fatal('error error, errno:%d,errmsg:%s,file:%s,line:%d', $error[0], $error[1], $error[2], $error[3]);
         $this->status = 'error';
         $res = true;
     }
     set_error_handler(array($this, 'errorHandler'));
     return $res;
 }
Example #22
0
 /**
  * Releases daemon pid file
  * This method is called on exit (destructor like)
  *
  * @return void
  */
 public function releaseDaemon()
 {
     if ($this->isChildren && file_exists($this->pidFileLocation)) {
         Logger::trace('Releasing daemon');
         @unlink($this->pidFileLocation);
     }
 }
 /**
  * endElement is called whenever the parser encounters a closing tag.
  * Here
  * we are interested in handling both the closing tag of a Noark 5 complexType as well
  * as that of simpleType.
  * A simple check that the head of the stack is in sync with the xml file is undertaken
  * as well as calling a postProcess() function for the complexTypes and a handle function
  * for the simpleTypes. The handle functions copy the value in currentCdata to the appropriate
  * variable in the Noark 5 object. $this->currentCdata gets its value from the cdata function
  *
  * These handle and postProcess functions are very useful when creating a subclass.
  *
  * Note: Only when you have processed the end tag, will you actually have a complete instance
  * of a Noark 5 object (no:arkivenhet)
  *
  * Note: It is important that this function resets currentCdata to an empty value, "". Otherwise
  * you will have problems with your element values. This is done in the last statement of
  * this function.
  *
  * @param xml_parser $parser
  *            Link to parser, not used
  *
  * @param string $tag
  *            The actual tag that has been encountered
  *
  */
 function endElement($parser, $tag)
 {
     $this->logger->trace('Processing endElement ' . $tag);
     switch ($tag) {
         case 'arkiv':
             $this->checkObjectClassTypeCorrect('Fonds');
             $this->postProcessFonds();
             $this->statistics->numberOfFondsProcessed++;
             array_pop($this->stack);
             break;
         case 'arkivdel':
             $this->checkObjectClassTypeCorrect('Series');
             $this->postProcessSeries();
             $this->statistics->numberOfSeriesProcessed++;
             array_pop($this->stack);
             break;
         case 'mappe':
             $classType = get_class(end($this->stack));
             if (strcasecmp($classType, 'CaseFile') == 0) {
                 $this->checkObjectClassTypeCorrect('CaseFile');
                 $this->statistics->numberOfFileProcessed++;
             } elseif (strcasecmp($classType, 'File') == 0) {
                 $this->checkObjectClassTypeCorrect('File');
                 $this->statistics->numberOfCaseFileProcessed++;
             } elseif (strcasecmp($classType, 'MeetingFile') == 0) {
                 $this->checkObjectClassTypeCorrect('MeetingFile');
                 $this->statistics->numberOfMeetingFileProcessed++;
             } else {
                 $this->logger->error('Unable to process a specific mappe type. Type identified as (' . $classType . ')');
                 throw new Exception('Unable to process a specific mappe type. Type identified as (' . $classType . ')');
             }
             $this->postProcessFile($classType);
             array_pop($this->stack);
             break;
         case 'registrering':
             $classType = get_class(end($this->stack));
             if (strcasecmp($classType, 'Record') == 0) {
                 $this->checkObjectClassTypeCorrect('Record');
                 $this->statistics->numberOfRecordProcessed++;
             } elseif (strcasecmp($classType, 'BasicRecord') == 0) {
                 $this->checkObjectClassTypeCorrect('BasicRecord');
                 $this->statistics->numberOfBasicRecordProcessed++;
             } elseif (strcasecmp($classType, 'RegistryEntry') == 0) {
                 $this->checkObjectClassTypeCorrect('RegistryEntry');
                 $this->statistics->numberOfRegistryEntryProcessed++;
             } elseif (strcasecmp($classType, 'MeetingRecord') == 0) {
                 $this->checkObjectClassTypeCorrect('MeetingRecord');
                 $this->statistics->numberOfMeetingRecordProcessed++;
             } else {
                 $this->logger->error('Unable to process a specific registrering type. Type identified as (' . $classType . ')');
                 throw new Exception('Unable to process a specific registrering type. Type identified as (' . $classType . ')');
             }
             $this->postProcessRecord($classType);
             array_pop($this->stack);
             break;
         case 'korrespondansepart':
             $this->checkObjectClassTypeCorrect('CorrespondencePart');
             $this->statistics->numberOfCorrespondencePartProcessed++;
             $this->postProcessCorrespondencePart();
             array_pop($this->stack);
             break;
         case 'avskrivning':
             $this->checkObjectClassTypeCorrect('SignOff');
             $this->postProcessSignOff();
             $this->statistics->numberOfSignOffProcessed++;
             array_pop($this->stack);
             break;
         case 'presedens':
             $this->checkObjectClassTypeCorrect('Precedence');
             $this->postProcessPrecedence();
             $this->statistics->numberOfPrecedenceProcessed++;
             array_pop($this->stack);
             break;
         case 'dokumentbeskrivelse':
             $this->checkObjectClassTypeCorrect('DocumentDescription');
             $this->postProcessDocumentDescription();
             $this->statistics->numberOfDocumentDescriptionProcessed++;
             array_pop($this->stack);
             break;
         case 'dokumentobjekt':
             $this->checkObjectClassTypeCorrect('DocumentObject');
             $this->statistics->numberOfDocumentObjectProcessed++;
             $this->postProcessDocumentObject();
             array_pop($this->stack);
             break;
         case 'arkivskaper':
             $this->checkObjectClassTypeCorrect('FondsCreator');
             $this->postProcessFondsCreator();
             $this->statistics->numberOfFondsCreatorProcessed++;
             array_pop($this->stack);
             break;
         case 'gradering':
             /**
              * NOTE: arkivstruktur.xsd has <gradering> both as a complexType
              * and as a simpleType. This makes handling the element a little
              * more complex in an event-based parser.
              *
              * There are potential two ways of dealing with this. First, check
              * to see if $this->currentCdata is empty or not. If it is, then
              * this is most likely the complexType. However, I think
              * <gradering></gradering> would be misinterpreted in this
              * situation. So I have decided to set a boolean flag when we detect
              * <gradering> as a simpleType, then we know whether this closing
              * element is a simpleType or a complexType
              */
             if ($this->graderingIsSimpleType === true) {
                 $this->handleClassification();
                 $this->graderingIsSimpleType = false;
             } else {
                 $this->checkObjectClassTypeCorrect('Classified');
                 $this->postProcessClassified();
                 $this->statistics->numberOfClassificationProcessed++;
                 array_pop($this->stack);
             }
             break;
         case 'klasse':
             $this->checkObjectClassTypeCorrect('Klass');
             $this->postProcessClass();
             $this->statistics->numberOfClassProcessed++;
             array_pop($this->stack);
             break;
         case 'klassifikasjonssystem':
             $this->checkObjectClassTypeCorrect('ClassificationSystem');
             $this->postProcessClassificationSystem();
             $this->statistics->numberOfClassificationSystemProcessed++;
             array_pop($this->stack);
             break;
         case 'kryssreferanse':
             $this->checkObjectClassTypeCorrect('CrossReference');
             $this->postProcessCrossReference();
             $this->statistics->numberOfCrossReferenceProcessed++;
             array_pop($this->stack);
             break;
         case 'sletting':
             $this->checkObjectClassTypeCorrect('Deletion');
             $this->postProcessDeletion();
             $this->statistics->numberOfDeletionProcessed++;
             array_pop($this->stack);
             break;
         case 'kassasjon':
             $this->checkObjectClassTypeCorrect('Disposal');
             $this->postProcessDisposal();
             $this->statistics->numberOfDisposalProcessed++;
             array_pop($this->stack);
             break;
         case 'utfoertKassasjon':
             $this->checkObjectClassTypeCorrect('DisposalUndertaken');
             $this->postProcessDisposal();
             $this->statistics->numberOfDisposalUndertakenProcessed++;
             array_pop($this->stack);
             break;
         case 'sakspart':
             $this->checkObjectClassTypeCorrect('CaseParty');
             $this->postProcessDisposal();
             $this->statistics->numberOfCasePartyProcessed++;
             array_pop($this->stack);
             break;
         case 'elektroniskSignatur':
             $this->checkObjectClassTypeCorrect('ElectronicSignature');
             $this->postProcessDisposal();
             $this->statistics->numberOfElectronicSignatureProcessed++;
             array_pop($this->stack);
             break;
         case 'skjerming':
             $this->checkObjectClassTypeCorrect('Screening');
             $this->postProcessScreening();
             $this->statistics->numberOfScreeningProcessed++;
             array_pop($this->stack);
             break;
         case 'merknad':
             $this->checkObjectClassTypeCorrect('Comment');
             $this->postProcessComment();
             $this->statistics->numberOfCommentProcessed++;
             array_pop($this->stack);
             break;
         case 'konvertering':
             $this->checkObjectClassTypeCorrect('Conversion');
             $this->postProcessConversion();
             $this->statistics->numberOfConversionProcessed++;
             array_pop($this->stack);
             break;
         case 'dokumentflyt':
             $this->checkObjectClassTypeCorrect('Workflow');
             $this->postProcessWorkflow();
             $this->statistics->numberOfWorkflowProcessed++;
             array_pop($this->stack);
             break;
         case 'moetedeltaker':
             $this->checkObjectClassTypeCorrect('MeetingParticipant');
             $this->postProcessMeetingParticipant();
             $this->statistics->numberOfMeetingParticipantProcessed++;
             array_pop($this->stack);
             break;
             // The rest of the elements are elements that simpleTypes and
             // within one of the complexTypes above
         // The rest of the elements are elements that simpleTypes and
         // within one of the complexTypes above
         case 'administrativEnhet':
             $this->handleAdministrativeUnit();
             break;
         case 'antallVedlegg':
             $this->handleNumberOfAttachments();
             break;
         case 'arkivdelstatus':
             $this->handleSeriesStatus();
             break;
         case 'arkivskaperID':
             $this->handleFondsCreatorID();
             break;
         case 'arkivskaperNavn':
             $this->handleFondsCreatorName();
             break;
         case 'arkivstatus':
             $this->handleFondsStatus();
             break;
         case 'avskrevetAv':
             $this->handleSignOffBy();
             break;
         case 'avskrivningsdato':
             $this->handleSignOffDate();
             break;
         case 'avskrivningsmaate':
             $this->handleSignOffMethod();
             break;
         case 'avsluttetAv':
             $this->handleFinalisedBy();
             break;
         case 'avsluttetDato':
             $this->handleFinalisedDate();
             break;
         case 'arkivertAv':
             $this->handleArchivedBy();
             break;
         case 'arkivertDato':
             $this->handleArchivedDate();
             break;
         case 'arkivperiodeStartDato':
             $this->handleSeriesStartDate();
             break;
         case 'arkivperiodeSluttDato':
             $this->handleSeriesEndDate();
             break;
         case 'beskrivelse':
             $this->handleDescription();
             break;
         case 'bevaringstid':
             $this->handlePreservationTime();
             break;
         case 'dokumentetsDato':
             $this->handleDocumentDate();
             break;
         case 'dokumentmedium':
             $this->handleDocumentMedium();
             break;
         case 'dokumentnummer':
             $this->handleDocumentNumber();
             break;
         case 'dokumentstatus':
             $this->handleDocumentStatus();
             break;
         case 'dokumenttype':
             $this->handleDocumentType();
             break;
         case 'elektroniskSignaturSikkerhetsnivaa':
             $this->handleElectronicSignatureSecurityLevel();
             break;
         case 'elektroniskSignaturVerifisert':
             $this->handleElectronicSignatureVerified();
             break;
         case 'epostadresse':
             $this->handleEmailAddress();
             break;
         case 'filstoerrelse':
             $this->handleFileSize();
             break;
         case 'flytFra':
             $this->handleWorkflowFrom();
             break;
         case 'flytTil':
             $this->handleWorkflowTo();
             break;
         case 'flytMottattDato':
             $this->handleWorkflowReceivedDate();
             break;
         case 'flytSendtDato':
             $this->handleWorkflowSentDate();
             break;
         case 'flytStatus':
             $this->handleWorkflowStatus();
             break;
         case 'flytMerknad':
             $this->handleWorkflowComment();
             break;
         case 'forfallsdato':
             $this->handleDueDate();
             break;
         case 'forfatter':
             $this->handleAuthor();
             break;
         case 'format':
             $this->handleFormat();
             break;
         case 'formatDetaljer':
             $this->handleFormatDetails();
             break;
         case 'gradertAv':
             $this->handleClassificationBy();
             break;
         case 'graderingsdato':
             $this->handleClassificationDate();
             break;
         case 'journalaar':
             $this->handleRecordYear();
             break;
         case 'journaldato':
             $this->handleRecordDate();
             break;
         case 'journalenhet':
             $this->handleRecordsManagementUnit();
             break;
         case 'journalpostnummer':
             $this->handleRecordNumber();
             break;
         case 'journalposttype':
             $this->handleRecordType();
             break;
         case 'journalsekvensnummer':
             $this->handleRecordSequenceNumber();
             break;
         case 'journalstatus':
             $this->handleRecordStatus();
             break;
         case 'journalStartDato':
             $this->handleRecordStartDate();
             break;
         case 'kassasjonsdato':
             $this->handleDisposalDate();
             break;
         case 'kassasjonshjemmel':
             $this->handleDisposalAuthority();
             break;
         case 'kassasjonsvedtak':
             $this->handleDisposalDecision();
             break;
         case 'kassertAv':
             $this->handleDisposalUndertakenBy();
             break;
         case 'kassertDato':
             $this->handleDisposalUndertakenDate();
             break;
         case 'klasseID':
             $this->handleClassId();
             break;
         case 'klassifikasjonstype':
             $this->handleClassificationType();
             break;
         case 'kontaktperson':
             $this->handleContactPerson();
             break;
         case 'konverteringsverktoey':
             $this->handleConversionTool();
             break;
         case 'konverteringskommentar':
             $this->handleConversionComment();
             break;
         case 'konvertertAv':
             $this->handleConvertedBy();
             break;
         case 'konvertertDato':
             $this->handleConvertedDate();
             break;
         case 'konvertertFraFormat':
             $this->handleConvertedFromFormat();
             break;
         case 'konvertertTilFormat':
             $this->handleConvertedToFormat();
             break;
         case 'korrespondansepartNavn':
             $this->handleCorrespondencePartName();
             break;
         case 'korrespondanseparttype':
             $this->handleCorrespondencePartType();
             break;
         case 'land':
             $this->handleCountry();
             break;
         case 'mappeID':
             $this->handleFileId();
             break;
         case 'merknadRegistrertAv':
             $this->handleCommentRegisteredBy();
             break;
         case 'merknadsdato':
             $this->handleCommentDate();
             break;
         case 'merknadstype':
             $this->handleCommentType();
             break;
         case 'merknadstekst':
             $this->handleCommentText();
             break;
         case 'moetedato':
             $this->handleMeetingDate();
             break;
         case 'moetedeltakerFunksjon':
             $this->handleMeetingParticipantFunction();
             break;
         case 'moetedeltakerNavn':
             $this->handleMeetingParticipantName();
             break;
         case 'moetenummer':
             $this->handleMeetingNumber();
             break;
         case 'moeteregistreringsstatus':
             $this->handleMeetingRecordStatus();
             break;
         case 'moeteregistreringstype':
             $this->handleMeetingRecordType();
             break;
         case 'moetesakstype':
             $this->handleMeetingCaseType();
             break;
         case 'moetested':
             $this->handleMeetingPlace();
             break;
         case 'mottattDato':
             $this->handleReceivedDate();
             break;
         case 'nedgradertAv':
             $this->handleClassificationDowngradedBy();
             break;
         case 'nedgraderingsdato':
             $this->handleClassificationDowngradedDate();
             break;
         case 'noekkelord':
             $this->handleKeyword();
             break;
         case 'offentlighetsvurdertDato':
             $this->handleReviewFOIDate();
             break;
         case 'offentligTittel':
             $this->handleOfficialTitle();
             break;
         case 'oppbevaringssted':
             $this->handleStorageLocation();
             break;
         case 'opprettetAv':
             $this->handleCreatedBy();
             break;
         case 'opprettetDato':
             $this->handleCreatedDate();
             break;
         case 'postadresse':
             $this->handlePostalAddress();
             break;
         case 'postnummer':
             $this->handlePostalNumber();
             break;
         case 'poststed':
             $this->handlePostalTown();
             break;
         case 'presedensDato':
             $this->handlePrecedenceDate();
             break;
         case 'presedensStatus':
             $this->handlePrecedenceStatus();
             break;
         case 'presedensHjemmel':
             $this->handlePrecedenceAuthority();
             break;
         case 'presedensGodkjentDato':
             $this->handlePrecedenceApprovedDate();
             break;
         case 'presedensGodkjentAv':
             $this->handlePrecedenceApprovedBy();
             break;
         case 'referanseArkivdel':
             $this->handleReferenceSeries();
             break;
         case 'referanseArvtaker':
             $this->handleReferenceSuccessor();
             break;
         case 'referanseAvskrivesAvJournalpost':
             $this->handleReferenceSignedOffByRegistryEntry();
             break;
         case 'referanseDokumentfil':
             $this->handleReferenceDocumentFile();
             break;
         case 'referanseFraMoeteregistrering':
             $this->handleReferenceFromMeetingRecord();
             break;
         case 'referanseForloeper':
             $this->handleReferencePrecursor();
             break;
         case 'referanseForrigeMoete':
             $this->handleReferencePreviousMeeting();
             break;
         case 'referanseNesteMoete':
             $this->handleReferenceNextMeeting();
             break;
         case 'referanseSekundaerKlassifikasjon':
             $this->handleSecondaryClassification();
             break;
         case 'referanseTilMoeteregistrering':
             $this->handleReferenceToMeetingRecord();
             break;
         case 'referanseTilKlasse':
             $this->handleReferenceToClass();
             break;
         case 'referanseTilMappe':
             $this->handleReferenceToFile();
             break;
         case 'referanseTilRegistrering':
             $this->handleReferenceToRecord();
             break;
         case 'registreringsID':
             $this->handleRecordId();
             break;
         case 'rettskildefaktor':
             $this->handleSourceOfLaw();
             break;
         case 'saksaar':
             $this->handleCaseYear();
             break;
         case 'saksansvarlig':
             $this->handleCaseResponsible();
             break;
         case 'saksbehandler':
             $this->handleCaseHandler();
             break;
         case 'saksdato':
             $this->handleCaseDate();
             break;
         case 'sakspartID':
             $this->handleCasePartyId();
             break;
         case 'sakspartNavn':
             $this->handleCasePartyName();
             break;
         case 'sakspartRolle':
             $this->handleCasePartyRole();
             break;
         case 'sakssekvensnummer':
             $this->handleCaseSequenceNumber();
             break;
         case 'saksstatus':
             $this->handleCaseStatus();
             break;
         case 'sendtDato':
             $this->handleSentDate();
             break;
         case 'sjekksum':
             $this->handleChecksum();
             break;
         case 'sjekksumAlgoritme':
             $this->handleChecksumAlgorithm();
             break;
         case 'skjermingshjemmel':
             $this->handleScreeningAuthority();
             break;
         case 'skjermingDokument':
             $this->handleScreeningDocument();
             break;
         case 'skjermingMetadata':
             $this->handleScreeningMetadata();
             break;
         case 'skjermingOpphoererDato':
             $this->handleScreeningExpiresDate();
             break;
         case 'skjermingsvarighet':
             $this->handleScreeningDuration();
             break;
         case 'slettetAv':
             $this->handleDeletionBy();
             break;
         case 'slettetDato':
             $this->handleDeletionDate();
             break;
         case 'slettingstype':
             $this->handleDeletionType();
             break;
         case 'systemID':
             $this->handleSystemId();
             break;
         case 'telefonnummer':
             $this->handleTelephoneNumber();
             break;
         case 'tilgangsrestriksjon':
             $this->handleAccessRestriction();
             break;
         case 'tilknyttetAv':
             $this->handleAssociatedBy();
             break;
         case 'tilknyttetDato':
             $this->handleAssociationDate();
             break;
         case 'tilknyttetRegistreringSom':
             $this->handleAssociatedWithRecordAs();
             break;
         case 'tittel':
             $this->handleTitle();
             break;
         case 'utlaantDato':
             $this->handleLoanedDate();
             break;
         case 'utlaantTil':
             $this->handleLoanedTo();
             break;
         case 'utvalg':
             $this->handleCommittee();
             break;
         case 'variantformat':
             $this->handleVariantFormat();
             break;
         case 'versjonsnummer':
             $this->handleVersionNumber();
             break;
         case 'verifisertAv':
             $this->handleVerifiedBy();
             break;
         case 'verifisertDato':
             $this->handleVerifiedDate();
             break;
         default:
             $this->logger->fatal('Unknown Noark 5 tag ' . $tag . '. This has not been handled. This is a serious error');
     }
     $this->currentCdata = "";
 }
Example #24
0
File: App.php Project: lkmmmj/iphp
 private static function html_resp()
 {
     #var_dump(find_view_and_layout());
     list($__view, $__layout) = find_view_and_layout();
     if (!$__view) {
         Logger::trace("No view for " . base_path());
     } else {
         Logger::trace("View {$__view}");
         $__params = App::$context->as_array();
         extract($__params);
         ob_start();
         include $__view;
         self::$view_content = ob_get_clean();
     }
     if ($__layout) {
         Logger::trace("Layout {$__layout}");
         $__params = App::$context->as_array();
         extract($__params);
         include $__layout;
     } else {
         if (App::$controller->layout !== false) {
             Logger::error("No layout for " . base_path());
         }
         _view();
     }
 }
 public function call()
 {
     $queryString = !empty($this->getQuery()) ? http_build_query($this->getQuery()) : null;
     $targetUrl = $this->url . $this->getMethodPath() . ($queryString !== null ? '?' . $queryString : '');
     Logger::trace('Call target URL: ' . $targetUrl);
     $bodyContent = $this->getBody() !== null ? $this->getRequestMarshaller()->marshall($this->getBody()) : null;
     Logger::trace('Call body: ' . $bodyContent);
     $securityHelper = new SecurityHelper($this->apiKey, $this->signatureKey, $this->partnerApiKey, $this->partnerSignatureKey);
     $signature = $securityHelper->calculateSignature($queryString, $bodyContent);
     Logger::trace('Signature: ' . $signature);
     $headers = $this->getHeaders($signature);
     Logger::trace('Headers: {0}', $headers);
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $targetUrl);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ch, CURLOPT_HEADER, true);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     if ($bodyContent !== null) {
         curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyContent);
     }
     switch ($this->getHttpMethod()) {
         case self::HTTP_GET:
             curl_setopt($ch, CURLOPT_HTTPGET, true);
             break;
         case self::HTTP_POST:
             curl_setopt($ch, CURLOPT_POST, true);
             break;
         case self::HTTP_PUT:
             curl_setopt($ch, CURLOPT_PUT, true);
             break;
         case self::HTTP_DELETE:
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
             break;
         default:
             break;
     }
     Logger::trace("Calling {0} with http method {1}, body content: {2}", $targetUrl, $this->getHttpMethod(), $bodyContent);
     $response = curl_exec($ch);
     if ($response === false) {
         throw new Exception('Connection error: ' . curl_error($ch));
     }
     $responseStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     $responseHeaderSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
     curl_close($ch);
     Logger::trace("Response status: {0}, header size: {1}", $responseStatus, $responseHeaderSize);
     $responseHeader = trim(substr($response, 0, $responseHeaderSize));
     $responseBody = trim(substr($response, $responseHeaderSize));
     Logger::trace("Response header: {0}", $responseHeader);
     Logger::trace("Response body: {0}", $responseBody);
     if ($responseStatus != '200') {
         $this->setIsResponseSignatureCheckDisabled(true);
         $this->getResponseUnmarshaller()->setOutputClass(new ApiOperationException());
         $this->getResponseUnmarshaller()->setOutputClassResolveFunction(array('Unmarshaller', 'ResolveExceptionClass'));
         $this->getResponseUnmarshaller()->setIsOutputAnArray(false);
         $this->getResponseUnmarshaller()->setPropertyClassResolveFunctions(array());
     }
     if (!$this->isResponseSignatureCheckDisabled()) {
         $responseSignature = $securityHelper->getSignature($responseHeader);
         $securityHelper->checkSignature($responseSignature, $responseBody);
     }
     $output = $this->getResponseUnmarshaller()->unmarshall($responseBody);
     if ($output instanceof Exception) {
         throw $output;
     }
     return $output;
 }
<?php

$logger = new Logger();
$logger->log('Hello World');
$logger->trace('Trace to here');
$logger->logCustomLine('Hello World (custom line)', 3);
try {
    throw new Exception("Test Exception");
} catch (Exception $e) {
    $logger->handleException($e);
}
class Logger
{
    private $console;
    private $engine;
    function __construct()
    {
        $this->console = FirePHP::to("page")->console();
        $this->console = $this->console->options(array('encoder.trace.offsetAdjustment' => 1));
        $this->engine = FirePHP::plugin('engine');
        $this->engine->onException($this->console);
    }
    function log($msg)
    {
        $this->console->log($msg);
    }
    function logCustomLine($msg, $line)
    {
        $this->console->options(array('line' => $line))->log($msg);
    }
    function trace($title)
Example #27
0
 public static function eh($errno, $errstr, $errfile, $errline, $errcontext)
 {
     $message = str_replace("\n", '<br/>', $errstr);
     Logger::trace($message);
     throw new RuntimeException($message);
 }
Example #28
0
 /**
  * 备份
  * @param int $imgId
  * @param string $blob
  * @param int $from
  * @param int $createTime
  * @param string $md5
  */
 function doBackup($imgId, $blob, $from)
 {
     $info = $this->unpackId($imgId);
     if (!$info) {
         // TODO 错误处理
         return;
     }
     $node = $this->getNode($info['node_id']);
     if (!$node) {
         throw new Exception('storage.nodeNotFound node_id=' . $node['node_id']);
     }
     $cnode = $this->getCurrentNode();
     if ($node['node_id'] == $cnode['node_id']) {
         trigger_error('not need to backup', E_USER_WARNING);
         return;
     }
     $copyNode = $cnode;
     $copyNode['node_id'] = $node['node_id'];
     $path = $this->getBlockFile($copyNode, $info['block_id']);
     Logger::trace('backup:' . $path);
     Logger::trace('backup.data:' . strlen($blob));
     $fh = null;
     if (!is_file($path)) {
         $dir = dirname($path);
         if (!is_dir($dir)) {
             mkdir($dir, 0755, true);
         }
         touch($path);
         $fh = fopen($path, 'r+');
         ftruncate($fh, self::BLOCK_INIT_SIZE);
     } else {
         clearstatcache();
         $size = filesize($path);
         $nSize = $from + strlen($blob);
         if ($nSize > $size) {
             do {
                 $size += self::BLOCK_INCR_SIZE;
             } while ($nSize >= $size);
             $fh = fopen($path, 'r+');
             ftruncate($fh, $size);
         }
     }
     if (!$fh) {
         $fh = fopen($path, 'r+');
     }
     fseek($fh, $from);
     fwrite($fh, $blob);
     fclose($fh);
     Logger::trace('backup image:' . $imgId);
 }
Example #29
0
File: test.php Project: hihus/newpi
 public function run()
 {
     $login = new com_login_login();
     $login->login();
     Logger::trace('get trace, errno:%d,errmsg:%s,file:%s,line:%d', 33, 44, 55, 66);
 }
Example #30
0
function _view()
{
    $file = find_view_file();
    if (!$file) {
        Logger::trace("No view for " . base_path());
        return false;
    }
    Logger::trace("View {$file}");
    $params = App::$context->as_array();
    extract($params);
    include $file;
}