/** * Initialize ZFDebug plugin * */ public function initDebugPlugin() { if (!$this->_init && $this->getEnabled()) { $this->_init = true; $options = $this->getParams(); if (isset($options['ladenka']) and $options['ladenka'] == true) { require_once 'Nette/Debug.php'; Debug::enable(); } $plugins = array('plugins' => array('Variables', 'File' => array('base_path' => realpath(APP_PATH . "/../"), 'library' => array('Unodor', 'Nette')), 'Html', 'Exception', 'Time')); if ($this->getBootstrap()->hasPluginResource('CacheManager')) { $manager = $this->getBootstrap()->getResource('CacheManager'); $dbCache = $manager->getCache('database'); $dbTranslate = $manager->getCache('translate'); $plugins['plugins']['Cache']['backend'] = $manager->getCaches(); } if ($this->getBootstrap()->hasPluginResource('db')) { $plugins['plugins']['Database']['adapter'] = array(); //$plugins['plugins']['Database']['explain'] = true; } $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->registerNamespace('ZFDebug_'); $this->getBootstrap()->bootstrap('frontController'); $debug = new ZFDebug_Controller_Plugin_Debug($plugins); $frontController = $this->getBootstrap()->getResource('frontController'); $frontController->registerPlugin($debug); } }
/** * @param null $mode * @return null */ public static function DebugMode($mode = null) { if ($mode !== null) { self::$debug_mode = $mode; Debug::enable($mode); } return self::$debug_mode; }
/** * Pokud je v Cofigu zapnuty debub mode zapne ladenku. * * @return Bobr_Bobr */ private function debug() { $config = new Config(); if (TRUE === $config->debugMode) { Debug::enable(E_ALL | E_STRICT | E_NOTICE, FALSE); ini_set('xdebug.extended_info', 0); ini_set('xdebug.auto_trace', 1); ini_set('xdebug.trace_output_dir', '/local/xdebug/'); ini_set('xdebug.collect_includes', 1); ini_set('xdebug.profiler_enable', 1); ini_set('xdebug.collect_params', 4); ini_set('xdebug.show_mem_delta', 'On'); //xdebug_start_trace(); } return $this; }
function run() { $module = ($result = explode('/', Request::get('module'))) && sizeof($result) > 1 ? $result[sizeof($result) - 1] : Request::get('module'); $this->smarty->setTemplateDir(APP_DIR . DS . App::getAppName() . DS . APP_TEMPLATES_DIR . DS . Request::get('module') . DS); if (sizeof($result) > 0) { $this->smarty->addTemplateDir(APP_DIR . DS . App::getAppName() . DS . APP_THEMES . DS . APP_DEFAULT_THEME . DS . $result[0] . DS); } $this->smarty->addTemplateDir(APP_DIR . DS . App::getAppName() . DS . APP_THEMES . DS . APP_DEFAULT_THEME . DS . Request::get('module') . DS); $this->smarty->addTemplateDir(APP_DIR . DS . App::getAppName() . DS . APP_THEMES . DS . APP_DEFAULT_THEME . DS . Request::get('app_theme') . DS); $this->smarty->addTemplateDir(APP_DIR . DS . 'core' . DS . APP_THEMES . DS . APP_DEFAULT_THEME . DS . Request::get('app_theme') . DS); // Fix it: defaul Backend themes $this->template = App::getAppName() . strtoupper(substr($module, 0, 1)) . substr($module, 1) . strtoupper(substr(Request::get('action'), 0, 1)) . substr(Request::get('action'), 1); $this->smarty->assign('frame', true); Request::get('dataType', 'html'); $this->execute(); $template_extention = isset($this->extention) ? $this->extention : 'html'; if (isset($this->frame) && !$this->frame) { $this->smarty->display($this->template . '.' . $template_extention); return true; } $this->smarty->assign('main_template', $this->template . '.' . $template_extention); $this->smarty->display('index.html'); Debug::enable(); }
* You should have received a copy of the GNU Affero General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ define('SB_DEVELOPMENT', true); // Change the "false" to "true" to perform logging on basic level in production // software. define('SB_DEBUGGING', SB_DEVELOPMENT || false); // Please note that the http server must have rights to write to the file // specified bellow. You may change the log file path here. define('SB_SHOW_PHP_ERRORS', SB_DEBUGGING); define('SB_LOG_HTTP', SB_DEBUGGING && false); define('SB_LOG_SQL', SB_DEBUGGING && true); if (SB_SHOW_PHP_ERRORS) { require_once './lib/Nette/Debug.php'; // enable Nette\Debug Debug::enable(NULL, ini_get('error_log')); error_reporting(E_ALL | E_STRICT); // We want to see all errors, regardless of php.ini } // This should be a static class variable, if PHP 4 were OO language :-) $SB_errorHandler__errorCount = 0; $SB_errorHandler__warnCount = 0; $SB_errorHandler__messages = array(); $SB_errorHandler__phpHandlerUsed = 0; $SB_errorHandler__phpHandlerSet = 0; $SB_errorHandler__ignoreWarnings = 0; function SB_safeVal(&$ascArr, $field, $default = null) { if (isset($ascArr[$field])) { return $ascArr[$field]; }
Environment::setName($name); } //$config = Environment::loadConfig(); $config = MultiConfig::load(); //$loader = new RobotLoader(); //$loader->autoRebuild = true; // pokud nenajdu třídu, mám se znovusestavit? //dump($loader); //die(); // debug only //Environment::setMode(Environment::PRODUCTION, 1 ); // Step 2: Configure environment // 2a) enable Debug for better exception and error visualisation Debug::$strictMode = TRUE; // determines whether to consider all errors as fatal // todo: v novsej verzii sa predava uz iba adresar, nie nazov suboru Debug::enable('213.215.67.27, 127.0.0.1', Environment::getVariable('logDir') . '/err.log', '*****@*****.**'); //Debug::enable(false, Environment::getVariable('logDir') . '/err.log', '*****@*****.**'); // always dev mode //Debug::enable('213.215.67.27', Environment::getVariable('logDir') . '/err.log', '*****@*****.**'); //Debug::enable('213.215.67.27, 127.0.0.1', Environment::getVariable('logDir') . '/err.log', '*****@*****.**'); //dump(Debug::$productionMode); //Environment::setMode(Environment::PRODUCTION, true); //Environment::setMode(Environment::PRODUCTION, true); //Environment::setMode(Environment::DEVELOPMENT, false); // 2b) load configuration from config.ini file //require LIBS_DIR . '/Custom/MultipleConfigurator.php'; //Environment::setConfigurator(new MultipleConfigurator()); //$config = Environment::loadConfig(); // 2c) check if cache, sessions and log directories are writable if (@file_put_contents(Environment::expand('%tempDir%/_check'), '') === FALSE) { throw new Exception("Make directory '" . Environment::getVariable('tempDir') . "' writable!"); }
/** Parses the GET parameter. @return null. **/ function parsArgs() { if (isset($_GET['host']) && !empty($_GET['host'])) { define("HOST", $_GET["host"]); } else { returnData('Hostname is missing!', 1, 'Hostname is missing!'); } if (isset($_GET['service']) && !empty($_GET['service'])) { define("SERVICE", $_GET["service"]); } else { define("SERVICE", ""); } if (isset($_GET['debug'])) { Debug::enable(); } if (isset($_GET['height']) && !empty($_GET['height'])) { define("HEIGHT", $_GET["height"]); } else { define("HEIGHT", "400px"); } if (isset($_GET['legend']) && !empty($_GET['legend'])) { if ($_GET["legend"] == "true") { define("LEGEND_SHOW", true); } else { define("LEGEND_SHOW", false); } } else { define("LEGEND_SHOW", true); } }
public static function enable() { self::$enable = true; }
static function setEnable($bool) { self::setBufferID(); self::$enable = $bool; }
/** Expects a filename and parses the file, to return a rule and a dashbord lambda. @param string $file Path to file. @return array. **/ public static function parseSimpleTemplate($file) { $lines = file($file, FILE_SKIP_EMPTY_LINES); $foundJson = false; $ruleHits = array(); $dashboard = ""; foreach ($lines as $line) { if (substr($line, 1) == "#") { //Comment found continue; } if ($foundJson) { $dashboard .= $line; } else { if (sizeof($ruleHits) != 4) { //Searching for Ruleset foreach (array('host', 'service', 'command', 'perfLabel') as $type) { if (preg_match(";^\\s*{$type}\\s*=\\s*(.*?)\$;", $line, $hit)) { if ($type == 'perfLabel') { $ruleHits[$type] = str_getcsv($hit[1]); foreach ($ruleHits[$type] as &$label) { $label = trim($label); } } else { $ruleHits[$type] = trim($hit[1]); } } } } if (preg_match(";^\\s*{;", $line)) { //Found dashboard beginning $foundJson = true; $dashboard .= $line; } } } $rule = new Rule($ruleHits['host'], $ruleHits['service'], $ruleHits['command'], $ruleHits['perfLabel']); $genTemplate = function ($perfData) use($dashboard) { $tablenameRegex = ";(.*\\\\?\\\"+)(.*?)&(.*?)&(.*?)&(.*?)&(.*?)(.*);"; if (preg_match($tablenameRegex, $dashboard, $hits)) { $tempPerfData = array('host' => $hits[2], 'service' => $hits[3], 'command' => $hits[4]); $dashboard = preg_replace($tablenameRegex, sprintf("\$1%s&%s&%s&\$5&\$6\$7", $perfData['host'], $perfData['service'], $perfData['command']), $dashboard); $tempPerfDataSize = sizeof($tempPerfData); $tempPerfDataKeys = array_keys($tempPerfData); for ($i = 0; $i < $tempPerfDataSize; $i++) { if ($tempPerfData[$tempPerfDataKeys[$i]] != $tempPerfData[$tempPerfDataKeys[($i + 1) % $tempPerfDataSize]] && $tempPerfData[$tempPerfDataKeys[$i]] != $tempPerfData[$tempPerfDataKeys[($i + 2) % $tempPerfDataSize]]) { $dashboard = str_replace($tempPerfData[$tempPerfDataKeys[$i]], $perfData[$tempPerfDataKeys[$i]], $dashboard); } } } else { //regex does not work } if (!static::isStringValidJson($dashboard)) { Debug::enable(); return Debug::errorMarkdownDashboard('#The Template given was not valid json!'); } else { return $dashboard; } }; return array($rule, $genTemplate); }
} foreach (require Environment::expand('%adminLoginFile%') as $k => $v) { define('ADMIN_' . strtoupper($k), $v); } foreach (require Environment::expand('%commonFile%') as $k => $v) { Environment::setVariable($k, $v); } if (!function_exists('date_default_timezone_set')) { function date_default_timezone_set($timezone) { ini_set('date.timezone', $timezone); } } date_default_timezone_set(require Environment::expand('%timezoneFile%')); // debugging Debug::enable(NULL, BASE_DIR . '/error.log', Environment::expand('%adminEmail%')); // paths Environment::setVariable('themeDir', Environment::expand('%baseDir%/themes')); Environment::setVariable('templatesDir', Environment::expand('%themeDir%/%theme%')); Environment::setVariable('tempDir', Environment::expand('%baseDir%/tmp')); Environment::setVariable('themeBaseUri', Environment::expand('%baseUri%/themes/%theme%')); Environment::setVariable('mediaDir', Environment::expand('%baseDir%/media')); Environment::setVariable('mediaBaseUri', Environment::expand('%baseUri%/media')); set_include_path(LIB_DIR . PATH_SEPARATOR . get_include_path()); Html::$xhtml = FALSE; SafeStream::register(); setlocale(LC_ALL, require Environment::expand('%localeFile%')); Zend_Search_Lucene::setDefaultSearchField('description'); // configure locale require_once LIB_DIR . '/tr.php'; $available = array();
<?php require LIBS_DIR . '/Nette/loader.php'; require LIBS_DIR . '/debug.php'; Debug::enable(Debug::DEVELOPMENT, APP_DIR . 'log/log.txt'); Debug::enableProfiler(); Environment::loadConfig(); $application = Environment::getApplication(); $router = $application->getRouter(); $router[] = new Route('index.php', array('module' => 'Default', 'presenter' => 'Default', 'action' => 'default'), Route::ONE_WAY); $router[] = new Route('<module student|teacher|admin|default>/<presenter>/<action>/<id>', array('presenter' => 'Default', 'action' => 'default', 'id' => NULL)); $router[] = new Route('<module>', array('module' => 'Default', 'presenter' => 'Default', 'action' => 'default', 'id' => NULL)); $application->errorPresenter = 'Error'; $application->catchExceptions = FALSE; db::connect(); $application->run();
{ echo "\nSending mail with message '{$message}'\n"; echo "\nFiles:\n"; global $errorLog; foreach (glob(dirname($errorLog) . '/*') as $file) { echo "{$file}:\n"; echo "----------------\n"; echo file_get_contents($file); echo "\n----------------\n\n"; } } $errorLog = dirname(__FILE__) . '/log/php_error.log'; foreach (glob(dirname($errorLog) . '/*') as $file) { unlink($file); } // delete all files Debug::enable(Debug::PRODUCTION, $errorLog, '*****@*****.**'); function first($arg1, $arg2) { second(TRUE, FALSE); } function second($arg1, $arg2) { third(array(1, 2, 3)); } function third($arg1) { //missing(); trigger_error('Error generated by trigger_error', E_USER_ERROR); } first(10, 'any string');
<?php /** * Nette TreeView example bootstrap file. * * @copyright Copyright (c) 2010 Roman Novák * @package nette-treeview */ // Step 1: Load Nette Framework // this allows load Nette Framework classes automatically so that // you don't have to litter your code with 'require' statements require LIBS_DIR . '/Nette/loader.php'; // Step 2: Configure environment // 2a) enable Nette\Debug for better exception and error visualisation Debug::enable(false); Debug::enableProfiler(); // 2b) load configuration from config.ini file Environment::loadConfig(); Environment::getSession()->start(); dibi::connect(Environment::getConfig('database')); // Step 3: Configure application // 3a) get and setup a front controller $application = Environment::getApplication(); //$application->errorPresenter = 'Error'; $application->catchExceptions = false; // Step 4: Setup application router $router = $application->getRouter(); $router[] = new Route('index.php', array('presenter' => 'Homepage', 'action' => 'default'), Route::ONE_WAY); $router[] = new Route('<presenter>/<action>/<id>', array('presenter' => 'Homepage', 'action' => 'default', 'id' => NULL)); // Step 5: Run the application! $application->run();
require_once LIBS_DIR . '/Nette/loader.php'; // Step 2: Configure environment /** 2a) load configuration from config.ini file */ Environment::setName(Environment::DEVELOPMENT); $config = Environment::loadConfig(); /** 2b) check if needed directories are writable */ if (!is_writable(Environment::getVariable('tempDir'))) { die("Make directory '" . realpath(Environment::getVariable('tempDir')) . "' writable!"); } if (!is_writable(Environment::getVariable('logDir'))) { die("Make directory '" . realpath(Environment::getVariable('logDir')) . "' writable!"); } /** 2c) Setup Nette\Debug for better exception and error visualisation */ //Debug::$productionMode = $_SERVER['REMOTE_ADDR'] !== '127.0.0.1'; // admin's computer IP $mode = !Environment::isProduction() && !Environment::getHttpRequest()->isAjax() ? Debug::DEVELOPMENT : Debug::PRODUCTION; Debug::enable($mode, NULL); Debug::$strictMode = TRUE; Debug::$showLocation = TRUE; /** 2d) enable RobotLoader - this allows load all classes automatically */ $loader = new RobotLoader(); $loader->addDirectory(explode(';', $config->scanDirs)); $loader->autoRebuild = Environment::isProduction() ? FALSE : TRUE; // rebuild if class is not found? $loader->register(); /** 2e) load extension methods */ if (is_file(APP_DIR . '/extensions.php')) { include_once APP_DIR . '/extensions.php'; } /** 2f) enable DebugBar */ if ($mode == Debug::DEVELOPMENT) { Debug::$showBar = TRUE;
<?php namespace Components; Log::push(new Log_Appender_Syslog(COMPONENTS_APP_CODE)); if (Environment::isDev()) { Runtime::addManagementIp(Runtime::getClientAddress()); } if (isset($_REQUEST['debug']) || Environment::isDev()) { if (isset($_REQUEST['debug'])) { $debug = (int) $_REQUEST['debug']; } else { $debug = Debug::INFO; } if (0 < $debug) { Debug::activate(); } Debug::verbosity($debug); Debug::appender(Debug::INFO, new Debug_Appender_Console()); Debug::enable(Debug::MARKUP); }
public function __construct($filePath) { Debug::enable($filePath); }
<h1>Nette\Forms invalid HTTP data test</h1> <?php require_once '../../Nette/loader.php'; /*use Nette\ComponentContainer;*/ /*use Nette\Forms\Form;*/ /*use Nette\Forms\TextInput;*/ /*use Nette\Forms\FormContainer;*/ /*use Nette\Environment;*/ /*use Nette\Debug;*/ Debug::enable(); $countries = array('Select your country', 'Europe' => array(1 => 'Czech Republic', 2 => 'Slovakia'), 3 => 'USA', 4 => 'other'); $sex = array('m' => 'male', 'f' => 'female'); $form = new Form(); $form->addText('name', 'Your name:', 35); // item name, label, size, maxlength $form->addTextArea('note', 'Comment:', 30, 5); $form->addRadioList('gender', 'Your gender:', $sex); $form->addCheckbox('send', 'Ship to address'); $form->addSelect('country', 'Country:', $countries)->skipFirst(); $form->addMultiSelect('countrym', 'Country:', $countries); $form->addPassword('password', 'Choose password:'******'avatar', 'Picture:'); $form->addHidden('userid'); $sub = $form->addContainer('firstperson'); $sub->addText('age', 'Your age:', 5); $sub = $form->addContainer('secondperson'); $sub->addText('age', 'Your age:', 5); $sub->addFile('avatar', 'Picture:'); $form->addSubmit('submit1', 'Send'); $_SERVER['REQUEST_METHOD'] = 'POST';
function setEnable($bool) { self::$enable = $bool; }