Exemplo n.º 1
0
 /**
  * Handles DaemonCore requests.
  *
  * @param string $Input
  * @return boolean
  */
 public static function Start($Input)
 {
     System_Daemon::debug('Starting "DaemonCore::Start" subprocess.');
     $retVal = null;
     $Input = explode(" ", $Input, 2);
     switch ($Input[0]) {
         case 'checkAll':
             $retVal = self::checkAllData();
             break;
         case 'Restart':
             System_Daemon::info('Running Restart subprocess.');
             SocketHandler::Close();
             System_Daemon::restart();
             break;
         case 'SaveConfig':
             System_Daemon::debug('Running SaveConfig subprocess.');
             if (isset($Input[1]) && is_array($Input[1])) {
                 foreach (json_decode(trim($Input[1])) as $name => $wert) {
                     if (isset(DaemonConfig::$cfg->{$name})) {
                         DaemonConfig::$cfg->{$name} = $wert;
                     }
                 }
             }
             DaemonConfig::Save();
             DaemonConfig::SaveOldConfig();
             System_Daemon::debug('Finished SaveConfig subprocess.');
             $retVal = true;
             break;
         case 'Setup':
             if (file_exists(dirname(__FILE__) . '/DaemonCoreSetup.php')) {
                 require_once dirname(__FILE__) . '/DaemonCoreSetup.php';
                 if (isset($Input[1]) && $Input[1] != '') {
                     $retVal = Setup($Input[1]);
                 }
             } else {
                 $retVal = false;
             }
             break;
         default:
             System_Daemon::warning("Don't know what to do with " . $Input[0]);
             $retVal = false;
             break;
     }
     System_Daemon::debug('Finished "DaemonCore::Start" subprocess.');
     return $retVal;
 }