Exemplo n.º 1
0
 /**
  *
  */
 public function layoutDistAction()
 {
     $lsDependency = System::localRequest(BASE_DIR . DS . "layout" . DS . "layout.json");
     $laDependency = json_decode($lsDependency, true);
     Debug::debug($laDependency);
     if (isset($laDependency['dist']) && is_array($laDependency['dist'])) {
         System::createDir($this->_sLayoutVendor);
         foreach ($laDependency['dist'] as $lsPackage => $lsDist) {
             $laPackage = explode("/", $lsPackage);
             $lsPackageDir = $this->_sLayoutVendor . DS . $laPackage[0];
             System::createDir($lsPackageDir);
             if (is_dir($lsPackageDir)) {
                 chdir($lsPackageDir);
                 echo "Getting {$lsDist}\n";
                 System::execute("wget {$lsDist}");
                 $laDist = parse_url($lsDist);
                 $laPath = explode("/", $laDist['path']);
                 $lsGzFile = $laPath[count($laPath) - 1];
                 $lsGzFilePath = $lsPackageDir . DS . $lsGzFile;
                 if (is_file($lsGzFilePath)) {
                     if (preg_match("/.zip\$/", $lsGzFile)) {
                         System::execute("unzip {$lsGzFile}");
                     } elseif (preg_match("/.tar.gz\$/", $lsGzFile)) {
                         System::execute("tar -xzf {$lsGzFile}");
                     }
                     System::removeFile($lsGzFile);
                 }
             }
         }
     }
 }
Exemplo n.º 2
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.");
     }
 }