| @@ -49,6 +49,8 @@ if (!$userid){ | |||||
| if ($_SESSION['admin'] == 1){ | if ($_SESSION['admin'] == 1){ | ||||
| echo'(<a href="adminlanding.php" class="navlink">Administration</a>) '; | echo'(<a href="adminlanding.php" class="navlink">Administration</a>) '; | ||||
| } | } | ||||
| echo '(<a href="logout.php?action=logout" class="navlink">Logout ' . $_SESSION['username'] . '</a>)</form><hr><br / >'; | |||||
| echo '(<a href="logout.php?action=logout" class="navlink">Logout ' . $_SESSION['username'] . '</a>)</form><hr>'; | |||||
| echo '(<a href="updatecharstats.php" class="navlink">Update character titles</a>) (<a href="updateaccountstats.php" class="navlink">Update account titles</a>) '; | |||||
| echo '(<a href="addaccounts.php" class="navlink">Manage accounts & characters</a>)<br /><br />'; | |||||
| } | } | ||||
| ?> | ?> | ||||
| @@ -0,0 +1,53 @@ | |||||
| <?php | |||||
| if (isset($_SESSION['userid'])){ | |||||
| echo '<table border="1"><caption>Titles progress</caption>'; | |||||
| echo '<tr><th>Title</th><th>Title Rank</th><th>Title Points</th><th>Current Rank</th><th>Points Remaining</th><th>Max Title %</th><th>Next Rank</th></tr>'; | |||||
| if ($_SESSION['prefcharid'] == "0") { | |||||
| // $gcc = Get Current Character stats | |||||
| $gcc = $con->prepare("SELECT * FROM gwstats WHERE charid = 0 AND accid = ? AND userid = ? ORDER BY percent DESC, currentstrank DESC, percent ASC"); | |||||
| $gcc->bind_param("ii", $_SESSION['prefaccid'], $_SESSION['userid']); | |||||
| } else { | |||||
| // $gcc = Get Current Character stats | |||||
| $gcc = $con->prepare("SELECT * FROM gwstats WHERE charid = 0 AND accid = ? AND userid = ? UNION ALL SELECT * FROM gwstats WHERE charid = ? AND accid = ? AND userid = ? ORDER BY percent DESC, currentstrank DESC, percent ASC"); | |||||
| $gcc->bind_param("iiiii", $_SESSION['prefaccid'], $_SESSION['userid'], $_SESSION['prefcharid'], $_SESSION['prefaccid'], $_SESSION['userid']); | |||||
| } | |||||
| $gcc->execute(); | |||||
| $gccres = $gcc->get_result(); | |||||
| while ($row = $gccres->fetch_assoc()) { | |||||
| // $gnr = Get Next Rank | |||||
| $gnr = $con->prepare("SELECT stpoints, stname FROM gwsubtitles WHERE titlenameid = ? AND stpoints >= ? ORDER BY stpoints ASC LIMIT 1"); | |||||
| $gnr->bind_param("ii", $row['titlenameid'], $row['titlepoints']); | |||||
| $gnr->execute(); | |||||
| $gnr->bind_result($stpoints, $stname); | |||||
| $gnr->fetch(); | |||||
| $gnr->close(); | |||||
| // $gt = Get Title | |||||
| $gt = $con->prepare("SELECT titlename FROM gwtitles WHERE titlenameid = ?"); | |||||
| $gt->bind_param("i", $row['titlenameid']); | |||||
| $gt->execute(); | |||||
| $gt->bind_result($titlename); | |||||
| $gt->fetch(); | |||||
| $gt->close(); | |||||
| $pr = number_format(($stpoints - $row['titlepoints'])); | |||||
| if ($pr <= 0) { | |||||
| $pr = "Highest rank achieved!"; | |||||
| $stname = "Highest rank achieved!"; | |||||
| } | |||||
| if ($row['currentstrankname'] === NULL) { | |||||
| $row['currentstrankname'] = "No title earned yet!"; | |||||
| $row['currentstrank'] = "0"; | |||||
| } | |||||
| if ($row['percent'] >= 100) { | |||||
| $ohp = 100; | |||||
| } else { | |||||
| $ohp = $row['percent']; | |||||
| } | |||||
| echo '<tr><td style="width:175px;">' . $titlename . '</td><td style="width:210px;">' . $row['currentstrankname'] . '</td><td style="width:100px;">' . number_format($row['titlepoints']) . '</td><td style="width:70px;">' . $row['currentstrank'] . '</td>'; | |||||
| echo '<td style="width:100px;">' . $pr . '</td><td><div class="percentbar" style="width:100px;"><div style="width:' . $ohp . 'px;"></div></div>'; | |||||
| echo $ohp; | |||||
| echo '% completed</td><td>' . $stname . '</td></tr>'; | |||||
| } | |||||
| $gccres->close(); | |||||
| echo '</table><br />'; | |||||
| } | |||||
| ?> | |||||
| @@ -3,7 +3,7 @@ if (isset($_SESSION['userid'])) { | |||||
| echo '<table border="1"><caption>Account wide stats</caption>'; | echo '<table border="1"><caption>Account wide stats</caption>'; | ||||
| echo '<tr><th>Title</th><th>Title Rank</th><th>Title Points</th><th>Current Rank</th><th>Points Remaining</th><th>Max Title %</th><th>Next Rank</th></tr>'; | echo '<tr><th>Title</th><th>Title Rank</th><th>Title Points</th><th>Current Rank</th><th>Points Remaining</th><th>Max Title %</th><th>Next Rank</th></tr>'; | ||||
| // $gas = GetAccountStats | // $gas = GetAccountStats | ||||
| $gas = $con->prepare("SELECT * FROM gwaccstats WHERE userid = ? AND accid = ? ORDER BY currentstrank DESC, percent ASC"); | |||||
| $gas = $con->prepare("SELECT * FROM gwstats WHERE charid = 0 AND userid = ? AND accid = ? ORDER BY percent DESC, currentstrank DESC, percent ASC"); | |||||
| $gas->bind_param("ii", $_SESSION['userid'], $_SESSION['prefaccid']); | $gas->bind_param("ii", $_SESSION['userid'], $_SESSION['prefaccid']); | ||||
| $gas->execute(); | $gas->execute(); | ||||
| $result = $gas->get_result(); | $result = $gas->get_result(); | ||||
| @@ -3,7 +3,7 @@ if (isset($_SESSION['userid'])) { | |||||
| echo '<table border="1"><caption>Character stats</caption>'; | echo '<table border="1"><caption>Character stats</caption>'; | ||||
| echo '<tr><th>Title</th><th>Title Rank</th><th>Title Points</th><th>Current Rank</th><th>Points Remaining</th><th>Max Title %</th><th>Next Rank</th></tr>'; | echo '<tr><th>Title</th><th>Title Rank</th><th>Title Points</th><th>Current Rank</th><th>Points Remaining</th><th>Max Title %</th><th>Next Rank</th></tr>'; | ||||
| // $gcs = Get Character Stats | // $gcs = Get Character Stats | ||||
| $gcs = $con->prepare("SELECT * FROM gwcharstats WHERE charid = ? AND accid = ? AND userid = ? ORDER BY currentstrank DESC, percent ASC"); | |||||
| $gcs = $con->prepare("SELECT * FROM gwstats WHERE charid = ? AND accid = ? AND userid = ? ORDER BY percent DESC, currentstrank DESC, percent ASC"); | |||||
| $gcs->bind_param("iii", $_SESSION['prefcharid'], $_SESSION['prefaccid'], $_SESSION['userid']); | $gcs->bind_param("iii", $_SESSION['prefcharid'], $_SESSION['prefaccid'], $_SESSION['userid']); | ||||
| $gcs->execute(); | $gcs->execute(); | ||||
| $result = $gcs->get_result(); | $result = $gcs->get_result(); | ||||
| @@ -2,7 +2,7 @@ | |||||
| if (isset($_SESSION['userid'])) { | if (isset($_SESSION['userid'])) { | ||||
| // check to see if we're going to INSERT or UPDATE a row | // check to see if we're going to INSERT or UPDATE a row | ||||
| // $cfr = Check For Results | // $cfr = Check For Results | ||||
| $cfr = $con->prepare("SELECT COUNT(*) FROM gwcharstats WHERE charid = ? AND titlenameid = ? AND accid = ? AND userid = ?"); | |||||
| $cfr = $con->prepare("SELECT COUNT(*) FROM gwstats WHERE charid = ? AND titlenameid = ? AND accid = ? AND userid = ?"); | |||||
| $cfr->bind_param("iiii", $_SESSION['prefcharid'], $_POST['titlenameid'], $_SESSION['prefaccid'], $_SESSION['userid']); | $cfr->bind_param("iiii", $_SESSION['prefcharid'], $_POST['titlenameid'], $_SESSION['prefaccid'], $_SESSION['userid']); | ||||
| $cfr->execute(); | $cfr->execute(); | ||||
| $cfr->bind_result($r1); | $cfr->bind_result($r1); | ||||
| @@ -25,14 +25,14 @@ if (isset($_SESSION['userid'])) { | |||||
| $progress = ceil(($_POST['titlepoints'] / $pmr) * 100); | $progress = ceil(($_POST['titlepoints'] / $pmr) * 100); | ||||
| if ($r1 > 0) { | if ($r1 > 0) { | ||||
| // $urs = Update Rank Stats | // $urs = Update Rank Stats | ||||
| $urs = $con->prepare("UPDATE gwcharstats SET stnameid = ?, titlepoints = ?, currentstrankname = ?, currentstrank = ?, percent = ? WHERE charid = ? AND titlenameid = ? AND accid = ? AND userid = ?"); | |||||
| $urs = $con->prepare("UPDATE gwstats SET stnameid = ?, titlepoints = ?, currentstrankname = ?, currentstrank = ?, percent = ? WHERE charid = ? AND titlenameid = ? AND accid = ? AND userid = ?"); | |||||
| $urs->bind_param("iisiiiiii", $stnameid, $_POST['titlepoints'], $stname, $strank, $progress, $_SESSION['prefcharid'], $_POST['titlenameid'], $_SESSION['prefaccid'], $_SESSION['userid']); | $urs->bind_param("iisiiiiii", $stnameid, $_POST['titlepoints'], $stname, $strank, $progress, $_SESSION['prefcharid'], $_POST['titlenameid'], $_SESSION['prefaccid'], $_SESSION['userid']); | ||||
| $urs->execute(); | $urs->execute(); | ||||
| $urs->close(); | $urs->close(); | ||||
| echo 'Title has been updated!<br /><br />'; | echo 'Title has been updated!<br /><br />'; | ||||
| } else { | } else { | ||||
| // $irs = Insert Rank Stats | // $irs = Insert Rank Stats | ||||
| $irs = $con->prepare("INSERT INTO gwcharstats (titlenameid, stnameid, titlepoints, currentstrankname, currentstrank, percent, charid, accid, userid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); | |||||
| $irs = $con->prepare("INSERT INTO gwstats (titlenameid, stnameid, titlepoints, currentstrankname, currentstrank, percent, charid, accid, userid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); | |||||
| $irs->bind_param("iiisiiiii", $_POST['titlenameid'], $stnameid, $_POST['titlepoints'], $stname, $strank, $progress, $_SESSION['prefcharid'], $_SESSION['prefaccid'], $_SESSION['userid']); | $irs->bind_param("iiisiiiii", $_POST['titlenameid'], $stnameid, $_POST['titlepoints'], $stname, $strank, $progress, $_SESSION['prefcharid'], $_SESSION['prefaccid'], $_SESSION['userid']); | ||||
| $irs->execute(); | $irs->execute(); | ||||
| $irs->close(); | $irs->close(); | ||||
| @@ -2,7 +2,7 @@ | |||||
| if (isset($_SESSION['userid'])) { | if (isset($_SESSION['userid'])) { | ||||
| // check to see if we're going to INSERT or UPDATE a row | // check to see if we're going to INSERT or UPDATE a row | ||||
| // $cfr = Check For Results | // $cfr = Check For Results | ||||
| $cfr = $con->prepare("SELECT COUNT(*) FROM gwaccstats WHERE titlenameid = ? AND accid = ? AND userid = ?"); | |||||
| $cfr = $con->prepare("SELECT COUNT(*) FROM gwstats WHERE titlenameid = ? AND accid = ? AND userid = ?"); | |||||
| $cfr->bind_param("iii", $_POST['titlenameid'], $_SESSION['prefaccid'], $_SESSION['userid']); | $cfr->bind_param("iii", $_POST['titlenameid'], $_SESSION['prefaccid'], $_SESSION['userid']); | ||||
| $cfr->execute(); | $cfr->execute(); | ||||
| $cfr->bind_result($r1); | $cfr->bind_result($r1); | ||||
| @@ -25,14 +25,14 @@ if (isset($_SESSION['userid'])) { | |||||
| $progress = ceil(($_POST['titlepoints'] / $pmr) * 100); | $progress = ceil(($_POST['titlepoints'] / $pmr) * 100); | ||||
| if ($r1 > 0) { | if ($r1 > 0) { | ||||
| // $urs = Update Rank Stats | // $urs = Update Rank Stats | ||||
| $urs = $con->prepare("UPDATE gwaccstats SET stnameid = ?, titlepoints = ?, currentstrankname = ?, currentstrank = ?, percent = ? WHERE titlenameid = ? AND accid = ? AND userid = ?"); | |||||
| $urs = $con->prepare("UPDATE gwstats SET stnameid = ?, titlepoints = ?, currentstrankname = ?, currentstrank = ?, percent = ? WHERE titlenameid = ? AND charid = 0 AND accid = ? AND userid = ?"); | |||||
| $urs->bind_param("iisiiiii", $stnameid, $_POST['titlepoints'], $stname, $strank, $progress, $_POST['titlenameid'], $_SESSION['prefaccid'], $_SESSION['userid']); | $urs->bind_param("iisiiiii", $stnameid, $_POST['titlepoints'], $stname, $strank, $progress, $_POST['titlenameid'], $_SESSION['prefaccid'], $_SESSION['userid']); | ||||
| $urs->execute(); | $urs->execute(); | ||||
| $urs->close(); | $urs->close(); | ||||
| echo 'Title has been updated!<br /><br />'; | echo 'Title has been updated!<br /><br />'; | ||||
| } else { | } else { | ||||
| // $irs = Insert Rank Stats | // $irs = Insert Rank Stats | ||||
| $irs = $con->prepare("INSERT INTO gwaccstats (titlenameid, stnameid, titlepoints, currentstrankname, currentstrank, percent, accid, userid) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); | |||||
| $irs = $con->prepare("INSERT INTO gwstats (titlenameid, stnameid, titlepoints, currentstrankname, currentstrank, percent, accid, userid) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); | |||||
| $irs->bind_param("iiisiiii", $_POST['titlenameid'], $stnameid, $_POST['titlepoints'], $stname, $strank, $progress, $_SESSION['prefaccid'], $_SESSION['userid']); | $irs->bind_param("iiisiiii", $_POST['titlenameid'], $stnameid, $_POST['titlepoints'], $stname, $strank, $progress, $_SESSION['prefaccid'], $_SESSION['userid']); | ||||
| $irs->execute(); | $irs->execute(); | ||||
| $irs->close(); | $irs->close(); | ||||
| @@ -3,10 +3,7 @@ | |||||
| $pagetitle = "Guild Wars Stats Tracker"; | $pagetitle = "Guild Wars Stats Tracker"; | ||||
| include_once ('header.php'); | include_once ('header.php'); | ||||
| if (isset($_SESSION['userid'])){ | if (isset($_SESSION['userid'])){ | ||||
| echo 'View individual character stats <A HREF="listchars.php" class="navlink">here</A><BR /><BR />'; //make this a drop down list later | |||||
| echo 'Update character stats <A HREF="updatecharstats.php" class="navlink">here</A><BR /><BR />'; | |||||
| echo 'Update account stats <A HREF="updateaccountstats.php" class="navlink">here</A><BR /><BR />'; | |||||
| echo 'Add Guild Wars accounts and manage characters <a href="addaccounts.php" class="navlink">here</a><br /><br />'; | |||||
| include_once ('includes/current-character.php'); | |||||
| } | } | ||||
| include_once ('footer.php'); | include_once ('footer.php'); | ||||
| ?> | ?> | ||||
| @@ -13,7 +13,7 @@ if (isset($_SESSION['userid'])) { | |||||
| if ($_POST['acctitle'] == "notselected") { | if ($_POST['acctitle'] == "notselected") { | ||||
| echo '<form action="updateaccountstats.php" method="post">'; | echo '<form action="updateaccountstats.php" method="post">'; | ||||
| echo 'Select account title to update: <select name="acctitle">'; | |||||
| echo 'Select account title to update: <select name="acctitle" onchange="this.form.submit()">'; | |||||
| // $ats = Account Title Select | // $ats = Account Title Select | ||||
| $ats = $con->prepare("SELECT titlenameid, titlename FROM gwtitles WHERE titletype = 0 ORDER BY titlename"); | $ats = $con->prepare("SELECT titlenameid, titlename FROM gwtitles WHERE titletype = 0 ORDER BY titlename"); | ||||
| $ats->execute(); | $ats->execute(); | ||||