function rmdirRecursive($path)
{
    global $runningOnWindows;
    if (!file_exists($path)) {
        return;
    }
    if ($runningOnWindows) {
        runCommand("rd /S /Q " . $path);
    } else {
        runCommand("/bin/rm -rf " . $path);
    }
}
Example #2
0
 /**
  * Execute the action.
  * @param array command line parameters specific for this command
  */
 public function actionIndex()
 {
     if (in_array(Yii::app()->params['env.code'], $this->testEnvironments)) {
         $this->_isTestEnv = true;
     }
     $dbName = Yii::app()->params['db.name'];
     //connect to the DB server
     $DSNparts = explode(';', Yii::app()->params['db.connectionString']);
     $serverOnlyDSN = $DSNparts[0];
     //because standard dsn is : mysql:host=127.0.0.1;dbname=...
     $db = new CDbConnection($serverOnlyDSN, Yii::app()->params['db.username'], Yii::app()->params['db.password']);
     $db->active = true;
     //drop the, existing database, if it exists indeed
     $dbs = $db->createCommand("show databases")->queryAll();
     if (in_array(array('Database' => $dbName), $dbs)) {
         if (!$this->noQuestions) {
             echo "\nStop!\n\nThis will completely destroy the existing database " . $dbName . "\n\nAre you sure? (Yes/No) ";
             if (strcasecmp(trim(fgets(STDIN)), 'Yes') != 0) {
                 echo "Cancelled by the user\n";
                 Yii::app()->end();
             }
         }
         echo "Destroying existing database " . $dbName . "...";
         $db->createCommand("drop database " . $dbName)->execute();
         if ($this->_isTestEnv) {
             if (in_array(array('Database' => $dbName . '_test'), $dbs)) {
                 echo "Destroying existing test database " . $dbName . '_test' . " ...";
                 $db->createCommand("drop database " . $dbName . '_test')->execute();
             }
         }
         echo " Done\n";
     }
     //create the database
     echo "Creating new database " . $dbName . "...";
     $db->createCommand("create database " . $dbName)->execute();
     echo " Done\n";
     if ($this->_isTestEnv) {
         echo "Creating new database " . $dbName . '_test' . " ...";
         $db->createCommand("create database " . $dbName . '_test')->execute();
         echo " Done\n";
     }
     //reset the connection
     $db->active = false;
     $db = new CDbConnection(Yii::app()->params['db.connectionString'], Yii::app()->params['db.username'], Yii::app()->params['db.password']);
     $db->active = true;
     if ($this->_isTestEnv) {
         $testdb = new CDbConnection(Yii::app()->params['testdb.connectionString'], Yii::app()->params['testdb.username'], Yii::app()->params['testdb.password']);
         $testdb->active = true;
     }
     //import the base sql file, uppon which migrations are built
     if ($this->useBaseSql) {
         $baseSqlFile = Yii::getPathOfAlias('common.migrations.base') . '.sql';
         echo "Importing base.sql...";
         $statements = explode(";", file_get_contents($baseSqlFile));
         //dani: are you absolutely sure, no *data* in this file contains ';' ? Even if this is the case, generally it doesn't seem a safe assumption when importing an sql file
         foreach ($statements as $statement) {
             if (empty($statement)) {
                 continue;
             }
             $db->pdoInstance->exec($statement);
             if ($this->_isTestEnv) {
                 $testdb->pdoInstance->exec($statement);
             }
         }
         echo " Done\n";
         echo "\n";
     }
     //running migrations
     echo "Running migrations...\n";
     runCommand(getPhpPath() . " " . Yii::getPathOfAlias('root.yiic') . " migrate --interactive=0 ");
     if ($this->_isTestEnv) {
         echo "Running migrations for test db...\n";
         runCommand(getPhpPath() . " " . Yii::getPathOfAlias('root.yiic') . " migrate --interactive=0 --connectionID=testdb");
         echo "Done\n";
     }
 }
