예제 #1
0
 /**
  *
  */
 public function installDbAction()
 {
     $this->setClientFolder($this->getRequestArg('folder', null, true));
     $lsDbPath = 'config' . DS . 'db.php';
     $laDbClientConf = (require $this->_sClientPath . DS . $lsDbPath);
     $lsDbDriver = $this->getRequestArg('driver', $laDbClientConf['production']['driver']);
     $lsDbCharset = $this->getRequestArg('charset', $laDbClientConf['production']['charset']);
     $lsDbHost = $this->getRequestArg('host', $laDbClientConf['production']['hostname']);
     $lsDbPort = $this->getRequestArg('port', $laDbClientConf['production']['port']);
     $lsDbUser = $this->getRequestArg('user', $laDbClientConf['production']['username']);
     $lsDbPass = $this->getRequestArg('pass', $laDbClientConf['production']['password']);
     $lsDbName = $this->getRequestArg('dbname', $laDbClientConf['production']['database'], true);
     $laDbConf = array('driver' => $lsDbDriver, 'charset' => $lsDbCharset, 'hostname' => $lsDbHost, 'port' => $lsDbPort, 'username' => $lsDbUser, 'password' => $lsDbPass);
     $this->_aRepository['newDb'] = new InstallRepository($laDbConf);
     if ($this->_aRepository['newDb']->connect()) {
         if (!$this->_aRepository['newDb']->checkDb($lsDbName)) {
             if (System::confirm("The database [{$lsDbName}] does not exists! Create a new database useing dbname [{$lsDbName}]?")) {
                 if ($this->_aRepository['newDb']->createDb($lsDbName)) {
                     $laDbConf['database'] = $lsDbName;
                 } else {
                     System::echoError($this->_aRepository['newDb']->getErrorMsg());
                     return;
                 }
             } else {
                 System::echoWarning("You need a database to continue. Aborting proccess!");
                 return;
             }
         } elseif (System::confirm("The database [{$lsDbName}] already exists! Confirm use this database?")) {
             $laDbConf['database'] = $lsDbName;
         } else {
             System::echoWarning("You need a database to continue. Aborting proccess!");
             return;
         }
     } else {
         System::echoError($this->_aRepository['newDb']->getErrorMsg());
         return;
     }
     echo "Select a database type:\n";
     echo "[1] onion-base (default)\n";
     echo "[2] onion-full\n";
     echo "[3] onion-parking\n";
     echo "[4] onion-service\n";
     echo "[5] onion-telmsg\n";
     $lsAnswer = System::prompt("Option:");
     switch ($lsAnswer) {
         case "2":
             $lsDbFile = "onion-full.sql";
             break;
         case "3":
             $lsDbFile = "onion-parking.sql";
             break;
         case "4":
             $lsDbFile = "onion-service.sql";
             break;
         case "5":
             $lsDbFile = "onion-telmsg.sql";
             break;
         default:
             $lsDbFile = "onion-base.sql";
     }
     $lsDbBase = System::localRequest($this->_sDbPath . DS . $lsDbFile);
     $this->_aRepository['newDb']->setDbConf($laDbConf);
     if (!$this->_aRepository['newDb']->importDb($lsDbBase)) {
         System::echoError($this->_aRepository['newDb']->getErrorMsg());
     } else {
         System::echoSuccess("Success in configure database!");
     }
     $this->confDbAction($laDbConf);
 }
예제 #2
0
 /**
  * 
  */
 public function newClientAction()
 {
     $this->setClientFolder($this->getRequestArg('folder', "onionapp.com"));
     $this->setModuleName($this->getRequestArg('service', "index"));
     $lsPathClient = $this->_sClientPath;
     $this->createDir($lsPathClient);
     if (file_exists($lsPathClient)) {
         $lsFileLicense = $this->getLicense($this->_sClientFolder);
         $this->saveFile($lsPathClient, 'onionsrv', $lsFileLicense);
         $lsPathConfig = $lsPathClient . DS . 'config';
         $this->createDir($lsPathConfig);
         $this->saveFile($lsPathConfig, 'srv-config');
         $this->saveFile($lsPathConfig, 'srv-module');
         $this->saveFile($lsPathConfig, 'srv-service');
         $this->saveFile($lsPathConfig, 'srv-validate');
         $lsPathData = $lsPathClient . DS . 'data';
         $this->createDir($lsPathData, true, 0777);
         $lsPathDataLogs = $lsPathData . DS . 'logs';
         $this->createDir($lsPathDataLogs, true, 0777);
         $lsPathLayout = $lsPathClient . DS . 'layout';
         $this->createDir($lsPathLayout);
         $lsPathLayoutTheme = $lsPathLayout . DS . 'theme';
         $this->createDir($lsPathLayoutTheme);
         $lsPathLayoutTemplate = $lsPathLayout . DS . 'template';
         $this->createDir($lsPathLayoutTemplate);
         $lsPathPublic = $lsPathClient . DS . 'srv-public';
         $this->createDir($lsPathPublic, false);
         $this->saveFile($lsPathPublic, 'index', $lsFileLicense);
         $this->saveFile($lsPathPublic, 'htaccess');
         $this->saveFile($lsPathPublic, 'robots');
         $this->saveFile($lsPathPublic, 'sitemap');
         $lsPathPublicCss = $lsPathPublic . DS . 'css';
         $this->createDir($lsPathPublicCss);
         $lsPathPublicFonts = $lsPathPublic . DS . 'fonts';
         $this->createDir($lsPathPublicFonts);
         $lsPathPublicImg = $lsPathPublic . DS . 'img';
         $this->createDir($lsPathPublicImg);
         $lsPathPublicJs = $lsPathPublic . DS . 'js';
         $this->createDir($lsPathPublicJs);
         $lsPathService = $lsPathClient . DS . 'service';
         $this->createDir($lsPathService);
     }
     if ($this->_sModuleName == null) {
         $this->setModuleName("Index");
     }
     $this->newServiceAction();
     if (System::confirm("Configure Apache 2 virtual host for dev environment? (You need to have root access!)")) {
         $this->_sAction = "virtualHostDev";
         $this->virtualHostDevAction();
     } else {
         $this->showVHostConfAction();
     }
 }
예제 #3
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.");
     }
 }