Example #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;
 }
Example #2
0
 public static function Reload()
 {
     // unset(self::$cfg);
     self::$cfg = simplexml_load_file(EasyConfig_PATH . '/EasySCP_Config.xml');
 }
Example #3
0
function EasySCP_main_configuration_file()
{
    $xml = simplexml_load_file(DaemonConfig::$cfg->{'ROOT_DIR'} . '/../setup/config.xml');
    DaemonConfig::$cfg->{'BuildDate'} = '20160122';
    DaemonConfig::$cfg->{'Version'} = '2.1.0';
    DaemonConfig::$cfg->{'DistName'} = $xml->{'DistName'};
    DaemonConfig::$cfg->{'DistVersion'} = $xml->{'DistVersion'};
    DaemonConfig::$cfg->{'DEFAULT_ADMIN_ADDRESS'} = $xml->{'PANEL_MAIL'};
    DaemonConfig::$cfg->{'SERVER_HOSTNAME'} = $xml->{'HOST_FQHN'};
    DaemonConfig::$cfg->{'BASE_SERVER_IP'} = $xml->{'HOST_IP'};
    DaemonConfig::$cfg->{'BASE_SERVER_IPv6'} = $xml->{'HOST_IPv6'};
    DaemonConfig::$cfg->{'BASE_SERVER_VHOST'} = $xml->{'HOST_NAME'};
    DaemonConfig::$cfg->{'DATABASE_HOST'} = $xml->{'DB_HOST'};
    DaemonConfig::$cfg->{'DATABASE_NAME'} = $xml->{'DB_DATABASE'};
    if (extension_loaded('mcrypt')) {
        $td = @mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_CBC, '');
        // Initialize encryption
        @mcrypt_generic_init($td, $xml->{'DB_KEY'}, $xml->{'DB_IV'});
        // Encrypt string
        $encrypted = @mcrypt_generic($td, $xml->{'DB_PASSWORD'});
        @mcrypt_generic_deinit($td);
        @mcrypt_module_close($td);
        DaemonConfig::$cfg->{'DATABASE_PASSWORD'} = @base64_encode($encrypted);
    } else {
        throw new Exception('Error: PHP extension "mcrypt" not loaded!');
    }
    DaemonConfig::$cfg->{'DATABASE_USER'} = $xml->{'DB_USER'};
    DaemonConfig::$cfg->{'PHP_TIMEZONE'} = $xml->{'Timezone'};
    DaemonConfig::$cfg->{'SECONDARY_DNS'} = $xml->{'Secondary_DNS'};
    if ($xml->{'LocalNS'} == '_yes_') {
        DaemonConfig::$cfg->{'LOCAL_DNS_RESOLVER'} = 'yes';
    } else {
        DaemonConfig::$cfg->{'LOCAL_DNS_RESOLVER'} = 'no';
    }
    if ($xml->{'MySQL_Prefix'} != 'none') {
        DaemonConfig::$cfg->{'MYSQL_PREFIX'} = 'yes';
        DaemonConfig::$cfg->{'MYSQL_PREFIX_TYPE'} = $xml->{'MySQL_Prefix'};
    }
    unset($xml);
    DaemonConfig::Save();
    switch (DaemonConfig::$cfg->{'DistName'}) {
        case 'Debian':
            DaemonConfig::$cfg->{'MTA_SSL_STATUS'} = 1;
            break;
        default:
            DaemonConfig::$cfg->{'MTA_SSL_STATUS'} = 0;
    }
    DaemonConfig::Save();
    return DaemonConfig::SaveOldConfig();
    // return 'Ok';
}