diff --git a/header.php b/header.php
index 4854ae8..f7b0888 100644
--- a/header.php
+++ b/header.php
@@ -36,9 +36,6 @@ if (!$userid){
}
echo '
';
+ echo ') ';
+ if ($_SESSION['admin'] == 1){
+ echo'(Administration) ';
+ }
+ echo '(Logout ' . $_SESSION['username'] . ')
';
}
?>
\ No newline at end of file
diff --git a/includes/getaccountstats.php b/includes/getaccountstats.php
index a6359ae..9ab32cd 100644
--- a/includes/getaccountstats.php
+++ b/includes/getaccountstats.php
@@ -23,7 +23,7 @@ if (isset($_SESSION['userid'])) {
$gt->fetch();
$gt->close();
$pr = number_format(($stpoints - $row['titlepoints']));
- if ($pr < 0) {
+ if ($pr <= 0) {
$pr = "Highest rank achieved!";
$stname = "Highest rank achieved!";
}
@@ -31,7 +31,7 @@ if (isset($_SESSION['userid'])) {
$row['currentstrankname'] = "No title earned yet!";
$row['currentstrank'] = "0";
}
- if ($row['percent'] > 100) {
+ if ($row['percent'] >= 100) {
$ohp = 100;
} else {
$ohp = $row['percent'];
diff --git a/includes/getcharstats.php b/includes/getcharstats.php
new file mode 100644
index 0000000..faa792c
--- /dev/null
+++ b/includes/getcharstats.php
@@ -0,0 +1,47 @@
+Character stats';
+ echo '| Title | Title Rank | Title Points | Current Rank | Points Remaining | Max Title % | Next Rank |
';
+ // $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 '| ' . $titlename . ' | ' . $row['currentstrankname'] . ' | ' . number_format($row['titlepoints']) . ' | ' . $row['currentstrank'] . ' | ';
+ echo '' . $pr . ' | ';
+ echo $ohp;
+ echo '% completed | ' . $stname . ' |
';
+ }
+ $gcs->close();
+ echo '
';
+}
+?>
\ No newline at end of file
diff --git a/includes/update-chartitleranks.php b/includes/update-chartitleranks.php
new file mode 100644
index 0000000..91eca2d
--- /dev/null
+++ b/includes/update-chartitleranks.php
@@ -0,0 +1,42 @@
+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!
';
+ } 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!
';
+ }
+}
+?>
\ No newline at end of file
diff --git a/updateaccountstats.php b/updateaccountstats.php
index 9189ad8..218c42e 100644
--- a/updateaccountstats.php
+++ b/updateaccountstats.php
@@ -15,7 +15,7 @@ if (isset($_SESSION['userid'])) {
echo '