/** * */ public function clearDir($psPackageReleaseDir) { chdir($psPackageReleaseDir); if (is_dir($psPackageReleaseDir . DS . "dist")) { $loDir = dir($psPackageReleaseDir); while (false !== ($lsResource = $loDir->read())) { Debug::debug($lsResource); if ($lsResource != 'dist' && $lsResource != 'lang' && $lsResource != '.' && $lsResource != '..') { if (is_dir($loDir->path . DS . $lsResource)) { System::removeDir($loDir->path . DS . $lsResource); } else { System::removeFile($loDir->path . DS . $lsResource); } } } $loDir->close(); } else { $loDir = dir($psPackageReleaseDir); $lsDependency = System::localRequest(BASE_DIR . DS . "layout" . DS . "layout.json"); $laDependency = json_decode($lsDependency, true); Debug::debug($laDependency); if (isset($laDependency['ignore'])) { $laPatern = $laDependency['ignore']; } else { $laPatern = array("^dev", "^src", "^build", "^external", "^test", "^log", "^error", "^task", "^extra", "^script", "^meteor", "^template", "^sample", "^example", "^demo", "^doc", "\\.json\$", "\\.md\$", "\\.txt\$", "\\.rb\$", "\\.yml\$", "\\.xml\$", "\\.html\$", "\\.htm\$", "\\.sh\$", "gruntfile.js", "^\\."); } while (false !== ($lsResource = $loDir->read())) { Debug::debug($lsResource); if ($lsResource != 'dist' && $lsResource != 'lang' && $lsResource != '.' && $lsResource != '..') { foreach ($laPatern as $lsPatern) { if (preg_match("/{$lsPatern}/i", $lsResource)) { if (is_dir($loDir->path . DS . $lsResource)) { System::removeDir($loDir->path . DS . $lsResource); } else { System::removeFile($loDir->path . DS . $lsResource); } } } } } $loDir->close(); } }
/** * */ 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."); } }