Exemplo n.º 1
0
 public function testGetConfigFilePath()
 {
     $configFilePath = Setup_Core::getConfigFilePath();
     $this->assertTrue(file_exists($configFilePath));
     //        rename($configFilePath, $configFilePath.'.phpunit');
     //        var_dump(Setup_Core::getConfigFilePath());
     //        $this->assertNull(Setup_Core::getConfigFilePath());
     //        rename($configFilePath.'.phpunit', $configFilePath);
 }
 /**
  * nagios monitoring for tine 2.0 config file
  * 
  * @return integer
  * @see http://nagiosplug.sourceforge.net/developer-guidelines.html#PLUGOUTPUT
  */
 public function monitoringCheckConfig()
 {
     $message = 'CONFIG FAIL';
     $configcheck = FALSE;
     $configfile = Setup_Core::getConfigFilePath();
     if ($configfile) {
         $configfile = escapeshellcmd($configfile);
         if (preg_match('/^win/i', PHP_OS)) {
             exec("php -l {$configfile} 2> NUL", $error, $code);
         } else {
             exec("php -l {$configfile} 2> /dev/null", $error, $code);
         }
         if ($code == 0) {
             $configcheck = TRUE;
         } else {
             $message .= ': CONFIG FILE SYNTAX ERROR';
         }
     } else {
         $message .= ': CONFIG FILE MISSING';
     }
     if ($configcheck) {
         echo "CONFIG FILE OK\n";
         return 0;
     } else {
         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);
     }
 }