/** * init setup framework */ public static function initFramework() { Setup_Core::setupConfig(); Setup_Core::setupTempDir(); // Server Timezone must be setup before logger, as logger has timehandling! Setup_Core::setupServerTimezone(); Setup_Core::setupLogger(); //Database Connection must be setup before cache because setupCache uses constant "SQL_TABLE_PREFIX" Setup_Core::setupDatabaseConnection(); Setup_Core::setupStreamWrapper(); //Cache must be setup before User Locale because otherwise Zend_Locale tries to setup //its own cache handler which might result in a open_basedir restriction depending on the php.ini settings Setup_Core::setupCache(); Setup_Core::setupSession(); // setup a temporary user locale/timezone. This will be overwritten later but we // need to handle exceptions during initialisation process such as seesion timeout Setup_Core::set('locale', new Zend_Locale('en_US')); Setup_Core::set('userTimeZone', 'UTC'); Setup_Core::setupUserLocale(); header('X-API: http://www.tine20.org/apidocs/tine20/'); }
/** * nagios monitoring for tine 2.0 database connection * * @return integer * @see http://nagiosplug.sourceforge.net/developer-guidelines.html#PLUGOUTPUT */ public function monitoringCheckDB() { $message = 'DB CONNECTION FAIL'; try { if (!Setup_Core::isRegistered(Setup_Core::CONFIG)) { Setup_Core::setupConfig(); } if (!Setup_Core::isRegistered(Setup_Core::LOGGER)) { Setup_Core::setupLogger(); } $time_start = microtime(true); $dbcheck = Setup_Core::setupDatabaseConnection(); $time = (microtime(true) - $time_start) * 1000; } catch (Exception $e) { $message .= ': ' . $e->getMessage(); $dbcheck = FALSE; } if ($dbcheck) { echo "DB CONNECTION OK | connecttime={$time}ms;;;;\n"; return 0; } echo $message . "\n"; return 2; }
/** * save data to config file * * @param array $_data * @param boolean $_merge */ public function saveConfigData($_data, $_merge = TRUE) { if (!empty($_data['setupuser']['password']) && !Setup_Auth::isMd5($_data['setupuser']['password'])) { $password = $_data['setupuser']['password']; $_data['setupuser']['password'] = md5($_data['setupuser']['password']); } if (Setup_Core::configFileExists() && !Setup_Core::configFileWritable()) { throw new Setup_Exception('Config File is not writeable.'); } if (Setup_Core::configFileExists()) { $doLogin = FALSE; $filename = Setup_Core::getConfigFilePath(); } else { $doLogin = TRUE; $filename = dirname(__FILE__) . '/../config.inc.php'; } $config = $this->writeConfigToFile($_data, $_merge, $filename); Setup_Core::set(Setup_Core::CONFIG, $config); Setup_Core::setupLogger(); if ($doLogin && isset($password)) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Create session for setup user ' . $_data['setupuser']['username']); $this->login($_data['setupuser']['username'], $password); } }