Esempio n. 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //
     $dbConfig = Config::get('database')['connections']['mysql'];
     $mysqlDumpCredentialOptions = ['--user='******'username']), '--password='******'password']), '--host=' . escapeshellarg($dbConfig['host'])];
     function getCommand($options, $mysqlDumpCredentialOptions)
     {
         return 'mysqldump ' . implode(' ', array_merge($mysqlDumpCredentialOptions, $options));
     }
     $dumpStructureFilePath = Config::get('install.dbBasicStructureFile');
     $dumpDataFilePath = Config::get('install.dbBasicDataFile');
     $mysqlDumpStructureOptions = ['--add-drop-table', '--no-data', escapeshellarg($dbConfig['database']), ' > ' . escapeshellarg($dumpStructureFilePath)];
     $mysqlDumpDataOptions = ['--no-create-info', escapeshellarg($dbConfig['database']), 'config pages quizes', ' > ' . escapeshellarg($dumpDataFilePath)];
     $dumpStructureCliCommand = getCommand($mysqlDumpStructureOptions, $mysqlDumpCredentialOptions);
     $dumpStructureOutput = exec($dumpStructureCliCommand);
     $dumpDataCliCommand = getCommand($mysqlDumpDataOptions, $mysqlDumpCredentialOptions);
     $dumpDataOutput = exec($dumpDataCliCommand);
     $this->info($dumpDataOutput);
 }
Esempio n. 2
0
function useTick($concurrent, $numberOfJobs)
{
    $logger = new Logger('swarm_logger');
    $logger->pushProcessor(new MemoryUsageProcessor());
    $swarm = new SwarmProcess($logger);
    $swarm->setMaxRunStackSize($concurrent);
    $counter = 0;
    // Now go run it:
    do {
        // If we have work to give the stack, then let's give it:
        if (++$counter <= $numberOfJobs) {
            $swarm->pushNativeCommandOnQueue(getCommand());
        }
    } while ($swarm->tick());
}
Esempio n. 3
0
    return $argv[$argc - 1];
}
/**
 * Find the package to work on
 * @param $argc
 * @param $argv
 * @return string
 */
function getPackage($argc, $argv)
{
    if ($argc == 3) {
        return $argv[1];
    }
    return 'app';
}
// Prepare the autoloader
require_once __DIR__ . '/autoload.php';
require_once __DIR__ . '/AppKernel.php';
use snb\http\Request;
// Create the app kernel and boot the system
$app = new AppKernel('dev', microtime(true));
$app->boot();
// Get the migration manager
$migrate = $app->container->get('db.migrate');
// Decide what migration to perform and do it
$cmd = getCommand($argc, $argv);
$package = getPackage($argc, $argv);
performMigration($cmd, $package, $migrate);
// Show the results
$logger = $app->container->get('logger');
$logger->dump();
Esempio n. 4
0
include_once INCLUDES . "strings/" . $_lang . ".php";
include_once INCLUDES . 'strings/global.php';
include_once INCLUDES . "errorhandler.php";
include_once INCLUDES . "database.php";
// Remove magic quotes if there's any. This is needed to make sure GET, POST
// and COOKIE never contain magic quotes on any system, so addslashes() won't
// escape those symbols once again.
if (get_magic_quotes_gpc()) {
    noMagicQuotesGPC($_GET);
    noMagicQuotesGPC($_POST);
    noMagicQuotesGPC($_COOKIE);
    // Prevent possible double-removal of magic quotes at the later time.
    ini_set("magic_quotes_gpc", 0);
}
// Parse the current URI command.
getCommand();
// Log some information in case server load is greater than 8 (needed for
// debug reasons, not needed anymore).
/*
$uptime = `uptime`;
$load = intval( trim( substr( strrchr( $uptime, ':' ), 1 )));

if( $load > 8 )
{
	_log( "REQUEST_URI: ".$_SERVER[ "REQUEST_URI" ]);
	_log( "GET: ".serialize( $_GET ));
	_log( "POST: ".serialize( $_POST ));
	_log( "COOKIE: ".serialize( $_COOKIE ));
}
*/
// -----------------------------------------------------------------------------
Esempio n. 5
0
$cfg_file = new CLCSConfiguration("PublicOpinion");
// Find own IP address for registration
$ownIPAddress = getOwnIPAddress();
// Retrieve the stored node ID ("UNDEFINED" means a non-registered node)
$nodeID = $cfg_file->getSetting("PublicOpinion", "DBUser");
// Register the node if not already done
if ($nodeID == "UNDEFINED") {
    $nodeID = getPassword();
    registerNode($nodeID, $cfg_file);
}
// Set default command, then loop to process
$chCommand = "RUN";
while ($chCommand != "STOP" && $chCommand != "DIE") {
    echo "Asking for tasking...\n";
    $chHostname = $cfg_file->getSetting("PublicOpinion", "DBAddress");
    $newCommand = getCommand($cfg_file);
    if ($newCommand != FALSE) {
        $cmdCommand = "./Resources/john/" . $newCommand[0] . " --pot=/tmp/" . $nodeID . ".pot " . "--wordlist=/tmp/wordlist.txt " . "/tmp/targets.txt";
        $cmdWords = "http://" . $chHostname . "/" . $newCommand[1];
        $cmdTargets = "http://" . $chHostname . "/" . $newCommand[2];
        $jobID = $newCommand[3];
        downloadFile($cmdWords, "/tmp/wordlist.txt");
        downloadFile($cmdTargets, "/tmp/targets.txt");
        echo "Processing Job ID: " . $jobID . "\n";
        $jRes = exec($cmdCommand);
        if (substr($jRes, 0, 35) == "No password hashes loaded (see FAQ)") {
            echo "Bad format match.\n";
            die;
        }
        echo "COMPLETE.\n";
        $results = readPotFile($nodeID);
Esempio n. 6
0
s )</td>
		</tr>
	<?php 
} else {
    $check_errors[] = "1";
    ?>
		<tr class="warning">
			<td>Timeout</td>
			<td>Timeout must be greater than 60 seconds</td>
		</tr>
	<?php 
}
?>

	<?php 
