本文整理汇总了PHP中w3_is_database_error函数的典型用法代码示例。如果您正苦于以下问题:PHP w3_is_database_error函数的具体用法?PHP w3_is_database_error怎么用?PHP w3_is_database_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了w3_is_database_error函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ob_callback
/**
* Output buffering callback
*
* @param string $buffer
* @return string
*/
function ob_callback($buffer)
{
global $wpdb;
if ($buffer != '') {
if (w3_is_database_error($buffer)) {
status_header(503);
} else {
if (w3_can_print_comment($buffer)) {
/**
* Add footer comment
*/
$date = date_i18n('Y-m-d H:i:s');
$host = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost';
if (w3_is_preview_mode()) {
$buffer .= "\r\n<!-- W3 Total Cache used in preview mode -->";
}
if ($this->_config->get_string('common.support') != '' || $this->_config->get_boolean('common.tweeted')) {
$buffer .= sprintf("\r\n<!-- Served from: %s @ %s by W3 Total Cache -->", w3_escape_comment($host), $date);
} else {
$strings = array();
if ($this->_config->get_boolean('minify.enabled') && !$this->_config->get_boolean('minify.debug')) {
$w3_plugin_minify = w3_instance('W3_Plugin_Minify');
$strings[] = sprintf(__('Minified using %s%s', 'w3-total-cache'), w3_get_engine_name($this->_config->get_string('minify.engine')), $w3_plugin_minify->minify_reject_reason != '' ? sprintf(' (%s)', $w3_plugin_minify->minify_reject_reason) : '');
}
if ($this->_config->get_boolean('pgcache.enabled') && !$this->_config->get_boolean('pgcache.debug')) {
$w3_pgcache = w3_instance('W3_PgCache');
$strings[] = sprintf(__('Page Caching using %s%s', 'w3-total-cache'), w3_get_engine_name($this->_config->get_string('pgcache.engine')), $w3_pgcache->cache_reject_reason != '' ? sprintf(' (%s)', $w3_pgcache->cache_reject_reason) : '');
}
if ($this->_config->get_boolean('dbcache.enabled') && !$this->_config->get_boolean('dbcache.debug')) {
/**
* @var W3_DbCache $db
*/
$db = w3_instance('W3_DbCache');
$append = ($reason = $db->get_reject_reason()) ? sprintf(' (%s)', $reason) : '';
if ($db->query_hits) {
$strings[] = sprintf(__('Database Caching %d/%d queries in %.3f seconds using %s%s', 'w3-total-cache'), $db->query_hits, $db->query_total, $db->time_total, w3_get_engine_name($this->_config->get_string('dbcache.engine')), $append);
} else {
$strings[] = sprintf(__('Database Caching using %s%s', 'w3-total-cache'), w3_get_engine_name($this->_config->get_string('dbcache.engine')), $append);
}
}
if (w3_is_dbcluster()) {
$db_cluster = w3_instance('W3_Enterprise_DbCluster');
$strings[] = $db_cluster->status_message();
}
if ($this->_config->get_boolean('objectcache.enabled') && !$this->_config->get_boolean('objectcache.debug')) {
/**
* @var W3_ObjectCache $w3_objectcache
*/
$w3_objectcache = w3_instance('W3_ObjectCache');
$append = ($reason = $w3_objectcache->get_reject_reason()) ? sprintf(' (%s)', $reason) : '';
$strings[] = sprintf(__('Object Caching %d/%d objects using %s%s', 'w3-total-cache'), $w3_objectcache->cache_hits, $w3_objectcache->cache_total, w3_get_engine_name($this->_config->get_string('objectcache.engine')), $append);
}
if (w3_is_pro($this->_config) || w3_is_enterprise($this->_config)) {
if ($this->_config->get_boolean('fragmentcache.enabled') && !$this->_config->get_boolean('fragmentcache.debug')) {
$w3_fragmentcache = w3_instance('W3_Pro_FragmentCache');
$append = $w3_fragmentcache->cache_reject_reason != '' ? sprintf(' (%s)', $w3_fragmentcache->cache_reject_reason) : '';
$strings[] = sprintf(__('Fragment Caching %d/%d fragments using %s%s', 'w3-total-cache'), $w3_fragmentcache->cache_hits, $w3_fragmentcache->cache_total, w3_get_engine_name($this->_config->get_string('fragmentcache.engine')), $append);
}
}
if ($this->_config->get_boolean('cdn.enabled') && !$this->_config->get_boolean('cdn.debug')) {
$w3_plugin_cdn = w3_instance('W3_Plugin_Cdn');
$w3_plugin_cdncommon = w3_instance('W3_Plugin_CdnCommon');
$cdn = $w3_plugin_cdncommon->get_cdn();
$via = $cdn->get_via();
$strings[] = sprintf(__('Content Delivery Network via %s%s', 'w3-total-cache'), $via ? $via : 'N/A', $w3_plugin_cdn->cdn_reject_reason != '' ? sprintf(' (%s)', $w3_plugin_cdn->cdn_reject_reason) : '');
}
if ($this->_config->get_boolean('newrelic.enabled')) {
$w3_newrelic = w3_instance('W3_Plugin_NewRelic');
$append = $w3_newrelic->newrelic_reject_reason != '' ? sprintf(' (%s)', $w3_newrelic->newrelic_reject_reason) : '';
$strings[] = sprintf(__("Application Monitoring using New Relic%s", 'w3-total-cache'), $append);
}
$buffer .= "\r\n<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/\r\n";
if (count($strings)) {
$buffer .= "\r\n" . implode("\r\n", $strings) . "\r\n";
}
$buffer .= sprintf("\r\n Served from: %s @ %s by W3 Total Cache -->", w3_escape_comment($host), $date);
}
if ($this->is_debugging()) {
if ($this->_config->get_boolean('dbcache.enabled') && $this->_config->get_boolean('dbcache.debug')) {
$db = w3_instance('W3_DbCache');
$buffer .= "\r\n\r\n" . $db->_get_debug_info();
}
if ($this->_config->get_boolean('objectcache.enabled') && $this->_config->get_boolean('objectcache.debug')) {
$w3_objectcache = w3_instance('W3_ObjectCache');
$buffer .= "\r\n\r\n" . $w3_objectcache->_get_debug_info();
}
if (w3_is_pro($this->_config) || w3_is_enterprise($this->_config)) {
if ($this->_config->get_boolean('fragmentcache.enabled') && $this->_config->get_boolean('fragmentcache.debug')) {
$w3_fragmentcache = w3_instance('W3_Pro_FragmentCache');
$buffer .= "\r\n\r\n" . $w3_fragmentcache->_get_debug_info();
}
}
}
}
//.........这里部分代码省略.........
示例2: can_minify2
/**
* Returns true if we can minify
*
* @param string $buffer
* @return string
*/
function can_minify2(&$buffer)
{
/**
* Check for database error
*/
if (w3_is_database_error($buffer)) {
$this->minify_reject_reason = 'Database Error occurred';
return false;
}
/**
* Check for DONOTMINIFY constant
*/
if (defined('DONOTMINIFY') && DONOTMINIFY) {
$this->minify_reject_reason = 'DONOTMINIFY constant is defined';
return false;
}
/**
* Check feed minify
*/
if ($this->_config->get_boolean('minify.html.reject.feed') && function_exists('is_feed') && is_feed()) {
$this->minify_reject_reason = 'Feed is rejected';
return false;
}
return true;
}
示例3: can_minify2
/**
* Returns true if we can minify
*
* @param string $buffer
* @return string
*/
function can_minify2(&$buffer)
{
/**
* Check for database error
*/
if (w3_is_database_error($buffer)) {
$this->minify_reject_reason = 'Database Error occurred';
return false;
}
/**
* Check for DONOTMINIFY constant
*/
if (defined('DONOTMINIFY') && DONOTMINIFY) {
$this->minify_reject_reason = 'DONOTMINIFY constant is defined';
return false;
}
return true;
}
示例4: _can_cache2
/**
* Checks if can we do cache logic
*
* @param string $buffer
* @return boolean
*/
function _can_cache2(&$buffer)
{
/**
* Skip if caching is disabled
*/
if (!$this->_caching) {
return false;
}
/**
* Check for database error
*/
if (w3_is_database_error($buffer)) {
$this->cache_reject_reason = 'Database error occurred';
return false;
}
/**
* Check for DONOTCACHEPAGE constant
*/
if (defined('DONOTCACHEPAGE') && DONOTCACHEPAGE) {
$this->cache_reject_reason = 'DONOTCACHEPAGE constant is defined';
return false;
}
/**
* Check hostname
*/
if ((!w3_is_multisite() || w3_is_multisite() && !w3_force_master()) && $this->_config->get_boolean('pgcache.check.domain') && w3_get_host() != w3_get_home_domain()) {
$this->cache_reject_reason = 'Hostname mismatch';
return false;
}
/**
* Don't cache 404 pages
*/
if (!$this->_config->get_boolean('pgcache.cache.404') && function_exists('is_404') && is_404()) {
$this->cache_reject_reason = 'Page is 404';
return false;
}
/**
* Don't cache homepage
*/
if (!$this->_config->get_boolean('pgcache.cache.home') && function_exists('is_home') && is_home()) {
$this->cache_reject_reason = is_front_page() && is_home() ? 'Page is front page' : 'Page is posts page';
return false;
}
/**
* Don't cache front page
*/
if ($this->_config->get_boolean('pgcache.reject.front_page') && function_exists('is_front_page') && is_front_page() && !is_home()) {
$this->cache_reject_reason = 'Page is front page';
return false;
}
/**
* Don't cache feed
*/
if (!$this->_config->get_boolean('pgcache.cache.feed') && function_exists('is_feed') && is_feed()) {
$this->cache_reject_reason = 'Page is feed';
return false;
}
/**
* Check if page contains dynamic tags
*/
if ($this->_enhanced_mode && $this->_has_dynamic($buffer)) {
$this->cache_reject_reason = 'Page contains dynamic tags (mfunc or mclude) can not be cached in enhanced mode';
return false;
}
return true;
}
示例5: can_cdn2
/**
* Returns true if we can do CDN logic
*
* @param $buffer
* @return string
*/
function can_cdn2(&$buffer)
{
/**
* Check for database error
*/
if (w3_is_database_error($buffer)) {
$this->cdn_reject_reason = 'Database Error occurred';
return false;
}
/**
* Check for DONOTCDN constant
*/
if (defined('DONOTCDN') && DONOTCDN) {
$this->cdn_reject_reason = 'DONOTCDN constant is defined';
return false;
}
/**
* Check logged in admin
*/
if ($this->_config->get_boolean('cdn.reject.admins') && current_user_can('manage_options')) {
$this->cdn_reject_reason = 'logged in admin is rejected';
return false;
}
return true;
}
示例6: ob_callback
/**
* Output buffering callback
*
* @param string $buffer
* @return string
*/
function ob_callback(&$buffer)
{
global $wpdb;
if ($buffer != '' && w3_is_xml($buffer)) {
if (w3_is_database_error($buffer)) {
@header('HTTP/1.1 503 Service Unavailable');
} else {
/**
* Replace links for preview mode
*/
if (w3_is_preview_mode() && isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] != W3TC_POWERED_BY) {
$domain_url_regexp = w3_get_domain_url_regexp();
$buffer = preg_replace_callback('~(href|src|action)=([\'"])(' . $domain_url_regexp . ')?(/[^\'"]*)~', array(&$this, 'link_replace_callback'), $buffer);
}
/**
* Add footer comment
*/
$date = date_i18n('Y-m-d H:i:s');
$host = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost';
if ($this->is_supported()) {
$buffer .= sprintf("\r\n<!-- Served from: %s @ %s by W3 Total Cache -->", w3_escape_comment($host), $date);
} else {
$strings = array();
if ($this->_config->get_boolean('minify.enabled') && !$this->_config->get_boolean('minify.debug')) {
require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php';
$w3_plugin_minify =& W3_Plugin_Minify::instance();
$strings[] = sprintf("Minified using %s%s", w3_get_engine_name($this->_config->get_string('minify.engine')), $w3_plugin_minify->minify_reject_reason != '' ? sprintf(' (%s)', $w3_plugin_minify->minify_reject_reason) : '');
}
if ($this->_config->get_boolean('pgcache.enabled') && !$this->_config->get_boolean('pgcache.debug')) {
require_once W3TC_LIB_W3_DIR . '/PgCache.php';
$w3_pgcache =& W3_PgCache::instance();
$strings[] = sprintf("Page Caching using %s%s", w3_get_engine_name($this->_config->get_string('pgcache.engine')), $w3_pgcache->cache_reject_reason != '' ? sprintf(' (%s)', $w3_pgcache->cache_reject_reason) : '');
}
if ($this->_config->get_boolean('dbcache.enabled') && !$this->_config->get_boolean('dbcache.debug') && is_a($wpdb, 'W3_Db')) {
$append = is_user_logged_in() ? ' (user is logged in)' : '';
if ($wpdb->query_hits) {
$strings[] = sprintf("Database Caching %d/%d queries in %.3f seconds using %s%s", $wpdb->query_hits, $wpdb->query_total, $wpdb->time_total, w3_get_engine_name($this->_config->get_string('dbcache.engine')), $append);
} else {
$strings[] = sprintf("Database Caching using %s%s", w3_get_engine_name($this->_config->get_string('dbcache.engine')), $append);
}
}
if ($this->_config->get_boolean('objectcache.enabled') && !$this->_config->get_boolean('objectcache.debug')) {
require_once W3TC_LIB_W3_DIR . '/ObjectCache.php';
$w3_objectcache =& W3_ObjectCache::instance();
$strings[] = sprintf("Object Caching %d/%d objects using %s", $w3_objectcache->cache_hits, $w3_objectcache->cache_total, w3_get_engine_name($this->_config->get_string('objectcache.engine')));
}
if ($this->_config->get_boolean('cdn.enabled') && !$this->_config->get_boolean('cdn.debug')) {
require_once W3TC_LIB_W3_DIR . '/Plugin/Cdn.php';
$w3_plugin_cdn =& W3_Plugin_Cdn::instance();
$cdn =& $w3_plugin_cdn->get_cdn();
$via = $cdn->get_via();
$strings[] = sprintf("Content Delivery Network via %s%s", $via ? $via : 'N/A', $w3_plugin_cdn->cdn_reject_reason != '' ? sprintf(' (%s)', $w3_plugin_cdn->cdn_reject_reason) : '');
}
$buffer .= "\r\n<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/\r\n";
if (count($strings)) {
$buffer .= "\r\n" . implode("\r\n", $strings) . "\r\n";
}
$buffer .= sprintf("\r\nServed from: %s @ %s -->", w3_escape_comment($host), $date);
}
}
}
return $buffer;
}
示例7: can_cdn2
/**
* Returns true if we can do CDN logic
*
* @param $buffer
* @return string
*/
function can_cdn2(&$buffer)
{
/**
* Check for database error
*/
if (w3_is_database_error($buffer)) {
$this->cdn_reject_reason = 'Database Error occurred';
return false;
}
/**
* Check for DONOTCDN constant
*/
if (defined('DONOTCDN') && DONOTCDN) {
$this->cdn_reject_reason = 'DONOTCDN constant is defined';
return false;
}
/**
* Check logged users roles
*/
if ($this->_config->get_boolean('cdn.reject.logged_roles') && !$this->_check_logged_in_role_allowed()) {
$this->cdn_reject_reason = 'logged in role is rejected';
return false;
}
return true;
}
示例8: _can_cache2
/**
* Checks if can we do cache logic
*
* @param string $buffer
* @return boolean
*/
function _can_cache2(&$buffer)
{
/**
* Skip if caching is disabled
*/
if (!$this->_caching) {
return false;
}
/**
* Check for request URI trailing slash
*/
if ($this->_enhanced_mode) {
$permalink_structure = get_option('permalink_structure');
$permalink_structure_slash = substr($permalink_structure, -1) == '/';
$request_uri_slash = substr($this->_request_uri, -1) == '/';
if ($permalink_structure_slash != $request_uri_slash) {
if ($permalink_structure_slash) {
if (!$this->_check_accept_uri()) {
$this->cache_reject_reason = 'Requested URI doesn\'t have a trailing slash';
return false;
}
} else {
$this->cache_reject_reason = 'Requested URI has a trailing slash';
return false;
}
}
}
/**
* Check for database error
*/
if (w3_is_database_error($buffer)) {
$this->cache_reject_reason = 'Database error occurred';
return false;
}
/**
* Check for DONOTCACHEPAGE constant
*/
if (defined('DONOTCACHEPAGE') && DONOTCACHEPAGE) {
$this->cache_reject_reason = 'DONOTCACHEPAGE constant is defined';
return false;
}
/**
* Don't cache 404 pages
*/
if (!$this->_config->get_boolean('pgcache.cache.404') && function_exists('is_404') && is_404()) {
$this->cache_reject_reason = 'Page is 404';
return false;
}
/**
* Don't cache homepage
*/
if (!$this->_config->get_boolean('pgcache.cache.home') && function_exists('is_home') && is_home()) {
$this->cache_reject_reason = 'Page is home';
return false;
}
/**
* Don't cache feed
*/
if (!$this->_config->get_boolean('pgcache.cache.feed') && function_exists('is_feed') && is_feed()) {
$this->cache_reject_reason = 'Page is feed';
return false;
}
/**
* Check if page contains dynamic tags
*/
if ($this->_enhanced_mode && $this->_has_dynamic($buffer)) {
$this->cache_reject_reason = 'Page contains dynamic tags (mfunc or mclude) can not be cached in enhanced mode';
return false;
}
return true;
}
示例9: ob_callback
/**
* Output buffering callback
*
* @param string $buffer
* @return string
*/
function ob_callback(&$buffer)
{
global $wpdb;
if ($buffer != '' && w3_is_xml($buffer)) {
if (w3_is_database_error($buffer)) {
status_header(503);
} else {
/**
* Replace links for preview mode
*/
if (w3_is_preview_mode() && isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] != W3TC_POWERED_BY) {
$domain_url_regexp = w3_get_domain_url_regexp();
$buffer = preg_replace_callback('~(href|src|action)=([\'"])(' . $domain_url_regexp . ')?(/[^\'"]*)~', array(&$this, 'link_replace_callback'), $buffer);
}
/**
* Add footer comment
*/
$date = date_i18n('Y-m-d H:i:s');
$host = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost';
if ($this->_config->get_string('common.support') != '' || $this->_config->get_boolean('common.tweeted')) {
$buffer .= sprintf("\r\n<!-- Served from: %s @ %s by W3 Total Cache -->", w3_escape_comment($host), $date);
} else {
$strings = array();
if ($this->_config->get_boolean('minify.enabled') && !$this->_config->get_boolean('minify.debug')) {
$w3_plugin_minify = w3_instance('W3_Plugin_Minify');
$strings[] = sprintf("Minified using %s%s", w3_get_engine_name($this->_config->get_string('minify.engine')), $w3_plugin_minify->minify_reject_reason != '' ? sprintf(' (%s)', $w3_plugin_minify->minify_reject_reason) : '');
}
if ($this->_config->get_boolean('pgcache.enabled') && !$this->_config->get_boolean('pgcache.debug')) {
$w3_pgcache = w3_instance('W3_PgCache');
$strings[] = sprintf("Page Caching using %s%s", w3_get_engine_name($this->_config->get_string('pgcache.engine')), $w3_pgcache->cache_reject_reason != '' ? sprintf(' (%s)', $w3_pgcache->cache_reject_reason) : '');
}
if ($this->_config->get_boolean('dbcache.enabled') && !$this->_config->get_boolean('dbcache.debug')) {
$db = w3_instance('W3_DbCache');
$append = !is_null($db->cache_reject_reason) ? sprintf(' (%s)', $db->cache_reject_reason) : '';
if ($db->query_hits) {
$strings[] = sprintf("Database Caching %d/%d queries in %.3f seconds using %s%s", $db->query_hits, $db->query_total, $db->time_total, w3_get_engine_name($this->_config->get_string('dbcache.engine')), $append);
} else {
$strings[] = sprintf("Database Caching using %s%s", w3_get_engine_name($this->_config->get_string('dbcache.engine')), $append);
}
}
if (w3_is_dbcluster()) {
$db_cluster = w3_instance('W3_Enterprise_DbCluster');
$strings[] = $db_cluster->status_message();
}
if ($this->_config->get_boolean('objectcache.enabled') && !$this->_config->get_boolean('objectcache.debug')) {
$w3_objectcache = w3_instance('W3_ObjectCache');
$append = $w3_objectcache->cache_reject_reason != '' ? sprintf(' (%s)', $w3_objectcache->cache_reject_reason) : '';
$strings[] = sprintf("Object Caching %d/%d objects using %s%s", $w3_objectcache->cache_hits, $w3_objectcache->cache_total, w3_get_engine_name($this->_config->get_string('objectcache.engine')), $append);
}
if ($this->_config->get_boolean('fragmentcache.enabled') && !$this->_config->get_boolean('fragmentcache.debug')) {
$w3_fragmentcache = w3_instance('W3_Pro_FragmentCache');
$append = $w3_fragmentcache->cache_reject_reason != '' ? sprintf(' (%s)', $w3_fragmentcache->cache_reject_reason) : '';
$strings[] = sprintf("Fragment Caching %d/%d fragments using %s%s", $w3_fragmentcache->cache_hits, $w3_fragmentcache->cache_total, w3_get_engine_name($this->_config->get_string('fragmentcache.engine')), $append);
}
if ($this->_config->get_boolean('cdn.enabled') && !$this->_config->get_boolean('cdn.debug')) {
$w3_plugin_cdn = w3_instance('W3_Plugin_Cdn');
$w3_plugin_cdncommon = w3_instance('W3_Plugin_CdnCommon');
$cdn =& $w3_plugin_cdncommon->get_cdn();
$via = $cdn->get_via();
$strings[] = sprintf("Content Delivery Network via %s%s", $via ? $via : 'N/A', $w3_plugin_cdn->cdn_reject_reason != '' ? sprintf(' (%s)', $w3_plugin_cdn->cdn_reject_reason) : '');
}
if ($this->_config->get_boolean('newrelic.enabled')) {
$w3_newrelic = w3_instance('W3_Plugin_NewRelic');
$append = $w3_newrelic->newrelic_reject_reason != '' ? sprintf(' (%s)', $w3_newrelic->newrelic_reject_reason) : '';
$strings[] = sprintf(__("Application Monitoring using New Relic%s", 'w3-total-cache'), $append);
}
$buffer .= "\r\n<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/\r\n";
if (count($strings)) {
$buffer .= "\r\n" . implode("\r\n", $strings) . "\r\n";
}
$buffer .= sprintf("\r\n Served from: %s @ %s by W3 Total Cache -->", w3_escape_comment($host), $date);
}
if ($this->is_debugging()) {
if ($this->_config->get_boolean('dbcache.enabled') && $this->_config->get_boolean('dbcache.debug')) {
$db = w3_instance('W3_DbCache');
$buffer .= "\r\n\r\n" . $db->_get_debug_info();
}
if ($this->_config->get_boolean('objectcache.enabled') && $this->_config->get_boolean('objectcache.debug')) {
$w3_objectcache = w3_instance('W3_ObjectCache');
$buffer .= "\r\n\r\n" . $w3_objectcache->_get_debug_info();
}
if ($this->_config->get_boolean('fragmentcache.enabled') && $this->_config->get_boolean('fragmentcache.debug')) {
$w3_fragmentcache = w3_instance('W3_Pro_FragmentCache');
$buffer .= "\r\n\r\n" . $w3_fragmentcache->_get_debug_info();
}
}
}
}
return $buffer;
}