Exemple #1
0
function GUI_RoundCube()
{
    $cubeUser = '******';
    $cubeUserPwd = DaemonCommon::generatePassword(18);
    $cubeDBHost = idn_to_ascii(DaemonConfig::$cfg->{'DATABASE_HOST'});
    $rc = simplexml_load_file(DaemonConfig::$cfg->{'CONF_DIR'} . '/tpl/EasySCP_Config_RC.xml');
    System_Daemon::debug('Building the new roundcube config file');
    $rc->{'CUBE_USER'} = $cubeUser;
    $rc->{'CUBE_PASS'} = DB::encrypt_data($cubeUserPwd);
    $rc->{'DATABASE_HOST'} = $cubeDBHost;
    $handle = fopen(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_RC.xml', "wb");
    fwrite($handle, $rc->asXML());
    fclose($handle);
    DaemonCommon::systemSetFilePermissions(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_RC.xml', DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0640);
    DaemonConfigTools::SaveRCConfig();
    $sql_param = array(':CUBE_USER' => $cubeUser, ':CUBE_PASS' => $cubeUserPwd, ':HOSTNAME' => $cubeDBHost);
    $sql_query = "\n\t\tGRANT ALL PRIVILEGES ON roundcubemail.* TO :CUBE_USER@:HOSTNAME IDENTIFIED BY :CUBE_PASS;\n\t\tFLUSH PRIVILEGES;\n\t";
    DB::prepare($sql_query);
    DB::execute($sql_param)->closeCursor();
    return 'Ok';
}
 /**
  * @param string $config
  * @return mixed
  */
 public static function rebuildConfigPass($config = 'system')
 {
     System_Daemon::debug('Starting "DaemonConfigCommon::rebuildConfigPass" subprocess.');
     switch ($config) {
         case 'DNS':
             System_Daemon::debug('Starting "DNS" subprocess.');
             $SavePDNSConfig = DaemonConfigDNS::SavePDNSConfig();
             if ($SavePDNSConfig !== true) {
                 return $SavePDNSConfig;
             }
             System_Daemon::debug('Finished "DNS" subprocess.');
             break;
         case 'FTP':
             System_Daemon::debug('Starting "FTP" subprocess.');
             $SaveProFTPdConfig = DaemonConfigFTP::SaveProFTPdConfig();
             if ($SaveProFTPdConfig !== true) {
                 return $SaveProFTPdConfig;
             }
             System_Daemon::debug('Finished "FTP" subprocess.');
             break;
         case 'MTA':
             System_Daemon::debug('Starting "MTA" subprocess.');
             $SaveMTAConfig = DaemonConfigMail::SaveMTAConfig();
             if ($SaveMTAConfig !== true) {
                 return $SaveMTAConfig;
             }
             System_Daemon::debug('Finished "MTA" subprocess.');
             break;
         case 'PMA':
             System_Daemon::debug('Starting "PMA" subprocess.');
             DaemonConfigTools::SavePMAConfig();
             System_Daemon::debug('Finished "PMA" subprocess.');
             break;
         case 'RC':
             System_Daemon::debug('Starting "RC" subprocess.');
             DaemonConfigTools::SaveRCConfig();
             System_Daemon::debug('Finished "RC" subprocess.');
             break;
         case 'system':
             System_Daemon::debug('Starting "system" subprocess.');
             $SavePDNSConfig = DaemonConfigDNS::SavePDNSConfig();
             if ($SavePDNSConfig !== true) {
                 return $SavePDNSConfig;
             }
             $SaveProFTPdConfig = DaemonConfigFTP::SaveProFTPdConfig();
             if ($SaveProFTPdConfig !== true) {
                 return $SaveProFTPdConfig;
             }
             $SaveMTAConfig = DaemonConfigMail::SaveMTAConfig();
             if ($SaveMTAConfig !== true) {
                 return $SaveMTAConfig;
             }
             System_Daemon::debug('Finished "system" subprocess.');
             break;
         default:
             System_Daemon::warning("Don't know what to do with " . $config);
             return false;
     }
     System_Daemon::debug('Finished "DaemonConfigCommon::rebuildConfigPass" subprocess.');
     return true;
 }