/** * 开启调试输出 * @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(); } }
/** * Construct. * * @since 1.0.0 */ public function __construct() { $this->plugin_name = 'wp-php-console'; $this->version = '1.3.3'; $this->options = get_option('wp_php_console'); // Perform PHP Console initialisation required asap for other code to be able to output to the JavaScript console $connector = PhpConsole\Connector::getInstance(); // Apply 'register' option to PHP Console if (!empty($this->options['register'])) { if (!class_exists('PC', false)) { // only if PC not registered yet PhpConsole\Helper::register(); } // PC::debug( 'PC::debug() is available'); } // Apply 'stack' option to PHP Console if (!empty($this->options['stack'])) { $connector->getDebugDispatcher()->detectTraceAndSource = true; } // Apply 'short' option to PHP Console if (!empty($this->options['short'])) { $connector->setSourcesBasePath($_SERVER['DOCUMENT_ROOT']); } // Initialise WordPress actions // Translation add_action('plugins_loaded', array($this, 'set_locale')); // Admin menu add_action('admin_menu', array($this, 'register_settings_page')); // Delay further PHP Console initialisation to have more context during Remote PHP execution add_action('wp_loaded', array($this, 'init')); }
<?php require __DIR__ . '/vendor/autoload.php'; // require_once('phar:///home/ubuntu/workspace/Modulo3/PhpConsole.phar'); // autoload will be initialized automatically require_once 'phar://PhpConsole.phar'; // autoload will be initialized automatically $connector = PhpConsole\Connector::getInstance(); $handler = PhpConsole\Handler::getInstance(); $handler->start(); // $handler->debug('called from handler debug', 'some.three.tags'); PhpConsole\Helper::register(); // para PC::db y PC::debug // PC::db((new Tidy)->getConfig(), "Tidy"); function myInit($f, $title = "") { // calling file, optional title if ($title == "") { $title = basename($f); } echo ' <DOCTYPE html> <html lang="es"> <head> <meta charset="UTF-8"> <title>' . $title . '</title> </head> <body> '; echo "<h3><a href=" . basename($f) . ">{$f}</a></h3>"; PC::db('Entering ' . $f); if ($_GET) {
<?php require_once __DIR__ . '/../../src/PhpConsole/__autoload.php'; $password = null; if (!$password) { die('Please set $password variable value in ' . __FILE__); } $connector = PhpConsole\Helper::register(); if ($connector->isActiveClient()) { // Init errors & exceptions handler $handler = PC::getHandler(); $handler->start(); // start handling PHP errors & exceptions $connector->setSourcesBasePath($_SERVER['DOCUMENT_ROOT']); // so files paths on client will be shorter (optional) $connector->setPassword($password); // protect access by password // $connector->enableSslOnlyMode(); // PHP Console clients will be always redirected to HTTPS // $connector->setAllowedIpMasks(array('192.168.*.*')); // Enable eval provider $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); /* $evalProvider->setOpenBaseDirs(array(__DIR__)); // set directories limited for include(), require(), file_get_contents() & etc $evalProvider->addCodeHandler(function(&$code) { // modify or validate code before execution $code = 'return '. $code; });