作者:Kaspis7
项目:Faceboo
/**
* 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;
}
作者:leonardoc
项目:tool
/**
* Dumps information about a variable in readable format.
*
* @param mixed $var to dump
* @param null $title
* @return void
*/
public static function sdump($var, $title = null)
{
if (!Debugger::$productionMode) {
self::initialize();
$trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
$item = Helpers::findTrace($trace, 'sdump', $index) ?: Helpers::findTrace($trace, __CLASS__ . '::sdump', $index);
if (isset($item['file'], $item['line']) && is_file($item['file'])) {
$lines = file($item['file']);
preg_match('#sdump\\((.*)\\)#', $lines[$item['line'] - 1], $matches);
$params = isset($matches[1]) ? htmlspecialchars($matches[1]) : false;
if ($params) {
preg_match('#array\\((.*)\\)#', $params, $matches2);
$params = isset($matches2[1]) ? $matches2[1] : $params;
$params = explode(',', $params);
}
$dumpParams = isset($matches[0]) ? "{$matches['0']};" : '';
$location = Debugger::$showLocation ? "<br>" . Helpers::editorLink($item['file'], $item['line']) : false;
}
$tiMethod = $trace[$index + 1];
$dumpTitle = isset($tiMethod['class']) ? $tiMethod['class'] . $tiMethod['type'] . $tiMethod['function'] . '(); ' : $tiMethod['function'] . $title;
$dumpObject = self::$dumpObject && isset($tiMethod['object']) ? Dumper::toHtml($tiMethod['object']) : '';
$dump = (isset($dumpParams) ? "<b>{$dumpParams}</b> " : '') . (isset($location) ? $location : '') . $dumpObject;
if (self::$traceMode) {
for ($i = 0; $i <= $index; $i++) {
array_shift($trace);
}
$dump .= "<br/>" . self::showTraceSimple($trace);
}
$dump .= Dumper::toHtml($var);
self::$dumps = array('title' => $dumpTitle, 'dump' => $dump);
self::addToDumpPanel($dump, $dumpTitle);
}
}
作者:mikula
项目:nette-panel-querie
/**
* e.g. SQL explain
*
* @return NULL|Html|string
*/
public function getInfo()
{
$info = $this->response;
unset($info['hits']['hits']);
$html = Dumper::toHtml($info, [Dumper::COLLAPSE => TRUE, Dumper::TRUNCATE => 50]);
return Html::el()->setHtml($html);
}
作者:petrparole
项目:web_cm
private function renderHtml()
{
$res = '<style>code, pre {white-space:nowrap} a {text-decoration:none} pre {color:gray;display:inline} big {color:red}</style><code>';
foreach ($this->list as $item) {
$res .= Helpers::editorLink($item[0], $item[1]) . ' ' . str_replace(self::BOM, '<big>BOM</big>', Dumper::toHtml($item[2])) . "<br>\n";
}
return $res . '</code>';
}
作者:nell
项目:tracy-debug-inf
/**
* @internal
* @param \Exception|NULL $e
* @return string[]|NULL
*/
public static function render(\Exception $e = NULL)
{
if (!$e instanceof \Nella\Tracy\DebugInfoException) {
return NULL;
// skip
}
return ['tab' => 'Exception Debug Info', 'panel' => \Tracy\Dumper::toHtml($e->__debugInfo())];
}
作者:mikula
项目:nette-panel-querie
/**
* @return Html|string
*/
public function getResult()
{
$data = iterator_to_array($this->result);
foreach ($data as &$row) {
$row = $this->rowToArray($row);
}
$html = Dumper::toHtml($data, [Dumper::COLLAPSE => TRUE]);
return Html::el()->setHtml($html);
}
作者:YepFoundatio
项目:tracy-twig-extension
protected function doDump($data)
{
if (!class_exists('\\Tracy\\Dumper')) {
return '';
}
ob_start();
Dumper::dump($data, $this->options);
return ob_get_clean();
}
作者:pipaslo
项目:doctrin
/**
* @param array
* @return string
*/
protected function processQuery(array $query)
{
$s = '';
list($sql, $params, $time) = $query;
$s .= '<tr><td>' . sprintf('%0.3f', $time * 1000);
$s .= '</td><td class="nette-Doctrine2Panel-sql">' . Helpers::dumpSql($sql);
$s .= '</td><td>' . Dumper::toHtml($params) . '</tr>';
return $s;
}
作者:nakouka
项目:fakturac
public static function initializePanel(Nette\Application\Application $application)
{
Tracy\Debugger::getBlueScreen()->addPanel(function ($e) use ($application) {
return $e ? NULL : array(
'tab' => 'Nette Application',
'panel' => '<h3>Requests</h3>' . Tracy\Dumper::toHtml($application->getRequests())
. '<h3>Presenter</h3>' . Tracy\Dumper::toHtml($application->getPresenter()),
);
});
}
作者:trejja
项目:validatio
/**
* Renders HTML code for custom panel.
* @return string
*/
function getPanel()
{
if (!$this->messages) {
return NULL;
}
ob_start();
$esc = callback('Nette\\Templating\\Helpers::escapeHtml');
$click = class_exists('\\Tracy\\Dumper') ? function ($o, $c = FALSE) {
return \Tracy\Dumper::toHtml($o, array('collapse' => $c));
} : callback('\\Tracy\\Helpers::clickableDump');
require __DIR__ . '/panel.phtml';
return ob_get_clean();
}
作者:re1la2ps
项目:GromesProjek
private function renderHtml()
{
$res = '<style>code, pre {white-space:nowrap} a {text-decoration:none} pre {color:gray;display:inline} big {color:red}</style><code>';
foreach ($this->list as $item) {
$stack = array();
foreach (array_slice($item[3], 1) as $t) {
$t += array('class' => '', 'type' => '', 'function' => '');
$stack[] = "{$t['class']}{$t['type']}{$t['function']}()" . (isset($t['file'], $t['line']) ? ' in ' . basename($t['file']) . ":{$t['line']}" : '');
}
$res .= Helpers::editorLink($item[0], $item[1]) . ' ' . '<span title="' . htmlspecialchars(implode("\n", $stack), ENT_IGNORE | ENT_QUOTES, 'UTF-8') . '">' . str_replace(self::BOM, '<big>BOM</big>', Dumper::toHtml($item[2])) . "</span><br>\n";
}
return $res . '</code>';
}
作者:FreezyBe
项目:MailChim
/**
* Renders HTML code for custom panel.
* @return string
*/
public function getPanel()
{
if (!$this->resources) {
return null;
}
$esc = \Nette\Utils\Callback::closure('Latte\\Runtime\\Filters::escapeHtml');
$click = function ($o, $c = false) {
return \Tracy\Dumper::toHtml($o, ['collapse' => $c]);
};
ob_start();
include __DIR__ . '/panel.phtml';
return ob_get_clean();
}
作者:baz
项目:nette-features-extensio
/**
* @return string
*/
public function getPanel()
{
if (empty($this->evaluatedFeatures)) {
return NULL;
}
$evaluatedFeatures = $this->evaluatedFeatures;
$click = class_exists('\\Tracy\\Dumper') ? function ($o, $c = TRUE, $d = 4) {
return \Tracy\Dumper::toHtml($o, array('collapse' => $c, 'depth' => $d));
} : callback('\\Tracy\\Helpers::clickableDump');
ob_start();
require __DIR__ . '/panel.phtml';
return ob_get_clean();
}
作者:enuma
项目:trac
/**
* @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);
}
作者:kdyb
项目:googl
/**
* @return string
*/
public function getPanel()
{
if (!$this->calls) {
return NULL;
}
ob_start();
$esc = array('Nette\\Templating\\Helpers', 'escapeHtml');
$click = class_exists('\\Tracy\\Dumper') ? function ($o, $c = FALSE) {
return \Tracy\Dumper::toHtml($o, array('collapse' => $c));
} : array('\\Tracy\\Helpers', 'clickableDump');
$totalTime = $this->totalTime ? sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : 'none';
require __DIR__ . '/panel.phtml';
return ob_get_clean();
}
作者:noiki
项目:Cur
/**
* @param \Kdyby\Curl\Response $response
*
* @return string
*/
public static function allResponses($response)
{
if (!$response instanceof Curl\Response) {
return NULL;
}
$click = function ($o, $c = TRUE) {
return Dumper::toHtml($o, array('collapse' => $c));
};
$responses = array($click($response, TRUE));
while ($response = $response->getPrevious()) {
$responses[] = $click($response, TRUE);
}
return implode('', $responses);
}
作者:lookyma
项目:mandril
public function getPanel()
{
if (empty($this->requests)) {
return '';
}
$panel = '<h1>Mandrill API calls</h1>' . '<div class="tracy-inner tracy-MandrillPanel">' . '<style type="text/css">' . '#tracy-debug .tracy-panel .tracy-MandrillPanel tr:nth-child(2n) td { background: inherit; }' . '</style>' . '<table>';
foreach ($this->requests as $index => $request) {
$panel .= '<tr><th>' . ($index + 1) . '</th><td>';
ob_start();
Dumper::dump($request, [Dumper::DEPTH => 6]);
$panel .= ob_get_clean() . '</td></tr>';
}
return $panel . '</table>' . '</div>';
}
作者:rohlikc
项目:DoctrineSearc
protected function execute(InputInterface $input, OutputInterface $output)
{
$printMapping = $output->getVerbosity() > $output::VERBOSITY_NORMAL;
$metadataFactory = $this->searchManager->getMetadataFactory();
/** @var ClassMetadata $class */
foreach ($metadataFactory->getAllMetadata() as $class) {
$output->writeln(sprintf('Entity <info>%s</info> is searchable', $class->getName()));
if (!$printMapping) {
continue;
}
$meta = (array) $class;
unset($meta['reflFields'], $meta['reflClass']);
$output->writeln(Dumper::toTerminal($meta));
}
}
作者:runt1
项目:Github-
/**
* @return string
*/
public function getPanel()
{
if (!$this->calls) {
return NULL;
}
ob_start();
$esc = function ($s) {
return htmlSpecialChars($s, ENT_QUOTES, 'UTF-8');
};
$click = class_exists('\\Tracy\\Dumper') ? function ($o, $c = FALSE) {
return \Tracy\Dumper::toHtml($o, array('collapse' => $c));
} : Callback::closure('\\Tracy\\Helpers::clickableDump');
$totalTime = $this->totalTime ? sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : 'none';
require __DIR__ . '/panel.phtml';
return ob_get_clean();
}
作者:kdyb
项目:faceboo
/**
* @return string
*/
public function getPanel()
{
if (!$this->calls) {
return NULL;
}
ob_start();
if (class_exists('Latte\\Runtime\\Filters')) {
$esc = Nette\Utils\Callback::closure('Latte\\Runtime\\Filters::escapeHtml');
} else {
$esc = 'Nette\\Templating\\Helpers::escapeHtml';
}
$click = class_exists('\\Tracy\\Dumper') ? function ($o, $c = FALSE) {
return \Tracy\Dumper::toHtml($o, array('collapse' => $c));
} : '\\Tracy\\Helpers::clickableDump';
$totalTime = $this->totalTime ? sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : 'none';
require __DIR__ . '/panel.phtml';
return ob_get_clean();
}