| @@ -36,9 +36,6 @@ if (!$userid){ | |||||
| } | } | ||||
| echo '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">'; | echo '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">'; | ||||
| echo '(<a href="index.php" class="navlink">Home</a>) (<a href="preferences.php" class="navlink">Options</a>) '; | echo '(<a href="index.php" class="navlink">Home</a>) (<a href="preferences.php" class="navlink">Options</a>) '; | ||||
| if ($_SESSION['admin'] == 1){ | |||||
| echo'(<a href="adminlanding.php" class="navlink">Administration</a>) '; | |||||
| } | |||||
| echo '(<select name="prefaccid" onchange="this.form.submit()">'; | echo '(<select name="prefaccid" onchange="this.form.submit()">'; | ||||
| echo '<option class="header" value="' . $_SESSION['prefaccid'] . '">' . $_SESSION['prefaccname'] . '</option>'; | echo '<option class="header" value="' . $_SESSION['prefaccid'] . '">' . $_SESSION['prefaccname'] . '</option>'; | ||||
| echo '<option value="nopref">No default selected</option>'; | echo '<option value="nopref">No default selected</option>'; | ||||
| @@ -48,6 +45,10 @@ if (!$userid){ | |||||
| echo '<option "class="header" value="' . $_SESSION['prefcharid'] . '">' . $_SESSION['prefcharname'] . '</option>'; | echo '<option "class="header" value="' . $_SESSION['prefcharid'] . '">' . $_SESSION['prefcharname'] . '</option>'; | ||||
| echo '<option value="nopref">No default selected</option>'; | echo '<option value="nopref">No default selected</option>'; | ||||
| include_once ('header-list-chars.php'); | include_once ('header-list-chars.php'); | ||||
| echo '</select>)<noscript><input type="submit" value="Preferrence"></noscript> (<a href="logout.php?action=logout" class="navlink">Logout ' . $_SESSION['username'] . '</a>)</form><hr><br / >'; | |||||
| echo '</select>)<noscript><input type="submit" value="Preferrence"></noscript> '; | |||||
| if ($_SESSION['admin'] == 1){ | |||||
| 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 / >'; | |||||
| } | } | ||||
| ?> | ?> | ||||
| @@ -23,7 +23,7 @@ if (isset($_SESSION['userid'])) { | |||||
| $gt->fetch(); | $gt->fetch(); | ||||
| $gt->close(); | $gt->close(); | ||||
| $pr = number_format(($stpoints - $row['titlepoints'])); | $pr = number_format(($stpoints - $row['titlepoints'])); | ||||
| if ($pr < 0) { | |||||
| if ($pr <= 0) { | |||||
| $pr = "Highest rank achieved!"; | $pr = "Highest rank achieved!"; | ||||
| $stname = "Highest rank achieved!"; | $stname = "Highest rank achieved!"; | ||||
| } | } | ||||
| @@ -31,7 +31,7 @@ if (isset($_SESSION['userid'])) { | |||||
| $row['currentstrankname'] = "No title earned yet!"; | $row['currentstrankname'] = "No title earned yet!"; | ||||
| $row['currentstrank'] = "0"; | $row['currentstrank'] = "0"; | ||||
| } | } | ||||
| if ($row['percent'] > 100) { | |||||
| if ($row['percent'] >= 100) { | |||||
| $ohp = 100; | $ohp = 100; | ||||
| } else { | } else { | ||||
| $ohp = $row['percent']; | $ohp = $row['percent']; | ||||
| @@ -0,0 +1,47 @@ | |||||
| <?php | |||||
| if (isset($_SESSION['userid'])) { | |||||
| 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>'; | |||||
| // $gcs = Get Character Stats | |||||
| $gcs = $con->prepare("SELECT * FROM gwcharstats WHERE charid = ? AND accid = ? AND userid = ? ORDER BY currentstrank DESC, percent ASC"); | |||||
| $gcs->bind_param("iii", $_SESSION['prefcharid'], $_SESSION['prefaccid'], $_SESSION['userid']); | |||||
| $gcs->execute(); | |||||
| $result = $gcs->get_result(); | |||||
| while ($row = $result->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>'; | |||||
| } | |||||
| $gcs->close(); | |||||
| echo '</table><br />'; | |||||
| } | |||||
| ?> | |||||
| @@ -0,0 +1,42 @@ | |||||
| <?php | |||||
| if (isset($_SESSION['userid'])) { | |||||
| // check to see if we're going to INSERT or UPDATE a row | |||||
| // $cfr = Check For Results | |||||
| $cfr = $con->prepare("SELECT COUNT(*) FROM gwcharstats WHERE charid = ? AND titlenameid = ? AND accid = ? AND userid = ?"); | |||||
| $cfr->bind_param("iiii", $_SESSION['prefcharid'], $_POST['titlenameid'], $_SESSION['prefaccid'], $_SESSION['userid']); | |||||
| $cfr->execute(); | |||||
| $cfr->bind_result($r1); | |||||
| $cfr->fetch(); | |||||
| $cfr->close(); | |||||
| // $gcr = Get Current Rank | |||||
| $gcr = $con->prepare("SELECT stnameid, stname, strank FROM gwsubtitles WHERE titlenameid = ? AND stpoints <= ? ORDER BY stpoints DESC LIMIT 1"); | |||||
| $gcr->bind_param("ii", $_POST['titlenameid'], $_POST['titlepoints']); | |||||
| $gcr->execute(); | |||||
| $gcr->bind_result($stnameid, $stname, $strank); | |||||
| $gcr->fetch(); | |||||
| $gcr->close(); | |||||
| // $gpc = Get Percentage Completed | |||||
| $gpc = $con->prepare("SELECT stpoints FROM gwsubtitles WHERE titlenameid = ? ORDER BY stnameid DESC LIMIT 1"); | |||||
| $gpc->bind_param("i", $_POST['titlenameid']); | |||||
| $gpc->execute(); | |||||
| $gpc->bind_result($pmr); //$pmr = Percentage Max Rank | |||||
| $gpc->fetch(); | |||||
| $gpc->close(); | |||||
| $progress = ceil(($_POST['titlepoints'] / $pmr) * 100); | |||||
| if ($r1 > 0) { | |||||
| // $urs = Update Rank Stats | |||||
| $urs = $con->prepare("UPDATE gwcharstats 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->execute(); | |||||
| $urs->close(); | |||||
| echo 'Title has been updated!<br /><br />'; | |||||
| } else { | |||||
| // $irs = Insert Rank Stats | |||||
| $irs = $con->prepare("INSERT INTO gwcharstats (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->execute(); | |||||
| $irs->close(); | |||||
| echo 'Title entered!<br /></br />'; | |||||
| } | |||||
| } | |||||
| ?> | |||||
| @@ -15,7 +15,7 @@ if (isset($_SESSION['userid'])) { | |||||
| 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">'; | ||||
| // $ats = Account Title Select | // $ats = Account Title Select | ||||
| $ats = $con->prepare("SELECT titlenameid, titlename FROM gwtitles WHERE titletype = 0"); | |||||
| $ats = $con->prepare("SELECT titlenameid, titlename FROM gwtitles WHERE titletype = 0 ORDER BY titlename"); | |||||
| $ats->execute(); | $ats->execute(); | ||||
| $result = $ats->get_result(); | $result = $ats->get_result(); | ||||
| while ($row = $result->fetch_assoc()) { | while ($row = $result->fetch_assoc()) { | ||||
| @@ -2,7 +2,34 @@ | |||||
| $pagetitle = "Update character stats"; | $pagetitle = "Update character stats"; | ||||
| include_once ('header.php'); | include_once ('header.php'); | ||||
| if (isset($_SESSION['userid'])) { | if (isset($_SESSION['userid'])) { | ||||
| echo 'Return to your <a href="index.php" class="navlink">user</a> page'; | |||||
| if (!isset($_POST['chartitle'])) { | |||||
| $_POST['chartitle'] = "notselected"; | |||||
| } | |||||
| if (isset($_POST['titlepoints'])) { | |||||
| // include file just updates the database | |||||
| include_once ('includes/update-chartitleranks.php'); | |||||
| } | |||||
| if ($_POST['chartitle'] == "notselected") { | |||||
| echo '<form action="updatecharstats.php" method="post">'; | |||||
| echo 'Select character title to update: <select name="chartitle" onchange="this.form.submit()">'; | |||||
| // $cts = Character Title Select | |||||
| $cts = $con->prepare("SELECT titlenameid, titlename FROM gwtitles WHERE titletype = 1 ORDER BY titlename"); | |||||
| $cts->execute(); | |||||
| $result = $cts->get_result(); | |||||
| while ($row = $result->fetch_assoc()) { | |||||
| echo '<option value="' . $row['titlenameid'] . '">' . $row['titlename'] . '</option>'; | |||||
| } | |||||
| echo '</select><input type="submit" value="Select title"></form><br />'; | |||||
| $cts->close(); | |||||
| } else { | |||||
| echo '<form action="updatecharstats.php" method="post"><input type="hidden" name="titlenameid" value="' . $_POST['chartitle'] .'">'; | |||||
| echo '<input type="number" step="0.1" name="titlepoints" required autofocus><noscript><input type="submit" value="Update points"></noscript></form>'; | |||||
| } | |||||
| echo 'Current character stats for: <b>' . $_SESSION['prefcharname'] . '</b><br />'; | |||||
| include_once ('includes/getcharstats.php'); | |||||
| echo 'Return to your <a href="index.php" class="navlink">user</a> page<br />'; | |||||
| } | } | ||||
| include_once ('footer.php'); | include_once ('footer.php'); | ||||
| ?> | ?> | ||||