diff --git a/includes/getaccountstats.php b/includes/getaccountstats.php
index 4500c9f..ce5241a 100644
--- a/includes/getaccountstats.php
+++ b/includes/getaccountstats.php
@@ -1,23 +1,43 @@
| ' . $row['currentstrankname'] . ' | ' . $row['titlepoints'] . ' | ' . $row['currentstrank'] . ' | ';
- echo '';
- $pr = ($row['nextstrankpoints'] - $row['titlepoints']);
- if ($pr < 0) {
- echo 'Maximum rank achieved!';
- } else {
- echo $pr;
+//include_once ('includes/session-debug.php');
+//include_once ('includes/session-dump.php');
+// remove the above 2 lines
+if (isset($_SESSION['userid'])) {
+ echo 'Account wide stats';
+ echo '| Title | Title Rank | Title Points | Current Rank | Points Remaining | Next Rank | ';
+ // $gas = GetAccountStats
+ $gas = $con->prepare("SELECT * FROM gwaccstats WHERE userid = ? AND accid = ?");
+ $gas->bind_param("ii", $_SESSION['userid'], $_SESSION['prefaccid']);
+ $gas->execute();
+ $result = $gas->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";
+ }
+ echo '| ' . $titlename . ' | ' . $row['currentstrankname'] . ' | ' . number_format($row['titlepoints']) . ' | ' . $row['currentstrank'] . ' | ';
+ echo '' . $pr . ' | ' . $stname . ' | ';
}
- echo '';
- echo '' . $row['nextstrank'] . ' | ';
+ $gas->close();
+ echo ' ';
}
-$gas->close();
-echo '';
?>
\ No newline at end of file
diff --git a/includes/titleranks-update.php b/includes/titleranks-update.php
index 427cce6..2e0a42a 100644
--- a/includes/titleranks-update.php
+++ b/includes/titleranks-update.php
@@ -1,38 +1,33 @@
prepare("DELETE FROM gwsubtitles WHERE titlenameid = ? AND stnameid = ?")) {
- $delst->bind_param("ii", $tnameid, $stnameid);
- for ($i = 0; $i < count($_POST['delsubtitle']); $i++) {
- $tnameid = $_POST['titlenameid'][$i];
- $stnameid = $_POST['delsubtitle'][$i];
- $delst->execute();
- }
- $delst->close();
- }
- echo 'Title rank(s) have been deleted, redirecting!';
- header ("Refresh:1; url=titlemanager.php");
-} else {
- // this section updates the title name
- if ($upd = $con->prepare("UPDATE gwsubtitles SET stname = ?, stpoints = ?, strank = ? WHERE titlenameid = ? AND stnameid = ?")) {
- $upd->bind_param("siiii", $stname, $stpoints, $strank, $titlenameid, $stnameid);
- for ($i = 0; $i < count($_POST['stname']); $i++) {
- $stname = $_POST['stname'][$i];
- $stpoints = $_POST['stpoints'][$i];
- $strank = $_POST['strank'][$i];
- $titlenameid = $_POST['titlenameid'][$i];
- $stnameid = $_POST['stnameid'][$i];
- $upd->execute();
- }
- $upd->close();
- }
- echo 'Title rank(s) updated, redirecting!';
- header ("Refresh:1; url=titlemanager.php");
+if (isset($_SESSION['userid'])) {
+ if (isset($_POST['delsubtitle'])) {
+ if ($delst = $con->prepare("DELETE FROM gwsubtitles WHERE titlenameid = ? AND stnameid = ?")) {
+ $delst->bind_param("ii", $tnameid, $stnameid);
+ for ($i = 0; $i < count($_POST['delsubtitle']); $i++) {
+ $tnameid = $_POST['titlenameid'][$i];
+ $stnameid = $_POST['delsubtitle'][$i];
+ $delst->execute();
+ }
+ $delst->close();
+ }
+ echo 'Title rank(s) have been deleted, redirecting!';
+ header ("Refresh:1; url=titlemanager.php");
+ } else {
+ // this section updates the title name
+ if ($upd = $con->prepare("UPDATE gwsubtitles SET stname = ?, stpoints = ?, strank = ? WHERE titlenameid = ? AND stnameid = ?")) {
+ $upd->bind_param("siiii", $stname, $stpoints, $strank, $titlenameid, $stnameid);
+ for ($i = 0; $i < count($_POST['stname']); $i++) {
+ $stname = $_POST['stname'][$i];
+ $stpoints = $_POST['stpoints'][$i];
+ $strank = $_POST['strank'][$i];
+ $titlenameid = $_POST['titlenameid'][$i];
+ $stnameid = $_POST['stnameid'][$i];
+ $upd->execute();
+ }
+ $upd->close();
+ }
+ echo 'Title rank(s) updated, redirecting!';
+ header ("Refresh:1; url=titlemanager.php");
+ }
}
?>
\ No newline at end of file
diff --git a/includes/update-titleranks.php b/includes/update-titleranks.php
new file mode 100644
index 0000000..eab365a
--- /dev/null
+++ b/includes/update-titleranks.php
@@ -0,0 +1,34 @@
+prepare("SELECT COUNT(*) FROM gwaccstats WHERE titlenameid = ? AND accid = ? AND userid = ?");
+ $cfr->bind_param("iii", $_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();
+ if ($r1 > 0) {
+ // $urs = Update Rank Stats
+ $urs = $con->prepare("UPDATE gwaccstats SET stnameid = ?, titlepoints = ?, currentstrankname = ?, currentstrank = ? WHERE titlenameid = ? AND accid = ? AND userid = ?");
+ $urs->bind_param("iisiiii", $stnameid, $_POST['titlepoints'], $stname, $strank, $_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 gwaccstats (titlenameid, stnameid, titlepoints, currentstrankname, currentstrank, accid, userid) VALUES (?, ?, ?, ?, ?, ?, ?)");
+ $irs->bind_param("iiisiii", $_POST['titlenameid'], $stnameid, $_POST['titlepoints'], $stname, $strank, $_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 df125da..9189ad8 100644
--- a/updateaccountstats.php
+++ b/updateaccountstats.php
@@ -2,11 +2,34 @@
$pagetitle = "Update account wide stats";
include_once ('header.php');
if (isset($_SESSION['userid'])) {
- include_once ('includes/session-debug.php');
- include_once ('includes/session-dump.php');
+ if (!isset($_POST['acctitle'])) {
+ $_POST['acctitle'] = "notselected";
+ }
+
+ if (isset($_POST['titlepoints'])) {
+ // include file just updates the database
+ include_once ('includes/update-titleranks.php');
+ }
+
+ if ($_POST['acctitle'] == "notselected") {
+ echo ' ';
+ $ats->close();
+ } else {
+ echo '';
+ }
echo 'Current account stats for: ' . $_SESSION['prefaccname'] . ' ';
include_once ('includes/getaccountstats.php');
- echo 'Return to your user page';
+ echo 'Return to your user page ';
}
include_once ('footer.php');
?>
\ No newline at end of file
|