Adding some programs
Esse commit está contido em:
Arquivo executável
+71
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
class Auth extends Symfony\Component\Console\Command\Command
|
||||
{
|
||||
public function configure()
|
||||
{
|
||||
$this->setName('auth')
|
||||
->setDescription('Autenticate a user')
|
||||
->setDefinition(Array(
|
||||
new InputArgument('login', InputArgument::REQUIRED, 'Login to access')
|
||||
))
|
||||
->setHelp(<<<EOT
|
||||
Sets the user with a password.
|
||||
It is required to run most of the commands
|
||||
EOT
|
||||
);
|
||||
}
|
||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
|
||||
{
|
||||
Mind::write('passwordRequired', true);
|
||||
$pw= $this->getPassword(true);
|
||||
Mind::write('autenticated', true, $input->getArgument('login'));
|
||||
Mind::write("xxxxxx");
|
||||
//echo "\n[OK] ".$input->getArgument('login')." ".Mind::write('autenticated')."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 user's password not showing any character of their password
|
||||
* @param Booladn $stars if true, show an * for each typed char
|
||||
* @return String password
|
||||
*/
|
||||
private function getPassword($stars = false)
|
||||
{
|
||||
// Get current style
|
||||
$oldStyle = shell_exec('stty -g');
|
||||
|
||||
if ($stars === false) {
|
||||
shell_exec('stty -echo');
|
||||
$password = rtrim(fgets(STDIN), "\n");
|
||||
} else {
|
||||
shell_exec('stty -icanon -echo min 1 time 0');
|
||||
|
||||
$password = '';
|
||||
while (true) {
|
||||
$char = fgetc(STDIN);
|
||||
|
||||
if ($char === "\n") {
|
||||
break;
|
||||
} else if (ord($char) === 127) {
|
||||
if (strlen($password) > 0) {
|
||||
fwrite(STDOUT, "\x08 \x08");
|
||||
$password = substr($password, 0, -1);
|
||||
}
|
||||
} else {
|
||||
fwrite(STDOUT, "*");
|
||||
$password .= $char;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reset old style
|
||||
shell_exec('stty ' . $oldStyle);
|
||||
|
||||
// Return the password
|
||||
return $password;
|
||||
}
|
||||
}
|
||||
Arquivo executável
+68
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
class Auth extends Symfony\Component\Console\Command\Command
|
||||
{
|
||||
public function configure()
|
||||
{
|
||||
$this->setName('auth')
|
||||
->setDescription('Autenticate a user')
|
||||
->setDefinition(Array(
|
||||
new InputArgument('login', InputArgument::REQUIRED, 'Login to access')
|
||||
))
|
||||
->setHelp(<<<EOT
|
||||
Sets the user with a password.
|
||||
It is required to run most of the commands
|
||||
EOT
|
||||
);
|
||||
}
|
||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
|
||||
{
|
||||
$pw= $this->getPassword(true);
|
||||
echo "\n[OK] ".$input->getArgument('login')." autenticated\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 user's password not showing any character of their password
|
||||
* @param Booladn $stars if true, show an * for each typed char
|
||||
* @return String password
|
||||
*/
|
||||
private function getPassword($stars = false)
|
||||
{
|
||||
// Get current style
|
||||
$oldStyle = shell_exec('stty -g');
|
||||
|
||||
if ($stars === false) {
|
||||
shell_exec('stty -echo');
|
||||
$password = rtrim(fgets(STDIN), "\n");
|
||||
} else {
|
||||
shell_exec('stty -icanon -echo min 1 time 0');
|
||||
|
||||
$password = '';
|
||||
while (true) {
|
||||
$char = fgetc(STDIN);
|
||||
|
||||
if ($char === "\n") {
|
||||
break;
|
||||
} else if (ord($char) === 127) {
|
||||
if (strlen($password) > 0) {
|
||||
fwrite(STDOUT, "\x08 \x08");
|
||||
$password = substr($password, 0, -1);
|
||||
}
|
||||
} else {
|
||||
fwrite(STDOUT, "*");
|
||||
$password .= $char;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reset old style
|
||||
shell_exec('stty ' . $oldStyle);
|
||||
|
||||
// Return the password
|
||||
return $password;
|
||||
}
|
||||
}
|
||||
Arquivo executável
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
class Clear extends Symfony\Component\Console\Command\Command
|
||||
{
|
||||
public function configure()
|
||||
{
|
||||
$this->setName('clear')
|
||||
->setDescription('Clears the console')
|
||||
->setDefinition(array())
|
||||
->setHelp(<<<EOT
|
||||
Clears the console
|
||||
EOT
|
||||
);
|
||||
}
|
||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
|
||||
{
|
||||
system('clear');
|
||||
}
|
||||
}
|
||||
Arquivo executável
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
class Quit extends Symfony\Component\Console\Command\Command
|
||||
{
|
||||
public function configure()
|
||||
{
|
||||
$this->setName('Mind:exit')
|
||||
->setDescription('Finishes the application')
|
||||
->setDefinition(null)
|
||||
->setHelp(<<<EOT
|
||||
Finishes the application, leaving the console;
|
||||
EOT
|
||||
);
|
||||
}
|
||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
|
||||
{
|
||||
//exit;
|
||||
}
|
||||
}
|
||||
Arquivo executável
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
class Quit extends Symfony\Component\Console\Command\Command
|
||||
{
|
||||
public function configure()
|
||||
{
|
||||
$this->setName('exit')
|
||||
->setDescription('Finishes the application')
|
||||
->setDefinition(Array())
|
||||
->setHelp(<<<EOT
|
||||
Finishes the application, leaving the console;
|
||||
EOT
|
||||
);
|
||||
}
|
||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
|
||||
{
|
||||
echo "Logging out...\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
Arquivo executável
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
class Quit extends Symfony\Component\Console\Command\Command
|
||||
{
|
||||
public function configure()
|
||||
{
|
||||
$this->setName('quit')
|
||||
->setDescription('Finishes the application')
|
||||
->setDefinition(Array())
|
||||
->setHelp(<<<EOT
|
||||
Finishes the application, leaving the console;
|
||||
EOT
|
||||
);
|
||||
}
|
||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
|
||||
{
|
||||
echo "Logging out...\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
Arquivo executável
+37
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
class RunTest extends Symfony\Component\Console\Command\Command
|
||||
{
|
||||
public function configure()
|
||||
{
|
||||
$this
|
||||
->setName('test')
|
||||
->setDescription('Performs some tests on theWebMind')
|
||||
->setDefinition(array())
|
||||
->setHelp(<<<EOT
|
||||
Executes specific tests and report their results, about the system itself
|
||||
EOT
|
||||
);
|
||||
}
|
||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
|
||||
{
|
||||
if(!isset($_SESSION['auth']))
|
||||
{
|
||||
Mind::write('not_allowed');
|
||||
Mind::write('not_allowed_tip');
|
||||
return false;
|
||||
}
|
||||
$this->runStep1();
|
||||
}
|
||||
|
||||
private function runStep1()
|
||||
{
|
||||
Mind::message('Autoloader', '[OK]');
|
||||
Mind::message('Includes', '[OK]');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Arquivo executável
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
class RunTest extends Symfony\Component\Console\Command\Command
|
||||
{
|
||||
public function configure()
|
||||
{
|
||||
$this
|
||||
->setName('test')
|
||||
->setDescription('Executes arbitrary DQL directly from the command line.')
|
||||
->setDefinition(array())
|
||||
->setHelp(<<<EOT
|
||||
Executes arbitrary DQL directly from the command line.
|
||||
EOT
|
||||
);
|
||||
}
|
||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
|
||||
{
|
||||
$this->runStep1();
|
||||
}
|
||||
|
||||
private function runStep1()
|
||||
{
|
||||
Mind::message('Autoloader', '[OK]');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Arquivo normal → Arquivo executável
Arquivo executável
+32
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
class CommandName extends Symfony\Component\Console\Command\Command
|
||||
{
|
||||
public function configure()
|
||||
{
|
||||
$this->setName('Mind:commandName')
|
||||
->setDescription('CommandDescription')
|
||||
->setDefinition(array(
|
||||
new InputArgument('arg1', InputArgument::REQUIRED, 'ArgDescription.'),
|
||||
new InputOption(
|
||||
'Option', null, InputOption::PARAMETER_REQUIRED,
|
||||
'Description of the option',
|
||||
'object'
|
||||
),
|
||||
new InputOption(
|
||||
'first-result', null, InputOption::PARAMETER_REQUIRED,
|
||||
'The first result in the result set.'
|
||||
)
|
||||
))
|
||||
->setHelp(<<<EOT
|
||||
Executes arbitrary DQL directly from the command line.
|
||||
EOT
|
||||
);
|
||||
}
|
||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
|
||||
{
|
||||
}
|
||||
}
|
||||
Arquivo executável
+32
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
class CommandName extends Symfony\Component\Console\Command\Command
|
||||
{
|
||||
public function configure()
|
||||
{
|
||||
$this->setName('Mind:commandName')
|
||||
->setDescription('CommandDescription')
|
||||
->setDefinition(array(
|
||||
new InputArgument('arg1', InputArgument::REQUIRED, 'ArgDescription.'),
|
||||
new InputOption(
|
||||
'Option', null, InputOption::PARAMETER_REQUIRED,
|
||||
'Description of the option',
|
||||
'object'
|
||||
),
|
||||
new InputOption(
|
||||
'first-result', null, InputOption::PARAMETER_REQUIRED,
|
||||
'The first result in the result set.'
|
||||
)
|
||||
))
|
||||
->setHelp(<<<EOT
|
||||
Executes arbitrary DQL directly from the command line.
|
||||
EOT
|
||||
);
|
||||
}
|
||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
|
||||
{
|
||||
}
|
||||
}
|
||||
Referência em uma Nova Issue
Bloquear um usuário