diff --git a/.gitignore b/.gitignore index b80f6ec..a1700b3 100755 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ mind3rd/SQLite/mind ## Temporary files ## mind3rd/API/temp/* +mind3rd/API/logs/* ## ## Development meta files diff --git a/docs/RIDE/scripts/jquery.js b/docs/RIDE/scripts/jquery.js index be039a1..714b3b4 100755 --- a/docs/RIDE/scripts/jquery.js +++ b/docs/RIDE/scripts/jquery.js @@ -1809,7 +1809,6 @@ var Expr = Sizzle.selectors = { match[3] = test[3] - 0; } - // TODO: Move to normal caching system match[0] = done++; return match; diff --git a/docs/ide/scripts/jquery.js b/docs/ide/scripts/jquery.js index be039a1..714b3b4 100755 --- a/docs/ide/scripts/jquery.js +++ b/docs/ide/scripts/jquery.js @@ -1809,7 +1809,6 @@ var Expr = Sizzle.selectors = { match[3] = test[3] - 0; } - // TODO: Move to normal caching system match[0] = done++; return match; diff --git a/index.php b/index.php index 80e0bb8..be3e2fa 100755 --- a/index.php +++ b/index.php @@ -19,7 +19,7 @@ case 'PUT' : parse_str(file_get_contents('php://input'), $put_vars); $_REQ['data'] = $put_vars; break; - default: + default : $_REQ['data']= null; } include('mind3rd/API/utils/utils.php'); \ No newline at end of file diff --git a/mind3rd/API/L10N/en.php b/mind3rd/API/L10N/en.php index c8889cb..2dfc49a 100755 --- a/mind3rd/API/L10N/en.php +++ b/mind3rd/API/L10N/en.php @@ -29,6 +29,7 @@ class En implements l10n{ } public function __construct() { + $this->messages['welcome'] = "Welcome to mind3rd.\nPlease, type 'help' to see the basic help content.\nType 'list' to see the complete list of commands.\n"; $this->messages['programRequired'] = Mind::message("API: You must send the program name, to execute", '[Fail]', false); $this->messages['loginRequired'] = Mind::message("Auth: Both login and password are required", '[Fail]', false); $this->messages['passwordRequired'] = "I need a password for this user, please: "; diff --git a/mind3rd/API/L10N/pt.php b/mind3rd/API/L10N/pt.php index c98bb8e..3a129b7 100755 --- a/mind3rd/API/L10N/pt.php +++ b/mind3rd/API/L10N/pt.php @@ -36,6 +36,7 @@ class pt implements l10n{ public function __construct() { //header('Content-type: text/html; charset=iso-8859-1'); + $this->messages['welcome'] = "Bem vindo ao mind3rd.\nDigite 'help' para ver o conteúdo básico da ajuda.\nDigite 'list' para ver a lista completa de comandos.\n"; $this->messages['programRequired'] = Mind::message("API: Você precisa passar o nome do programa a ser executado.", '[Fail]', false); $this->messages['loginRequired'] = Mind::message("Auth: Tanto login quanto senha são obrigatórios.", '[Fail]', false); $this->messages['passwordRequired'] = "Precisarei do password para este usuário, por favor: "; diff --git a/mind3rd/API/classes/MindCommand.php b/mind3rd/API/classes/MindCommand.php index f243d29..d065fe2 100755 --- a/mind3rd/API/classes/MindCommand.php +++ b/mind3rd/API/classes/MindCommand.php @@ -481,9 +481,12 @@ class MindCommand extends Symfony\Component\Console\Command\Command } /** + * Reads from keyboard in hiddenn mode. + * * function taken from: http://www.dasprids.de/blog/2008/08/22/getting-a-password-hidden-from-stdin-with-php-cli * this method should read the passwords from console, not showing any character * or replacing them by stars(asterisks) + * * @method readPassword * @param Boolan $stars if true, show an * for each typed char * @return String password diff --git a/mind3rd/API/classes/MindLog.php b/mind3rd/API/classes/MindLog.php new file mode 100644 index 0000000..62eacf6 --- /dev/null +++ b/mind3rd/API/classes/MindLog.php @@ -0,0 +1,63 @@ +conf['log_user_interaction'])){ + if(!@file_put_contents(_MINDSRC_.\LOGS_DIR.'user.log', $msg."\n", FILE_APPEND)){ + echo "ERROR: failed trying to create log! please, check the writting permissions for "._MINDSRC_.\LOGS_DIR."!"; + } + } + break; + } + case self::LOG_TYPE_PROJECT:{ + if(strtolower($_MIND->conf['log_project_interaction'])){ + if(@file_put_contents(_MINDSRC_.\LOGS_DIR.'project.log', $msg."\n", FILE_APPEND)){ + echo "ERROR: failed trying to create log! please, check the writting permissions for "._MINDSRC_.\LOGS_DIR."!"; + } + } + break; + } + default:{ + if(!@file_put_contents(_MINDSRC_.\LOGS_DIR.'sys.log', $msg."\n", FILE_APPEND)){ + echo "ERROR: failed trying to create log! please, check the writting permissions for "._MINDSRC_.\LOGS_DIR."!"; + } + break; + } + } + } + +} \ No newline at end of file diff --git a/mind3rd/API/classes/MindProject.php b/mind3rd/API/classes/MindProject.php index 9a55ba5..79d7e14 100755 --- a/mind3rd/API/classes/MindProject.php +++ b/mind3rd/API/classes/MindProject.php @@ -141,7 +141,7 @@ class MindProject extends VersionManager{ "; $data= $db->query($hasProject); if(sizeof($data)>0) - return true; + return $data; return false; } diff --git a/mind3rd/API/programs/Add.php b/mind3rd/API/programs/Add.php index 4d2ba63..9332c1e 100755 --- a/mind3rd/API/programs/Add.php +++ b/mind3rd/API/programs/Add.php @@ -25,7 +25,6 @@ public function executableFunction() { - //echo "AAAAAAAAA"; if(!\API\User::userExists($this->user)) { echo "user does not exist"; @@ -36,7 +35,7 @@ echo "project does not exist"; return false; // TODO: put it into L10N } - $pF= new DAO\ProjectFactory($this->project); + $pF= new DAO\ProjectFactory(Array('name'=>$this->project)); //print_r($pF); echo $this->project."\n\n"; echo "BBBBBBBBB"; diff --git a/mind3rd/API/programs/Auth.php b/mind3rd/API/programs/Auth.php index 37fcae9..f791f78 100755 --- a/mind3rd/API/programs/Auth.php +++ b/mind3rd/API/programs/Auth.php @@ -43,12 +43,15 @@ if(!$row) { Mind::write('auth_fail', true); + \MindLog::log(\MindLog::LOG_TYPE_USER, 'FAIL - Tried login with user \''.$this->login.'\' and failed'); return false; } }else{ die('Database not found!'); } Mind::write('autenticated', true, $this->login); + \MindLog::log(\MindLog::LOG_TYPE_USER, ' OK - \''.$this->login.'\' logged in'); + return $this; } diff --git a/mind3rd/API/programs/Create.php b/mind3rd/API/programs/Create.php index e1bcda8..553477a 100755 --- a/mind3rd/API/programs/Create.php +++ b/mind3rd/API/programs/Create.php @@ -159,6 +159,7 @@ EOT Mind::openProject(Array('pk_project'=>$key, 'name'=>$this->argName)); + \MindLog::log(\MindLog::LOG_TYPE_PROJECT, " OK - Project '".$this->argName."' create by ".$_SESSION['login']); break; case 'user': $db= new MindDB(); @@ -195,6 +196,7 @@ EOT )"; $db->execute($qr_newUser); Mind::write('userCreated', true, $this->argName); + \MindLog::log(\MindLog::LOG_TYPE_USER, " OK - User '".$this->argName."' create by ".$_SESSION['login']); echo "\n"; break; default: diff --git a/mind3rd/API/programs/helpContent.php b/mind3rd/API/programs/helpContent.php deleted file mode 100755 index 2f62d6c..0000000 --- a/mind3rd/API/programs/helpContent.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @license licenses/mind3rd.license - */ - use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Symfony\Component\Console; - - /** - * This class represents a model for programs - * - * @author Felipe Nascimento de Moura - */ - class helpContent extends MindCommand implements program - { - - public function executableFunction() - { - echo "theWebMind(or just mind):\n website: http://thewebmind.org\n Twitter: @thewebmind\n Docs: http://docs.thewebmind.org\n\n"; - "The list of startup commands:\n". - " install : installs the application itself\n". - " uninstall: uninstalls the application, but do NOT remove projects,\n". - " users or history\n". - " remove : installs the application AND REMOVE every data it may\n". - " have created, including ALL projects, history and users.\n". - " --help :\n"; - " -h :\n"; - " help :\n"; - " ? :\n"; - " Shows this help content.\n\n"; - echo "After installing, you can open the application by calling the 'mind' command anywhere.\n". - "You will also be able to send POST requisition to mind's server address sending the command you want to execute and its parameters.\n"; - } - - public function __construct() - { - $this->setCommandName('helps') - ->setFileName('helpContent') - ->setDescription("Shows the help content") - ->setRestrict(false) - ->setHelp("Shows the help content") - ->setAction(function($class){ - $class->executableFunction(); - }); - - /*$this->addRequiredArgument('firstArgument', - 'first, and required argument', - Array('X', 'Y', 'Z'));*/ - $this->init(); - } - } \ No newline at end of file diff --git a/mind3rd/API/programs/who.php b/mind3rd/API/programs/who.php new file mode 100755 index 0000000..2071661 --- /dev/null +++ b/mind3rd/API/programs/who.php @@ -0,0 +1,47 @@ + + * @license licenses/mind3rd.license + */ + use Symfony\Component\Console\Input\InputArgument, + Symfony\Component\Console\Input\InputOption, + Symfony\Component\Console; + + /** + * This class represents a model for programs + * + * @author Felipe Nascimento de Moura + */ + class Who extends MindCommand implements program + { + + public function executableFunction() + { + $name= JSON_decode($_SESSION['auth']); + $name= $name->name; + echo 'You are '.$_SESSION['login'].", also known as ".$name."\n"; + } + + public function __construct() + { + $this->setCommandName('who') + ->setDescription("Show information about the currently logged used") + ->setRestrict(true) + ->setHelp("Show information about the currently logged used") + ->setAction(function($class){ + $class->executableFunction(); + }); + + /*$this->addOption('am', 'am'); + $this->addOption('i', 'i');*/ + $this->addRequiredArgument('am', + 'am', + Array('am')); + $this->addRequiredArgument('i', + 'I', + Array('i', 'I', 'i?', 'I?')); + $this->init(); + } + } \ No newline at end of file diff --git a/mind3rd/API/shell.php b/mind3rd/API/shell.php index 09d8655..d2f4d84 100755 --- a/mind3rd/API/shell.php +++ b/mind3rd/API/shell.php @@ -7,8 +7,8 @@ */ // setting the general helperSet - $helperSet= true; - /*$helperSet= ($helperSet) ?: new Symfony\Component\Console\Helper\HelperSet(); + $helperSet= true; + /*$helperSet= ($helperSet) ?: new Symfony\Component\Console\Helper\HelperSet(); $app->setHelperSet($helperSet);*/ if(isset($_SERVER['argv'])) @@ -20,11 +20,10 @@ /* let's load the plugins, if they are allowed */ Mind::$triggers= array_keys($app->getCommands()); - - //var_dump($app); - + try { $sh= new Symfony\Component\Console\Shell($app); + \Mind::write('welcome'); $sh->run(); }catch(Exception $exc) { diff --git a/mind3rd/API/utils/constants.php b/mind3rd/API/utils/constants.php index 056c241..95d5ba3 100755 --- a/mind3rd/API/utils/constants.php +++ b/mind3rd/API/utils/constants.php @@ -34,6 +34,7 @@ define('KNOWLEDGE_BASE', 'mind3rd/SQLite/mind'); define('KNOWLEDGE_DDL', 'mind3rd/SQLite/ddl.sql'); define('MODELS_DIR', '/mind3rd/API/models/'); + define('LOGS_DIR', '/mind3rd/API/logs/'); define('ABOUT_INI', '/mind3rd/env/about.ini'); define('DEFAULTS_INI', '/mind3rd/env/defaults.ini'); define('MIND_CONF', '/mind3rd/env/mind.ini'); diff --git a/mind3rd/env/mind.ini b/mind3rd/env/mind.ini index a2aaac5..4ff3bdb 100755 --- a/mind3rd/env/mind.ini +++ b/mind3rd/env/mind.ini @@ -23,4 +23,8 @@ use_prefix_on_merged_entities= true ; how many points should consider an entity worth of mergin or not merging_amount_pts=2 ; should admin users be able to install components to the structure? -allow_installation=true \ No newline at end of file +allow_installation=true +; should log user interactions(like login or login failures) +log_user_interaction=yes +; shouold log project interactions(like creation, commit or permissions) +log_project_interaction=yes \ No newline at end of file