Exemplo n.º 1
0
 /**
  * 开启调试输出
  * @method _initDebug
  * @author NewFuture
  */
 public function _initDebug()
 {
     if (Config::get('isdebug')) {
         /*加载 PHP Console Debug模块*/
         Yaf_Loader::import('PhpConsole/__autoload.php');
         $connector = PhpConsole\Connector::getInstance();
         if ($connector->isActiveClient()) {
             Log::write('PHP Console 已经链接', 'INFO');
             $handler = PhpConsole\Handler::getInstance();
             $dispatcher = $connector->getDebugDispatcher();
             $handler->start();
             $connector->setSourcesBasePath(APP_PATH);
             $connector->setServerEncoding('utf8');
             $dispatcher->detectTraceAndSource = true;
             //跟踪信息
             if ($pwd = Config::get('debug.auth')) {
                 $connector->setPassword($pwd);
                 $evalProvider = $connector->getEvalDispatcher()->getEvalProvider();
                 // $evalProvider->disableFileAccessByOpenBaseDir();             // means disable functions like include(), require(), file_get_contents() & etc
                 // $evalProvider->addSharedVar('uri', $_SERVER['REQUEST_URI']); // so you can access $_SERVER['REQUEST_URI'] just as $uri in terminal
                 // $evalProvider->addSharedVarReference('post', $_POST);
                 $connector->startEvalRequestsListener();
             }
         }
         PhpConsole\Helper::register();
     }
 }
Exemplo n.º 2
0
 public function _init()
 {
     if (is_null($this->_handler)) {
         $this->_key = Mage::getStoreConfig('general/store_information/name');
         $this->_handler = PhpConsole\Handler::getInstance();
         $this->_handler->start();
         $this->_handler->getConnector()->setSourcesBasePath($_SERVER['DOCUMENT_ROOT']);
         // so files paths on client will be shorter (optional)
         $this->_handler->getConnector()->getDebugDispatcher()->setDumper(new PhpConsole\Dumper(20, 1000, 1000));
     }
 }
Exemplo n.º 3
0
 /**
  * PHPConsoleを初期化、登録
  * 
  * @return void
  */
 public function __construct()
 {
     $this->C = appConfigure::get();
     if ($this->C['PRODUCTION_RUN']) {
         Console::$debugMode = 'false';
     } else {
         Console::$debugMode = 'true';
         $APP_ROOT = dirname(__DIR__);
         $logFile = $APP_ROOT . '/var/log/trace.log';
         $oldMask = umask(0);
         @chmod($logFile, 0777);
         umask($oldMask);
         Logger::configure(array('rootLogger' => array('appenders' => array('default')), 'appenders' => array('default' => array('class' => 'LoggerAppenderFile', 'layout' => array('class' => 'LoggerLayoutPattern', 'params' => array('conversionPattern' => '%date [%logger] %message%newline')), 'params' => array('file' => $logFile, 'append' => true)))));
         global $LOGGER;
         $LOGGER = Logger::getLogger("log");
         if (php_sapi_name() != 'cli') {
             global $handler;
             $handler = PhpConsole\Handler::getInstance();
             $handler->start();
             // start handling PHP errors & exceptions
             $handler->getConnector()->setSourcesBasePath($_SERVER['DOCUMENT_ROOT']);
         }
     }
 }
Exemplo n.º 4
0
<?php

define('DEBUG_GAFA', true);
require_once dirname(__FILE__) . "/fragmentos/access_gafa.php";
require_once dirname(__FILE__) . "/fragmentos/etiquetas_og.php";
if (DEBUG_GAFA) {
    /*PHP CONSOLE*/
    require_once 'php-console/src/PhpConsole/__autoload.php';
    $handler = PhpConsole\Handler::getInstance();
    $handler->start();
}
function gafa($var, $tags = null)
{
    PhpConsole\Connector::getInstance()->getDebugDispatcher()->dispatchDebug($var, $tags, 1);
}
if (is_admin()) {
    function custom_colors()
    {
        require_once "admin/css/style.php";
    }
    add_action('admin_head', 'custom_colors');
}
Exemplo n.º 5
0
<?php

