Пример #1
0
 public function init()
 {
     if (function_exists("eaccelerator_get")) {
         eaccelerator_caching(true);
         eaccelerator_optimizer(true);
         return true;
     } else {
         return false;
     }
 }
Пример #2
0
 /**
  * Attempt to disable any detetected opcode caches / optimizers
  * @access public
  * @return void
  */
 public static function disable_opcode_cache()
 {
     if (extension_loaded('xcache')) {
         @ini_set('xcache.optimizer', false);
         // Will be implemented in 2.0, here for future proofing
         // XCache seems to do some optimizing, anyway.
         // The recorded number of ticks is smaller with xcache.cacher enabled than without.
     } elseif (extension_loaded('apc')) {
         @ini_set('apc.optimization', 0);
         // Removed in APC 3.0.13 (2007-02-24)
         apc_clear_cache();
     } elseif (extension_loaded('eaccelerator')) {
         @ini_set('eaccelerator.optimizer', 0);
         if (function_exists('eaccelerator_optimizer')) {
             @eaccelerator_optimizer(false);
         }
         // Try setting eaccelerator.optimizer = 0 in a .user.ini or .htaccess file
     } elseif (extension_loaded('Zend Optimizer+')) {
         @ini_set('zend_optimizerplus.optimization_level', 0);
     }
 }
Пример #3
0
 /**
  * Constructor
  * Initialize the object, figure out if profiling is enabled, and if so,
  * start the profile.
  * @return p3_profiler
  */
 public function __construct()
 {
     // Set up paths
     $this->_P3_PATH = realpath(dirname(__FILE__));
     // Debug mode
     $this->_debug_entry = array('profiling_enabled' => false, 'recording_ip' => '', 'scan_name' => '', 'recording' => false, 'disable_optimizers' => false, 'url' => $this->_get_url(), 'visitor_ip' => p3_profiler_get_ip(), 'time' => time(), 'pid' => getmypid());
     // Check to see if we should profile
     $opts = array();
     if (function_exists('get_option')) {
         $opts = get_option('p3-profiler_options');
         if (!empty($opts['profiling_enabled'])) {
             if (isset($this->_debug_entry)) {
                 $this->_debug_entry['profiling_enabled'] = true;
                 $this->_debug_entry['scan_name'] = $opts['profiling_enabled']['name'];
                 $this->_debug_entry['recording_ip'] = $opts['profiling_enabled']['ip'];
                 $this->_debug_entry['disable_optimizers'] = $opts['profiling_enabled']['disable_opcode_cache'];
             }
         }
     }
     // Add a global flag to let everyone know we're profiling
     if (!empty($opts) && preg_match('/' . $opts['profiling_enabled']['ip'] . '/', p3_profiler_get_ip())) {
         define('WPP_PROFILING_STARTED', true);
     }
     // Save the debug info
     $this->_debug_entry['recording'] = defined('WPP_PROFILING_STARTED');
     // Check the profiling flag
     if (!defined('WPP_PROFILING_STARTED')) {
         return $this;
     }
     // Emergency shut off switch
     if (isset($_REQUEST['P3_SHUTOFF']) && !empty($_REQUEST['P3_SHUTOFF'])) {
         p3_profiler_disable();
         return $this;
     }
     // Hook shutdown
     register_shutdown_function(array($this, 'shutdown_handler'));
     // Error detection
     $flag = get_option('p3_profiler-error_detection');
     if (!empty($flag) && $flag > time() + 60) {
         p3_profiler_disable();
         return $this;
     }
     // Set the error detection flag
     if (empty($flag)) {
         update_option('p3_profiler-error_detection', time());
     }
     // Kludge memory limit / time limit
     if ((int) @ini_get('memory_limit') < 256) {
         @ini_set('memory_limit', '256M');
     }
     @set_time_limit(90);
     // Set the profile file
     $this->_profile_filename = $opts['profiling_enabled']['name'] . '.json';
     // Start timing
     $this->_start_time = microtime(true);
     $this->_last_call_start = microtime(true);
     // Reset state
     $this->_last_call_time = 0;
     $this->_runtime = 0;
     $this->_plugin_runtime = 0;
     $this->_core = 0;
     $this->_theme = 0;
     $this->_last_call_category = self::CATEGORY_CORE;
     $this->_last_stack = array();
     // Add some startup information
     $this->_profile = array('url' => $this->_get_url(), 'ip' => p3_profiler_get_ip(), 'pid' => getmypid(), 'date' => @date('c'), 'stack' => array());
     // Disable opcode optimizers.  These "optimize" calls out of the stack
     // and hide calls from the tick handler and backtraces
     if ($opts['profiling_enabled']['disable_opcode_cache']) {
         if (extension_loaded('xcache')) {
             @ini_set('xcache.optimizer', false);
             // Will be implemented in 2.0, here for future proofing
             // XCache seems to do some optimizing, anyway.  The recorded stack size is smaller with xcache.cacher enabled than without.
         } elseif (extension_loaded('apc')) {
             @ini_set('apc.optimization', 0);
             // Removed in APC 3.0.13 (2007-02-24)
             apc_clear_cache();
         } elseif (extension_loaded('eaccelerator')) {
             @ini_set('eaccelerator.optimizer', 0);
             if (function_exists('eaccelerator_optimizer')) {
                 @eaccelerator_optimizer(false);
             }
             // If you're reading this, try setting eaccelerator.optimizer = 0 in a .user.ini or .htaccess file
         } elseif (extension_loaded('Zend Optimizer+')) {
             @ini_set('zend_optimizerplus.optimization_level', 0);
         }
         // Tested with wincache
         // Tested with ioncube
         // Tested with zend guard loader
     }
     // Monitor all function-calls
     declare (ticks=1);
     register_tick_function(array($this, 'tick_handler'));
 }
