本文整理匯總了PHP中IPSDebug::startTimer方法的典型用法代碼示例。如果您正苦於以下問題:PHP IPSDebug::startTimer方法的具體用法?PHP IPSDebug::startTimer怎麽用?PHP IPSDebug::startTimer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IPSDebug
的用法示例。
在下文中一共展示了IPSDebug::startTimer方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: query
/**
* Execute a direct database query
*
* @param string Database query
* @param boolean [Optional] Do not convert table prefix
* @return @e resource
*/
public function query($the_query, $bypass = false)
{
//-----------------------------------------
// Debug?
//-----------------------------------------
if ($this->obj['debug'] or $this->obj['use_debug_log'] and $this->obj['debug_log'] or $this->obj['use_bad_log'] and $this->obj['bad_log']) {
IPSDebug::startTimer();
$_MEMORY = IPSDebug::getMemoryDebugFlag();
}
//-----------------------------------------
// Stop sub selects? (UNION)
//-----------------------------------------
if (!IPS_DB_ALLOW_SUB_SELECTS) {
# On the spot allowance?
if (!$this->allow_sub_select) {
$_tmp = strtolower($this->_removeAllQuotes($the_query));
if (preg_match("#(?:/\\*|\\*/)#i", $_tmp)) {
$this->throwFatalError("You are not allowed to use comments in your SQL query.\nAdd \\ipsRegistry::DB()->allow_sub_select=1; before any query construct to allow them");
return false;
}
if (preg_match("#[^_a-zA-Z]union[^_a-zA-Z]#s", $_tmp)) {
$this->throwFatalError("UNION query joins are not allowed.\nAdd \\ipsRegistry::DB()->allow_sub_select=1; before any query construct to allow them");
return false;
} else {
if (preg_match_all("#[^_a-zA-Z](select)[^_a-zA-Z]#s", $_tmp, $matches)) {
if (count($matches) > 1) {
$this->throwFatalError("SUB SELECT query joins are not allowed.\nAdd \\ipsRegistry::DB()->allow_sub_select=1; before any query construct to allow them");
return false;
}
}
}
}
}
//-----------------------------------------
// Run the query
//-----------------------------------------
$this->_tmpQ = substr($the_query, 0, 100) . '...';
$this->query_id = mysqli_query($this->connection_id, $the_query);
//-----------------------------------------
// Reset array...
//-----------------------------------------
$this->resetDataTypes();
$this->allow_sub_select = false;
if (!$this->query_id) {
$this->throwFatalError("mySQL query error: {$the_query}");
}
//-----------------------------------------
// Logging?
//-----------------------------------------
if ($this->obj['use_debug_log'] and $this->obj['debug_log'] or $this->obj['use_bad_log'] and $this->obj['bad_log'] or $this->obj['use_slow_log'] and $this->obj['slow_log']) {
$endtime = IPSDebug::endTimer();
$_data = '';
if (preg_match("/^(?:\\()?select/i", $the_query)) {
$eid = mysqli_query($this->connection_id, "EXPLAIN {$the_query}");
$_bad = false;
while ($array = mysqli_fetch_array($eid)) {
$array['extra'] = isset($array['extra']) ? $array['extra'] : '';
$_data .= "\n+------------------------------------------------------------------------------+";
$_data .= "\n|Table: " . $array['table'];
$_data .= "\n|Type: " . $array['type'];
$_data .= "\n|Possible Keys: " . $array['possible_keys'];
$_data .= "\n|Key: " . $array['key'];
$_data .= "\n|Key Len: " . $array['key_len'];
$_data .= "\n|Ref: " . $array['ref'];
$_data .= "\n|Rows: " . $array['rows'];
$_data .= "\n|Extra: " . $array['Extra'];
//$_data .= "\n+------------------------------------------------------------------------------+";
if ($this->obj['use_bad_log'] and $this->obj['bad_log'] and (stristr($array['Extra'], 'filesort') or stristr($array['Extra'], 'temporary'))) {
$this->writeDebugLog($the_query, $_data, $endtime, $this->obj['bad_log'], TRUE);
}
if ($this->obj['use_slow_log'] and $this->obj['slow_log'] and $endtime >= $this->obj['use_slow_log']) {
$this->writeDebugLog($the_query, $_data, $endtime, $this->obj['slow_log'], TRUE);
}
}
if ($this->obj['use_debug_log'] and $this->obj['debug_log']) {
$this->writeDebugLog($the_query, $_data, $endtime);
}
} else {
if ($this->obj['use_debug_log'] and $this->obj['debug_log']) {
$this->writeDebugLog($the_query, $_data, $endtime);
}
}
}
//-----------------------------------------
// Debugging?
//-----------------------------------------
if ($this->obj['debug']) {
$endtime = IPSDebug::endTimer();
$memoryUsed = IPSDebug::setMemoryDebugFlag('', $_MEMORY);
$memory = '';
$shutdown = $this->is_shutdown ? 'SHUTDOWN QUERY: ' : '';
if (preg_match("/^(?:\\()?select/i", $the_query)) {
$eid = mysqli_query($this->connection_id, "EXPLAIN {$the_query}");
//.........這裏部分代碼省略.........
示例2: query
/**
* Execute a direct database query
*
* @access public
* @param string Database query
* @param boolean [Optional] Do not convert table prefix
* @return resource Query id
*/
public function query($the_query, $bypass = false)
{
//-----------------------------------------
// Change the table prefix if needed
//-----------------------------------------
if ($this->no_prefix_convert) {
$bypass = 1;
}
if (!$bypass) {
if ($this->obj['sql_tbl_prefix'] != "ibf_" and !$this->prefix_changed) {
//$the_query = preg_replace("/\sibf_(\S+?)([\s\.,]|$)/", " ".$this->obj['sql_tbl_prefix']."\\1\\2", $the_query);
}
}
//-----------------------------------------
// Debug?
//-----------------------------------------
if ($this->obj['debug'] or $this->obj['use_debug_log'] and $this->obj['debug_log']) {
IPSDebug::startTimer();
}
//-----------------------------------------
// Stop sub selects? (UNION)
//-----------------------------------------
if (!IPS_DB_ALLOW_SUB_SELECTS) {
# On the spot allowance?
if (!$this->allow_sub_select) {
$_tmp = strtolower($this->_removeAllQuotes($the_query));
if (preg_match("#(?:/\\*|\\*/)#i", $_tmp)) {
$this->throwFatalError("You are not allowed to use comments in your SQL query.\nAdd \\ipsRegistry::DB()->allow_sub_select=1; before any query construct to allow them\n{$the_query}");
return false;
}
if (preg_match("#[^_a-zA-Z]union[^_a-zA-Z]#s", $_tmp)) {
$this->throwFatalError("UNION query joins are not allowed.\nAdd \\ipsRegistry::DB()->allow_sub_select=1; before any query construct to allow them\n{$the_query}");
return false;
} else {
if (preg_match_all("#[^_a-zA-Z](select)[^_a-zA-Z]#s", $_tmp, $matches)) {
if (count($matches) > 1) {
$this->throwFatalError("SUB SELECT query joins are not allowed.\nAdd \\ipsRegistry::DB()->allow_sub_select=1; before any query construct to allow them\n{$the_query}");
return false;
}
}
}
}
}
//-----------------------------------------
// Run the query
//-----------------------------------------
#I had to switch this around... The query goes first, connection id second. Otherwise it just breaks - KF
#$this->query_id = mysql_query($this->connection_id, $the_query );
$this->query_id = mysql_query($the_query, $this->connection_id);
//-----------------------------------------
// Reset array...
//-----------------------------------------
$this->force_data_type = array();
$this->allow_sub_select = false;
if (!$this->query_id) {
$this->throwFatalError("mySQL query error: {$the_query}");
}
//-----------------------------------------
// Debug?
//-----------------------------------------
if ($this->obj['use_debug_log'] and $this->obj['debug_log']) {
$endtime = IPSDebug::endTimer();
if (preg_match("/^(?:\\()?select/i", $the_query)) {
$eid = mysql_query("EXPLAIN {$the_query}", $this->connection_id);
while ($array = mysql_fetch_array($eid)) {
$_data .= "\n+------------------------------------------------------------------------------+";
$_data .= "\n|Table: " . $array['table'];
$_data .= "\n|Type: " . $array['type'];
$_data .= "\n|Possible Keys: " . $array['possible_keys'];
$_data .= "\n|Key: " . $array['key'];
$_data .= "\n|Key Len: " . $array['key_len'];
$_data .= "\n|Ref: " . $array['ref'];
$_data .= "\n|Rows: " . $array['rows'];
$_data .= "\n|Extra: " . $array['extra'];
$_data .= "\n+------------------------------------------------------------------------------+";
}
$this->writeDebugLog($the_query, $_data, $endtime);
} else {
$this->writeDebugLog($the_query, $_data, $endtime);
}
} else {
if ($this->obj['debug']) {
$endtime = IPSDebug::endTimer();
$shutdown = $this->is_shutdown ? 'SHUTDOWN QUERY: ' : '';
if (preg_match("/^(?:\\()?select/i", $the_query)) {
$eid = mysql_query("EXPLAIN {$the_query}", $this->connection_id);
$this->debug_html .= "<table width='95%' border='1' cellpadding='6' cellspacing='0' bgcolor='#FFE8F3' align='center'>\n\t\t\t\t\t\t\t\t\t\t <tr>\n\t\t\t\t\t\t\t\t\t\t \t <td colspan='8' style='font-size:14px' bgcolor='#FFC5Cb'><b>{$shutdown}Select Query</b></td>\n\t\t\t\t\t\t\t\t\t\t </tr>\n\t\t\t\t\t\t\t\t\t\t <tr>\n\t\t\t\t\t\t\t\t\t\t <td colspan='8' style='font-family:courier, monaco, arial;font-size:14px;color:black'>{$the_query}</td>\n\t\t\t\t\t\t\t\t\t\t </tr>\n\t\t\t\t\t\t\t\t\t\t <tr bgcolor='#FFC5Cb'>\n\t\t\t\t\t\t\t\t\t\t\t <td><b>table</b></td><td><b>type</b></td><td><b>possible_keys</b></td>\n\t\t\t\t\t\t\t\t\t\t\t <td><b>key</b></td><td><b>key_len</b></td><td><b>ref</b></td>\n\t\t\t\t\t\t\t\t\t\t\t <td><b>rows</b></td><td><b>Extra</b></td>\n\t\t\t\t\t\t\t\t\t\t </tr>\n";
while ($array = mysql_fetch_array($eid)) {
$type_col = '#FFFFFF';
if ($array['type'] == 'ref' or $array['type'] == 'eq_ref' or $array['type'] == 'const') {
$type_col = '#D8FFD4';
} else {
//.........這裏部分代碼省略.........
示例3: init
/**
* Initiate the registry
*
* @return mixed false or void
*/
public static function init()
{
$INFO = array();
$_ipsPowerSettings = array();
if (self::$initiated === TRUE) {
return FALSE;
}
self::$initiated = TRUE;
/* Load static classes */
require IPS_ROOT_PATH . "sources/base/core.php";
/*noLibHook*/
require IPS_ROOT_PATH . "sources/base/ipsMember.php";
/*noLibHook*/
/* Debugging notices? */
if (defined('IPS_ERROR_CAPTURE') and IPS_ERROR_CAPTURE !== FALSE) {
@error_reporting(E_ALL | E_NOTICE);
@set_error_handler("IPSDebug::errorHandler");
}
/* Load core variables */
self::_loadCoreVariables();
/* Load config file */
if (is_file(DOC_IPS_ROOT_PATH . 'conf_global.php')) {
require DOC_IPS_ROOT_PATH . 'conf_global.php';
/*noLibHook*/
if (is_array($INFO)) {
foreach ($INFO as $key => $val) {
ipsRegistry::$settings[$key] = str_replace('\', '\\', $val);
}
}
}
/* Load secret sauce */
if (is_array($_ipsPowerSettings)) {
ipsRegistry::$settings = array_merge($_ipsPowerSettings, ipsRegistry::$settings);
}
/* Make sure we're installed */
if (empty($INFO['sql_database'])) {
/* Quick PHP version check */
if (!version_compare(MIN_PHP_VERS, PHP_VERSION, '<=')) {
print "You must be using PHP " . MIN_PHP_VERS . " or better. You are currently using: " . PHP_VERSION;
exit;
}
$host = $_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : @getenv('HTTP_HOST');
$self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : @getenv('PHP_SELF');
if (IPS_AREA == 'admin') {
@header("Location: http://" . $host . rtrim(dirname($self), '/\\') . "/install/index.php");
} else {
if (!defined('CP_DIRECTORY')) {
define('CP_DIRECTORY', 'admin');
}
@header("Location: http://" . $host . rtrim(dirname($self), '/\\') . "/" . CP_DIRECTORY . "/install/index.php");
}
}
/* Switch off dev mode you idjit */
if (!defined('IN_DEV')) {
define('IN_DEV', 0);
}
/* Shell defined? */
if (!defined('IPS_IS_SHELL')) {
define('IPS_IS_SHELL', FALSE);
}
/* If this wasn't defined in the gateway file... */
if (!defined('ALLOW_FURLS')) {
define('ALLOW_FURLS', ipsRegistry::$settings['use_friendly_urls'] ? TRUE : FALSE);
}
if (!defined('IPS_IS_MOBILE_APP')) {
define('IPS_IS_MOBILE_APP', false);
}
/**
* File and folder permissions
*/
if (!defined('IPS_FILE_PERMISSION')) {
define('IPS_FILE_PERMISSION', 0777);
}
if (!defined('IPS_FOLDER_PERMISSION')) {
define('IPS_FOLDER_PERMISSION', 0777);
}
/* Set it again incase a gateway turned it off */
ipsRegistry::$settings['use_friendly_urls'] = ALLOW_FURLS;
/* Start timer */
IPSDebug::startTimer();
/* Cookies... */
IPSCookie::$sensitive_cookies = array('session_id', 'admin_session_id', 'member_id', 'pass_hash');
/* INIT DB */
self::$handles['db'] = ips_DBRegistry::instance();
/* Set DB */
self::$handles['db']->setDB(ipsRegistry::$settings['sql_driver']);
/* Input set up... */
if (is_array($_POST) and count($_POST)) {
foreach ($_POST as $key => $value) {
# Skip post arrays
if (!is_array($value)) {
$_POST[$key] = IPSText::stripslashes($value);
}
}
}
//.........這裏部分代碼省略.........
示例4: query
/**
* Execute a direct database query
*
* @param string Database query
* @param boolean [Optional] Do not convert table prefix
* @return @e resource
*/
public function query($the_query, $bypass = false)
{
//-----------------------------------------
// Debug?
//-----------------------------------------
if ($this->obj['debug'] or $this->obj['use_debug_log'] and $this->obj['debug_log']) {
IPSDebug::startTimer();
}
//-----------------------------------------
// Stop sub selects? (UNION)
//-----------------------------------------
if (!IPS_DB_ALLOW_SUB_SELECTS) {
# On the spot allowance?
if (!$this->allow_sub_select) {
$_tmp = strtolower($this->_removeAllQuotes($the_query));
if (preg_match("#(?:/\\*|\\*/)#i", $_tmp)) {
$this->throwFatalError("Не разрешается использовать комментарии в SQL запросе.\nДобавьте \\ipsRegistry::DB()->allow_sub_select=1; перед запросом, чтобы разрешить их\n{$the_query}");
return false;
}
if (preg_match("#[^_a-zA-Z]union[^_a-zA-Z]#s", $_tmp)) {
$this->throwFatalError("Использование UNION в запросах запрещено.\nДобавьте \\ipsRegistry::DB()->allow_sub_select=1; перед запросом, чтобы разрешить использование\n{$the_query}");
return false;
} else {
if (preg_match_all("#[^_a-zA-Z](select)[^_a-zA-Z]#s", $_tmp, $matches)) {
if (count($matches) > 1) {
$this->throwFatalError("Вложенные SELECT в запросах запрещены.\nДобавьте \\ipsRegistry::DB()->allow_sub_select=1; перед запросом, чтобы разрешить их\n{$the_query}");
return false;
}
}
}
}
}
//-----------------------------------------
// Run the query
//-----------------------------------------
#I had to switch this around... The query goes first, connection id second. Otherwise it just breaks - KF
#$this->query_id = mysql_query($this->connection_id, $the_query );
$this->query_id = mysql_query($the_query, $this->connection_id);
//-----------------------------------------
// Reset array...
//-----------------------------------------
$this->resetDataTypes();
$this->allow_sub_select = false;
if (!$this->query_id) {
$this->throwFatalError("mySQL query error: {$the_query}");
}
//-----------------------------------------
// Debug?
//-----------------------------------------
if ($this->obj['use_debug_log'] and $this->obj['debug_log'] or $this->obj['use_bad_log'] and $this->obj['bad_log'] or $this->obj['use_slow_log'] and $this->obj['slow_log']) {
$endtime = IPSDebug::endTimer();
$_data = '';
if (preg_match("/^(?:\\()?select/i", $the_query)) {
$eid = mysql_query("EXPLAIN {$the_query}", $this->connection_id);
$_bad = false;
while ($array = mysql_fetch_array($eid)) {
$array['extra'] = isset($array['extra']) ? $array['extra'] : '';
$_data .= "\n+------------------------------------------------------------------------------+";
$_data .= "\n|Table: " . $array['table'];
$_data .= "\n|Type: " . $array['type'];
$_data .= "\n|Possible Keys: " . $array['possible_keys'];
$_data .= "\n|Key: " . $array['key'];
$_data .= "\n|Key Len: " . $array['key_len'];
$_data .= "\n|Ref: " . $array['ref'];
$_data .= "\n|Rows: " . $array['rows'];
$_data .= "\n|Extra: " . $array['Extra'];
//$_data .= "\n+------------------------------------------------------------------------------+";
if ($this->obj['use_bad_log'] and $this->obj['bad_log'] and (stristr($array['Extra'], 'filesort') or stristr($array['Extra'], 'temporary'))) {
$this->writeDebugLog($the_query, $_data, $endtime, $this->obj['bad_log'], TRUE);
}
if ($this->obj['use_slow_log'] and $this->obj['slow_log'] and $endtime >= $this->obj['use_slow_log']) {
$this->writeDebugLog($the_query, $_data, $endtime, $this->obj['slow_log'], TRUE);
}
}
if ($this->obj['use_debug_log'] and $this->obj['debug_log']) {
$this->writeDebugLog($the_query, $_data, $endtime);
}
} else {
if ($this->obj['use_debug_log'] and $this->obj['debug_log']) {
$this->writeDebugLog($the_query, $_data, $endtime);
}
}
}
//-----------------------------------------
// Debugging?
//-----------------------------------------
if ($this->obj['debug']) {
$endtime = IPSDebug::endTimer();
$shutdown = $this->is_shutdown ? 'SHUTDOWN QUERY: ' : '';
if (preg_match("/^(?:\\()?select/i", $the_query)) {
$eid = mysql_query("EXPLAIN {$the_query}", $this->connection_id);
$this->debug_html .= "<table width='95%' border='1' cellpadding='6' cellspacing='0' bgcolor='#FFE8F3' align='center'>\n\t\t\t\t\t\t\t\t\t\t <tr>\n\t\t\t\t\t\t\t\t\t\t \t <td colspan='8' style='font-size:14px' bgcolor='#FFC5Cb'><b>{$shutdown}Select Query</b></td>\n\t\t\t\t\t\t\t\t\t\t </tr>\n\t\t\t\t\t\t\t\t\t\t <tr>\n\t\t\t\t\t\t\t\t\t\t <td colspan='8' style='font-family:courier, monaco, arial;font-size:14px;color:black'>{$the_query}</td>\n\t\t\t\t\t\t\t\t\t\t </tr>\n\t\t\t\t\t\t\t\t\t\t <tr bgcolor='#FFC5Cb'>\n\t\t\t\t\t\t\t\t\t\t\t <td><b>table</b></td><td><b>type</b></td><td><b>possible_keys</b></td>\n\t\t\t\t\t\t\t\t\t\t\t <td><b>key</b></td><td><b>key_len</b></td><td><b>ref</b></td>\n\t\t\t\t\t\t\t\t\t\t\t <td><b>rows</b></td><td><b>Extra</b></td>\n\t\t\t\t\t\t\t\t\t\t </tr>\n";
while ($array = mysql_fetch_array($eid)) {
//.........這裏部分代碼省略.........