Beispiel #1
0
 public function addMachine()
 {
     $this->requireGet('hostname', 'port');
     $db = Database::getDatabase();
     $machine_id = $db->getValue('SELECT id FROM hw_cpus WHERE hostname = ' . $db->quote($_GET['hostname']) . ' AND user_id = ' . $this->user->id);
     if ($machine_id === false) {
         $cpu = new CPU();
         $cpu->user_id = $this->user->id;
         $cpu->hostname = $_GET['hostname'];
         $cpu->ip = $_SERVER['REMOTE_ADDR'];
         $cpu->port = $_GET['port'];
         $cpu->dt_created = dater();
         $cpu->dt_updated = $cpu->dt_created;
         $cpu->insert();
     } else {
         $cpu = new CPU($machine_id);
         $cpu->ip = $_SERVER['REMOTE_ADDR'];
         $cpu->port = $_GET['port'];
         $cpu->dt_updated = dater();
         $cpu->update();
     }
     $this->success();
 }