private static function tracert($cmd, $ip, $callback)
 {
     $hops = 30;
     $as = 0;
     if ($as === 0) {
         $handle = popen("{$cmd} -n -m {$hops} {$ip} 2>&1", 'r');
     } else {
         $handle = popen("{$cmd} -n -A -m {$hops} {$ip} 2>&1", 'r');
     }
     while (feof($handle) === FALSE) {
         $line = fgets($handle);
         $int = (int) $line;
         if ($int > 0 && preg_match('/(\\d+\\.\\d+\\.\\d+\\.\\d+)/is', trim($line), $match) > 0) {
             $route_ip = $match[1];
             $host = host::execute(['ip' => $route_ip, 'cmd' => 'host']);
             $host1 = '';
             foreach (explode("\n", $host) as $value) {
                 if (strpos($value, 'domain name pointer') !== FALSE) {
                     $host1 = $value;
                     break;
                 }
             }
             if ($host1 != '' && preg_match('/pointer\\s(.+)\\.$/is', trim($host1), $match) > 0) {
                 $line = str_replace($route_ip, "{$match[1]} ({$route_ip})", $line);
             } else {
                 $line = str_replace($route_ip, "{$route_ip} ({$route_ip})", $line);
             }
         }
         $callback(trim($line));
     }
     pclose($handle);
 }
Beispiel #2
0
 /**
  * Response when updating role succeed.
  *
  * @param  \Orchestra\Model\Role  $role
  *
  * @return mixed
  */
 public function destroySucceed(host $host)
 {
     $message = trans('orchestra/control::response.roles.delete', ['name' => $host->getAttribute('name')]);
     return $this->redirectWithMessage(handles('orchestra::host'), $message);
 }
Beispiel #3
0
<?php

$SSH = rp::get('SSH');
$host = new host($SSH['ip'], $SSH['user'], $SSH['password']);
unset($SSH);
?>

<div class="row">

    <div class="col-lg-4">
    
    	<h2><?php 
echo lang::get('rokket_about');
?>
</h2>
        
        <p><?php 
echo lang::get('rokket_text');
?>
</p>
    	
        <div class="row">
        	<div class="col-sm-6">
        		<a href="https://www.facebook.com/pages/Rokket/1562909277254179" class="button facebook full svg" target="_blank"><?php 
echo layout::svg('facebook');
?>
Facebook</a>
        	</div>
        	<div class="col-sm-6">
        		<a href="https://github.com/callofsorrow/rokket" class="button github full svg" target="_blank"><?php 
echo layout::svg('github');
 function getNew($hostname, $name, $strategyCode, $cronExpression, $volumeName, $datadir, $mysqlUser, $mysqlPass)
 {
     $datadir = rtrim($datadir, '/');
     // Validate inputs
     host::validateHostname($hostname);
     scheduledBackup::validateName($name);
     backupStrategy::validateStrategyCode($strategyCode);
     scheduledBackup::validateCronExpression($cronExpression);
     backupVolume::validateName($volumeName);
     scheduledBackup::validateDatadirPath($datadir);
     scheduledBackup::validateMysqlUser($mysqlUser);
     scheduledBackup::validateMysqlPass($mysqlPass);
     // Lookup host by name
     $hostGetter = new hostGetter();
     $hostGetter->setLogStream($this->log);
     if (!($host = $hostGetter->getByName($hostname))) {
         throw new ProcessingException("Error: No Host could be found with a hostname matching: {$hostname}");
     }
     // Lookup volume by name
     $volumeGetter = new volumeGetter();
     $volumeGetter->setLogStream($this->log);
     if (!($volume = $volumeGetter->getByName($volumeName))) {
         throw new ProcessingException("Error: No Volume could be found with a name matching: {$volumeName}");
     }
     // Lookup backup strategy by code
     $strategyGetter = new backupStrategyGetter();
     $strategyGetter->setLogStream($this->log);
     if (!($strategy = $strategyGetter->getByCode($strategyCode))) {
         throw new ProcessingException("Error: No Backup Strategy could be found matching the code: {$strategyCode}");
     }
     // Check for existing scheduled backups with the same name for this host
     if ($existing = $this->getByHostnameAndName($hostname, $name)) {
         throw new ProcessingException("Error: A Scheduled Backup already exists for host {$hostname} with a name matching: {$name}");
     }
     // INSERT the row
     $conn = dbConnection::getInstance($this->log);
     // Create a new scheduledBackup entry
     // For now we just always create with "xtrabackup" binary used (mysql_type_id = 1)..
     // Maybe this can change later..
     $sql = "INSERT INTO scheduled_backups \n\t\t\t\t\t( name, cron_expression, datadir_path, mysql_user, mysql_password, \n\t\t\t\t\t  host_id, backup_volume_id, mysql_type_id, backup_strategy_id \n\t\t\t\t\t) VALUES ( \n\t\t\t\t\t\t'" . $conn->real_escape_string($name) . "',\n\t\t\t\t\t\t'" . $conn->real_escape_string($cronExpression) . "',\n\t\t\t\t\t\t'" . $conn->real_escape_string($datadir) . "',\n\t\t\t\t\t\t'" . $conn->real_escape_string($mysqlUser) . "',\n\t\t\t\t\t\t'" . $conn->real_escape_string($mysqlPass) . "',\n\t\t\t\t\t\t" . $host->id . ",\n\t\t\t\t\t\t" . $volume->id . ",\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t" . $strategy->id . "\n\t\t\t\t\t)";
     if (!$conn->query($sql)) {
         throw new DBException('scheduledBackupGetter->getNew: ' . "Error: Query: {$sql} \nFailed with MySQL Error: {$conn->error}");
     }
     // Init the object
     $scheduledBackup = new scheduledBackup($conn->insert_id);
     $scheduledBackup->setLogStream($this->log);
     // Init the default scheduledBackup parameters for the strategy
     $sql = "INSERT INTO scheduled_backup_params (scheduled_backup_id, backup_strategy_param_id, param_value) \n\t\t\t\t\t\tSELECT " . $scheduledBackup->id . ", backup_strategy_param_id, default_value \n\t\t\t\t\t\tFROM backup_strategy_params\n\t\t\t\t\t\tWHERE backup_strategy_id=" . $strategy->id;
     if (!$conn->query($sql)) {
         throw new DBException('scheduledBackupGetter->getNew: ' . "Error: Query: {$sql} \nFailed with MySQL Error: {$conn->error}");
     }
     return $scheduledBackup;
 }
<?php

use Models\Host;
use Lib\OAuth2\OAuth2;
$app->group('/host', function () use($app, $authorize, $resourceServer) {
    //create host account//
    $app->post('/', function () use($app, $resourceServer) {
        $host = new host();
        $firstname = $app->request->post('firstname');
        $lastname = $app->request->post('lastname');
        $email = $app->request->post('email');
        $phone = $app->request->post('phone');
        $username = $app->request->post('username');
        $password = $app->request->post('password');
        //perform insertion//
        $json = $host->addHost($firstname, $lastname, $email, $phone, $username, $password);
        echo $json;
    });
    //get specific host//
    $app->get('/', $authorize(), function () use($app, $resourceServer) {
        //determine currently logged in host//
        $id = $resourceServer->getAccessToken()->getSession()->getOwnerId();
        $host = new host();
        $json = $host->getHost($id);
        echo $json;
    });
});