public function __construct($cardID)
 {
     //sql retrieval statement
     $cardRepArr = get_cbdb_card($cardID, get_cbdb_connection());
     if (!$cardRepArr) {
         //Then the id didn't exist in the DB or there was a DB error.
         print "<h2>Failed to get the passed in cardid of {$cardID} from the DB.</h2>";
         return;
     }
     //Grabs the front.
     $cardRep = $cardRepArr[1];
     //card information
     $this->id = $cardRep["cardid"];
     $this->name = $cardRep["name"];
     $this->picture = $cardRep["card_img"];
     $this->backpic = $cardRepArr[0]["card_img"];
     $this->cardType = $cardRep["type"];
     $this->swapType = $cardRep["swap"];
     $this->extraInfo = "DEFAULT VALUE";
     //card statistics
     $this->cost = $cardRep["cost"];
     $this->body = array("atk" => intval($cardRep["body_atk"]), "def" => intval($cardRep["body_def"]), "bst" => intval($cardRep["body_bst"]));
     $this->mind = array("atk" => intval($cardRep["mind_atk"]), "def" => intval($cardRep["mind_def"]), "bst" => intval($cardRep["mind_bst"]));
     $this->soul = array("atk" => intval($cardRep["soul_atk"]), "def" => intval($cardRep["soul_def"]), "bst" => intval($cardRep["soul_bst"]));
     $this->vit = $cardRep["vit"];
     $this->attributes = array("level" => $cardRep["level"], "action" => $cardRep["action"], "duration" => $cardRep["duration"], "range" => $cardRep["range"]);
     //non aspect card statistics
     $this->boostInfo = "DEFAULT VALUE";
     $this->magnitude = "DEFAULT VALUE";
     //Assign the information in the $cardRep (card representation) to the
     //private variables.
     //checks to ensure that boostInfo and magnitude are zero for aspect cards
     $this->checkType();
 }
 public function __construct($sUserID = FALSE)
 {
     if ($sUserID) {
         $this->sUserID = $sUserID;
     } else {
         $this->sUserID = '';
     }
     $this->arr = array();
     $tempdeck = get_cbdb_deck($this->sUserID, get_cbdb_connection());
     if (!$tempdeck) {
         //Couldn't retrieve the user's deck.
     } else {
         foreach ($tempdeck as $tempindex => $tempcardid) {
             $tempcard = new Card($tempcardid);
             $this->addCard($tempcard, $tempcardid);
         }
     }
 }
<?php

session_start();
//Sets the $userid variable.
require_once 'get_userid.php';
require_once 'cb_backend/db_lib.php';
if (isset($_GET['type']) || isset($_POST['type'])) {
    $command = isset($_GET['type']) ? $_GET['type'] : $_POST['type'];
    switch ($command) {
        case 'get_usercharslist':
            $arr = get_cbdb_users_characters($userid, get_cbdb_connection());
            $toret = array();
            foreach ($arr as $index => $char) {
                $toret[$char["charid"]] = strlen(trim($char["charname"])) > 0 ? $char["charname"] : "[Nameless Character]";
            }
            echo json_encode($toret);
            break;
        case 'get_racecard':
            if (isset($_GET['charid'])) {
                $charId = $_GET['charid'];
                $retVal = get_race_card_id($charId, get_cbdb_connection());
                echo $retVal;
            }
            break;
        default:
            break;
    }
}
 public function getCharacter($charid, $userid)
 {
     $newcharrep = get_cbdb_character($charid, $userid, get_cbdb_connection());
     //Overwrite this character's data with what the DB returned.
     $this->__construct($userid, $newcharrep["charinfo"]["charname"], $newcharrep["charinfo"]["totalup"]);
     $this->setCharID($charid);
     $this->setCharDesc($newcharrep["charinfo"]["chardesc"]);
     $this->lastModified = $newcharrep["charinfo"]["lastmodified"];
     foreach ($newcharrep["cards"] as $index => $cardid) {
         $tempcard = new Card($cardid);
         $this->addCard($tempcard);
     }
 }
function delete_cbdb_character($charid, $userid, $dbconn)
{
    if (!$dbconn) {
        $dbconn = get_cbdb_connection();
    }
    //Remove from the character table.
    $query = "delete from UserCharacter where charid = {$charid} and userid = '{$userid}'";
    $result = mysql_query($query);
    //Remove the character's card representation.
    $query2 = "delete from CharacterCards where charid = {$charid}";
    $result2 = mysql_query($query2);
}