/** * init setup framework */ public static function initFramework() { Setup_Core::setupConfig(); Setup_Core::setupTempDir(); //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::setupBuildConstants(); // 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(Tinebase_Core::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; }
/** * check config and return status * * @return array * * @todo add check if db settings have changed? */ public function checkConfig() { // check first if db settings have changed? //if (!Setup_Core::get(Setup_Core::CHECKDB)) Setup_Core::setupDatabaseConnection(); $checkDB = Setup_Core::get(Setup_Core::CHECKDB); $result = array('configExists' => Setup_Core::configFileExists(), 'configWritable' => Setup_Core::configFileWritable(), 'checkDB' => $checkDB, 'checkLogger' => $this->_controller->checkConfigLogger(), 'checkCaching' => $this->_controller->checkConfigCaching(), 'checkTmpDir' => $this->_controller->checkDir('tmpdir'), 'checkSessionDir' => $this->_controller->checkDir('path', 'session'), 'checkFilesDir' => $this->_controller->checkDir('filesdir'), 'setupRequired' => empty($checkDB) ? TRUE : $this->_controller->setupRequired()); return $result; }
/** * check config and return status * * @return array * * @todo add check if db settings have changed? */ public function checkConfig() { Setup_Core::setupDatabaseConnection(); $checkDB = Setup_Core::get(Setup_Core::CHECKDB); $result = array('configExists' => Setup_Core::configFileExists(), 'configWritable' => Setup_Core::configFileWritable(), 'checkDB' => $checkDB, 'checkLogger' => $this->_controller->checkConfigLogger(), 'checkCaching' => $this->_controller->checkConfigCaching(), 'checkQueue' => $this->_controller->checkConfigQueue(), 'checkTmpDir' => $this->_controller->checkDir('tmpdir'), 'checkSession' => $this->_controller->checkConfigSession(), 'checkFilesDir' => $this->_controller->checkDir('filesdir'), 'setupRequired' => empty($checkDB) ? TRUE : $this->_controller->setupRequired()); return $result; }