function step4()
 {
     if ($this->request->is('post')) {
         $this->disableCache();
         Configure::write('debug', 3);
         $this->autoRender = false;
         $data = $this->request->data;
         if (preg_match("/localhost/", $data['address']) || preg_match("/127.0.0.1/", $data['address']) || preg_match("/::1/", $data['address'])) {
             $data['external_address'] = file_get_contents("http://icanhazip.com/");
         } else {
             $data['external_address'] = $data['address'];
         }
         $add = array('title' => $data['name'], 'address' => $data['address'], 'password' => $data['salt'], 'port1' => $data['port1'], 'port2' => $data['port2'], 'external_address' => $data['external_address']);
         $server = $data['address'];
         $salt = $data['salt'];
         $p1 = $data['port1'];
         $p2 = $data['port2'];
         //call API
         include APP . 'SpaceBukkitAPI.php';
         // This line is used to include the ressources file.
         $api = new SpaceBukkitAPI($server, $p1, $p2, $salt);
         //CHECK IF SERVER IS RUNNING
         $args = array();
         $running = $api->call("isServerRunning", $args, true);
         $this->set('running', $running);
         if (is_null($running)) {
             $answer = 'Server was not reached. Is the address correct, are the ports open?';
         } elseif ($running == "true" || $running == true || $running == 1) {
             $this->loadModel('Server');
             if ($this->Server->save($add)) {
                 $answer = 'true';
             } else {
                 $answer = 'The server could not be saved, please try again.';
             }
         } elseif ($running == "salt") {
             $answer = 'Incorrect Salt supplied. If you changed it in the config, make sure you restarted Remote Toolkit with ".stopwrapper" and "sh rtoolkit.sh".';
         }
         echo $answer;
     }
     $this->layout = 'install';
     $this->loadModel('Role');
     $this->set('roles', $this->Role->find("all"));
 }
 function getServer($id)
 {
     if ($this->request->is('ajax')) {
         $this->disableCache();
         Configure::write('debug', 0);
         $this->autoRender = false;
         require APP . 'spacebukkitcall.php';
         $bukkit = $this->Server->findById($id);
         //DATABASE SERVER RETRIVAL
         $server = $bukkit['Server']['address'];
         $salt = $bukkit['Server']['password'];
         //call API
         $api = new SpaceBukkitAPI($server, 2011, 2012, $salt);
         $args = array();
         $running = $api->call("isServerRunning", $args, true);
         if ($running == 1) {
             $run = "circle_green.png";
         } elseif ($running == 0) {
             $run = "circle_orange.png";
         } else {
             $run = "circle_red.png";
         }
         echo '<img src="img/' . $run . '" style="margin-right: 10px"/>';
     }
 }