diff --git a/mind3rd/API/L10N/en.php b/mind3rd/API/L10N/en.php index 9c77be5..421af77 100755 --- a/mind3rd/API/L10N/en.php +++ b/mind3rd/API/L10N/en.php @@ -64,6 +64,7 @@ class En implements l10n{ $this->messages['runnintPHPUnit'] = "Please wait...running PHPUnit...\n"; $this->messages['mustBeAdmin'] = Mind::message("API: You must be the admin to perform this action", '[Fail]', false); $this->messages['cannotInstall'] = Mind::message("API: To install a component, you need to change the 'allow_installation' property into mind.ini file, setting it as true", '[Fail]', false); + $this->messages['wrongParam'] = Mind::message("\nMain: The parameter '%s', whose value is '%s', is not valid!", '[Fail]', false); $this->messages['phpunitNotFound'] = "You must specify where to find phpUnit classes\n". "You can configure it on mind3rd/env/mind.ini ini file\n". "changing the phpunit-src ini property\n";; diff --git a/mind3rd/API/L10N/pt.php b/mind3rd/API/L10N/pt.php index 85e075f..c98bb8e 100755 --- a/mind3rd/API/L10N/pt.php +++ b/mind3rd/API/L10N/pt.php @@ -72,6 +72,7 @@ class pt implements l10n{ $this->messages['runnintPHPUnit'] = "Aguarde...executando testes unitários...\n"; $this->messages['mustBeAdmin'] = Mind::message("API: Você precisa ser o administrador para executar esta instrução", '[Fail]', false); $this->messages['cannotInstall'] = Mind::message("API: Para instalar um componente, será preciso alterar a propriedade 'allow_installation' no arquivo mind.ini para true", '[Fail]', false); + $this->messages['wrongParam'] = Mind::message("\nMain: O parâmetro '%s', com valor '%s' é inválido!", '[Fail]', false); $this->messages['phpunitNotFound'] = "Especifique onde encontram-se as classes do PHPUnit\n". "Você pode configurar isto em mind3rd/env/mind.ini ini file\n". "alterando a propriedade phpunit-src\n"; diff --git a/mind3rd/API/facade/Program.php b/mind3rd/API/facade/Program.php index 689e2c8..332abfd 100644 --- a/mind3rd/API/facade/Program.php +++ b/mind3rd/API/facade/Program.php @@ -160,7 +160,13 @@ echo self::getHelp($programName); return; } - $program->$realArgs[$k]= $arg; + + if(!key_exists($k, $realArgs)){ + \Mind::write('wrongParam', true, $k, $arg); + exit; + }else{ + $program->$realArgs[$k]= $arg; + } } if(is_string($program->commandAction)) diff --git a/mind3rd/API/utils.php b/mind3rd/API/utils.php index dadcc11..2f2fdcb 100755 --- a/mind3rd/API/utils.php +++ b/mind3rd/API/utils.php @@ -11,8 +11,20 @@ * @author Felipe Nascimento de Moura * @license licenses/mind3rd.license */ + require(_MINDSRC_.'/mind3rd/API/utils/header.php'); + + if(!Mind::isInstalled()){ + if($_REQ['env']=='shell'){ + echo "You have to install the application!\nTo install it, please run: sudo php mind install"; + }else{ + header('location:setup.php'); + } + exit; + } + include(_MINDSRC_.'/mind3rd/API/utils/constants.php'); + require(_MINDSRC_.'/mind3rd/env/setup/Setup.php'); /** * @global Mind $_MIND This variable contains many information about the proect, the system and also have some methods an attributes to deal with such data @@ -54,9 +66,9 @@ $d->close(); $app->addCommands($programs); \MIND::$programs= $programs; - // starting the application - if($_REQ['env']=='shell') - include('shell.php'); - else - include('http.php'); \ No newline at end of file + if($_REQ['env']=='shell'){ + include('shell.php'); + }else{ + include('http.php'); + } \ No newline at end of file diff --git a/mind3rd/API/utils/header.php b/mind3rd/API/utils/header.php index 2e73874..ccf5465 100755 --- a/mind3rd/API/utils/header.php +++ b/mind3rd/API/utils/header.php @@ -9,77 +9,77 @@ define('_CONSOLE_LINE_LENGTH_', 80); require(_MINDSRC_.'/mind3rd/API/classes/Mind.php'); - if(!Mind::isInstalled()) + if(Mind::isInstalled()) { - //include(_MINDSRC_.'/wizard/installation-1.php'); - exit; - } + Mind::autoloadRegisterPath(Array( + _MINDSRC_.'/mind3rd/API/external/', + _MINDSRC_.'/mind3rd/API/interfaces/', + _MINDSRC_.'/mind3rd/API/programs/', + _MINDSRC_.'/mind3rd/API/L10N/', + _MINDSRC_.'/mind3rd/API/classes/', + _MINDSRC_.'/mind3rd/API/cortex/Lexer/', + _MINDSRC_.'/mind3rd/API/cortex/tokenizer/', + _MINDSRC_.'/mind3rd/API/cortex/canonic/', + _MINDSRC_.'/mind3rd/API/cortex/syntaxer/', + _MINDSRC_.'/mind3rd/API/cortex/analyst/', + _MINDSRC_.'/mind3rd/API/languages/', + _MINDSRC_.'/mind3rd/API/DBMS/', + _MINDSRC_.'/mind3rd/API/Lobe/', + _MINDSRC_.'/mind3rd/API/' + )); - Mind::autoloadRegisterPath(Array( - _MINDSRC_.'/mind3rd/API/external/', - _MINDSRC_.'/mind3rd/API/interfaces/', - _MINDSRC_.'/mind3rd/API/programs/', - _MINDSRC_.'/mind3rd/API/L10N/', - _MINDSRC_.'/mind3rd/API/classes/', - _MINDSRC_.'/mind3rd/API/cortex/Lexer/', - _MINDSRC_.'/mind3rd/API/cortex/tokenizer/', - _MINDSRC_.'/mind3rd/API/cortex/canonic/', - _MINDSRC_.'/mind3rd/API/cortex/syntaxer/', - _MINDSRC_.'/mind3rd/API/cortex/analyst/', - _MINDSRC_.'/mind3rd/API/languages/', - _MINDSRC_.'/mind3rd/API/DBMS/', - _MINDSRC_.'/mind3rd/API/Lobe/', - _MINDSRC_.'/mind3rd/API/' - )); - - function __autoload($what) - { - GLOBAL $_MIND; - $what= preg_replace("/[ '\"\.\/]/", '', $what); - $what= str_replace('\\', '/', $what); - $what= str_replace('.', '', $what); - - if(file_exists(_MINDSRC_.'/mind3rd/API/programs/'.$what.'.php')) + function __autoload($what) { - include(_MINDSRC_.'/mind3rd/API/programs/'.$what.'.php'); - return true; - } - - // checking if the class is not a facad from the API - if(strpos($what, 'API/')!==false) - { - $what= explode('/', $what); - $classFile= array_pop($what); - $what= str_replace('/', '\\', $what); - $file= _MINDSRC_.'/mind3rd/API/facade/'.$classFile.".php"; - if(file_exists($file)) - { - include($file); - return true; - } - } - - // checking if the class is inside any of the autoload paths - $dirs= Mind::$autoloadPaths; + GLOBAL $_MIND; + $what= preg_replace("/[ '\"\.\/]/", '', $what); + $what= str_replace('\\', '/', $what); + $what= str_replace('.', '', $what); - for($i=0; $idefaults['default_human_languageName'].'/'.$what.'.php'; - if(file_exists($langPath)) - { - require_once($langPath); - return true; - } + // checking if the class is not a facad from the API + if(strpos($what, 'API/')!==false) + { + $what= explode('/', $what); + $classFile= array_pop($what); + $what= str_replace('/', '\\', $what); + $file= _MINDSRC_.'/mind3rd/API/facade/'.$classFile.".php"; + if(file_exists($file)) + { + include($file); + return true; + } + } - // ok, if it's reached here...it didn't go well! - echo " [ERROR] Class not found: ".$what."\n"; - return false; + // checking if the class is inside any of the autoload paths + $dirs= Mind::$autoloadPaths; + + for($i=0; $idefaults['default_human_languageName'].'/'. + $what.'.php'; + + if(file_exists($langPath)) + { + require_once($langPath); + return true; + } + + // ok, if it's reached here...it didn't go well! + echo " [ERROR] Class not found: ".$what."\n"; + return false; + } } \ No newline at end of file diff --git a/mind3rd/env/setup/Setup.php b/mind3rd/env/setup/Setup.php index a493846..2273897 100755 --- a/mind3rd/env/setup/Setup.php +++ b/mind3rd/env/setup/Setup.php @@ -135,6 +135,10 @@ abstract class Setup { return self::$installationOk= $phpVsOk && $sqliteOk && $projectsDir && $sqliteDir && $apiDir; } + public static function isInstalled(){ + return file_exists('mind3rd/SQLite/mind'); + } + /** * Creates the SQLite DataBase. *