Beispiel #1
0
 /**
  * @todo Implement testInit().
  */
 public function testInit()
 {
     $config = Panda::getConfig();
     $config[Panda::CONFIG_DEBUG] = true;
     Panda::init($config);
     $config = Panda::getConfig();
     $this->assertTrue($config[Panda::CONFIG_DEBUG] === true);
 }
Beispiel #2
0
 /**
  * 全てのキャッシュをクリア
  *
  * @param bool $showMessage メッセージ表示?
  *
  * @return void
  */
 public static function clearAllCache($showMessage = false)
 {
     $app = BEAR::get('app');
     if ($app['core']['debug'] !== true) {
         return;
     }
     BEAR::factory('BEAR_Dev_Shell')->clearCache();
     if ($showMessage) {
         Panda::message('Cache Clear', '全てのキャッシュファイルとキャッシュメモリをクリアしました');
     }
 }
Beispiel #3
0
<?php

require_once 'App.php';
include_once _BEAR_APP_HOME . '/App/data/dev.config.php';
if (!$isSet) {
    Panda::error('現在利用できません。', 'dev.config.phpファイルを編集して設定を完了させてください', _BEAR_APP_HOME . '/App/data/dev.config.php');
    exit;
}
/**
 * Put this file in a web-accessible directory as index.php (or similar)
 * and point your webbrowser to it.
 */
// OPTIONAL: If you have protected this webfrontend with a password in a
// custom way, then uncomment to disable the 'not protected' warning:
$pear_frontweb_protected = true;
/***********************************************************
 * Following code tests $pear_dir and loads the webfrontend:
 */
if (!file_exists($pear_dir . '/PEAR.php')) {
    trigger_error('No PEAR.php in supplied PEAR directory: (PEARディレクトリにPEAR.phpがありません)' . $pear_dir, E_USER_ERROR);
}
ini_set('include_path', $pear_dir);
require_once 'PEAR.php';
// Include WebInstaller
putenv('PHP_PEAR_INSTALL_DIR=' . $pear_dir);
// needed if unexisting config
require_once 'pearfrontendweb.php';
Beispiel #4
0
 /**
  * Init
  *
  * reset error/exception handler and atach panda handler
  *
  * @param array $config config
  *
  * @return void
  */
 public static function init(array $config = array())
 {
     if (isset($_GET['_nopanda'])) {
         return;
     }
     $er = error_reporting(false);
     self::$_config = array_merge(self::$_config, $config);
     // reset handler
     if (self::$_config[self::CONFIG_DEBUG] !== true) {
         ini_set('display_errors', 0);
         function p($v = '')
         {
             syslog(LOG_INFO, print_r($v, true));
         }
         if (class_exists('PEAR', false)) {
             PEAR::setErrorHandling(PEAR_Exception);
         }
         set_exception_handler(array('Panda', 'onException'));
     } else {
         if (self::$_config[self::CONFIG_ENABLE_FIREPHP]) {
             include_once 'FirePHPCore/FirePHP.class.php';
             include_once 'FirePHPCore/fb.php';
         }
         self::_initOnDebug();
         if (self::$_config[self::CONFIG_CATCH_FATAL] === true) {
             ob_start(array('Panda', 'onFatalError'));
         }
         // catch E_STRICT
         if (self::$_config[self::CONFIG_CATCH_STRICT] === true) {
             error_reporting(E_ALL | E_STRICT);
             ob_start(array('Panda', 'onStrictError'));
         }
     }
     error_reporting($er);
 }
