Exemplo n.º 1
0
    RedirectResponse('links.php');
}
if (isset($_POST['fleetLink']) && isset($_POST['name'])) {
    $matches;
    if (preg_match('/gang:(?<id>\\d+)/', GetPost('fleetLink'), $matches)) {
        $a = Alliance::EnsureAlliance($brow->AllianceId(), $brow->AllianceName());
        $f = new Fleet();
        $f->Id = $matches['id'];
        $f->AllianceId = $a->Id;
        $f->Name = GetPost('name');
        $f->Added = time();
        if ($f->Validate()) {
            $f->Save();
            // this seems like a good place to delete old fleets
            Fleet::DeleteOldFleets();
            DataManager::GetInstance()->CloseConnection();
            RedirectResponse('links.php');
        }
    }
}
?>

<html>

<head>
	<title>Fleet Links - Add Fleet</title>
</head>

<body>
<h1><a href="index.php">Fleet Links</a></h1>
<h2>Add Fleet</h2>
Exemplo n.º 2
0
 public function Save()
 {
     if (!$this->Validate()) {
         throw new Exception('Alliance not valid; unable to save.');
     }
     $conn = DataManager::GetInstance()->GetConnection();
     if (!$this->inDatabase) {
         $stmt = $conn->prepare('INSERT INTO alliance (id, name) VALUES (?, ?)');
         $stmt->bind_param('is', $this->Id, $this->Name);
         $stmt->execute();
         $rows = $stmt->affected_rows;
         $stmt->close();
         if ($rows === 1) {
             $this->inDatabase = TRUE;
             return TRUE;
         } else {
             return FALSE;
         }
     } else {
         $stmt = $conn->prepare('UPDATE alliance SET name=? WHERE id=?');
         $stmt->bind_param('si', $this->Name, $this->Id);
         $stmt->execute();
         $rows = $stmt->affected_rows;
         $stmt->close();
         if ($rows === 1) {
             return TRUE;
         } else {
             return FALSE;
         }
     }
     return FALSE;
 }
Exemplo n.º 3
0
 public function Save()
 {
     if (!$this->Validate()) {
         throw new Exception('Fleet not valid; unable to save.');
     }
     $conn = DataManager::GetInstance()->GetConnection();
     if (!$this->inDatabase) {
         $stmt = $conn->prepare('INSERT INTO fleet (id, allianceId, name, added) VALUES (?, ?, ?, ?)');
         $stmt->bind_param('diss', $this->Id, $this->AllianceId, $this->Name, DataManager::FormatTimestampForSql($this->Added));
         $stmt->execute();
         $rows = $stmt->affected_rows;
         $stmt->close();
         if ($rows === 1) {
             $this->inDatabase = TRUE;
             return TRUE;
         } else {
             return FALSE;
         }
     } else {
         $stmt = $conn->prepare('UPDATE fleet SET allianceId=?, name=?, added=? WHERE id=?');
         $stmt->bind_param('issd', $this->AllianceId, $this->Name, DataManager::FormatTimestampForSql($this->Added), $this->Id);
         $stmt->execute();
         $rows = $stmt->affected_rows;
         $stmt->close();
         if ($rows === 1) {
             return TRUE;
         } else {
             return FALSE;
         }
     }
     return FALSE;
 }