* For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ //namespace Yare; if (defined('WP_DEBUG') and WP_DEBUG) { $password = Yare::config('theme.debug.password'); if (!$password) { return; } $connector = \PhpConsole\Helper::register(); if ($connector->isActiveClient()) { // Apply 'stack' option to PHP Console. //if ( true === $this->options['stack'] ) { //} // Init errors & exceptions handler $handler = \PC::getHandler(); /* You can override default Handler behavior: $handler->setHandleErrors(false); // disable errors handling $handler->setHandleExceptions(false); // disable exceptions handling $handler->setCallOldHandlers(false); // disable passing errors & exceptions to prviously defined handlers */ $handler->start(); // start handling PHP errors & exceptions if (Yare::config('theme.debug.stack')) { $connector->getDebugDispatcher()->detectTraceAndSource = true; $connector->setSourcesBasePath($_SERVER['DOCUMENT_ROOT']); // so files paths on client will be shorter (optional) } //var_dump($_SERVER['DOCUMENT_ROOT']); $connector->setPassword($password); // protect access by password
<?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; });