Beispiel #5
0
 /**
  * Get trace summary HTML string
  *
  * <code>
  * echo getTraceSummary(debug_backtrace()); //output trace summary
  * </code>
  *
  * @param array $debuBackTrace trace data
  *
  * @return void
  */
 public static function getTraceSummary($debuBackTrace = null)
 {
     $debuBackTrace = is_null($debuBackTrace) ? debug_backtrace() : $debuBackTrace;
     $traceLevels = array_keys($debuBackTrace);
     $i = 0;
     $traceSummary = '';
     foreach ($traceLevels as $level) {
         $trace = $debuBackTrace[$level];
         if (isset($trace['file'])) {
             $file = $trace['file'];
             $line = $trace['line'];
             $fileArray = file($file);
             $hitLine = $fileArray[$line - 1];
         } elseif (isset($trace['class']) && isset($trace['function'])) {
             $ref = new ReflectionMethod($trace['class'], $trace['function']);
             $file = $ref->getFileName();
             $line = $ref->getStartLine();
             $fileArray = file($file);
             $hitLine = $fileArray[$line - 1];
         } elseif (isset($trace['function'])) {
             $ref = new ReflectionFunction($trace['function']);
             $file = $ref->getFileName();
             $line = $ref->getStartLine();
             $fileArray = $file ? file($file) : array();
             $hitLine = $file ? $fileArray[$line - 1] : '';
         } else {
             $file = false;
             $hitLine = 'n/a';
         }
         $hitLine = trim($hitLine);
         $args = array();
         if (isset($trace['args'])) {
             foreach ($trace['args'] as $arg) {
                 if (is_array($arg)) {
                     $args[] = 'Array';
                 } elseif (is_string($arg)) {
                     $args[] = "'{$arg}'";
                 } elseif (is_scalar($arg)) {
                     $args[] = $arg;
                 } else {
                     $args[] = 'Object';
                 }
             }
         }
         if (isset($trace['class'])) {
             $hitInfo = "{$trace['class']}{$trace['type']}{$trace['function']}({$args}) ";
         } elseif (isset($trace['function'])) {
             $hitInfo = "{$trace['function']}({$args}) ";
         } else {
             $hitInfo = '';
         }
         $args = implode(',', $args);
         $traceSummary .= '<li><span class="timeline-num">' . $i . '</span>';
         $traceSummary .= '<span class="timeline-body">' . $hitLine . '</span>';
         $traceSummary .= '<span class="timeline-info">' . $hitInfo . '<br />';
         $traceSummary .= $file ? Panda::getEditorLink($file, $line) : '';
         $traceSummary .= '</span></li>';
         $i++;
     }
     $traceSummary = '<ol id="trace-summary" class="timeline">' . $traceSummary . '</ol>';
     return $traceSummary;
 }