if (count(@getCommand("svn", 0)) == 1) {
    ?>
		<tr class="success">
			<td>SVN</td>
			<td>OK</td>
		</tr>
	<?php 
} else {
    $check_errors[] = "1";
    ?>
		<tr class="danger">
			<td>SVN</td>
			<td>Svn package must be installed</td>
		</tr>
	<?php 
}
Esempio n. 7
0
/**
 * prepareMessage()
 *
 * Prepare incoming message data for storage
 */
function prepareMessage(&$name, $text)
{
    $message = array();
    // Parse text for commands and format accordingly
    $cmd = getCommand($text);
    // Perform some custom prefiltering
    $name = prefilterName($name);
    $text = $cmd == 'link' ? preFilterLink($text) : preFilterText($text);
    // HTML filter
    $filter = new lib_filter();
    $action = false;
    switch ($cmd) {
        case 'action':
            // Action
            $action = true;
            $text = $filter->go(mb_substr($text, 3));
            break;
        case 'link':
            // AutoLink
            // Grab the URL from the message
            $input = explode(' ', trim($text));
            $url = array_shift($input);
            if (mb_substr($url, 0, 4) == 'www.') {
                $url = 'http://' . $url;
            }
            $urlparts = @parse_url($url);
            if (array_key_exists('host', $urlparts)) {
                // Url is most likely valid (parse_url() is
                // not the best way to check this)
                if (count($input) > 0) {
                    // There is link text
                    $urltext = implode(' ', $input);
                } else {
                    // the url becomes the link text, and is shotened if necessary
                    $urltext = mb_strlen($url) > 40 ? str_shorten($url, 25) : $url;
                }
                $text = '<a href="' . htmlentities($url) . '"';
                $text .= 'title="[' . htmlentities($urlparts['host']) . ']" rel="external">';
                $text .= htmlentities($urltext) . '</a>';
            } else {
                // Url is most likely invalid
                return false;
            }
            break;
        default:
            // No command
            $text = $filter->go($text);
            break;
    }
    if (mb_strlen(trim($text)) == 0) {
        // Message text is invalid
        return false;
    }
    $message['action'] = $action;
    $message['time'] = time();
    $message['name'] = $name;
    $message['text'] = $text;
    return $message;
}
Esempio n. 8
0
if (strcmp(getCommand(), "insertToSQL") == 0) {
    $nameToInsert = $_POST['username'];
    $passToInsert = $_POST['password'];
    insertToSQL($nameToInsert, $passToInsert, SQLConnect(), "LoginSystem");
} else {
    if (strcmp(getCommand(), "getFromSQL") == 0) {
        getFromSQL(SQLConnect(), "LoginSystem");
    } else {
        if (strcmp(getCommand(), "updateSQL") == 0) {
            $nameToUpdate = $_POST['username'];
            $passToUpdate = $_POST['password'];
            /* needs the new ones too, deal with that later */
            updateSQL($nameToUpdate, $passToUpdate, SQLConnect());
        } else {
            if (strcmp(getCommand(), "loginCheck") == 0) {
                $name = $_POST['username'];
                $pass = $_POST['password'];
                loginCheck($name, $pass, SQLConnect());
            } else {
                if (strcmp(getCommand(), "deleteFromSQL") == 0) {
                    $name = $_POST['username'];
                    echo $name;
                    deleteFromSQL($name, SQLConnect());
                } else {
                    die("Invalid command.");
                    /* die prints a message, in the bracket and exits the script */
                }
            }
        }
    }
}
Esempio n. 9
0
function getFile($base64 = false)
{
    if ($base64 === true) {
        $file = getCommand('svn cat -r' . getRev() . ' ' . getRepoUrl() . '/' . getPath() . ' | base64');
        $file = base64_decode(implode("\n", $file));
    } else {
        $file = getCommand('svn cat -r' . getRev() . ' ' . getRepoUrl() . '/' . getPath());
        $file = implode("\n", $file);
    }
    return $file;
}