protected function __construct() { // Register shutdown function here $useCron = vB::getDatastore()->getOption('mailqueue'); if (empty($useCron)) { vB_Shutdown::instance()->add(array('vB_Mail', 'execMailQueue')); } }
/** * Returns singleton instance of self. * * @return vB_Shutdown */ public static function instance() { if (!isset(self::$instance)) { $class = __CLASS__; self::$instance = new $class(); } return self::$instance; }
/** * Run cron * * @param bool $noshutdownfunc Set to true to run directly rather than to run in shutdown function * * @return bool */ public function run($noshutdownfunc = false) { require_once DIR . '/includes/functions_cron.php'; $options = vB::getDatastore()->get_value('options'); if (!$noshutdownfunc and empty($options['crontab'])) { vB_Shutdown::instance()->add('exec_cron'); } else { $cronid = NULL; if (!empty($options['crontab']) and php_sapi_name() == 'cli') { $cronid = intval($_SERVER['argv'][1]); // if its a negative number or 0 set it to NULL so it just grabs the next task if ($cronid < 1) { $cronid = NULL; } } exec_cron($cronid); } return true; }
/** * Add function to be executed at shutdown * * @param string Name of function to be executed on shutdown */ function add($function) { $obj =& vB_Shutdown::init(); if (function_exists($function) and !in_array($function, $obj->shutdown)) { $obj->shutdown[] = $function; } }
/** * Constructor - initializes the nozip system, * and calls and instance of the vB_Input_Cleaner class */ function vB_Registry() { // variable to allow bypassing of gzip compression $this->nozip = defined('NOZIP') ? true : (@ini_get('zlib.output_compression') ? true : false); // variable that controls HTTP header output $this->noheader = defined('NOHEADER') ? true : false; @ini_set('zend.ze1_compatibility_mode', 0); // initialize the input handler $this->cleaner =& vB::getCleaner(); $this->input = new vB_Input_Cleaner($this); // initialize the shutdown handler $this->shutdown = vB_Shutdown::instance(); $this->config =& vB::getConfig(); $this->csrf_skip_list = defined('CSRF_SKIP_LIST') ? explode(',', CSRF_SKIP_LIST) : array(); }
$filedata = base64_decode('R0lGODlhAQABAIAAAMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='); $filesize = strlen($filedata); // browser will think there is no more data if content-length is what is returned // regardless of how long the script continues to execute, apart from IIS + CGI header('Content-type: image/gif'); if (!(strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false and strpos(SAPI_NAME, 'cgi') !== false)) { header('Content-Length: ' . $filesize); header('Connection: Close'); } if (!$vbulletin->options['crontab']) { echo $filedata; flush(); } ($hook = vBulletinHook::fetch_hook('cron_start')) ? eval($hook) : false; if (!defined('NOSHUTDOWNFUNC') and !$vbulletin->options['crontab']) { vB_Shutdown::add('exec_cron'); } else { $cronid = NULL; if ($vbulletin->options['crontab'] and SAPI_NAME == 'cli') { $cronid = intval($_SERVER['argv'][1]); // if its a negative number or 0 set it to NULL so it just grabs the next task if ($cronid < 1) { $cronid = NULL; } } exec_cron($cronid); if (defined('NOSHUTDOWNFUNC')) { $db->close(); } } /*======================================================================*\
public static function shutdown() { if (self::$skipShutdown) { //always shutdown cache vB_Cache::instance(vB_Cache::CACHE_FAST)->shutdown(); vB_Cache::instance(vB_Cache::CACHE_LARGE)->shutdown(); vB_Cache::instance(vB_Cache::CACHE_STD)->shutdown(); } else { vB_Shutdown::instance()->shutdown(); } }
/** This sets the db. It will normally be call in the boot process * * @param array config array ***/ public static function init(&$config) { //currently mysqli is handled by the mysql class if ($config['Database']['dbtype'] == 'mysqli') { self::$dbtype = 'MYSQL'; } else { self::$dbtype = strtoupper($config['Database']['dbtype']); } $class = 'vB_dB_' . self::$dbtype . '_Assertor'; if (class_exists($class)) { self::$instance = new $class($config); } vB_Shutdown::instance()->add(array(self::$instance, 'executeShutdownQueries')); }
/** * Returns an instance of the global cache. * The cache type used is defined in options. * * @return vB_Cache - Reference to instance of the cache handler */ public static function instance($type = self::CACHE_STD) { $DEFAULTS_CACHETYPE = self::getDefaults(); $vb5_config =& vB::getConfig(); if (!empty($vb5_config['Misc']['debug']) and !empty($_REQUEST['nocache'])) { self::$disableCache = 1; } if (!isset(self::$instance[$type])) { if (!isset($vb5_config['Cache']) or !isset($vb5_config['Cache']['class']) or !is_array($vb5_config['Cache']['class']) or !isset($vb5_config['Cache']['class'][$type])) { $cacheClass = $DEFAULTS_CACHETYPE[$type]; } else { $cacheClass = $vb5_config['Cache']['class'][$type]; } // if more than 1 of the 3 types (STD, FAST, LARGE) are using the same implementation, // don't create a new instance, just share the same one. foreach (array(self::CACHE_STD, self::CACHE_FAST, self::CACHE_LARGE) as $cacheType) { if (!empty(self::$instance[$cacheType]) and is_a(self::$instance[$cacheType], $cacheClass)) { self::$instance[$type] = self::$instance[$cacheType]; return self::$instance[$type]; } } // call constructor directly. Having static functions with the same name but different // semantics in the subclasses works, but its tacky. self::$instance[$type] = new $cacheClass($type); //call_user_func(array($cacheClass, 'instance')); vB_Shutdown::instance()->add(array(self::$instance[$type], 'shutdown')); } return self::$instance[$type]; }