<?php if (version_compare(PHP_VERSION, "5.1.2", "<")) { die("This application requires PHP 5.1.2 or later."); } @set_time_limit(3600); require '../framework.config.php'; require_once DEVBLOCKS_PATH . 'Devblocks.class.php'; require_once APP_PATH . '/api/Application.class.php'; require_once APP_PATH . '/install/classes.php'; DevblocksPlatform::getCacheService()->clean(); // DevblocksPlatform::init() workaround if (!defined('DEVBLOCKS_WEBPATH')) { $php_self = $_SERVER["PHP_SELF"]; $php_self = str_replace('/install', '', $php_self); $pos = strrpos($php_self, '/'); $php_self = substr($php_self, 0, $pos) . '/'; @define('DEVBLOCKS_WEBPATH', $php_self); } define('STEP_ENVIRONMENT', 1); define('STEP_DATABASE', 2); define('STEP_SAVE_CONFIG_FILE', 3); define('STEP_INIT_DB', 4); define('STEP_FINISHED', 5); define('TOTAL_STEPS', 5); // Import GPC variables to determine our scope/step. @($step = DevblocksPlatform::importGPC($_REQUEST['step'], 'integer')); /* * [TODO] We can run some quick tests to bypass steps we've already passed * even when returning to the page with a NULL step. */
private function __construct() { $cache = DevblocksPlatform::getCacheService(); if (null !== ($map = $cache->load(self::CACHE_CLASS_MAP))) { $this->classMap = $map; } else { $this->_initLibs(); $this->_initPlugins(); $cache->save($this->classMap, self::CACHE_CLASS_MAP); } }
public function set($key, $value) { DAO_Setting::set($key, $value); $this->settings[$key] = $value; $cache = DevblocksPlatform::getCacheService(); $cache->remove(CerberusApplication::CACHE_SETTINGS_DAO); // Nuke sender cache if ($key == self::DEFAULT_REPLY_FROM) { $cache->remove(CerberusApplication::CACHE_HELPDESK_FROMS); } return TRUE; }
static function set($tool_code, $key, $value) { $db = DevblocksPlatform::getDatabaseService(); $db->Replace('community_tool_property', array(self::TOOL_CODE => $db->qstr($tool_code), self::PROPERTY_KEY => $db->qstr($key), self::PROPERTY_VALUE => $db->qstr($value)), array(self::TOOL_CODE, self::PROPERTY_KEY), false); // Invalidate cache $cache = DevblocksPlatform::getCacheService(); $cache->remove(self::_CACHE_PREFIX . $tool_code); }
static function getSettings() { $cache = DevblocksPlatform::getCacheService(); if (false === ($settings = $cache->load(Application::CACHE_SETTINGS_DAO))) { $db = DevblocksPlatform::getDatabaseService(); $settings = array(); $sql = sprintf("SELECT setting,value FROM setting"); $rs = $db->Execute($sql) or die(__CLASS__ . ':' . $db->ErrorMsg()); /* @var $rs ADORecordSet */ while (!$rs->EOF) { $settings[$rs->Fields('setting')] = $rs->Fields('value'); $rs->MoveNext(); } $cache->save($settings, Application::CACHE_SETTINGS_DAO); } return $settings; }
function handleRequest(DevblocksHttpRequest $request) { @set_time_limit(0); // no timelimit (when possible) $translate = DevblocksPlatform::getTranslationService(); $stack = $request->path; array_shift($stack); // update $cache = DevblocksPlatform::getCacheService(); /* @var $cache _DevblocksCacheManager */ $settings = DevblocksPlatform::getPluginSettingsService(); switch (array_shift($stack)) { case 'locked': if (!DevblocksPlatform::versionConsistencyCheck()) { $url = DevblocksPlatform::getUrlService(); echo "<h1>Cerberus Helpdesk 5.x</h1>"; echo "The helpdesk is currently waiting for an administrator to finish upgrading. " . "Please wait a few minutes and then " . sprintf("<a href='%s'>try again</a>.<br><br>", $url->write('c=update&a=locked')); echo sprintf("If you're an admin you may <a href='%s'>finish the upgrade</a>.", $url->write('c=update')); } else { DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login'))); } break; default: $path = APP_TEMP_PATH . DIRECTORY_SEPARATOR; $file = $path . 'c4update_lock'; $authorized_ips_str = $settings->get('cerberusweb.core', CerberusSettings::AUTHORIZED_IPS); $authorized_ips = DevblocksPlatform::parseCrlfString($authorized_ips_str); $authorized_ip_defaults = DevblocksPlatform::parseCsvString(AUTHORIZED_IPS_DEFAULTS); $authorized_ips = array_merge($authorized_ips, $authorized_ip_defaults); // Is this IP authorized? $pass = false; foreach ($authorized_ips as $ip) { if (substr($ip, 0, strlen($ip)) == substr($_SERVER['REMOTE_ADDR'], 0, strlen($ip))) { $pass = true; break; } } if (!$pass) { echo vsprintf($translate->_('update.ip_unauthorized'), $_SERVER['REMOTE_ADDR']); return; } // Check requirements $errors = CerberusApplication::checkRequirements(); if (!empty($errors)) { echo $translate->_('update.correct_errors'); echo "<ul style='color:red;'>"; foreach ($errors as $error) { echo "<li>" . $error . "</li>"; } echo "</ul>"; exit; } // If authorized, lock and attempt update if (!file_exists($file) || @filectime($file) + 600 < time()) { // 10 min lock touch($file); //echo "Running plugin patches...<br>"; if (DevblocksPlatform::runPluginPatches('core.patches')) { @unlink($file); // [JAS]: Clear all caches $cache->clean(); DevblocksPlatform::getClassLoaderService()->destroy(); // Clear compiled templates $tpl = DevblocksPlatform::getTemplateService(); $tpl->clear_compiled_tpl(); // Reload plugin translations DAO_Translation::reloadPluginStrings(); DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login'))); } else { @unlink($file); echo "Failure!"; // [TODO] Needs elaboration } break; } else { echo $translate->_('update.locked_another'); } } exit; }
public function set($key, $value) { DAO_Setting::set($key, $value); $this->settings[$key] = $value; $cache = DevblocksPlatform::getCacheService(); $cache->remove(Application::CACHE_SETTINGS_DAO); return TRUE; }
function handleRequest(DevblocksHttpRequest $request) { @set_time_limit(0); // no timelimit (when possible) $translate = DevblocksPlatform::getTranslationService(); $stack = $request->path; array_shift($stack); // update $cache = DevblocksPlatform::getCacheService(); /* @var $cache _DevblocksCacheManager */ switch (array_shift($stack)) { case 'locked': if (!DevblocksPlatform::versionConsistencyCheck()) { $url = DevblocksPlatform::getUrlService(); echo "<h1>Feg - Fax Email Gateway 1.x</h1>"; echo "The application is currently waiting for an administrator to finish upgrading. " . "Please wait a few minutes and then " . sprintf("<a href='%s'>try again</a>.<br><br>", $url->write('c=update&a=locked')); echo sprintf("If you're an admin you may <a href='%s'>finish the upgrade</a>.", $url->write('c=update')); } else { DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login'))); } break; default: $path = APP_TEMP_PATH . DIRECTORY_SEPARATOR; $file = $path . 'feg_update_lock'; $settings = DevblocksPlatform::getPluginSettingsService(); $authorized_ips_str = $settings->get('feg.core', FegSettings::AUTHORIZED_IPS); $authorized_ips = DevblocksPlatform::parseCrlfString($authorized_ips_str); $authorized_ip_defaults = DevblocksPlatform::parseCsvString(AUTHORIZED_IPS_DEFAULTS); $authorized_ips = array_merge($authorized_ips, $authorized_ip_defaults); // Is this IP authorized? $pass = false; foreach ($authorized_ips as $ip) { if (substr($ip, 0, strlen($ip)) == substr($_SERVER['REMOTE_ADDR'], 0, strlen($ip))) { $pass = true; break; } } if (!$pass) { echo vsprintf($translate->_('update.ip_unauthorized'), $_SERVER['REMOTE_ADDR']); return; } // Check requirements $errors = FegApplication::checkRequirements(); if (!empty($errors)) { echo $translate->_('update.correct_errors'); echo "<ul style='color:red;'>"; foreach ($errors as $error) { echo "<li>" . $error . "</li>"; } echo "</ul>"; exit; } try { // If authorized, lock and attempt update if (!file_exists($file) || @filectime($file) + 600 < time()) { // 10 min lock // Log everybody out since we're touching the database $session = DevblocksPlatform::getSessionService(); $session->clearAll(); // Lock file touch($file); // Recursive patch FegApplication::update(); // Clean up @unlink($file); $cache = DevblocksPlatform::getCacheService(); $cache->save(APP_BUILD, "devblocks_app_build"); // Clear all caches $cache->clean(); DevblocksPlatform::getClassLoaderService()->destroy(); // Clear compiled templates $tpl = DevblocksPlatform::getTemplateService(); $tpl->utility->clearCompiledTemplate(); $tpl->cache->clearAll(); // Reload plugin translations DAO_Translation::reloadPluginStrings(); // Redirect DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login'))); } else { echo $translate->_('update.locked_another'); } } catch (Exception $e) { unlink($file); die($e->getMessage()); } } exit; }
/** * Checks to see if the application needs to patch * * @return boolean */ static function versionConsistencyCheck() { $cache = DevblocksPlatform::getCacheService(); /* @var Zend_Cache_Core $cache */ if (null === ($build_cache = $cache->load("devblocks_app_build")) || $build_cache != APP_BUILD) { // If build changed, clear cache regardless of patch status // [TODO] We need to find a nicer way to not clear a shared memcached cluster when only one desk needs to $cache = DevblocksPlatform::getCacheService(); /* @var $cache Zend_Cache_Core */ $cache->clean('all'); // Re-read manifests DevblocksPlatform::readPlugins(); if (self::_needsToPatch()) { return false; // the update script will handle new caches } else { $cache->save(APP_BUILD, "devblocks_app_build"); DAO_Translation::reloadPluginStrings(); // reload strings even without DB changes return true; } } return true; }
static function clearCache() { $cache = DevblocksPlatform::getCacheService(); $cache->remove(self::_CACHE_ALL); }
static function clearCache() { $cache = DevblocksPlatform::getCacheService(); $cache->remove(self::CACHE_MACRO_ACTIONS); }
static function clearCountCache($worker_id) { $cache = DevblocksPlatform::getCacheService(); $cache->remove(self::CACHE_COUNT_PREFIX . $worker_id); }
private function _clearCache() { // Reload $cache = DevblocksPlatform::getCacheService(); $langs = DAO_Translation::getDefinedLangCodes(); if (is_array($langs) && !empty($langs)) { foreach ($langs as $lang_code => $lang_name) { $cache->remove(DevblocksPlatform::CACHE_TAG_TRANSLATIONS . '_' . $lang_code); } } }
/** * Checks to see if the application needs to patch * * @return boolean */ static function versionConsistencyCheck() { $cache = self::getCacheService(); /* @var Zend_Cache_Core $cache */ if (null == ($build_cache = $cache->load("devblocks_app_build")) || $build_cache != APP_BUILD) { // If build changed, clear cache regardless of patch status $cache = DevblocksPlatform::getCacheService(); /* @var $cache Zend_Cache_Core */ $cache->clean('all'); if (self::_needsToPatch()) { return false; } else { $cache->save(APP_BUILD, "devblocks_app_build"); return true; } } return true; }
private static function _clearCache() { $cache = DevblocksPlatform::getCacheService(); $cache->remove(DevblocksPlatform::CACHE_STORAGE_PROFILES); }
public static function clearCache() { // Invalidate cache on changes $cache = DevblocksPlatform::getCacheService(); $cache->remove(self::CACHE_ALL); }
private function __construct() { $cache = DevblocksPlatform::getCacheService(); if (false !== ($map = $cache->load(self::CACHE_CLASS_MAP))) { $this->classMap = $map; } else { $this->_initPEAR(); $this->_initLibs(); $this->_initZend(); } }
public static function getHelpdeskSenders() { $cache = DevblocksPlatform::getCacheService(); if (null === ($froms = $cache->load(self::CACHE_HELPDESK_FROMS))) { $froms = array(); $settings = DevblocksPlatform::getPluginSettingsService(); $group_settings = DAO_GroupSettings::getSettings(); // Global sender $from = strtolower($settings->get('cerberusweb.core', CerberusSettings::DEFAULT_REPLY_FROM)); @($froms[$from] = $from); // Group senders if (is_array($group_settings)) { foreach ($group_settings as $group_id => $gs) { @($from = strtolower($gs[DAO_GroupSettings::SETTING_REPLY_FROM])); if (!empty($from)) { @($froms[$from] = $from); } } } asort($froms); $cache->save($froms, self::CACHE_HELPDESK_FROMS); } return $froms; }
static function getSettings($plugin_id = null) { $cache = DevblocksPlatform::getCacheService(); if (null === ($plugin_settings = $cache->load(DevblocksPlatform::CACHE_SETTINGS))) { $db = DevblocksPlatform::getDatabaseService(); $plugin_settings = array(); $sql = sprintf("SELECT plugin_id,setting,value FROM devblocks_setting"); $rs = $db->Execute($sql); /* @var $rs ADORecordSet */ if (is_a($rs, 'ADORecordSet')) { while (!$rs->EOF) { $plugin_id = $rs->Fields('plugin_id'); $k = $rs->Fields('setting'); $v = $rs->Fields('value'); if (!isset($plugin_settings[$plugin_id])) { $plugin_settings[$plugin_id] = array(); } $plugin_settings[$plugin_id][$k] = $v; $rs->MoveNext(); } } if (!empty($plugin_settings)) { $cache->save($plugin_settings, DevblocksPlatform::CACHE_SETTINGS); } } return $plugin_settings; }