Example #3
0
#!/usr/bin/env php
<?php 
include_once 'common.php';
runCommand('composer self-update');
if (isLatestPhp() && isLatestSymfony()) {
    // Make sure composer.json references all necessary components by having one
    // job run a `composer update`. Since `composer update` will install the
    // latest Symfony, this should be done for the job corresponding to the
    // latest symfony version.
    runCommand('composer update --prefer-dist');
} else {
    if (getPhpVersion() === '5.3' && getSymfonyVersion() === '2.3.*') {
        // Prevent Travis throwing an out of memory error
        runCommand('echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini');
    }
    runCommand('composer require --prefer-dist symfony/symfony:' . getSymfonyVersion());
}
Example #4
0
#!/usr/bin/env php
<?php 
include_once 'common.php';
if (withCodeCoverage()) {
    runCommand('phpunit --coverage-text --coverage-clover coverage.xml');
} else {
    runCommand('phpunit');
}
Example #5
0
function resource($loggedIn)
{
    $routes = array("settings" => function ($action) {
        return restRequestSettings($action);
    }, "gallery" => function ($action) {
        return restRequestGallery();
    }, "portfolio" => function ($action) {
        return restRequestPortfolio($action, $_GET["id"]);
    }, "account" => function ($action) {
        return restRequestAccount($action, $_GET["email"]);
    }, "invite" => function ($action) {
        return restRequestInvite($action, $_GET["email"]);
    });
    $type = $_GET["type"];
    $action = $_GET["action"] ?: "get";
    $_GET["email"] = strtolower($_GET["email"]);
    $standardAction = in_array($action, array("create", "get", "update", "delete", "list"));
    if ($type === "security") {
        $resource = restRequestSecurity($action, $_POST["email"], $_POST["password"], $_POST["confirm"], $_POST["invite"]);
    } elseif (!$loggedIn) {
        $resource = restError(401);
    } elseif ($type === "command") {
        $resource = runCommand($action);
    } elseif (isset($routes[$type]) && $standardAction) {
        $resource = $routes[$type]($action);
    } else {
        $resource = restError(400);
    }
    logEvent("get-resource", $type, $action, $_GET["id"], !getProperty($resource, "error"));
    return $resource;
}
Example #6
0
function minecraft_restart_single($serverPort)
{
    // allow 10 seconds time
    set_time_limit(30);
    update_progress("10%");
    sleep(1);
    update_progress("15%");
    sleep(1);
    // Kill the cmd.exe processes
    //runCommand("start \"MineField\" cmd /C Call kill_${serverPort}.bat > NUL", "Shutting down server on ${serverPort}");
    runCommand('tasklist /A /V /S CIRCE /U CIRCE\\Mike /FI "IMAGENAME eq cmd*"');
    runCommand('tasklist /A /V /S CIRCE /U CIRCE\\Mike /FI "IMAGENAME eq java*"');
    //runCommand('tasklist /V /S CIRCE /U CIRCE\Mike /FI "WINDOWTITLE eq Minecraft*"');
    update_progress("30%");
    sleep(1);
    update_progress("50%");
    sleep(1);
    update_progress("60%");
    //runCommand("start \"MineCraft\" cmd /C Call start_${serverPort}.bat > NUL", "Starting server on ${serverPort}");
    update_progress("100%");
    flush_buffers();
}
$form_name = 'ipdiscover_analyse';
$table_name = $form_name;
echo open_form($form_name);
$pas = $protectedGet['rzo'];
//$rez = $nomRez;
$values = look_config_default_values(array('IPDISCOVER_IPD_DIR'));
$fname = $values['tvalue']['IPDISCOVER_IPD_DIR'];
$file_name = $fname . "/ipd/" . $pas . ".ipd";
//reset cache?
if (isset($protectedPost['reset']) and $protectedPost['reset'] != '') {
    unlink($file_name);
    reloadform_closeme('', true);
} else {
    $fp = @fopen($file_name, "r");
    if (!$fp) {
        runCommand("-cache -net=" . $pas, $fname);
    }
    @fclose($fp);
    $tabBalises = array($l->g(34) => "IP", $l->g(95) => "MAC", $l->g(49) => "NAME", $l->g(232) => "DATE", $l->g(66) => "TYPE");
    $ret = array();
    $ret = parse_xml_file($file_name, $tabBalises, "HOST");
    if ($ret != array()) {
        $sql = "select ";
        $i = 0;
        while ($ret[$i]) {
            foreach ($ret[$i] as $key => $value) {
                $sql .= "'" . $value . "' as " . $key . ",";
            }
            $sql = substr($sql, 0, -1) . " union select ";
            $i++;
        }
Example #8
0
 function isFile($path, $rev = '')
 {
     global $config;
     $path = encodepath($this->getSvnPath($path));
     $pegrev = $rev ? '@' . $rev : '';
     $cmd = $config->getSvnCommand() . ' info --xml ' . $this->repConfig->svnParams() . quote($path . $pegrev);
     return strpos(implode(' ', runCommand($cmd, true)), 'kind="file"') !== false;
 }
#!/usr/bin/env php
<?php 
include_once 'common.php';
if (withCodeCoverage()) {
    runCommand('wget https://scrutinizer-ci.com/ocular.phar');
    runCommand('php ocular.phar code-coverage:upload --format=php-clover coverage.xml');
}
#!/usr/bin/env php
<?php 
include_once 'common.php';
if (!isHhvm() && !withCodeCoverage()) {
    // Disable XDebug
    runCommand('phpenv config-rm xdebug.ini');
}