本文整理汇总了PHP中Debug::trace方法的典型用法代码示例。如果您正苦于以下问题:PHP Debug::trace方法的具体用法?PHP Debug::trace怎么用?PHP Debug::trace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Debug
的用法示例。
在下文中一共展示了Debug::trace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
// Set Cookie Defaults
$this->time = time() + 60 * 60 * 24 * 365;
$this->cookie_path = "/";
$this->cookie_domain = rtrim($_SERVER['HTTP_HOST'], '/');
// Add trace for debugging
\Debug::trace('Input class initiated successfully', __FILE__, __LINE__);
}
示例2: __construct
function __construct()
{
$this->load = load_class('Loader');
// Setup the databases and realm
$this->DB = $this->load->database('DB');
$this->RDB = $this->load->database('RDB');
$this->realm = $this->load->realm();
// Add trace for debugging
\Debug::trace('Base model class initialized', __FILE__, __LINE__);
}
示例3: query
/**
* Run a query against the global MySQL connection.
*
* @param string $query
* @param boolean $log
* @return MySQL Result
*/
function query($query, $log = false)
{
$res = mysql_query($query);
$err = mysql_errno();
self::$queryCount++;
if ($err != 0) {
Debug::trace("[QUERY] {$query}");
Debug::critical("[ERROR] " . "I'm sorry, Dave, I'm afraid I can't do that. " . mysql_error());
error_log($query);
error_log(mysql_error());
} elseif ($log) {
Debug::trace("[QUERY] {$query}");
}
return $res;
}
示例4: __construct
public function __construct()
{
// Add trace for debugging
\Debug::trace('Initializing language class...', __FILE__, __LINE__);
// Load the Input and Filesystem class'
$this->Input = load_class('Input');
$this->filesystem = load_class('Filesystem', 'Library');
// Load our languages
$this->scan_language_dirs();
// Set the default language
$this->default_language = load_class('Config')->get('default_language');
// Set the default Language
$this->selected_language();
// Add trace for debugging
\Debug::trace('Language class initiated successfully', __FILE__, __LINE__);
}
示例5: run
/**
* 执行某个行为
* @param string $name 行为名称
* @param Mixed $params 传人的参数
* @return void
*/
public static function run($name, &$params = null)
{
if (APP_DEBUG) {
Debug::mark('behaviorStart');
}
// 实例化并执行
// if($name == 'App\\Home\\Behaviors\\CheckSessionId') {
$class = $name;
// }
// else {
// $class = __NAMESPACE__ . '\\Behaviors\\' . $name;
// }
$behavior = new $class();
$behavior->run($params);
// 记录行为的执行日志
if (APP_DEBUG) {
Debug::mark('behaviorEnd');
Debug::trace('Run ' . $name . ' Behavior [ RunTime:' . Debug::mark('behaviorStart', 'behaviorEnd', 6) . 's ]', '', 'INFO');
}
}
示例6: delete
public function delete($path, $files = array())
{
// Correct path
$path = str_replace(array('/', '\\'), DS, $path);
// Add trace for debugging
\Debug::trace("Deleting file/folder '{$path}'", __FILE__, __LINE__);
if (is_dir($path)) {
// Make sure our path is correct
if ($path[strlen($path) - 1] != DS) {
$path = $path . DS;
}
// Check to see if we are just removing file or what :O
if (!empty($files)) {
foreach ($files as $f) {
// Attempt to delete the file, return false if even 1 fails
if (!$this->delete($path . $f)) {
return false;
}
}
// End of loop, return true
return true;
} else {
// Remove the whole dir
return $this->remove_dir($path);
}
} else {
return $this->delete_file($path);
}
}
示例7: findRoute
protected function findRoute()
{
// Make this a bit easier
$name = strtolower($this->controller);
// Add trace for debugging
\Debug::trace("Loading routes for url...", __FILE__, __LINE__);
// Load database
$this->DB = $this->load->database('DB');
// Check to see if the URI belongs to a module
$query = "SELECT `name`, `uri2` FROM `pcms_modules` WHERE (`uri1`=? AND `uri2`='*') OR `uri1`=?";
$result = $this->DB->query($query, array($name, $name))->fetchAll();
// If our result is an array, Then we load it as a module
if (is_array($result)) {
$found = false;
foreach ($result as $module) {
// Handle the method, if method is an astricks, then the module will handle all requests
if ($module['uri2'] == '*' || $module['uri2'] == $this->action) {
$found = true;
$controller = $module['name'];
break;
} elseif (strpos($module['uri2'], ',') !== FALSE) {
// Remove any spaces, and convert to an array
$array = explode(',', $module['uri2']);
if (!in_array($this->action, $array)) {
// The action IS NOT in the array, Next result set
continue;
} else {
// The action is in the array, so we set it as that
$found = true;
$controller = $module['name'];
break;
}
}
}
// If we didnt find a module for this URI, load the default controller
if (!$found) {
goto Skip;
}
// Define out globals and this controller/action
$GLOBALS['is_module'] = TRUE;
$this->controller = $GLOBALS['controller'] = ucfirst($controller);
$GLOBALS['action'] = $this->action;
// Add trace for debugging
\Debug::trace("Found module route in database. Using {$this->controller} as controller, and {$this->action} as method", __FILE__, __LINE__);
// Include the module controller file
include path(ROOT, 'third_party', 'modules', $this->controller, 'controller.php');
return TRUE;
} else {
Skip:
$path = path(SYSTEM_PATH, 'controllers', $name . '.php');
if (file_exists($path)) {
// Define out globals and this controller/action
$GLOBALS['is_module'] = FALSE;
$GLOBALS['controller'] = $this->controller;
$GLOBALS['action'] = $this->action;
foreach (get_defined_vars() as $key => $v) {
$defined_vars[$key] =& ${$key};
}
\Debug::mark($defined_vars, __FILE__, __LINE__);
// Add trace for debugging
\Debug::trace("No module found for url route, using default contoller from the system/controllers folder", __FILE__, __LINE__);
// Include the controller file
include $path;
return TRUE;
} else {
// If the method didnt exist, then we have a 404
\Debug::trace("Controller '{$name}' doesnt exist. Displaying 404", __FILE__, __LINE__);
}
}
// Neither exists, then no controller found.
return FALSE;
}
示例8: _build_header
protected function _build_header()
{
// Add trace for debugging
\Debug::trace('Building template header', __FILE__, __LINE__);
// Convert our JS vars into a string :)
$string = " var Plexis = {\n url : '" . SITE_URL . "',\n template_url : '{TEMPLATE_URL}',\n debugging : false,\n realm_id : " . get_realm_cookie() . ",\n }\n";
foreach ($this->jsvars as $key => $val) {
// Format the var based on type
$val = is_numeric($val) ? $val : '"' . $val . '"';
$string .= " var " . $key . " = " . $val . ";\n";
}
// Remove last whitespace
$string = rtrim($string);
// Setup the basic static headings
$this->append_metadata("")->append_metadata("<!-- Include jQuery Scripts -->")->append_metadata('<script type="text/javascript" src="' . BASE_URL . '/assets/js/jquery.js"></script>')->append_metadata('<script type="text/javascript" src="' . BASE_URL . '/assets/js/jquery-ui.js"></script>')->append_metadata('<script type="text/javascript" src="' . BASE_URL . '/assets/js/jquery.validate.js"></script>')->append_metadata("")->append_metadata("<!-- Define Global Vars and Include Plexis Static JS Scripts -->")->append_metadata('<script type="text/javascript">
' . $string . '
</script>')->append_metadata('<script type="text/javascript" src="' . BASE_URL . '/assets/js/plexis.js"></script>');
// Append the template meta data
$this->_append_template_metadata();
// Append loaded css files
if (!empty($this->cssfiles)) {
$this->append_metadata("");
// Add whitespace
$this->append_metadata("<!-- Include Controller Defined Css Files -->");
foreach ($this->cssfiles as $f) {
// Find the path :O
if (preg_match('@^(ftp|http(s)?)://@i', $f)) {
// We have a full url
$src = $f;
} else {
// Just a filename
$src = $this->template['http_path'] . '/' . trim($this->xml->config->css_folder, '/') . '/' . $f;
}
// Add the stylesheet to the header
$this->set_metadata('stylesheet', $src, 'link');
}
}
// Append loaded js files
if (!empty($this->jsfiles)) {
$this->append_metadata("");
// Add whitespace
$this->append_metadata("<!-- Include Controller Defined JS Files -->");
foreach ($this->jsfiles as $j) {
// Find the path :O
if (preg_match('@^(ftp|http(s)?)://@i', $j)) {
// We have a full url
$src = $j;
} else {
// Just a filename
$path = $this->template['path'] . DS . trim($this->xml->config->js_folder, '/') . DS . $j;
if (file_exists(str_replace(array('/', '\\'), DS, $path))) {
$src = $this->template['http_path'] . '/' . trim($this->xml->config->js_folder, '/') . '/' . $j;
} else {
$src = BASE_URL . '/assets/js/' . $j;
}
}
// Add the js path
$this->append_metadata('<script type="text/javascript" src="' . $src . '"></script>');
}
}
// Add the view if we have one
$line = $this->view_js_string();
if ($line != false) {
$this->append_metadata('');
$this->append_metadata("<!-- Include the page view JS file -->");
$this->append_metadata($line);
}
// Now, we build the header into a string
$head = "";
foreach ($this->_metadata as $data) {
$head .= "\t" . trim($data) . "\n";
}
return $head;
}
示例9: _init_user
protected function _init_user($userid)
{
// Fetch account
$Account = $this->realm->fetchAccount($userid);
if (!is_object($Account)) {
// Add trace for debugging
\Debug::trace("Account id {$userid} doesnt exist in the realm database. Failed to init user account", __FILE__, __LINE__);
return false;
}
// Build our rediculas query
$query = "SELECT \n `activated`, \n `pcms_accounts`.`group_id`, \n `last_seen`, \n `registered`, \n `registration_ip`, \n `language`, \n `selected_theme`, \n `votes`, \n `vote_points`, \n `vote_points_earned`, \n `vote_points_spent`, \n `donations`, \n `_account_recovery`,\n `pcms_account_groups`.`title`,\n `pcms_account_groups`.`is_banned`,\n `pcms_account_groups`.`is_user`,\n `pcms_account_groups`.`is_admin`,\n `pcms_account_groups`.`is_super_admin`,\n `pcms_account_groups`.`permissions`\n FROM `pcms_accounts` INNER JOIN `pcms_account_groups` ON \n pcms_accounts.group_id = pcms_account_groups.group_id WHERE `id` = ?";
// Query our database and get the users information
$result = $this->DB->query($query, array($Account->getId()), false)->fetchRow();
// If the user doesnt exists in the table, we need to insert it
if ($result === false) {
// Add trace for debugging
\Debug::trace("User account '{$Account->getUsername()}' doesnt exist in Plexis database, fetching account from realm", __FILE__, __LINE__);
$data = array('id' => $Account->getId(), 'username' => ucfirst(strtolower($Account->getUsername())), 'email' => $Account->getEmail(), 'activated' => 1, 'registered' => $Account->joinDate() == false ? date("Y-m-d H:i:s", time()) : $Account->joinDate(), 'registration_ip' => $this->data['ip_address']);
$this->DB->insert('pcms_accounts', $data);
$result = $this->DB->query($query)->fetchRow();
// If the insert failed, we have a fatal error
if ($result === false) {
// Add trace for debugging
\Debug::trace("There was a fatal error trying to insert account data into the plexis database", __FILE__, __LINE__);
show_error('fatal_error', false, E_ERROR);
return false;
}
}
// Load our perms into a different var and unset
$perms = unserialize($result['permissions']);
unset($result['permissions']);
// Make sure we have access to our account, we have to do this after saving the session unfortunatly
if ((!isset($perms['account_access']) || $perms['account_access'] == 0) && $result['is_super_admin'] == 0) {
// Add trace for debugging
\Debug::trace("User has no permission to access account. Login failed.", __FILE__, __LINE__);
output_message('warning', 'account_access_denied');
return false;
}
// We are good, save permissions for this user
$this->load_permissions($result['group_id'], $perms);
// Make sure the account isnt locked due to verification
if ($result['activated'] == false && config('reg_email_verification') == TRUE) {
// Add trace for debugging
\Debug::trace("Account '{$username}' is unactivated. Login failed.", __FILE__, __LINE__);
output_message('warning', 'login_failed_account_unactivated');
return false;
}
// Custom variable for QA checking
$result['_account_recovery'] = $result['_account_recovery'] != null && strlen($result['_account_recovery']) > 10;
// Set our users info up the the session and carry onwards :D
$this->data = array_merge(array('logged_in' => true, 'id' => $Account->getId(), 'username' => ucfirst(strtolower($Account->getUsername())), 'email' => $Account->getEmail(), 'ip_address' => $this->data['ip_address']), $result);
// Add trace for debugging
\Debug::trace('Loaded user ' . $Account->getUsername(), __FILE__, __LINE__);
return true;
}
示例10: trigger
public function trigger($event, $params = array())
{
// Get calling
$backtrace = debug_backtrace();
// Add trace for debugging
\Debug::trace("Event \"{$event}\" triggered from: {$backtrace[0]['file']} on line {$backtrace[0]['line']}", __FILE__, __LINE__);
// Free up memory
unset($backtrace);
// Check that event exists
if (array_key_exists($event, self::$events)) {
foreach (self::$events[$event] as $callback) {
// If the callback is an array, then we call a class/method
if (is_array($callback)) {
list($c, $a) = $callback;
// Try and proccess this manually as call_user_func_array is 2x slower then this!
switch (count($params)) {
case 0:
$c->{$a}();
break;
case 1:
$c->{$a}($params[0]);
break;
case 2:
$c->{$a}($params[0], $params[1]);
break;
case 3:
$c->{$a}($params[0], $params[1], $params[2]);
break;
case 4:
$c->{$a}($params[0], $params[1], $params[2], $params[3]);
break;
case 5:
$c->{$a}($params[0], $params[1], $params[2], $params[3], $params[4]);
break;
default:
call_user_func_array(array($c, $a), $params);
break;
}
} else {
// Try and proccess this manually as call_user_func_array is 2x slower then this!
switch (count($params)) {
case 0:
$callback();
break;
case 1:
$callback($params[0]);
break;
case 2:
$callback($params[0], $params[1]);
break;
case 3:
$callback($params[0], $params[1], $params[2]);
break;
case 4:
$callback($params[0], $params[1], $params[2], $params[3]);
break;
case 5:
$callback($params[0], $params[1], $params[2], $params[3], $params[4]);
break;
default:
call_user_func_array($callback, $params);
break;
}
}
}
return true;
}
return false;
}
示例11: showTrace
/**
* 显示页面Trace信息
* @access private
*/
private function showTrace()
{
// 系统默认显示信息
$files = get_included_files();
$info = array();
foreach ($files as $key => $file) {
$info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )';
}
$trace = array();
$base = array('请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . __SELF__, '运行时间' => $this->showTime(), '内存开销' => MEMORY_LIMIT_ON ? number_format((memory_get_usage() - $GLOBALS['_startUseMems']) / 1024, 2) . ' kb' : '不支持', '查询信息' => Debug::record('db_query') . ' queries ' . Debug::record('db_write') . ' writes ', '文件加载' => count(get_included_files()), '缓存信息' => Debug::record('cache_read') . ' gets ' . Debug::record('cache_write') . ' writes ', '配置加载' => count(c()), '会话信息' => 'SESSION_ID=' . session_id());
// 读取项目定义的Trace文件
$traceFile = CONF_PATH . 'trace.php';
if (is_file($traceFile)) {
$base = array_merge($base, include $traceFile);
}
$debug = Debug::trace();
$tabs = C('TRACE_PAGE_TABS');
foreach ($tabs as $name => $title) {
switch (strtoupper($name)) {
case 'BASE':
// 基本信息
$trace[$title] = $base;
break;
case 'FILE':
// 文件信息
$trace[$title] = $info;
break;
default:
// 调试信息
$name = strtoupper($name);
if (strpos($name, '|')) {
// 多组信息
$array = explode('|', $name);
$result = array();
foreach ($array as $name) {
$result += isset($debug[$name]) ? $debug[$name] : array();
}
$trace[$title] = $result;
} else {
$trace[$title] = isset($debug[$name]) ? $debug[$name] : '';
}
}
}
if ($save = C('PAGE_TRACE_SAVE')) {
// 保存页面Trace日志
if (is_array($save)) {
// 选择选项卡保存
$tabs = C('TRACE_PAGE_TABS');
$array = array();
foreach ($save as $tab) {
$array[] = $tabs[$tab];
}
}
$content = date('[ c ]') . ' ' . Response::get_client_ip() . ' ' . $_SERVER['REQUEST_URI'] . "\r\n";
foreach ($trace as $key => $val) {
if (!isset($array) || in_array($key, $array)) {
$content .= '[ ' . $key . " ]\r\n";
if (is_array($val)) {
foreach ($val as $k => $v) {
$content .= (!is_numeric($k) ? $k . ':' : '') . print_r($v, true) . "\r\n";
}
} else {
$content .= print_r($val, true) . "\r\n";
}
$content .= "\r\n";
}
}
error_log(str_replace('<br/>', "\r\n", $content), Log::FILE, LOG_PATH . date('y_m_d') . '_trace.log');
}
unset($files, $info, $base);
// 调用Trace页面模板
ob_start();
include C('TMPL_TRACE_FILE');
return ob_get_clean();
}
示例12: _initWowlib
protected function _initWowlib()
{
// Include the wowlib file
require path(ROOT, 'third_party', 'wowlib', 'Wowlib.php');
// Add Trace
\Debug::trace('Initializing Wowlib...', __FILE__, __LINE__);
// Try to init the wowlib
try {
\Wowlib::Init(config('emulator'));
\Debug::trace('Wowlib Initialized successfully', __FILE__, __LINE__);
} catch (Exception $e) {
\Debug::silent_mode(false);
\Debug::trace('Wowlib failed to initialize. Message thrown was: ' . $e->getMessage(), __FILE__, __LINE__);
show_error('Wowlib Error: ' . $e->getMessage(), false, E_ERROR);
}
}
示例13: wsCall
protected function wsCall($method, $params = [])
{
$done = false;
while (!$done) {
try {
$raw_response = $this->rawWSCall($method, $params);
break;
} catch (RippleAPIException $e) {
Debug::trace("error=" . $e->getRippleErrorName(), __FILE__, __LINE__, $this);
if ($e->getRippleErrorName() == 'slowDown') {
$sleep = rand(50000, 1000000);
Debug::trace("slow down request received. sleeping for {$sleep}...", __FILE__, __LINE__, $this);
// slow down
usleep($sleep);
// 50ms - 1 second
} else {
throw $e;
}
}
}
return $raw_response;
}
示例14: _process_db
private function _process_db()
{
// For starts, get our current database version
$query = "SELECT `value` FROM `pcms_versions` WHERE `key`='database'";
$version = real_ver($this->DB->query($query)->fetchColumn());
if ($version < real_ver(REQ_DB_VERSION)) {
$updates = array();
$path = path(SYSTEM_PATH, "sql", "updates");
// Add trace for debugging
\Debug::trace("Updating core database from {$version} to " . REQ_DB_VERSION, __FILE__, __LINE__);
// Open the __updates directory and scan all updates
$list = @opendir($path);
if ($list) {
while (false !== ($file = readdir($list))) {
if ($file[0] != "." && !is_dir(path($path, $file))) {
// Format should be like so "update_#.sql
$names = explode('_', $file);
$update = str_replace('.sql', '', $names[1]);
if (real_ver($update) > $version) {
$updates[] = array('file' => $file, 'version' => $update);
}
}
}
@closedir($list);
}
// If we have updates
if (!empty($updates)) {
// Order them by rev
sort($updates);
// Process updates
foreach ($updates as $update) {
if (!$this->DB->utilities->runSqlFile($path . DS . $update['file'])) {
// Add trace for debugging
\Debug::trace('Database update to version ' . $version . ' failed!', __FILE__, __LINE__);
log_message('Failed to run SQL file "' . $path . DS . $update['file'] . '" on database', 'error.log');
break;
}
// Add trace for debugging
\Debug::trace('Database successfully updated to version ' . $version, __FILE__, __LINE__);
$version = $update['version'];
}
}
}
// Define our REAL db version now, after updates are run
define('CMS_DB_VERSION', $version);
}
示例15: route_url
public function route_url()
{
// Add trace for debugging
\Debug::trace('Routing url...', __FILE__, __LINE__);
// Determine our http hostname, and site directory
$this->http_host = rtrim($_SERVER['HTTP_HOST'], '/');
$this->site_dir = dirname($_SERVER['PHP_SELF']);
// Detect our protocol
if (isset($_SERVER['HTTPS'])) {
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
$this->protocol = 'https';
} else {
$this->protocol = 'http';
}
} else {
$this->protocol = 'http';
}
// Build our Full Base URL
$site_url = $this->http_host . '/' . $this->site_dir;
while (strpos($site_url, '//') !== FALSE) {
$site_url = str_replace('//', '/', $site_url);
}
$this->site_url = str_replace('\\', '', $this->protocol . '://' . rtrim($site_url, '/'));
// Process the site URI
if (!$this->config->get('enable_query_strings', 'Core')) {
// Get our current url, which is passed on by the 'url' param
$this->uri = isset($_GET['url']) ? $this->input->get('url', TRUE) : '';
} else {
// Define our needed vars
$c_param = $this->config->get('controller_param', 'Core');
$a_param = $this->config->get('action_param', 'Core');
// Make sure we have a controller at least
$c = $this->input->get($c_param, TRUE);
if (!$c) {
$this->uri = '';
} else {
// Get our action
$a = $this->input->get($a_param, TRUE);
if (!$a) {
$a = $this->config->get('default_action', 'Core');
}
// Default Action
// Init the uri
$this->uri = $c . '/' . $a;
// Clean the query string
$qs = $this->input->clean($_SERVER['QUERY_STRING']);
$qs = explode('&', $qs);
foreach ($qs as $string) {
// Convert this segment to an array
$string = explode('=', $string);
// Dont add the controller / action twice ;)
if ($string[0] == $c_param || $string[0] == $a_param) {
continue;
}
// Append the uri vraiable
$this->uri .= '/' . $string[1];
}
}
}
// If the URI is empty, then load defaults
if (empty($this->uri)) {
// Set our Controller / Action to the defaults
$controller = $this->config->get('default_controller', 'Core');
// Default Controller
$action = $this->config->get('default_action', 'Core');
// Default Action
$queryString = array();
// Default query string
} else {
// Remove any left slashes or double slashes
$this->uri = ltrim(str_replace('//', '/', $this->uri), '/');
// We will start by bulding our controller, action, and querystring
$urlArray = array();
$urlArray = explode("/", $this->uri);
$controller = $urlArray[0];
// If there is an action, then lets set that in a variable
array_shift($urlArray);
if (isset($urlArray[0]) && !empty($urlArray[0])) {
$action = $urlArray[0];
array_shift($urlArray);
} else {
$action = $this->config->get('default_action', 'Core');
// Default Action
}
// $queryString is what remains
$queryString = $urlArray;
}
// Tell the system we've routed
$this->routed = true;
// Make sure the first character of the controller is not an _ !
if (strncmp($controller, '_', 1) == 0 || strncmp($action, '_', 1) == 0) {
// Add this to the trace
\Debug::trace('Controller or action contains a private prefix "_", showing 404', __FILE__, __LINE__);
show_404();
}
// Set static Variables
$this->controller = $controller;
$this->action = $action;
$this->queryString = $queryString;
// Add trace for debugging
//.........这里部分代码省略.........