Beispiel #6
0
 /**
  * スクリプトシャットダウン時のログ処理
  *
  * <pre>
  * アプリケーションログ、smartyアサインログ、グローバル変数ログ、
  * リクエストURIをシリアライズしてファイル保存します。
  * デバックモードの時のみ使用します。
  * 保存されたログは/__bear/のLogタブでブラウズできます。
  * シャットダウン時実行のメソッドとしてフレームワーク内で登録され、
  * スクリプト終了時に実行されます。
  * フレームワーク内で使用されます。
  * </pre>
  *
  * @return void
  * @ignore
  * @throws BEAR_Log_Exception
  */
 public function shutdownDebug($return = true)
 {
     if (PHP_SAPI === 'cli') {
         return;
     }
     if (strpos($_SERVER['REQUEST_URI'], '__bear/') !== false) {
         return;
     }
     restore_error_handler();
     error_reporting(0);
     try {
         $isBeardev = isset($_SERVER['__bear']);
         $pageLogPath = _BEAR_APP_HOME . '/logs/' . 'debug' . '.log';
         file_put_contents($pageLogPath, $this->_config['debug']);
         if ($isBeardev || PHP_SAPI === 'cli') {
             return;
         }
         $log = array();
         $pageLogPath = _BEAR_APP_HOME . '/logs/page.log';
         if (file_exists($pageLogPath) && !is_writable($pageLogPath)) {
             // 書き込み権限のエラー
             Panda::error('Permission denied.', "[{$pageLogPath}] is not writable.");
             return;
         }
         // page ログ
         $pageLog = file_exists($pageLogPath) ? BEAR_Util::unserialize(file_get_contents($pageLogPath)) : '';
         // show_vars
         if (!function_exists('show_vars')) {
             include 'BEAR/vendors/debuglib.php';
         }
         $log['var'] = show_vars('trim_tabs:2;show_objects:1;max_y:100;avoid@:1; return:1');
         if (class_exists('BEAR_Smarty', false)) {
             $smarty = BEAR::dependency('BEAR_Smarty');
             unset($smarty->_tpl_vars['content_for_layout']);
             $log['smarty'] = $smarty->_tpl_vars;
         } else {
             $log['smarty'] = '';
         }
         $oldPageLog = isset($pageLog['page']) ? $pageLog['page'] : array();
         $newPageLog = array('page' => $this->_logs, 'uri' => $_SERVER['REQUEST_URI']);
         $oldPageLog[] = $newPageLog;
         if (count($oldPageLog) > 3) {
             array_shift($oldPageLog);
         }
         $log += array('page' => $oldPageLog, 'include' => get_included_files(), 'class' => get_declared_classes());
         if (isset($_SERVER['REQUEST_URI'])) {
             $log += array('uri' => $_SERVER['REQUEST_URI']);
         }
         $reg = BEAR_Util::getObjectVarsRecursive(BEAR::getAll());
         $log['reg'] = $reg;
         if ($return === true) {
             return $log;
         } else {
             file_put_contents($pageLogPath, serialize($log));
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
{
    // Properties
    public $coat = 'fluffy';
    public $color;
    // Coat Method
    public function getCoat()
    {
        return $this->coat;
    }
    // Color Method
    public function getColor()
    {
        return $this->color;
    }
}
// PROCEDURAL CODE:
// Create a new instance.
$panda = new Panda();
// Change the value of properties.
$panda->color = 'red';
// Execute the coat method.
echo $panda->getCoat() . PHP_EOL;
echo $panda->getColor() . PHP_EOL;
// extend the class
class GiantPanda extends Panda
{
}
// Create a new instance.
$giantPanda = new GiantPanda();
// get coat type
echo $giantPanda->getCoat() . PHP_EOL;
Beispiel #8
0
}
// エラー初期化(Panda)
if (defined('_BEAR_APP_HOME')) {
    $validPath = array(_BEAR_APP_HOME . '/htdocs', _BEAR_APP_HOME . '/App');
} else {
    $validPath = array();
}
// BEAR developperのみBEAR内のエラー表示
if (isset($_SERVER['beardev']) && $_SERVER['beardev']) {
    $validPath[] = _BEAR_BEAR_HOME;
}
$pandaConfig = array(Panda::CONFIG_DEBUG => $appConfig['core']['debug'], Panda::CONFIG_VALID_PATH => $validPath, Panda::CONFIG_LOG_PATH => _BEAR_APP_HOME . '/logs/');
if (isset($appConfig['Panda'])) {
    $pandaConfig = array_merge($pandaConfig, $appConfig['Panda']);
}
Panda::init($pandaConfig);
// デバック用画面
include _BEAR_BEAR_HOME . '/BEAR/BEAR/script/dev_info_screen.php';
// _preクエリー
if (isset($_GET['_pre'])) {
    echo '<pre>';
}
// _errorクエリー
if (isset($_GET['_error'])) {
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    restore_error_handler();
    restore_exception_handler();
    return;
}
// exit
Beispiel #9
0
 /**
  * 最後のエラーを取得
  *
  * <pre>
  * _errorクエリーで最後のエラーを表示させます。
  * エラー表示がうまく行かない時に使用します。
  * </pre>
  *
  * <code>
  * ?_error                           エラー表示
  * ?_error=koriyama@bear-project.net エラーメール送信
  * ?_error=/tmp/error.log            エラーログファイルを書き込み
  * </code>
  *
  * @return void
  */
 public static function onShutdownDebug()
 {
     if (function_exists('FB')) {
         $errors = Panda::getOuterPathErrors();
         FB::group('errors', array('Collapsed' => true, 'Color' => 'gray'));
         foreach ($errors as $code => $error) {
             switch (true) {
                 case $code == E_WARNING || $code == E_USER_WARNING:
                     $fireLevel = FirePHP::WARN;
                     break;
                 case $code == E_NOTICE || $code == E_USER_NOTICE:
                     $fireLevel = FirePHP::INFO;
                     break;
                 case $code == E_STRICT || $code == E_DEPRECATED:
                     $fireLevel = FirePHP::LOG;
                     break;
                 default:
                     $fireLevel = FirePHP::ERROR;
                     break;
             }
             FB::send($error, '', $fireLevel);
         }
         FB::groupEnd();
     }
     $lastError = error_get_last();
     $err = print_r($lastError, true);
     if (isset($_GET['_error'])) {
         $errorTo = $_GET['_error'];
         if ($errorTo == '') {
             $errorCode = Panda::$phpError[$lastError['type']];
             Panda::error("{$errorCode} (Last Error)", "{$lastError['message']}", '', (array) $lastError);
             return;
         } elseif (strpos($errorTo, '@')) {
             error_log($err, 1, $errorTo);
         } elseif (is_writable(dirname($errorTo))) {
             error_log("{$err}\n\n", 3, $errorTo);
         } else {
             echo "<p style=\"color:red\">Error: Invalid destination for _error [{$errorTo}]</p>";
         }
     }
 }
Beispiel #10
0
 * <code>sudo pear install Text_Highlighter</code>
 *
 * トラブルシューティング
 *
 * failed to open stream: Permission denied エラーが出たファイルに644のパーミッションを与えてください
 *
 */
require_once 'App.php';
$_SERVER['__bear'] = 1;
$configPath = _BEAR_APP_HOME . '/App/data/dev.config.php';
if (!file_exists($configPath)) {
    Panda::error('現在利用できません。', 'debug用設定ファイルが設置されてるか確認してください', array('設定ファイル' => _BEAR_APP_HOME . '/App/data/dev.config.php'));
} else {
    include_once $configPath;
    if (!isset($isSet) || !$isSet) {
        Panda::error('現在利用できません。', 'debug用設定ファイルを編集して設定を完了させてください', array('設定ファイル' => _BEAR_APP_HOME . '/App/data/dev.config.php'));
        exit;
    }
}
?>
<style type="text/css">
.hl-main {
	font-family: monospace;
}

.hl-default {
	color: #000000;
}

.hl-code {
	color: #7f7f33;
Beispiel #11
0
 /**
  * 初期化
  *
  * BEARの使用時にbootstrapなどの部分で一度呼び使用クラスの設定
  * オートローダー、エラーハンドラの設定、デバック用機能有効化などを行います。
  *
  * @param array $appConfig アプリケーション別クラス設定
  *
  * @return void
  */
 public static function init(array $appConfig = array('core' => array('debug' => false)))
 {
     static $_run = false;
     if ($_run === true) {
         return;
     }
     $_run = true;
     // PEAR_Errorがオートローダー効かないための事前require
     include_once 'PEAR.php';
     // クラスオートローダー登録
     self::set('app', new ArrayObject($appConfig));
     self::$_config = $appConfig['core'];
     if (self::$_config['debug'] === false) {
         spl_autoload_register(array(__CLASS__, 'onAutoload'));
         //Panda (live)
         $pandaConfig = isset($appConfig['Panda']) ? $appConfig['Panda'] : array();
         $pandaConfig[Panda::CONFIG_DEBUG] = false;
         // デバックモードオフ
         if (defined('_BEAR_APP_HOME')) {
             $pandaConfig[Panda::CONFIG_LOG_PATH] = _BEAR_APP_HOME . '/logs/';
         }
         Panda::init($pandaConfig);
     } else {
         if (isset($appConfig['BEAR']['autoload'])) {
             spl_autoload_register($appConfig['BEAR']['autoload']);
         } else {
             spl_autoload_register(array(__CLASS__, 'onAutoload'));
         }
         include _BEAR_BEAR_HOME . '/BEAR/BEAR/script/debug_init.php';
     }
     if (PHP_SAPI === 'cli' && defined('_BEAR_APP_HOME')) {
         ini_set('include_path', _BEAR_APP_HOME . PATH_SEPARATOR . get_include_path());
     }
 }
Beispiel #12
0
 /**
  * リソースリクエスト
  *
  * @return BEAR_Ro
  * @throws Exception Ro内部で発生した例外
  */
 public function request()
 {
     $uri = $this->_config['uri'];
     $values = $this->_config['values'];
     $options = $this->_config['options'];
     // URIのクエリーと$valuesをmerge
     $parse = parse_url($uri);
     if (!isset($parse['scheme'])) {
         $this->_mergeQuery($uri, $values);
     }
     $isNotRead = $this->_config['method'] !== BEAR_Resource::METHOD_READ;
     if (!$isNotRead) {
         $hasCsrfOption = false;
     } elseif (isset($options[BEAR_Resource::OPTION_CSRF]) && $options[BEAR_Resource::OPTION_CSRF] === true) {
         // リソースリクエストオプション
         $hasCsrfOption = true;
     } elseif ($this->_config[BEAR_Resource::OPTION_CSRF] === true) {
         // yaml
         $hasCsrfOption = true;
     } else {
         $hasCsrfOption = false;
     }
     if (!$isNotRead) {
         $hasPoeOption = false;
     } elseif (isset($options[BEAR_Resource::OPTION_POE]) && $options[BEAR_Resource::OPTION_POE] === true) {
         // リソースリクエストオプション
         $hasPoeOption = true;
     } elseif ($this->_config[BEAR_Resource::OPTION_POE] === true) {
         // yaml
         $hasPoeOption = true;
     } else {
         $hasPoeOption = false;
     }
     if ($hasCsrfOption || $hasPoeOption) {
         $formToken = BEAR::dependency('BEAR_Form_Token');
         /* @var $formToken BEAR_Form_Token */
         $isTokenCsrfValid = $hasCsrfOption ? $formToken->isTokenCsrfValid() : true;
         if ($isTokenCsrfValid !== true) {
             throw $this->_exception('CSRF');
         }
         $isTokenPoeValid = $hasPoeOption ? $formToken->isTokenPoeValid() : true;
         if ($isTokenPoeValid !== true) {
             $headers = array('request config' => $this->_config, 'msg' => 'invalid token');
             $code = BEAR::CODE_BAD_REQUEST;
             $config = compact('headers', 'code');
             $ro = BEAR::factory('BEAR_Ro', $config);
             $ro->setConfig('uri', $uri);
             $ro->setConfig('values', $values);
             $ro->setConfig('options', $options);
             return $ro;
         } else {
             $formToken->newSessionToken();
         }
     }
     $config = $this->_config;
     $config['uri'] = $uri;
     $config['values'] = $values;
     $resourceRequestCache = BEAR::factory('BEAR_Resource_Request_Cache', $config);
     try {
         $ro = $resourceRequestCache->request();
         // 中で例外が発生しなかったらPOEオプションで使ったトークンを使用済みにマークする
         // @todo staticコールを廃止
         //             BEAR_Form::finishTokens();
         /* @todo 下のifブロックを置き換える
             $isOkRo = ($ro instanceof BEAR_Ro && $ro->getCode() === BEAR::CODE_OK);
            $isNotRo = ($ro instanceof BEAR_Ro === false);
            if (!$isOkRo && $isNotRo) {
            $body = $ro;
            $ro = BEAR::factory('BEAR_Ro');
            $ro->setBody($body);
            }
            */
         if ($ro instanceof BEAR_Ro && $ro->getCode() === BEAR::CODE_OK) {
             // $options ポストプロセスクラス
         } elseif ($ro instanceof BEAR_Ro === false) {
             $body = $ro;
             $ro = BEAR::factory('BEAR_Ro');
             $ro->setBody($body);
         }
         $request = "{$this->_config['method']} {$uri}" . ($values ? '?' . http_build_query($values) : '');
         self::_actionPostProcess($ro);
     } catch (Exception $e) {
         if (get_class($e) === 'Panda_Exception') {
             // HTTPエラー画面
             Panda::onException($e);
             throw $e;
         }
         if (BEAR::exists('page')) {
             $page = BEAR::get('page');
             if (method_exists($page, 'onException')) {
                 $page->onException($e);
             }
         }
         if ($this->_config['debug']) {
             $info = method_exists($e, 'getInfo') ? $e->getInfo() : '';
             Panda::error(get_class($e), $e->getCode() . ' ' . $e->getMessage(), $info);
         }
         //エラー (400=bad requset, or 500=server error
         $trace = $e->getTrace();
         $refTrace =& $trace;
         $trace = array_shift($refTrace);
         if (isset($trace['args'])) {
             $args = $trace['args'];
         } else {
             $args = '';
         }
         $headers = array();
         $exception = array('class' => get_class($e), 'msg' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine());
         $headers['_exception'] = $exception;
         if (method_exists($e, 'getInfo')) {
             $headers['_info'] = $e->getInfo();
         }
         $ro = BEAR::factory('BEAR_Ro');
         $ro->setHeaders($headers)->setCode($e->getCode());
     }
     if ($this->_config['debug']) {
         BEAR::dependency('BEAR_Ro_Debug', $this->_config)->debugShowResource($ro);
     }
     return $ro;
 }
        $infoDir .= '<h3>bearコマンド(CLI)のアプリケーションホーム設定</h3>';
        $infoDir .= '<div><code>bear set-app ' . _BEAR_APP_HOME . ';</code></div>';
        $infoDir .= '<h3>オンラインエディタの設定</h3>';
        $infoDir .= '<div><code>sudo ln -s ' . _BEAR_BEAR_HOME . '/data/htdocs/__edit ';
        $infoDir .= _BEAR_APP_HOME . '/htdocs; </code></div>';
        $infoDir .= '<p>※保存するためには対象ファイルのパーミッションを変更する必要があります</p>';
        $subHeading = 'このコードをシェルで実行してください';
        Panda::message('開発環境のセットアップ', $subHeading, $infoDir);
        $exit = true;
    } elseif (isset($_GET['_beardebug_query'])) {
        $subHeading = 'デバックモードでクエリーによるデバッグコマンドが使えます';
        $infoDir = '<h3>キャッシュクリア</h3>';
        $infoDir .= '<div><p>?_cc</p></div>';
        $infoDir .= '<h3>リソースデバック</h3>';
        $infoDir .= '<div><p>?_resource</p></div>';
        $infoDir .= '<h3>全てのエラー表示</h3>';
        $infoDir .= '<div><p>?_error</p></div>';
        $infoDir .= '<h3>改行を表示するためのpreタグ表示</h3>';
        $infoDir .= '<div><p>?_pre</p></div>';
        $infoDir .= '<h3>firePHPログ</h3>';
        $infoDir .= '<div><p>?_firelog</p></div>';
        $infoDir .= '<div>スクリプト最後に発生したエラーメッセージを表示します。</div>';
        $infoDir .= '<h3>Pandaエラーハンドラーoff</h3>';
        $infoDir .= '<div><p>?_nopanda</p></div>';
        $infoDir .= '<div> ※エラーメッセージが表示されないときなど</div>';
        $infoDir .= '<h3>プロファイリング</h3>';
        $infoDir .= '<div><p>?_prof</p></div><div> ※xdebug, xhprofの機能拡張とApp.phpでApp/prof.phpの読み込みが必要です</div>';
        Panda::message('デバック用クエリー', $subHeading, $infoDir);
        $exit = true;
    }
}
Beispiel #14
0
/**
 * Prints human-readable trace information's link on link
 *
 * @param bool $condition
 *
 * @return void
 */
function tr($condition = true)
{
    if (!$condition) {
        return;
    }
    if (function_exists('fb')) {
        fb("tr()", FirePHP::TRACE);
    }
    $config = Panda::getConfig();
    if ($config[Panda::CONFIG_DEBUG] !== true) {
        $trace = debug_backtrace();
        $file = $trace[0]['file'];
        $line = $trace[0]['line'];
        trigger_error('tr() is called in no debug mode in ' . $file . ' on line ' . $line, E_USER_WARNING);
        return;
    }
    Panda_Debug::trace(false, debug_backtrace());
}
Beispiel #15
0
<?php

ob_start();
/**
 * Panda init
 */
// required files
include 'Panda.php';
$config = array(Panda::CONFIG_DEBUG => true, Panda::CONFIG_VALID_PATH => array('/'), Panda::CONFIG_LOG_PATH => '/tmp/', Panda::CONFIG_HTTP_TPL => __DIR__ . '/../../../Panda/templates/http.php', Panda::CONFIG_FATAL_HTML => __DIR__ . '/../../../Panda/templates/fatal.php', Panda::CONFIG_ON_ERROR_FIRED => array('Panda_App_Error_Handler', 'onError'), Panda::CONFIG_ENABLE_FIREPHP => true, Panda::CONFIG_CATCH_FATAL => true, Panda::CONFIG_PANDA_PATH => '/', Panda::CONFIG_EDITOR => Panda::EDITOR_BESPIN | Panda::EDITOR_TEXTMATE, Panda::CONFIG_CATCH_STRICT => true);
// catch stric error in compile ?
Panda::init($config);
/**
 * Application error handler
 *
 * @param string $headering
 * @param string $subheading
 * @param array  $info
 * @param array  $options
 *
 * @return void
 */
class Panda_App_Error_Handler
{
    public static function onError($heading, $subheading, $info, $options)
    {
    }
}
Beispiel #16
0
<?php

require 'Panda.php';
$file = isset($_GET['file']) ? $_GET['file'] : false;
$line = isset($_GET['line']) ? $_GET['line'] : 0;
if (!is_readable($file)) {
    Panda::message('404 Not found', "[{$file}] is not readable.");
    exit;
}
// set variable for view
$view = array();
$view['file_path'] = $file;
$view['line'] = $line;
$view['file_contents'] = file_get_contents($file);
$id = md5($file);
$view['mod_date'] = date(DATE_RFC822, filemtime($file));
$view['owner_info'] = function_exists('posix_getpwuid') ? posix_getpwuid(fileowner($file)) : array('name' => 'n/a');
$fileperms = substr(decoct(fileperms($file)), 2);
$view['is_writable'] = is_writable($file);
$view['is_writable_label'] = $view['is_writable'] ? "" : " Read Only";
$view['auth'] = md5(session_id() . $id);
// render
include 'view.php';
 function test_string_to_sign()
 {
     $expected = "POST\napi-eu.pandastream.com\n/videos.json\naccess_key=9c264aba-8d97-df11-b01b-12313c0091c1&cloud_id=5385adf38f3e39de1ddcf4c1b81ad056&timestamp=2010-07-16T06%3A27%3A54%2B00%3A00&upload_redirect_url=http%3A%2F%2Flocalhost%3A44444%2Fpanda%2Fsimplest%2Fplayer.php%3Fpanda_video_id%3D%24id";
     $actual = Panda::string_to_sign('POST', '/videos.json', 'api-eu.pandastream.com', array('upload_redirect_url' => 'http://localhost:44444/panda/simplest/player.php?panda_video_id=$id', 'cloud_id' => '5385adf38f3e39de1ddcf4c1b81ad056', 'access_key' => '9c264aba-8d97-df11-b01b-12313c0091c1', 'timestamp' => '2010-07-16T06:27:54+00:00'));
     $this->assertEqual($expected, $actual);
 }
Beispiel #18
0
 /**
  * Init
  *
  * @return void
  */
 private function _init()
 {
     // init
     $traceFile = Panda::getTempDir() . '/trace-' . $_GET['id'] . '.log';
     if (!file_exists($traceFile)) {
         error_reporting(E_ALL);
         trigger_error('invalid trace file. ' . $traceFile, E_USER_ERROR);
     }
     // store trace data
     $this->_traceLog = @unserialize(file_get_contents($traceFile));
     if (!$this->_traceLog) {
         die("<p>trace is not available...</p>");
     }
     // store refection data if exists
     $refDataFile = "{$traceFile}.ref.log";
     if (file_exists($refDataFile)) {
         $this->_ref = unserialize(file_get_contents($refDataFile));
     }
     $this->_traceLevels = array_keys($this->_traceLog);
     $this->_levelNum = count($this->_traceLevels);
     $this->_editor = isset($_GET['editor']) ? $_GET['editor'] : self::EDITOR_NONE;
 }