Пример #4
0
}
/* }}} */
/* {{{ process any commands */
$info = eaccelerator_info();
if (isset($_POST['caching'])) {
    if ($info['cache']) {
        eaccelerator_caching(false);
    } else {
        eaccelerator_caching(true);
    }
} else {
    if (isset($_POST['optimizer']) && function_exists('eaccelerator_optimizer')) {
        if ($info['optimizer']) {
            eaccelerator_optimizer(false);
        } else {
            eaccelerator_optimizer(true);
        }
    } else {
        if (isset($_POST['clear'])) {
            eaccelerator_clear();
        } else {
            if (isset($_POST['clean'])) {
                eaccelerator_clean();
            } else {
                if (isset($_POST['purge'])) {
                    eaccelerator_purge();
                }
            }
        }
    }
}
Пример #5
0
if (!extension_loaded('eAccelerator')) {
    error('eAccelerator Extension not loaded.');
}
if (isset($_POST['submit'])) {
    if ($_POST['cache'] == 1) {
        authorize();
        eaccelerator_caching(true);
    } else {
        eaccelerator_caching(false);
    }
    if (function_exists('eaccelerator_optimizer')) {
        if ($_POST['optimize'] == 1) {
            authorize();
            eaccelerator_optimizer(true);
        } else {
            eaccelerator_optimizer(false);
        }
    }
    if (isset($_POST['clear'])) {
        authorize();
        eaccelerator_clear();
    }
    if (isset($_POST['clean'])) {
        authorize();
        eaccelerator_clean();
    }
    if (isset($_POST['purge'])) {
        authorize();
        eaccelerator_purge();
    }
}
$Id$
*/
if (VIPERAL !== 'Admin') {
    die;
}
if (!function_exists('eaccelerator_info')) {
}
global $_CLASS, $sort_by;
if (isset($_REQUEST['mode'])) {
    $setting = isset($_REQUEST['setting']) && $_REQUEST['setting'] ? true : false;
    switch ($_REQUEST['mode']) {
        case 'caching':
            eaccelerator_caching($setting);
            break;
        case 'optimizer':
            eaccelerator_optimizer($setting);
            break;
        case 'clear_cache':
            eaccelerator_clear();
            break;
        case 'clean_cache':
            eaccelerator_clean();
            break;
        case 'purge_cache':
            eaccelerator_purge();
            break;
        case 'keys':
        case 'scripts':
        case 'removed_scripts':
            $_CLASS['core_template']->assign('eaccelerator_info', false);
            eaccelerator_display($_REQUEST['mode'], get_variable('start', 'REQUEST', 0, 'integer'), 10);
 /**
  * Attempts to disable any detetected opcode caches / optimizers
  */
 protected static function _disableOpcodeCache()
 {
     if (extension_loaded('xcache')) {
         // will be implemented in 2.0, here for future proofing
         @ini_set('xcache.optimizer', false);
         // xcache seems to do some optimizing, anyway..
     } else {
         if (extension_loaded('apc')) {
             @ini_set('apc.optimization', 0);
             // removed in apc 3.0.13 (2007-02-24)
             apc_clear_cache();
         } else {
             if (extension_loaded('eaccelerator')) {
                 @ini_set('eaccelerator.optimizer', 0);
                 if (function_exists('eaccelerator_optimizer')) {
                     @eaccelerator_optimizer(false);
                 }
                 // try setting eaccelerator.optimizer = 0 in a .user.ini or .htaccess file
             } else {
                 if (extension_loaded('Zend Optimizer+')) {
                     @ini_set('zend_optimizerplus.optimization_level', 0);
                 }
             }
         }
     }
 }