当前位置: 首页>>代码示例>>PHP>>正文


PHP Dumper::toText方法代码示例

本文整理汇总了PHP中Tracy\Dumper::toText方法的典型用法代码示例。如果您正苦于以下问题:PHP Dumper::toText方法的具体用法?PHP Dumper::toText怎么用?PHP Dumper::toText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tracy\Dumper的用法示例。


在下文中一共展示了Dumper::toText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: decode

 /**
  * Parses a signed_request and validates the signature.
  *
  * @param string $signedRequest A signed token
  * @param string $appSecret
  *
  * @return array The payload inside it or null if the sig is wrong
  */
 public static function decode($signedRequest, $appSecret)
 {
     if (!$signedRequest || strpos($signedRequest, '.') === false) {
         Debugger::log('Signed request is invalid! ' . json_encode($signedRequest), 'facebook');
         return NULL;
     }
     list($encoded_sig, $payload) = explode('.', $signedRequest, 2);
     // decode the data
     $sig = Helpers::base64UrlDecode($encoded_sig);
     $data = Json::decode(Helpers::base64UrlDecode($payload), Json::FORCE_ARRAY);
     if (!isset($data['algorithm']) || strtoupper($data['algorithm']) !== Configuration::SIGNED_REQUEST_ALGORITHM) {
         Debugger::log("Unknown algorithm '{$data['algorithm']}', expected " . Configuration::SIGNED_REQUEST_ALGORITHM, 'facebook');
         return NULL;
     }
     // check sig
     $expected_sig = hash_hmac('sha256', $payload, $appSecret, $raw = TRUE);
     if (strlen($expected_sig) !== strlen($sig)) {
         Debugger::log('Bad Signed JSON signature! Expected ' . Dumper::toText($expected_sig) . ', but given ' . Dumper::toText($sig), 'facebook');
         return NULL;
     }
     $result = 0;
     for ($i = 0; $i < strlen($expected_sig); $i++) {
         $result |= ord($expected_sig[$i]) ^ ord($sig[$i]);
     }
     if ($result !== 0) {
         Debugger::log('Bad Signed JSON signature! Expected ' . Dumper::toText($expected_sig) . ', but given ' . Dumper::toText($sig), 'facebook');
         return NULL;
     }
     return $data;
 }
开发者ID:Kaspis77,项目名称:Facebook,代码行数:38,代码来源:SignedRequest.php

示例2: formatMessage

 /**
  * @return string
  */
 protected function formatMessage($message)
 {
     if ($message instanceof \Exception) {
         while ($message) {
             $tmp[] = ($message instanceof \ErrorException ? 'Fatal error: ' . $message->getMessage() : get_class($message) . ': ' . $message->getMessage()) . ' in ' . $message->getFile() . ':' . $message->getLine();
             $message = $message->getPrevious();
         }
         $message = implode($tmp, "\ncaused by ");
     } elseif (!is_string($message)) {
         $message = Dumper::toText($message);
     }
     return trim($message);
 }
开发者ID:enumag,项目名称:tracy,代码行数:16,代码来源:Logger.php

示例3: textDump

 public static function textDump($var)
 {
     trigger_error(__METHOD__ . '() is deprecated; use Tracy\\Dumper::toText() instead.', E_USER_DEPRECATED);
     return Tracy\Dumper::toText($var);
 }
开发者ID:pkristian,项目名称:flickrlickr,代码行数:5,代码来源:Helpers.php

示例4: log

 /**
  * Logs message or exception to file (if not disabled) and sends email notification (if enabled).
  * @param  string|Exception
  * @param  int  one of constant Debugger::INFO, WARNING, ERROR (sends email), EXCEPTION (sends email), CRITICAL (sends email)
  * @return string logged error filename
  */
 public static function log($message, $priority = self::INFO)
 {
     if (!self::$logDirectory) {
         return;
     }
     $exceptionFilename = NULL;
     if ($message instanceof \Exception) {
         $exception = $message;
         while ($exception) {
             $tmp[] = ($exception instanceof ErrorException ? 'Fatal error: ' . $exception->getMessage() : get_class($exception) . ': ' . $exception->getMessage()) . ' in ' . $exception->getFile() . ':' . $exception->getLine();
             $exception = $exception->getPrevious();
         }
         $exception = $message;
         $message = implode($tmp, "\ncaused by ");
         $hash = md5(preg_replace('~(Resource id #)\\d+~', '$1', $exception));
         $exceptionFilename = 'exception-' . @date('Y-m-d-H-i-s') . "-{$hash}.html";
         foreach (new \DirectoryIterator(self::$logDirectory) as $entry) {
             if (strpos($entry, $hash)) {
                 $exceptionFilename = $entry;
                 $saved = TRUE;
                 break;
             }
         }
     } elseif (!is_string($message)) {
         $message = Dumper::toText($message);
     }
     if ($exceptionFilename) {
         $exceptionFilename = self::$logDirectory . '/' . $exceptionFilename;
         if (empty($saved) && ($logHandle = @fopen($exceptionFilename, 'w'))) {
             ob_start();
             // double buffer prevents sending HTTP headers in some PHP
             ob_start(function ($buffer) use($logHandle) {
                 fwrite($logHandle, $buffer);
             }, 4096);
             self::getBlueScreen()->render($exception);
             ob_end_flush();
             ob_end_clean();
             fclose($logHandle);
         }
     }
     self::getLogger()->log(array(@date('[Y-m-d H-i-s]'), trim($message), self::$source ? ' @  ' . self::$source : NULL, $exceptionFilename ? ' @@  ' . basename($exceptionFilename) : NULL), $priority);
     return $exceptionFilename ? strtr($exceptionFilename, '\\/', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR) : NULL;
 }
开发者ID:xHRo,项目名称:simpleForum,代码行数:49,代码来源:Debugger.php

示例5: trace

 /**
  * Brief Description.
  * Complete Description.
  *
  * @param $msg (tipo) desc
  * @param $file (tipo) desc
  * @param $line=0 (tipo) desc
  *
  * @returns (tipo) desc
  *
  */
 public static function trace($var, $file = false, $line = 0)
 {
     $msg = Tracy\Dumper::toText($var, array('truncate' => self::getConf('maestro.debug.maxLen'), 'depth' => self::getConf('maestro.debug.maxDepth')));
     return self::getTrace()->trace($msg, $file, $line);
 }
开发者ID:elymatos,项目名称:expressive,代码行数:16,代码来源:Manager.php


注:本文中的Tracy\Dumper::toText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。