public function getResources() { if ($this->resources === null) { $this->resources = array('Memory' => memory_get_usage(true) / 1024 . ' KB', 'Time' => $this->formatTime(microtime(true) - DebugBar::getInit()) . ' ms', 'Files' => count(get_included_files())); } return $this->resources; }
/** * Outputs gathered data to make Profiler * * @return html? */ public function outputData() { // Check if profiler config file is present if (\Config::get('profiler::profiler')) { // Sort the view data alphabetically ksort($this->view_data); $this->time->totalTime(); $data = array('times' => $this->time->getTimes(), 'view_data' => $this->view_data, 'app_logs' => $this->logs, 'includedFiles' => get_included_files(), 'counts' => $this->getCounts(), 'assetPath' => __DIR__ . '/../../../public/'); // Check if SQL connection can be established try { $data['sql_log'] = \DB::getQueryLog(); } catch (\PDOException $exception) { $data['sql_log'] = array(); } // Check if btns.storage config option is set if (\Config::get('profiler::btns.storage')) { // get last 24 webserver log entries $data['storageLogs'] = $this->getStorageLogs(24); } // Check if btns.config config option is set if (\Config::get('profiler::btns.config')) { // get all Laravel config options and store in array $data['config'] = array_dot(\Config::getItems()); } return \View::make('profiler::profiler.core', $data); } }
/** * gather included files and its size. */ private function gatherFiles() { if (!array_key_exists('Files', $this->log_sections)) { return; } $files = get_included_files(); $section_data_array = array(); $total_size = 0; $largest_size = 0; if (is_array($files)) { foreach ($files as $file) { $size = filesize($file); $section_data_array[] = array('data' => $file, 'size' => $size); $total_size = bcadd($total_size, $size); if ($size > $largest_size) { $largest_size = $size; } } // endforeach; unset($file, $size); } $section_data_array['total_size'] = $total_size; $section_data_array['largest_size'] = $largest_size; unset($largest_size, $total_size); $this->log_sections['Files'] = $section_data_array; unset($files, $section_data_array); }
/** * 日志写入接口 * @access public * @param array $log 日志信息 * @return void */ public function save($log = []) { $now = date($this->config['time_format']); $destination = $this->config['path'] . date('y_m_d') . '.log'; !is_dir($this->config['path']) && mkdir($this->config['path'], 0755, true); //检测日志文件大小,超过配置大小则备份日志文件重新生成 if (is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) { rename($destination, dirname($destination) . DS . time() . '-' . basename($destination)); } // 获取基本信息 if (isset($_SERVER['HTTP_HOST'])) { $current_uri = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; } else { $current_uri = "cmd:" . implode(' ', $_SERVER['argv']); } $runtime = number_format(microtime(true) - START_TIME, 6); $reqs = number_format(1 / $runtime, 2); $time_str = " [运行时间:{$runtime}s] [吞吐率:{$reqs}req/s]"; $memory_use = number_format((memory_get_usage() - START_MEM) / 1024, 2); $memory_str = " [内存消耗:{$memory_use}kb]"; $file_load = " [文件加载:" . count(get_included_files()) . "]"; array_unshift($log, ['type' => 'log', 'msg' => $current_uri . $time_str . $memory_str . $file_load]); $info = ''; foreach ($log as $line) { $info .= '[' . $line['type'] . '] ' . $line['msg'] . "\r\n"; } error_log("[{$now}] {$_SERVER['SERVER_ADDR']} {$_SERVER['REMOTE_ADDR']} {$_SERVER['REQUEST_URI']}\r\n{$info}\r\n", 3, $destination); }
protected function onShutdown() { // TODO: Allow client to switch this off $files = get_included_files(); // exclude our own files $excluding = false; for ($i = 0; $i < count($files); $i++) { // TODO: Make this more reliable if (preg_match("/\\/FirePHP\\//", $files[$i]) || preg_match("/\\/FirePHPCore\\//", $files[$i]) || preg_match("/\\/Insight\\//", $files[$i]) || preg_match("/\\/Wildfire\\//", $files[$i]) || preg_match("/\\/Zend\\//", $files[$i])) { // potentially exclude $exclude = false; // start excluding when if (preg_match("/\\/FirePHP\\/Init.php\$/", $files[$i])) { $excluding = true; } else { // stop excluding after if (preg_match("/\\/Wildfire\\/Protocol\\/Component.php\$/", $files[$i]) || -preg_match("/\\/Insight\\/Encoder\\/Default.php\$/", $files[$i]) || preg_match("/\\/Zend\\/Reflection\\/Class.php\$/", $files[$i]) || preg_match("/\\/Zend\\/Reflection\\/Property.php\$/", $files[$i]) || preg_match("/\\/Zend\\/Reflection\\/Method.php\$/", $files[$i]) || preg_match("/\\/Zend\\/Reflection\\/Docblock.php\$/", $files[$i]) || preg_match("/\\/Zend\\/Reflection\\/Docblock\\/Tag.php\$/", $files[$i]) || preg_match("/\\/Zend\\/Loader.php\$/", $files[$i]) || preg_match("/\\/Zend\\/Reflection\\/Parameter.php\$/", $files[$i])) { $excluding = false; $exclude = true; } else { // always exclude if (preg_match("/\\/FirePHP\\//", $files[$i]) || preg_match("/\\/FirePHPCore\\//", $files[$i]) || preg_match("/\\/Insight\\//", $files[$i]) || preg_match("/\\/Wildfire\\//", $files[$i])) { $exclude = true; } } } if ($excluding || $exclude) { array_splice($files, $i, 1); $i--; } } } Insight_Helper::to('request')->files()->loaded($files); }
public function testLoadingOnlyPhpFiles() { $this->builder->setSource($this->files->get($this, '/no-parents')); $this->builder->setDestination($this->files->get($this, '/settings')); $this->builder->build('default'); self::assertFalse(in_array($this->files->get($this, '/no-parents/default/ignored.file'), get_included_files())); }
public function display() { $profiler = KFactory::get('com://admin/debug.profiler.events'); $database = KFactory::get('com://admin/debug.profiler.queries'); $language = KFactory::get('joomla:language'); //Remove the template includes $includes = get_included_files(); foreach($includes as $key => $value) { if($value == 'tmpl://koowa.template.stack') { unset($includes[$key]); } } $this->assign('memory' , $profiler->getMemory()) ->assign('events' , $profiler->getEvents()) ->assign('queries' , $database->getQueries()) ->assign('languages', $language->getPaths()) ->assign('includes' , $includes) ->assign('strings' , $language->getOrphans()); return parent::display(); }
/** * checkJavaExtension * check if the java extension was loaded. * * * @return true or false */ function checkJavaExtension() { try { if (!extension_loaded('java')) { if (!@(include_once "java/Java.inc")) { $urlJavaInc = "http://{$this->JavaBridgeHost}:{$this->JavaBridgePort}/{$this->JavaBridgeDir}/java/Java.inc"; @(include_once $urlJavaInc); $includedFiles = get_included_files(); $found = false; foreach ($includedFiles as $filename) { if ($urlJavaInc == $filename) { $found = true; } } if (!$found) { throw new Exception('The PHP/Java Bridge is not defined'); } } return true; } if (!function_exists("java_get_server_name")) { throw new Exception('The loaded java extension is not the PHP/Java Bridge'); } return true; } catch (Exception $e) { throw new Exception('Error in checkJavaExtension: ' . $e->getMessage()); } }
static function show() { $trace_tmp = self::$trace; $files = get_included_files(); foreach ($files as $key => $file) { $files[$key] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )'; } $cltime = T('POEM_TIME', -1); $trace_tmp['SYS'] = array("请求信息" => $_SERVER['REQUEST_METHOD'] . ' ' . strip_tags($_SERVER['REQUEST_URI']) . ' ' . $_SERVER['SERVER_PROTOCOL'] . ' ' . date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']), "总吞吐量" => number_format(1 / $cltime, 2) . ' req/s', "总共时间" => number_format($cltime, 5) . ' s', "框架加载" => number_format($cltime - T('POEM_EXEC_TIME', -1), 5) . ' s (func:' . number_format(T('POEM_FUNC_TIME', -1) * 1000, 2) . 'ms conf:' . number_format(T('POEM_CONF_TIME', -1) * 1000, 2) . 'ms route:' . number_format(T('POEM_ROUTE_TIME', -1) * 1000, 2) . 'ms)', "App时间" => number_format(T('POEM_EXEC_TIME', -1), 5) . ' s (compile:' . number_format(T('POEM_COMPILE_TIME', -1) * 1000, 2) . ' ms)', "内存使用" => number_format(memory_get_usage() / 1024 / 1024, 5) . ' MB', '文件加载' => count($files), '会话信息' => 'SESSION_ID=' . session_id()); $trace_tmp['FILE'] = $files; $arr = array('SYS' => '基本', 'FILE' => '文件', 'ERR' => '错误', 'SQL' => '数据库', 'DEBUG' => '调试'); foreach ($arr as $key => $value) { $num = 50; $len = 0; if (is_array($trace_tmp[$key]) && ($len = count($trace_tmp[$key])) > $num) { $trace_tmp[$key] = array_slice($trace_tmp[$key], 0, $num); } $trace[$value] = $trace_tmp[$key]; if ($len > $num) { $trace[$value][] = "...... 共 {$len} 条"; } } $totalTime = number_format($cltime, 3); include CORE_PATH . 'tpl/trace.php'; }
/** * Load plugin files * * @return boolean Always true. */ function load($all = false) { global $plugins, $set; $files = glob(MAI_ROOT . "plugins/*_plugin.php"); // grab active plugins list if (!is_array(unserialize($set->sinfo->active_plugins))) { $set->sinfo->active_plugins = serialize(array()); } foreach ($files as $file) { // grab plugin name $pname = substr(basename($file), 0, -11); // require active plugins if ($all == false) { if (in_array($pname, unserialize($set->sinfo->active_plugins))) { require_once $file; } } else { if (!in_array(basename($file), array_map("basename", get_included_files()))) { require_once $file; } } } if ($all) { $this->hooks = array(); } // we don't execute on plugin manager return true; }
public function gatherFileData() { $files = array_filter(get_included_files(), create_function('$var', 'return (strpos($var, "pqp/classes") === false);')); $fileList = array(); $fileTotals = array("count" => count($files), "size" => 0, "largest" => 0, "newest" => 0); foreach ($files as $key => $file) { $size = filesize($file); $age = filemtime($file); //if($fileTotals["size"] == 2) //{ //$output = null; //exec("svn status --show-updates $file",$output); //Debugger::log("--------------------------------------------------------------"); //Debugger::log($output); //error_log("output: " . print_r($output,true)); //} $fileList[] = array('name' => $file, 'age' => $age, 'size' => $this->getReadableFileSize($size)); $fileTotals['size'] += $size; if ($size > $fileTotals['largest']) { $fileTotals['largest'] = $size; } if ($age > $fileTotals["newest"]) { $fileTotals["newest"] = $age; $fileTotals["newest-file"] = $file; } } usort($fileList, array($this, "fileCompare")); //$fileTotals["newest"] = $this->getReableFileSize($fileTotals["newest"]); $fileTotals['size'] = $this->getReadableFileSize($fileTotals['size']); $fileTotals['largest'] = $this->getReadableFileSize($fileTotals['largest']); $this->output['files'] = $fileList; $this->output['fileTotals'] = $fileTotals; }
/** * @return bool */ protected function loadCommonLib() { $ret = false; $errors = array(); if (!defined('ROKCOMMON_LIB_PATH')) { define('ROKCOMMON_LIB_PATH', JPATH_SITE . '/libraries/rokcommon'); } $rokcommon_inlcude_path = @realpath(ROKCOMMON_LIB_PATH . '/include.php'); if (file_exists($rokcommon_inlcude_path)) { if (!defined('ROKCOMMON_ERROR_MISSING_LIBS')) { define('ROKCOMMON_ERROR_MISSING_LIBS', true); } $included_files = get_included_files(); if (!in_array($rokcommon_inlcude_path, $included_files) && ($libret = (require_once $rokcommon_inlcude_path)) !== 'ROKCOMMON_LIB_INCLUDED') { if (!defined('ROKCOMMON_ERROR_MISSING_LIBS')) { define('ROKCOMMON_ERROR_MISSING_LIBS', true); } $errors = (array) $libret; } else { $ret = true; } } else { $errors[] = 'Unable to find the RokCommon library at ' . ROKCOMMON_LIB_PATH; } if (!empty($errors)) { $app = JFactory::getApplication(); if ($app->isAdmin()) { foreach ($errors as $error) { $app->enqueueMessage('RokCommon: ' . $error, 'warning'); } } } return $ret; }
static function checkpoint($name) { if (!defined('PROFILER')) { return false; } self::$checkpoints[$name] = array('time' => self::microtime(), 'memory' => memory_get_usage(), 'included_files' => count(get_included_files()), 'queries' => count(self::$queries)); }
public function output(Pagemill_Data $data, Pagemill_Stream $stream) { Typeframe::Timestamp('Starting debug output'); $debug = new Pagemill_Data(); $timestamps = Typeframe::GetTimestamps(); $tdata = array(); if ($timestamps) { $begin = $timestamps[0]->time(); foreach ($timestamps as $t) { //$dump .= "{$t->action()}: " . ($t->time() - $begin) . "<br/>"; $tdata[] = array('action' => $t->action(), 'time' => $t->time() - $begin); } } $debug['timestamps'] = $tdata; $debug['memory_used'] = memory_get_usage(); $debug['memory_used_real'] = memory_get_usage(true); $debug['includes'] = get_included_files(); $debug['querycount'] = Dbi_Source::QueryCount(); $debug['templates'] = Pagemill::ProcessedTemplates(); // TODO: Get template files $debug['data'] = $data; $this->_recurseTines($debug); $include = new Typeframe_Tag_Include('include', array('template' => '/pagemill/tag/debug.html')); $include->process($debug, $stream); }
function Element($templateFile, array $options) { global $config, $debug, $twig; if (!$twig) { load_twig(); } if (function_exists('create_pm_header') && (isset($options['mod']) && $options['mod'] || isset($options['__mod']))) { $options['pm'] = create_pm_header(); } if (isset($options['body']) && $config['debug']) { if (isset($debug['start'])) { $debug['time'] = '~' . round((microtime(true) - $debug['start']) * 1000, 2) . 'ms'; unset($debug['start']); } $debug['included'] = get_included_files(); $debug['memory'] = round(memory_get_usage(true) / (1024 * 1024), 2) . ' MiB'; $options['body'] .= '<h3>Debug</h3><pre style="white-space: pre-wrap;font-size: 10px;">' . str_replace("\n", '<br/>', utf8tohtml(print_r($debug, true))) . '</pre>'; } // Read the template file if (@file_get_contents("{$config['dir']['template']}/{$templateFile}")) { $body = $twig->render($templateFile, $options); if ($config['minify_html'] && preg_match('/\\.html$/', $templateFile)) { $body = trim(preg_replace("/[\t\r\n]/", '', $body)); } return $body; } else { throw new Exception("Template file '{$templateFile}' does not exist or is empty in '{$config['dir']['template']}'!"); } }
public function includePath($path, \closure $closure = null) { $errors = array(); $path = (string) $path; $errorHandler = set_error_handler(function ($error, $message, $file, $line, $context) use(&$errors) { $errors[] = func_get_args(); }); $closure = $closure ?: function ($path) { include_once $path; }; $closure($path); restore_error_handler(); if (sizeof($errors) > 0) { $realpath = parse_url($path, PHP_URL_SCHEME) !== null ? $path : realpath($path) ?: $path; if (in_array($realpath, get_included_files(), true) === false) { throw new includer\exception('Unable to include \'' . $path . '\''); } else { if ($errorHandler !== null) { foreach ($errors as $error) { call_user_func_array($errorHandler, $error); } } } } return $this; }
public function compile($name = null) { $name = $name ?: self::BASE_FILE_NAME; if (!($isCompiledExists = file_exists($location = $this->getLocation($name)))) { $includedFiles = get_included_files(); // Remove first 4 files (index, _init, Kalibri, Compiler ) $includedFiles = array_slice($includedFiles, 4); foreach ($includedFiles as $file) { if (in_array($file, $this->_skipped) || strpos($file, '/Helper/') !== false || strpos($file, '/Config/') !== false) { continue; } if ($name == self::NAME_BASE || $name == self::NAME_ROUTE && strpos($file, '_compiled.php') === false) { if (!$isCompiledExists) { file_put_contents($location, '<?php', FILE_APPEND); chmod($location, 0777); } $this->skip($file); // Drop comments, new lines and put content into "compiled" file exec("cat {$file} | php -w | sed 's/<?php//g' >> {$location}"); // file_put_contents( $location, str_replace( array('<?php', '<?', '? >'), '', file_get_contents( $file ) ), FILE_APPEND); $isCompiledExists = true; } } //file_put_contents( $this->getLocation( $name, true ), json_encode($this->_infos[ $name ]) ); } }
public static function display() { echo '<div style=" min-height:100%; position: fixed; background-color: #f7f7f7; background-image: -moz-linear-gradient(-90deg, #e4e4e4, #ffffff); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#e4e4e4), to(#ffffff)); top:30px; bottom: 0; left:0; margin:0; padding: 0; z-index: 6000000; width: 100%; font: 12px Verdana, Arial, sans-serif; text-align: left; color: #2f2f2f;"> <div style="display: block; background-color: #2F2F2F; padding: 8px 20px; position: fixed; top: 0; left:0; width: 100%; font: 11px Verdana, Arial, sans-serif; text-align: left; color: #EEEEEE;"> asdf </div>'; echo timeEnd(TIMESTART) / 1000; pr(get_included_files()); echo self::convertSize(memory_get_usage()); echo '</div> <div style="position: fixed; background-color: #f7f7f7; background-image: -moz-linear-gradient(-90deg, #e4e4e4, #ffffff); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#e4e4e4), to(#ffffff)); bottom: 0; left:0; margin:0; padding: 0; z-index: 6000000; width: 100%; border-top: 1px solid #bbb; font: 11px Verdana, Arial, sans-serif; text-align: left; color: #2f2f2f;"> <span style="white-space:nowrap; color:#2f2f2f; display:inline-block; min-height:24px; border-right:1px solid #cdcdcd; padding:8px 7px 1px 4px; "> Cute Profiler </span> <span style="white-space:nowrap; color:#2f2f2f; display:inline-block; min-height:24px; border-right:1px solid #cdcdcd; padding:8px 7px 1px 4px; "> <span><a href="#" style="color: #2f2f2f">PHP ' . phpversion() . '</a></span> <span style="margin: 0; padding: 0; color: #979696;">|</span> <span style="color: #a33">xdebug</span> <span style="margin: 0; padding: 0; color: #979696">|</span> <span style="color: #759e1a">accel</span> </span> <span style="display:block; position:absolute; top:10px; right:30px; width:14px; height:14px; cursor: pointer;"> close </span> </div>'; }
public function __destruct() { $included_files = get_included_files(); $file_msg = '文件加载[' . count($included_files) . ']' . print_r($included_files, true); $mem = $this->mem; $mem_end = memory_get_usage() / 1024; $mem_msg = PHP_EOL . '[内存消耗统计]'; $mem_msg .= PHP_EOL . '启动消耗内存:' . $mem['start'] . 'Kb'; $mem_msg .= PHP_EOL . '路由消耗内存:' . ($mem['dispatch'] - $mem['start']) . 'Kb'; $mem_msg .= PHP_EOL . '处理消耗内存:' . ($mem_end - $mem['dispatch']) . 'Kb'; $mem_msg .= PHP_EOL . '总共消耗内存:' . $mem_end . 'Kb'; $time = $this->time; $end = self::mtime(); $time_msg = '启动时间:' . $time['request']; $time_msg .= PHP_EOL . '结束时间:' . $end; $time_msg .= PHP_EOL . '框架启动耗时:' . ($time['routerstartup'] - $time['request']) . 'ms'; $time_msg .= PHP_EOL . '路由处理耗时:' . ($time['routershutdown'] - $time['routerstartup']) . 'ms'; $time_msg .= PHP_EOL . '分发准备耗时:' . ($time['dispatchloopstartup'] - $time['routershutdown']) . 'ms'; if (isset($time['dispatchloopshutdown'])) { $time_msg .= PHP_EOL . '处理过程耗时:' . ($time['dispatchloopshutdown'] - $time['dispatchloopstartup']) . 'ms'; $time_msg .= PHP_EOL . '输出关闭耗时:' . ($end - $time['dispatchloopshutdown']) . 'ms'; } else { $time_msg .= PHP_EOL . '处理过程耗时:' . ($end - $time['dispatchloopstartup']) . 'ms'; } $time_msg .= PHP_EOL . '总耗时:' . ($end - $time['request']) . 'ms'; Log::write($file_msg . $time_msg . $mem_msg . PHP_EOL, 'TRACER'); }
public function renderLoadedFiles($tableName) { $status = opcache_get_status(true); $loadedFiles = get_included_files(); $scriptInfo = array(); if (isset($status['scripts']) == false) { return "Failed to load scripts info to generate OPCache info."; } foreach ($loadedFiles as $loadedFile) { $newScriptInfo = array(); if (array_key_exists($loadedFile, $status['scripts']) == true) { $newScriptInfo["memory_consumption"] = $status['scripts'][$loadedFile]["memory_consumption"]; $newScriptInfo["hits"] = $status['scripts'][$loadedFile]["hits"]; } else { $newScriptInfo["memory_consumption"] = "-"; $newScriptInfo["hits"] = "-"; } $newScriptInfo['path'] = $loadedFile; if (mb_strpos($loadedFile, $this->root) === 0) { $newScriptInfo['path'] = '.' . mb_substr($loadedFile, mb_strlen($this->root)); } $scriptInfo[] = $newScriptInfo; } return $this->renderTable($tableName, $scriptInfo); }
function ak_get_application_included_files($source_for = '') { $app_files = array(); foreach (get_included_files() as $k => $file) { if (strstr($file, AK_FRAMEWORK_DIR)) { continue; } $short_path = str_replace(AK_BASE_DIR, '', $file); if (strstr($file, AK_MODELS_DIR)) { $app_files['Models'][$k]['path'] = $short_path; if ($file == $source_for) { $app_files['Models'][$k]['original_path'] = $file; } } elseif (strstr($file, AK_COMPILED_VIEWS_DIR)) { $path = Ak::first(explode('.tpl.', str_replace(array(AK_COMPILED_VIEWS_DIR, '/compiled'), '', $file))) . '.tpl'; if (!in_array($path, array('/app/views/exception.tpl', '/app/views/_trace.tpl'))) { $app_files['Views'][$k]['path'] = $path; if ($file == $source_for) { $app_files['Views'][$k]['original_path'] = $file; } } } elseif (strstr($file, AK_CONTROLLERS_DIR)) { $app_files['Controllers'][$k]['path'] = $short_path; if ($file == $source_for) { $app_files['Controllers'][$k]['original_path'] = $file; } } elseif (strstr($file, AK_HELPERS_DIR)) { $app_files['Helpers'][$k]['path'] = $short_path; if ($file == $source_for) { $app_files['Helpers'][$k]['original_path'] = $file; } } } return $app_files; }
private function run($arguments = []) { // var $module, $controller, $action, $basedir, $prefix; $module = $this->getRouter()->getParameter("module"); $controller = $this->getRouter()->getParameter("controller"); $action = $this->getRouter()->getParameter("action"); $basedir = $this->getRouter()->getParameter("basedir"); $prefix = $this->getRouter()->getParameter("prefix"); $namespaceName = $this->getRouter()->getControllerNamespace(); foreach ($this->getRouter()->getParameters() as $key => $parameter) { $namespaceName = str_replace(['<' . $key . '>', '/'], [$parameter, '\\'], $namespaceName); } $className = $controller . $this->getRouter()->getControllerSuffix(); $actionName = $action . $this->getRouter()->getActionSuffix(); $baseFolderName = $this->getRouter()->getControllerDir(); foreach ($this->getRouter()->getParameters() as $key => $parameter) { $baseFolderName = str_replace('<' . $key . '>', $parameter, $baseFolderName); } $fileName = $baseFolderName . "/" . $className . ".php"; $folderName = dirname($fileName); $callClassName = $namespaceName . "\\" . $className; if (!$arguments) { $arguments = $this->getRouter()->getArguments(); } $requireInfo = ['namespace' => $namespaceName, 'folder' => $folderName, 'file' => $fileName, 'class' => $className, 'method' => $actionName]; $fileName = stream_resolve_include_path($fileName); if (TRUE === file_exists($fileName) && TRUE === is_readable($fileName)) { if (FALSE === in_array($fileName, get_included_files())) { require $fileName; } if (FALSE === class_exists($callClassName, FALSE)) { return $this->forwardNotFound($this->getRouter()->getNotFound(), ["CLASS_DOES_NOT_EXISTS", self::CLASS_DOES_NOT_EXISTS, $requireInfo]); } $requestMethod = "get"; if ($tmp = getenv("REQUEST_METHOD")) { $requestMethod = strtolower($tmp); } $instance; $instance = new $callClassName(); if (TRUE === method_exists($instance, '__before') && TRUE === is_callable([$instance, '__before'])) { if ($tmp = call_user_func_array([$instance, '__before'], $arguments)) { return $tmp; } } $arrActionName = [$requestMethod . $actionName, $actionName]; foreach ($arrActionName as $action) { if (TRUE === method_exists($instance, $action) && TRUE === is_callable([$instance, $action])) { return call_user_func_array([$instance, $action], $arguments); } } return $this->forwardNotFound($this->getRouter()->getNotFound(), ["METHOD_DOES_NOT_EXISTS", self::METHOD_DOES_NOT_EXISTS, $requireInfo]); } else { $folderName = stream_resolve_include_path($folderName); if (FALSE === is_dir($folderName)) { return $this->forwardNotFound($this->getRouter()->getNotFound(), ["FOLDER_DOES_NOT_EXISTS", self::FOLDER_DOES_NOT_EXISTS, $requireInfo]); } else { return $this->forwardNotFound($this->getRouter()->getNotFound(), ["FILE_DOES_NOT_EXISTS", self::FILE_DOES_NOT_EXISTS, $requireInfo]); } } }
/** * Processes the request. * * @param object HTML_QuickForm_Page the current form-page * @param string Current action name, as one Action object can serve multiple actions * @since 2.1.0 * @access public */ function perform(&$page, $actionName) { $page->isFormBuilt() or $page->buildForm(); $page->handle('display'); $sess =& $page->controller->container(); $opt = $page->getSubmitValue('dumpOption'); switch ($opt) { case '1': // Progress2 dump info $arr = $page->controller->_progress->toArray(); varDump($arr); break; case '2': // Forms values container varDump($sess); break; case '3': // Included files $includes = get_included_files(); varDump($includes); break; case '4': // declared classes $classes = get_declared_classes(); varDump($classes); break; case '5': // declared actions $actions = $page->controller->_actions; varDump($actions); break; } }
public static function runtime() { echo '<br><pre>'; echo microtime(1) - START_TIME; echo '<br>get_included_files => '; print_r(get_included_files()); }
/** +---------------------------------------------------------- * 显示运行时间、数据库操作、缓存次数、内存使用信息 +---------------------------------------------------------- * @access private +---------------------------------------------------------- * @return string +---------------------------------------------------------- */ private function showTime() { // 显示运行时间 G('beginTime', $GLOBALS['_beginTime']); G('viewEndTime'); $showTime = 'Process: ' . G('beginTime', 'viewEndTime') . 's '; // 显示详细运行时间 $showTime .= '( Load:' . G('beginTime', 'loadTime') . 's Init:' . G('loadTime', 'initTime') . 's Exec:' . G('initTime', 'viewStartTime') . 's Template:' . G('viewStartTime', 'viewEndTime') . 's )'; // 显示数据库操作次数 if (class_exists('Db', false)) { $showTime .= ' | DB :' . N('db_query') . ' queries ' . N('db_write') . ' writes '; } // 显示缓存读写次数 if (class_exists('Cache', false)) { $showTime .= ' | Cache :' . N('cache_read') . ' gets ' . N('cache_write') . ' writes '; } // 显示内存开销 if (MEMORY_LIMIT_ON) { $showTime .= ' | UseMem:' . number_format((memory_get_usage() - $GLOBALS['_startUseMems']) / 1024) . ' kb'; } // 显示文件加载数 $showTime .= ' | LoadFile:' . count(get_included_files()); // 显示函数调用次数 自定义函数,内置函数 $fun = get_defined_functions(); $showTime .= ' | CallFun:' . count($fun['user']) . ',' . count($fun['internal']); return $showTime; }
function _createNewTestingModel($test_model_name) { static $shutdown_called; switch ($test_model_name) { case 'AkTestNestedCategory': $model_source = '<?php class AkTestNestedCategory extends AkActiveRecord { var $act_as = "nested_set"; } ?>'; break; default: $model_source = '<?php class ' . $test_model_name . ' extends AkActiveRecord { } ?>'; break; } $file_name = AkInflector::toModelFilename($test_model_name); if (!Ak::file_put_contents($file_name, $model_source)) { die('Ooops!, in order to perform this test, you must set your app/model permissions so this can script can create and delete files into/from it'); } if (!in_array($file_name, get_included_files()) && !class_exists($test_model_name)) { include $file_name; } else { return false; } $this->_testing_models_to_delete[] = $file_name; if (!isset($shutdown_called)) { $shutdown_called = true; register_shutdown_function(array(&$this, '_deleteTestingModels')); } return true; }
/** * 显示运行时间、数据库操作、缓存次数、内存使用信息 * @access private * @return string */ private function showTime() { // 显示运行时间 G('beginTime', $GLOBALS['_beginTime']); G('viewEndTime'); $showTime = 'Process: ' . G('beginTime', 'viewEndTime') . 's '; if (C('SHOW_ADV_TIME')) { // 显示详细运行时间 $showTime .= '( Load:' . G('beginTime', 'loadTime') . 's Init:' . G('loadTime', 'initTime') . 's Exec:' . G('initTime', 'viewStartTime') . 's Template:' . G('viewStartTime', 'viewEndTime') . 's )'; } if (C('SHOW_DB_TIMES') && class_exists('Db', false)) { // 显示数据库操作次数 $showTime .= ' | DB :' . N('db_query') . ' queries ' . N('db_write') . ' writes '; } if (C('SHOW_CACHE_TIMES') && class_exists('Cache', false)) { // 显示缓存读写次数 $showTime .= ' | Cache :' . N('cache_read') . ' gets ' . N('cache_write') . ' writes '; } if (MEMORY_LIMIT_ON && C('SHOW_USE_MEM')) { // 显示内存开销 $showTime .= ' | UseMem:' . number_format((memory_get_usage() - $GLOBALS['_startUseMems']) / 1024) . ' kb'; } if (C('SHOW_LOAD_FILE')) { $showTime .= ' | LoadFile:' . count(get_included_files()); } if (C('SHOW_FUN_TIMES')) { $fun = get_defined_functions(); $showTime .= ' | CallFun:' . count($fun['user']) . ',' . count($fun['internal']); } return $showTime; }
/** * 获取首页博客 * * @author mrmsl <*****@*****.**> * @date 2013-04-26 22:57:37 * * @return array 博客数组 */ private function _getBlogs() { var_dump($this->_model, get_included_files()); exit; $blog_arr = $this->_model->table(TB_BLOG)->alias('b')->join(' JOIN ' . TB_CATEGORY . ' AS c ON b.cate_id=c.cate_id')->order('b.blog_id DESC')->limit(10)->field('b.blog_id,b.title,b.link_url,b.add_time,b.summary,b.seo_description,c.cate_name,c.link_url AS cate_url')->select(); return $blog_arr; }
function &getTransport($url, $encoding = SOAP_DEFAULT_ENCODING) { $urlparts = @parse_url($url); if (!$urlparts['scheme']) { return SOAP_Base_Object::_raiseSoapFault("Invalid transport URI: {$url}"); } if (strcasecmp($urlparts['scheme'], 'mailto') == 0) { $transport_type = 'SMTP'; } else { if (strcasecmp($urlparts['scheme'], 'https') == 0) { $transport_type = 'HTTP'; } else { /* handle other transport types */ $transport_type = strtoupper($urlparts['scheme']); } } $transport_include = 'SOAP/Transport/' . $transport_type . '.php'; $res = @(include_once $transport_include); if (!$res && !in_array($transport_include, get_included_files())) { return SOAP_Base_Object::_raiseSoapFault("No Transport for {$urlparts['scheme']}"); } $transport_class = "SOAP_Transport_{$transport_type}"; if (!class_exists($transport_class)) { return SOAP_Base_Object::_raiseSoapFault("No Transport class {$transport_class}"); } return new $transport_class($url, $encoding); }
public function index() { echo 'hehe'; echo '<pre>'; var_dump(get_included_files()); var_dump(BaseModel::test()); }