Esempio n. 1
0
     $service->flash('<div class="alert alert-danger">Allocated memory, disk, Block IO, and CPU must all be integers.</div>');
     $response->redirect('/admin/server/new')->send();
     return;
 }
 if ($request->param('block_io') > 1000 || $request->param('block_io') < 10) {
     $service->flash('<div class="alert alert-danger">Block IO must not be less than 10 or greater than 1000.</div>');
     $response->redirect('/admin/server/new')->send();
     return;
 }
 $plugin = ORM::forTable('plugins')->where('slug', $request->param('plugin'))->findOne();
 if (!$plugin) {
     $service->flash('<div class="alert alert-danger">The selected plugin does not appear to exist in the system.</div>');
     $response->redirect('/admin/server/new')->send();
     return;
 }
 $sftp_username = Functions::generateFTPUsername($request->param('server_name'));
 $server_hash = $core->auth->generateUniqueUUID('servers', 'hash');
 $daemon_secret = $core->auth->generateUniqueUUID('servers', 'daemon_secret');
 // Build Startup Variables
 $startup_variables = [];
 if ($request->param('daemon_variables') && !empty($request->param('daemon_variables'))) {
     foreach (explode(PHP_EOL, $request->param('daemon_variables')) as $line => $contents) {
         if (strpos($contents, '|')) {
             list($var, $value) = explode('|', $contents);
             $startup_variables[$var] = str_replace(array("\n", "\r"), "", $value);
         }
     }
 }
 foreach (json_decode($plugin->variables, true) as $name => $data) {
     if ((!$request->param('plugin_variable_' . $name) || empty($request->param('plugin_variable_' . $name))) && $data['required'] == true) {
         $service->flash('<div class="alert alert-danger">A required plugin variable was left blank when completing this server setup.</div>');
Esempio n. 2
0
});
$klein->respond('POST', '/admin/node/view/[i:id]/add-ip', function ($request, $response, $service) use($core) {
    $lines = explode("\r\n", str_replace(" ", "", $request->param('ip_port')));
    $node = ORM::forTable('nodes')->findOne($request->param('id'));
    if (!$node) {
        $service->flash('<div class="alert alert-danger">The requested node does not exist in the system.</div>');
        $response->redirect('/admin/node')->send();
        return;
    }
    $IPA = json_decode($node->ips, true);
    $IPP = json_decode($node->ports, true);
    foreach ($lines as $id => $values) {
        list($ip, $ports) = explode('|', $values);
        $IPA = array_merge($IPA, array($ip => array()));
        $IPP = array_merge($IPP, array($ip => array()));
        $portList = Functions::processPorts($ports);
        $portCount = count($portList);
        for ($l = 0; $l < $portCount; $l++) {
            $IPP[$ip][$portList[$l]] = 1;
        }
        if (count($IPP[$ip]) > 0) {
            $IPA[$ip] = array_merge($IPA[$ip], array("ports_free" => count($IPP[$ip])));
        } else {
            $service->flash('<div class="alert alert-danger">You must enter ports to be used with the IP.</div>');
            $response->redirect('/admin/node/view/' . $request->param('id') . '?tab-allocation')->send();
            return;
        }
    }
    $node->ips = json_encode($IPA);
    $node->ports = json_encode($IPP);
    $node->save();