Exemplo n.º 1
0
 /**
  * 
  */
 public function uninstallClientAction()
 {
     if ($_SERVER["USER"] == "root") {
         $this->setClientFolder($this->getRequestArg('folder', null, true));
         if ($this->_sController == 'Cms') {
             $lsDbPath = $this->_sClientPath . DS . 'config' . DS . 'db.php';
             $laDbClientConf = (require $lsDbPath);
             $laDbConf = array('driver' => $laDbClientConf['production']['driver'], 'charset' => $laDbClientConf['production']['charset'], 'hostname' => $laDbClientConf['production']['hostname'], 'port' => $laDbClientConf['production']['port'], 'username' => $laDbClientConf['production']['username'], 'password' => $laDbClientConf['production']['password'], 'database' => $laDbClientConf['production']['database']);
         }
         if (System::confirm("Remove client project folder {$this->_sClientFolder}?")) {
             System::removeDir($this->_sClientPath);
         }
         $laApacheConf = $this->getApacheConf();
         if (is_array($laApacheConf)) {
             $lsDocRoot = $laApacheConf['DocumentRoot'] . DS;
             $lsServerRoot = $laApacheConf['ServerRoot'] . DS;
         } else {
             $lsDocRoot = DS . "var" . DS . "www" . DS;
             $lsServerRoot = DS . "etc" . DS . "apache2" . DS;
         }
         if (System::confirm("Remove link from document root?")) {
             $lsDocRoot = $this->getRequestArg('docroot', $lsDocRoot, true);
             $laAppDirName = explode(DS, BASE_DIR);
             $lsAppDirName = array_pop($laAppDirName);
             System::removeSimblink($lsDocRoot . DS . $lsAppDirName);
         }
         if (System::confirm("Remove Apache virtual host?")) {
             $lsDomain = $this->getRequestArg('domain', "local.{$this->_sClientFolder}", true);
             $lsApacheDir = $this->getRequestArg('apachedir', $lsServerRoot);
             $lsSitesAvailablePath = $lsApacheDir . 'sites-available' . DS . "{$lsDomain}.conf";
             $lsSitesEnablePath = $lsApacheDir . 'sites-enabled' . DS . "{$lsDomain}.conf";
             System::removeFile($lsSitesAvailablePath);
             System::removeSimblink($lsSitesEnablePath);
             if (System::confirm("Reload Apache2?")) {
                 echo "Apache reload\n";
                 $laReturn = System::execute(DS . "etc" . DS . "init.d" . DS . "apache2 reload");
                 Debug::debug($laReturn);
             }
         }
         if ($this->_sController == 'Cms' && System::confirm("Drop database?")) {
             $this->_aRepository['db'] = new InstallRepository($laDbConf);
             if ($this->_aRepository['db']->connect()) {
                 if (System::confirm("Confirm drop database {$laDbConf['hostname']}:{$laDbConf['database']}?")) {
                     if (!$this->_aRepository['db']->dropDb($laDbConf['database'])) {
                         System::echoWarning("There is something wrong!");
                         return;
                     }
                 }
             }
         }
     } else {
         System::echoError("You need root access to run this action! Please try run this action using sudo.");
     }
 }