示例#1
0
function insertDeck()
{
    $deck = new Deck(0);
    $deck->name = $_POST['name'];
    $deck->archetype = $_POST['archetype'];
    $deck->notes = $_POST['notes'];
    $deck->playername = $_POST['player'];
    $deck->eventname = $_POST['event'];
    $deck->maindeck_cards = parseCards($_POST['contents']);
    $deck->sideboard_cards = parseCards($_POST['sideboard']);
    if (!$deck->save()) {
        deckForm($deck);
    }
    return $deck;
}
示例#2
0
}
function redirect_deck_update($latest_id = 0)
{
    $url = explode('?', $_SERVER['REQUEST_URI']);
    $url = $url[0] . "?deckupdate=" . $latest_id;
    echo "<a href=\"{$url}\">Continue</a>";
    echo "<script type=\"text/javascript\"> window.location = \"http://{$_SERVER['SERVER_NAME']}{$url}\"; </script>";
    exit(0);
}
if (isset($_GET['deckupdate'])) {
    $deckquery = do_query("SELECT id FROM decks WHERE id > " . $_GET['deckupdate']);
    $timestart = time();
    while ($deckid = $deckquery->fetch_array()) {
        flush();
        $deck = new Deck($deckid[0]);
        $deck->save();
        flush();
        if (time() - $timestart > 5) {
            echo "-> Updating decks, ID: {$deck->id}... <br />";
            redirect_deck_update($deck->id);
        }
    }
    echo "Done with deck updates...<br />";
    exit(0);
}
# Check for version 0.  (no players table)
if (!$db->query("SELECT name FROM players LIMIT 1")) {
    # Version 0.  Enter the whole schema.
    echo "DETECTED NO DATABASE.  Currently can't handle null database. Exiting. <br />";
    exit(0);
} else {
 public function edit_deck($deck_id = 0, $repeating = 0)
 {
     if ($repeating == 1) {
         $this->data['error'] = "New Deck Added.";
     }
     $deck = new Deck($deck_id);
     if ($_POST) {
         $repeat = FALSE;
         /*
         			if($deck_id == 0){
         				$repeat = TRUE;
         			}*/
         foreach ($this->input->post() as $key => $val) {
             $deck->{$key} = nl2br($val);
         }
         if ($this->input->post('enabled')) {
             $deck->enabled = 1;
         } else {
             $deck->enabled = 0;
         }
         $deck->save();
         if ($repeat) {
             redirect('/admin/cards/edit_deck/');
         }
     }
     $this->data['deck'] = $deck;
     $this->data['current_function_view'] = $this->load->view('admin/cards/edit_deck', $this->data, true);
     $this->load->view('admin/master', $this->data);
 }