Ejemplo n.º 1
0
//Start building query
$query = "SELECT m.ItemSetID, m.ItemID, m.ItemCount, s.OwnerID, s.Title, s.Type, s.Map, s.Mode, s.Sortrank, s.Champion, IFNULL(v.Rating, 0) AS Rating, s.Date, b.Name, b.recMath, b.minSumLvl, b.maxSumLvl, b.showIfSumSpell, b.hideIfSumSpell, i.Gold, i.Name AS ItemName, i.Description, ibi.BuildsIntoID, ibf.BuildsFromID FROM `ItemSetMap` m JOIN `ItemSets` s ON m.ItemSetID = s.ID JOIN `ItemBlocks` b ON m.BlockID = b.ID JOIN `Items` i ON m.ItemID = i.ID LEFT JOIN `ItemBuildsFrom` ibf ON m.ItemID = ibf.ItemID LEFT JOIN `ItemBuildsInto` ibi ON m.ItemID = ibi.ItemID LEFT JOIN (SELECT ItemsetID, SUM(Rating) AS Rating FROM `Votes` GROUP BY ItemsetID) v ON v.ItemsetID = m.ItemSetID";
if ($_GET['itemsetChampion'] != "Champion") {
    $query .= " WHERE `Champion`='" . $_GET['itemsetChampion'] . "'";
}
/*SELECT m.ItemSetID, m.ItemID, m.ItemCount, s.OwnerID, s.Title, s.Type, s.Map, s.Mode, s.Sortrank, s.Champion, s.Rating, s.Date, b.Name, b.recMath, b.minSumLvl, b.maxSumLvl, b.showIfSumSpell, b.hideIfSumSpell, i.Gold, i.Image, i.Name AS ItemName, i.Description FROM `ItemSetMap` m JOIN `ItemSets` s ON m.ItemSetID = s.ID JOIN `ItemBlocks` b ON m.BlockID = b.ID JOIN `Items` i ON m.ItemID = i.ID WHERE `Champion`='".$_GET['itemsetChampion']."'*/
if ($orderByDate && $orderByRating) {
    $query .= " ORDER BY `Date` " . $_GET['itemsetDate'] . ", `Rating` " . $_GET['itemsetRating'];
} elseif ($orderByDate && !$orderByRating) {
    $query .= " ORDER BY `Date` " . $_GET['itemsetDate'];
} elseif ($orderByRating && !$orderByDate) {
    $query .= " ORDER BY `Rating` " . $_GET['itemsetRating'];
}
//$query .= " LIMIT ".$_GET["itemsetStartIndex"].", ".$_GET['itemsetResultAmount']; TODO NEEDS SOME FIXING UP. DISTINCT SETS ONLY...
//Request the itemset with the prepared arguments
$rawItemSets = collapseResultArray($database->query($query));
//mysql query sorting by PHP Post Parameters: Range (Page #), Rating, champ, date, etc. Make the mysql wrapper in a way that this returns an array, not some weird MySQL stuff
//Create an array of actual ItemSet Objects.
$twentyItemSets = array();
foreach ($rawItemSets as $val) {
    array_push($twentyItemSets, newItemSet($database, $userAuth, $val));
}
$setListTemplate = new Template("www/templates/home_setList_template.html");
$setListTemplate->setVar("ChampionData", $championData);
//$setListTemplate->setVar("SpellData", $spellData);
$setListTemplate->setVar("CurrentChampion", $_GET["itemsetChampion"]);
$setListTemplate->setVar("ItemSets", $twentyItemSets);
//Itemset-Ajax for example when updating search parameters.
if (isset($_POST['itemsetAjax'])) {
    $setListTemplate->prepare();
    echo $setListTemplate->printTemplate();
Ejemplo n.º 2
0
    $stmt3->free_result();
    $stmt3->close();
    $itemset = ItemSet::newSet(collapseResultArray($ret)[$_GET["edit"]]);
} elseif (isset($_GET["upload"])) {
} elseif (isset($_GET["copy"])) {
    $stmt3 = $database->mysqli->prepare("SELECT m.ItemSetID, m.ItemID, m.ItemCount, s.OwnerID, s.Title, s.Type, s.Map, s.Mode, s.Sortrank, s.Champion, IFNULL(v.Rating, 0) AS Rating, s.Date, b.Name, b.recMath, b.minSumLvl, b.maxSumLvl, b.showIfSumSpell, b.hideIfSumSpell, i.Gold, i.Name AS ItemName, i.Description, ibi.BuildsIntoID, ibf.BuildsFromID FROM `ItemSetMap` m JOIN `ItemSets` s ON m.ItemSetID = s.ID JOIN `ItemBlocks` b ON m.BlockID = b.ID JOIN `Items` i ON m.ItemID = i.ID LEFT JOIN `ItemBuildsFrom` ibf ON m.ItemID = ibf.ItemID LEFT JOIN `ItemBuildsInto` ibi ON m.ItemID = ibi.ItemID LEFT JOIN (SELECT ItemsetID, SUM(Rating) AS Rating FROM `Votes` GROUP BY ItemsetID) v ON v.ItemsetID = m.ItemSetID WHERE m.ItemSetID = ?;");
    $stmt3->bind_param("i", $_GET["copy"]);
    $stmt3->execute();
    $res = $stmt3->get_result();
    $ret = array();
    while ($row = $res->fetch_assoc()) {
        array_push($ret, $row);
    }
    $stmt3->free_result();
    $stmt3->close();
    $itemset = ItemSet::newSet(collapseResultArray($ret)[$_GET["copy"]]);
}
//HTML Template for the user-specific part on the website
$userTemplate = new Template("www/templates/loggedin_template.html");
//Give the template the possibility to use the UserAuthentification class.
$userTemplate->setVar("UserAuthentification", $userAuth);
//Array mapping a champion name to its icon. Array ( ["ChampionName"] => "Icon", ["ChampionName2"] => "Icon2" )
$champJson = cURL("https://global.api.pvp.net/api/lol/static-data/euw/v1.2/champion?champData=image&api_key=" . $apiKey);
$championData = parseChampJSON($champJson, array("Champion" => new ArrayObject(array("img" => "www/any.png", "name" => "Any Champion", "key" => "Champion"), ArrayObject::ARRAY_AS_PROPS)));
//$spellData = parseSpellJSON(cURL("https://global.api.pvp.net/api/lol/static-data/euw/v1.2/summoner-spell?spellData=image,key&api_key=" . $apiKey));
//Get all those items...
$itemdata = recursiveArrayObject(collapseResultArray2($database->query("SELECT i.ID AS ItemID, i.Gold, i.Name AS ItemName, i.Description, ibi.BuildsIntoID, ibf.BuildsFromID, it.Tag FROM `Items` i LEFT JOIN `ItemBuildsFrom` ibf ON i.ID = ibf.ItemID LEFT JOIN `ItemBuildsInto` ibi ON i.ID = ibi.ItemID LEFT JOIN `ItemTags` it ON i.ID = it.ItemID"), true, true, true), ArrayObject::ARRAY_AS_PROPS);
$headerTemplate = new Template("www/templates/header_template.html");
$headerTemplate->setVar("UserTemplate", $userTemplate);
$headerTemplate->setVar("buttons", array(new ArrayObject(array("name" => "Home", "href" => "index.php"), ArrayObject::ARRAY_AS_PROPS), new ArrayObject(array("name" => "My Sets", "href" => "mysets.php"), ArrayObject::ARRAY_AS_PROPS)));
//And then, printerino!
Ejemplo n.º 3
0
            $stmt->bind_param("iiii", $sid, $bid, $item['id'], $item['count']);
            $stmt->execute();
            $stmt->close();
        }
    }
}
//HTML Template for the user-specific part on the website
$userTemplate = new Template("www/templates/loggedin_template.html");
//Give the template the possibility to use the UserAuthentification class.
$userTemplate->setVar("UserAuthentification", $userAuth);
//Array mapping a champion name to its icon. Array ( ["ChampionName"] => "Icon", ["ChampionName2"] => "Icon2" )
$champJson = cURL("https://global.api.pvp.net/api/lol/static-data/euw/v1.2/champion?champData=image&api_key=" . $apiKey);
$championData = parseChampJSON($champJson, array("Champion" => new ArrayObject(array("img" => "www/any.png", "name" => "Any Champion", "key" => "Champion"), ArrayObject::ARRAY_AS_PROPS)));
//$spellData = parseSpellJSON(cURL("https://global.api.pvp.net/api/lol/static-data/euw/v1.2/summoner-spell?spellData=image,key&api_key=" . $apiKey));
$res = $database->query("SELECT m.ItemSetID, m.ItemID, m.ItemCount, s.OwnerID, s.Title, s.Type, s.Map, s.Mode, s.Sortrank, s.Champion, IFNULL(v.Rating, 0) AS Rating, s.Date, b.Name, b.recMath, b.minSumLvl, b.maxSumLvl, b.showIfSumSpell, b.hideIfSumSpell, i.Gold, i.Name AS ItemName, i.Description, ibi.BuildsIntoID, ibf.BuildsFromID FROM `ItemSetMap` m JOIN `ItemSets` s ON m.ItemSetID = s.ID JOIN `ItemBlocks` b ON m.BlockID = b.ID JOIN `Items` i ON m.ItemID = i.ID LEFT JOIN `ItemBuildsFrom` ibf ON m.ItemID = ibf.ItemID LEFT JOIN `ItemBuildsInto` ibi ON m.ItemID = ibi.ItemID LEFT JOIN (SELECT ItemsetID, SUM(Rating) AS Rating FROM `Votes` GROUP BY ItemsetID) v ON v.ItemsetID = m.ItemSetID WHERE `OwnerID` = " . $userAuth->id . " ORDER BY `Sortrank` DESC;", false);
$rawSets = collapseResultArray($res);
$sets = array();
foreach ($rawSets as $rawSet) {
    $set = ItemSet::newSet($rawSet);
    $set->setEditable(true);
    $set->canRate(false);
    $set->canCopy(true);
    array_push($sets, $set);
}
$setListTemplate = new Template("www/templates/home_setList_template.html");
$setListTemplate->setVar("ChampionData", $championData);
//$setListTemplate->setVar("SpellData", $spellData);
$setListTemplate->setVar("ItemSets", $sets);
$headerTemplate = new Template("www/templates/header_template.html");
$headerTemplate->setVar("UserTemplate", $userTemplate);
$headerTemplate->setVar("buttons", array(new ArrayObject(array("name" => "Home", "href" => "index.php"), ArrayObject::ARRAY_AS_PROPS), new ArrayObject(array("name" => "Create Set", "href" => "createset.php"), ArrayObject::ARRAY_AS_PROPS)));