Example #1
0
 /**
  * 
  */
 public function showVHostConfAction()
 {
     $lsDomain = "local.project-name";
     $lsDocumentRoot = "/var/www/path/to/the/client/public";
     $lsVirtualHost = $this->vHost($lsDocumentRoot, $lsDomain);
     $lsAppFolder = "/foo/bar/application/folder";
     $loHelp = new Help();
     $loHelp->clear();
     $loHelp->set("        *** m3uzz OnionSrv - Version: " . $loHelp::VERSION . " ***        ", $loHelp::PURPLE, $loHelp::BGBLACK);
     $loHelp->set("\n");
     $loHelp->set("AUTHOR:  Humberto Lourenço <*****@*****.**>             ", $loHelp::CYAN, $loHelp::BGBLACK);
     $loHelp->set("\n");
     $loHelp->set("LINK:    http://github.com/m3uzz/onionsrv                ", $loHelp::CYAN, $loHelp::BGBLACK);
     $loHelp->set("\n");
     $loHelp->set("LICENCE: http://www.opensource.org/licenses/BSD-3-Clause ", $loHelp::CYAN, $loHelp::BGBLACK);
     $loHelp->set("\n\n");
     $loHelp->set("    **** Apache 2.2 - Config development environment ****    \n", $loHelp::BROWN, "", $loHelp::B);
     $loHelp->setTopic("STEP 1:");
     $loHelp->setLine("DocumentRoot", "Move or create a link of the application to the Apache document root (Linux default is /var/www)");
     $loHelp->setLine("Moving", "\$ sudo mv {$lsAppFolder} /var/www/");
     $loHelp->setLine("Or");
     $loHelp->setLine("Simblink", "\$ sudo ln -s {$lsAppFolder} /var/www/");
     $loHelp->setTopic("STEP 2:");
     $loHelp->setLine("CHMOD project", "\$ sudo chmod 755 {$lsAppFolder} -R");
     $loHelp->setLine("CHGPR project", "\$ sudo chgrp www-data {$lsAppFolder} -R");
     $loHelp->setTopic("STEP 3:");
     $loHelp->setLine("Set hosts file", "\$ sudo echo 127.0.0.1\t{$lsDomain} >> /etc/hosts");
     $loHelp->setTopic("STEP 4:");
     $loHelp->setLine("Edit a new vhost", "\$ sudo vi /etc/apache2/sites-available/{$lsDomain}.conf");
     $loHelp->setLine("Copy, paste & edit", $lsVirtualHost);
     $loHelp->setTopic("STEP 5:");
     $loHelp->setLine("Active in sites-enable", '$ sudo a2ensite {$lsDomain}');
     $loHelp->setTopic("STEP 6:");
     $loHelp->setLine("Reload Apache2", "\$ sudo /etc/init.d/apache2 reload");
     $loHelp->display();
 }
Example #2
0
 /**
  * 
  * @param string $psVar
  * @param string $pmDefault
  * @param bool $pbRequired
  * @return string
  */
 public function getRequestArg($psVar, $pmDefault = null, $pbRequired = false)
 {
     if (isset($this->_aParams['ARG'][$psVar])) {
         return $this->_aParams['ARG'][$psVar];
     } else {
         if (PHP_SAPI == "cli" && PROMPT) {
             $lsMsgHelp = "";
             $lsMsgHelpSeparate = "";
             $loHelp = new Help();
             $loHelp->factory($this->_sConfigPath);
             $lsVarHelp = $loHelp->getParamHelp($this->_sModule, $this->_sController, $this->_sAction, $psVar);
             if (!empty($lsVarHelp)) {
                 $lsMsgHelp = $lsVarHelp;
                 $lsMsgHelpSeparate = ". ";
             }
             if ($pmDefault != null) {
                 $lsMsgHelp .= "{$lsMsgHelpSeparate}Default: ({$pmDefault})";
                 $lsMsgHelpSeparate = ". ";
             }
             if ($pbRequired) {
                 $lsMsgHelp .= "{$lsMsgHelpSeparate}[required]";
             }
             if (!empty($lsMsgHelp)) {
                 echo "{$lsMsgHelp}\n";
             }
             $lsAnswer = System::prompt("Enter param [{$psVar}]:");
             if ($this->validateValue($psVar, $lsAnswer, 'ARG')) {
                 $this->_aParams['ARG'][$psVar] = $lsAnswer;
                 if (!empty($lsAnswer)) {
                     return $lsAnswer;
                 } elseif (!empty($pmDefault)) {
                     $this->_aParams['ARG'][$psVar] = $pmDefault;
                     return $pmDefault;
                 } elseif (!$pbRequired) {
                     return null;
                 } else {
                     System::echoError("The param value is required to continue!");
                     System::echoError("Try --help!");
                     System::exitError("ABORTING SCRIPT EXECUTION!");
                 }
             } else {
                 if (empty($lsAnswer) && !empty($pmDefault)) {
                     $this->_aParams['ARG'][$psVar] = $pmDefault;
                     return $pmDefault;
                 } elseif (empty($lsAnswer) && empty($pmDefault) && !$pbRequired) {
                     return null;
                 } else {
                     System::echoError("The param value do not match to the expected!");
                     System::echoError("Try --help!");
                     System::exitError("ABORTING SCRIPT EXECUTION!");
                 }
             }
         } else {
             return $pmDefault;
         }
     }
 }
Example #3
0
 /**
  * 
  * @param string $psService
  * @param string $psClass
  * @param string $psMethod
  * @param array $paParams
  * @return string
  */
 private static function run(array $paService, array $paParams)
 {
     global $gbHelp;
     //Verificando se o service existe
     if (file_exists($paService['service'])) {
         //Carregando o service
         include_once $paService['service'];
         //Verificando se a classe existe
         if (class_exists($paService['class'])) {
             //Criando o objeto da classe
             $loObj = new $paService['class']($paParams, $paService);
             if (is_object($loObj) && $loObj->_bHelp) {
                 return;
             }
             //Verificando se o objeto foi criado e se o metodo existe
             if (is_object($loObj) && method_exists($loObj, $paService['method'])) {
                 //Executando o metodo
                 $lmView = $loObj->{$paService}['method']();
                 if (method_exists($loObj, 'lineView')) {
                     $loObj->lineView($lmView);
                 }
             } else {
                 //Se o metodo não foi encontrado
                 System::exitError("Method not found!");
             }
         } else {
             //Se a classe não foi encontrada
             System::exitError("Class not found!");
         }
     } else {
         $loHelp = new Help();
         $loHelp->factory(dirname(dirname(dirname(dirname($paService['service'])))) . DS . 'config');
         $loHelp->setModuleHelp($loHelp->getModuleHelp($paService['module']));
         $loHelp->display();
     }
 }