/**
 * There is example of creating PHAR archive of PhpConsole
 * So now it can be included in your project just like: require_once('phar://path/to/PhpConsole.phar')
 *
 * @see https://github.com/barbushin/php-console
 * @author Barbushin Sergey http://linkedin.com/in/barbushin
 */
define('PHP_CONSOLE_DIR', __DIR__ . '/../../src/PhpConsole');
define('PHP_CONSOLE_PHAR_FILEPATH', __DIR__ . '/../PhpConsole.phar');
require_once PHP_CONSOLE_DIR . '/__autoload.php';
PhpConsole\Handler::getInstance()->start();
if (isset($_GET['download'])) {
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename="PhpConsole.phar"');
    readfile(PHP_CONSOLE_PHAR_FILEPATH);
    exit;
}
if (!Phar::canWrite()) {
    throw new Exception('Unable to create PHAR archive, must be phar.readonly=Off option in php.ini');
}
if (!is_writable(dirname(PHP_CONSOLE_PHAR_FILEPATH))) {
    throw new Exception('Directory ' . dirname(PHP_CONSOLE_PHAR_FILEPATH) . ' must be writable');
}
if (file_exists(PHP_CONSOLE_PHAR_FILEPATH)) {
    unlink(PHP_CONSOLE_PHAR_FILEPATH);
}
$phar = new Phar(PHP_CONSOLE_PHAR_FILEPATH);
$phar = $phar->convertToExecutable(Phar::PHAR);
$phar->startBuffering();
Exemplo n.º 6
0
 /**
  * Initialize PHP Console.
  *
  * @since   1.0.0
  */
 public function init()
 {
     if (!class_exists('PhpConsole\\Connector')) {
         return;
     }
     $options = $this->options;
     $password = isset($options['password']) ? $options['password'] : '';
     // Display admin notice and abort if no password
     if (!$password) {
         add_action('admin_notices', array($this, 'password_notice'));
         return;
         // abort
     }
     // Selectively remove slashes added by WordPress as expected by PhpConsole
     if (isset($_POST[PhpConsole\Connector::POST_VAR_NAME])) {
         $_POST[PhpConsole\Connector::POST_VAR_NAME] = stripslashes_deep($_POST[PhpConsole\Connector::POST_VAR_NAME]);
     }
     $connector = PhpConsole\Connector::getInstance();
     $connector->setPassword($password);
     $handler = PhpConsole\Handler::getInstance();
     if (PhpConsole\Handler::getInstance()->isStarted() != true) {
         $handler->start();
     }
     $enableSslOnlyMode = isset($options['ssl']) ? !empty($options['ssl']) ? $options['ssl'] : '' : '';
     if ($enableSslOnlyMode == true) {
         $connector->enableSslOnlyMode();
     }
     $allowedIpMasks = isset($options['ip']) ? !empty($options['ip']) ? explode(',', $options['ip']) : '' : '';
     if (is_array($allowedIpMasks) && !empty($allowedIpMasks)) {
         $connector->setAllowedIpMasks((array) $allowedIpMasks);
     }
     $evalProvider = $connector->getEvalDispatcher()->getEvalProvider();
     $evalProvider->addSharedVar('uri', $_SERVER['REQUEST_URI']);
     $evalProvider->addSharedVarReference('post', $_POST);
     // $evalProvider->disableFileAccessByOpenBaseDir();
     $openBaseDirs = array(ABSPATH, get_template_directory());
     $evalProvider->addSharedVarReference('dirs', $openBaseDirs);
     $evalProvider->setOpenBaseDirs($openBaseDirs);
     $connector->startEvalRequestsListener();
 }
Exemplo n.º 7
0
 /**
  * 仅在开发时开启
  *
  * @throws Exception
  */
 public function _initDebug()
 {
     $handler = PhpConsole\Handler::getInstance();
     $handler->start();
     $connector = PhpConsole\Connector::getInstance();
     $connector->setPassword('933271');
     // Configure eval provider
     $evalProvider = $connector->getEvalDispatcher()->getEvalProvider();
     $evalProvider->addSharedVar('post', $_POST);
     // so "return $post" code will return $_POST
     $evalProvider->setOpenBaseDirs(array(__DIR__));
     // see http://php.net/open-basedir
     $connector->startEvalRequestsListener();
     // must be called in the end of all configurations
 }