From f3ccb0a5ac747c8db584799b86baabc0934cafc3 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Sat, 4 Aug 2018 14:54:06 -1000 Subject: [PATCH 01/97] initial commit everything i've done live on a web server accessible on my local LAN only --- adminlanding.php | 10 ++++++++++ connect.php-sample | 6 ++++++ footer.php | 1 + header.php | 22 +++++++++++++--------- index.php | 3 ++- 5 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 adminlanding.php create mode 100644 connect.php-sample diff --git a/adminlanding.php b/adminlanding.php new file mode 100644 index 0000000..81025d4 --- /dev/null +++ b/adminlanding.php @@ -0,0 +1,10 @@ +Welcome to the admin area!

'; +echo 'Title creator / editor here (work in progress)

'; +echo 'User editor here (not working yet)
'; +include_once ('footer.php'); +?> \ No newline at end of file diff --git a/connect.php-sample b/connect.php-sample new file mode 100644 index 0000000..7f6f27f --- /dev/null +++ b/connect.php-sample @@ -0,0 +1,6 @@ + diff --git a/footer.php b/footer.php index b1a0dbb..095b9bf 100644 --- a/footer.php +++ b/footer.php @@ -1,5 +1,6 @@
'; } diff --git a/header.php b/header.php index ffaad99..6f2e7d6 100644 --- a/header.php +++ b/header.php @@ -4,20 +4,24 @@ connect_errno){ die ('Unable to connect to database [' . $db->connect_errno . ']'); } if (!$userid){ - echo 'Please login first'; - echo '
Username:
'; - echo 'Password:
'; - echo '
'; + echo 'Please login first
Aloha, and welcome to my Guild Wars stats tracker. Please login below.
'; + echo '
'; + echo '
Username:
Password:
'; + echo '


'; + echo 'If you haven\'t registered an account yet,
please click here to create one.
'; } else { - echo '' . $pagetitle . '
'; - echo '(Home) (SEARCH) (Logout ' . $uname . ')

'; + echo '' . $pagetitle . '
'; + echo '(Home) (Options) '; + if ($_SESSION['admin'] == 1){ + echo'(Administration) '; + } + echo '(Logout ' . $_SESSION['username'] . ')

'; } ?> \ No newline at end of file diff --git a/index.php b/index.php index a1bd06d..96579d6 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,4 @@ + here
'; } include_once ('footer.php'); -?> \ No newline at end of file +?> From 0ab125aab210eeb13e76c3d604f7db29b502c4ad Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Sat, 4 Aug 2018 14:55:12 -1000 Subject: [PATCH 02/97] no longer needed replaced by connect.php-sample --- connection.php-sample | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 connection.php-sample diff --git a/connection.php-sample b/connection.php-sample deleted file mode 100644 index e182191..0000000 --- a/connection.php-sample +++ /dev/null @@ -1,6 +0,0 @@ - From 63479f27ef26b178bff8d341df59f48c43472ca2 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Sat, 4 Aug 2018 14:56:46 -1000 Subject: [PATCH 03/97] initial commit everything from the includes directory --- includes/account-registration.php | 23 +++++++++++++++++++++++ includes/title-add.php | 5 +++++ includes/title-editor.php | 28 ++++++++++++++++++++++++++++ includes/titleranks-add.php | 39 +++++++++++++++++++++++++++++++++++++++ includes/titleranks-submit.php | 13 +++++++++++++ 5 files changed, 108 insertions(+) create mode 100644 includes/account-registration.php create mode 100644 includes/title-add.php create mode 100644 includes/title-editor.php create mode 100644 includes/titleranks-add.php create mode 100644 includes/titleranks-submit.php diff --git a/includes/account-registration.php b/includes/account-registration.php new file mode 100644 index 0000000..5266017 --- /dev/null +++ b/includes/account-registration.php @@ -0,0 +1,23 @@ +
+ + + + + + + +
Username desired
E-Mail address
PasswordVerify password
+ + + +
\ No newline at end of file diff --git a/includes/title-add.php b/includes/title-add.php new file mode 100644 index 0000000..396dbe6 --- /dev/null +++ b/includes/title-add.php @@ -0,0 +1,5 @@ +'; +echo ''; +echo '
Title NameTitle Type
Account
Character

'; +?> \ No newline at end of file diff --git a/includes/title-editor.php b/includes/title-editor.php new file mode 100644 index 0000000..5ceb51a --- /dev/null +++ b/includes/title-editor.php @@ -0,0 +1,28 @@ +'; +echo ''; +$stmtview = $con->prepare("SELECT * FROM gwtitles WHERE titlenameid = ?"); +$stmtview->bind_param("i", $_POST['tid']); +$stmtview->execute(); +$result = $stmtview->get_result(); +while ($row = $result->fetch_assoc()) { + $tid = $row['titlenameid']; + $tname = $row['titlename']; + $ttype = $row['titletype']; + echo ''; +} +$stmtview->close(); +echo '
titlenameidtitlenametitletype
'; + echo 'Account
'; + echo 'Character
Delete title?


'; +echo '
'; +echo 'Return to title manager'; +?> \ No newline at end of file diff --git a/includes/titleranks-add.php b/includes/titleranks-add.php new file mode 100644 index 0000000..5d2f93d --- /dev/null +++ b/includes/titleranks-add.php @@ -0,0 +1,39 @@ +'; +} +echo '
'; +echo '
Title Rank NameTitle PointsRank Level
'; +echo '

'; + +echo 'Here are the currently associated title ranks, starting with rank 1:
'; +echo ''; +$stmtview = $con->prepare("SELECT * FROM gwsubtitles WHERE titlenameid = ? ORDER BY strank ASC"); +$stmtview->bind_param("i", $_POST['tid']); +$stmtview->execute(); +$result = $stmtview->get_result(); +while ($row = $result->fetch_assoc()) { + $stnid = $row['stnameid']; + $tnid = $row['titlenameid']; + $stname = $row['stname']; + $stpoints = $row['stpoints']; + $strank = $row['strank']; + echo ''; +} +$stmtview->close(); +echo '
stnameidtitlenameidstnamestpointsstrank
' . $stnid . '' . $tnid . '' . $stname . '' . number_format($stpoints) . '' . $strank . '

If anything looks off, please fix it!

'; +echo 'Return to title manager'; //this line needs to go away soon. Maybe? +?> \ No newline at end of file diff --git a/includes/titleranks-submit.php b/includes/titleranks-submit.php new file mode 100644 index 0000000..7e4db9c --- /dev/null +++ b/includes/titleranks-submit.php @@ -0,0 +1,13 @@ +prepare("INSERT INTO gwsubtitles (titlenameid, stname, stpoints, strank) VALUES (?, ?, ?, ?)"); +$stmtstins->bind_param("isii", $_POST['titlenameid'], $_POST['titlerankname'], $_POST['titlepoints'], $_POST['titlerank']); +$stmtstins->execute(); +$stmtstins->close(); +$_SESSION['title'] = "repeat"; +$_SESSION['tid'] = $_POST['titlenameid']; +echo 'Title rank added, redirecting!'; +header ("Refresh:1; url=titlemanager.php"); +?> \ No newline at end of file From 4f2110bb329d1b43b210ebf9b0c8565f773c6271 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Sat, 4 Aug 2018 14:57:40 -1000 Subject: [PATCH 04/97] initial commit everything from my local includes directory --- includes/title-select.php | 11 ++++++++++ includes/title-submit.php | 19 ++++++++++++++++ includes/title-update.php | 26 ++++++++++++++++++++++ includes/verifications.php | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 includes/title-select.php create mode 100644 includes/title-submit.php create mode 100644 includes/title-update.php create mode 100644 includes/verifications.php diff --git a/includes/title-select.php b/includes/title-select.php new file mode 100644 index 0000000..f274625 --- /dev/null +++ b/includes/title-select.php @@ -0,0 +1,11 @@ +prepare("SELECT * FROM gwtitles ORDER BY titlename"); +$stmtview->execute(); +$result = $stmtview->get_result(); +while ($row = $result->fetch_assoc()) { + $tid = $row['titlenameid']; + $tname = $row['titlename']; + echo ''; +} +$stmtview->close(); +?> \ No newline at end of file diff --git a/includes/title-submit.php b/includes/title-submit.php new file mode 100644 index 0000000..cef8a57 --- /dev/null +++ b/includes/title-submit.php @@ -0,0 +1,19 @@ +prepare("INSERT INTO gwtitles (titlename, titletype) VALUES (?, ?)"); +$stmtins->bind_param("si", $_POST['titlename'], $_POST['titletype']); +$stmtins->execute(); +$stmtins->close(); +echo 'New title added!

'; +$stmtview = $con->prepare("SELECT * FROM gwtitles ORDER BY titlenameid DESC LIMIT 1"); +$stmtview->execute(); +$result = $stmtview->get_result(); +while ($row = $result->fetch_assoc()) { + $tid = $row['titlenameid']; + $tname = $row['titlename']; + $ttype = $row['titletype']; + echo ''; + echo '
titleidtitlenametitletype
' . $tid . '' . $tname . '' . $ttype . '

'; +} +$stmtview->close(); +echo 'Return to title manager'; +?> \ No newline at end of file diff --git a/includes/title-update.php b/includes/title-update.php new file mode 100644 index 0000000..4773de2 --- /dev/null +++ b/includes/title-update.php @@ -0,0 +1,26 @@ +Please check the box to verify you want to delete: ' . $_POST['titlename'] . ' '; + echo '

'; + } else if ($_POST['deltitle'] == "iamsure") { + // this section actually deletes the title + $stmtdel = $con->prepare("DELETE FROM gwtitles WHERE titlenameid = ?"); + $stmtdel->bind_param("i", $_POST['titlenameid']); + $stmtdel->execute(); + $stmtdel->close(); + echo 'Title has been deleted, redirecting!'; + header ("Refresh:1; url=titlemanager.php"); + } +} else { + // this section updates the title name + $stmtupd = $con->prepare("UPDATE gwtitles SET titlename = ?, titletype = ? WHERE titlenameid = ?"); + $stmtupd->bind_param("sii", $_POST['titlename'], $_POST['titletype'], $_POST['titlenameid']); + $stmtupd->execute(); + $stmtupd->close(); + echo 'Title updated, redirecting!'; + header ("Refresh:1; url=titlemanager.php"); +} +//echo 'Return to title manager'; //this line needs to go away soon +?> \ No newline at end of file diff --git a/includes/verifications.php b/includes/verifications.php new file mode 100644 index 0000000..24f4d06 --- /dev/null +++ b/includes/verifications.php @@ -0,0 +1,55 @@ += 1) { + echo '
This e-mail address is already registered, please click on the forgot password link.
Please try again!

'; + include_once ('footer.php'); + exit(); + } +} + +# this function verifies that a username doesn't already exist in the database +function validateUsername($uname) { + $con = mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME); + $sqlunamecheck = "SELECT username FROM userinfo WHERE userinfo.username = '" . $uname . "'"; + $results = mysqli_query($con, $sqlunamecheck); + if (mysqli_num_rows($results) >= 1) { + echo '
This username has already been taken, please choose another one
Please try again!
'; + include_once ('footer.php'); + exit(); + } +} + +#################### +# verifying the username doesn't already exist in the database +$username = mysqli_real_escape_string($con, $_POST['username']); +validateUsername($username); + +#################### +# verifying the e-mail address is in a valid format +$verifyemail = validateEmail($_POST['useremail']); +if (empty($verifyemail)) { + echo '
This address: ' . $_POST['useremail'] . ' is not a valid e-mail address!
Please verify and type it again.
'; + include_once ('footer.php'); + exit(); +} + +usedEmail($_POST['useremail']); + +#################### +# verifying passwords match each other + +if (($_POST['userpass1']) != ($_POST['userpass2'])) { + echo '
The passwords don\'t match!
Please try again!'; + include_once ('footer.php'); + exit(); +} +?> \ No newline at end of file From bac2711b0a6801bfa7a655b6a8d7c9013ab878d4 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Sat, 4 Aug 2018 14:58:51 -1000 Subject: [PATCH 05/97] replaced old files from master branch --- login.php | 42 +++++++++++++++++++----------------------- logout.php | 1 - style.css | 4 +++- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/login.php b/login.php index 6ebb8d2..e6ed1f0 100644 --- a/login.php +++ b/login.php @@ -7,33 +7,29 @@
15)); +$password = $_POST['password']; + if ($con->connect_errno > 0){ die ('Unable to connect to database [' . $db->connect_errno . ']'); } -$sqllogin = "SELECT * FROM users WHERE users.username = '$username' and passwd = '$passhash'"; -if ($result = $con->query($sqllogin)){ - $row_cnt = mysqli_num_rows($result); - if ($row_cnt > 0){ - while ($row = $result->fetch_array()){ - $uname = $row['username']; - $uid = $row['userid']; - $_SESSION['username'] = $uname; - $_SESSION['userid'] = $uid; - } - header("refresh:1;url=index.php"); - echo 'You have successfully logged in ...
Returning to index in a few seconds
'; - } else { - echo 'That was not a valid username or password!

'; - echo 'Please try again here
'; - } +$sqluname = "select * from userinfo where username = '$username'"; +$result = mysqli_query($con, $sqluname); +$row = mysqli_fetch_row ($result); +$verifypass = password_verify ($password,$row[2]); +if ($verifypass) { + $_SESSION['userid'] = $row[0]; + $_SESSION['username'] = $row[1]; + $_SESSION['usermail'] = $row[3]; + $_SESSION['admin'] = $row[4]; + include_once ('header.php'); + header("refresh:1;url=index.php"); + echo '
You have successfully logged in!
'; +} else { + echo 'The username or password provided don\'t match!
Please try again
'; + exit(); } -include_once ('footer.php'); ?> \ No newline at end of file diff --git a/logout.php b/logout.php index 4c3a5d9..d6f89d4 100644 --- a/logout.php +++ b/logout.php @@ -15,5 +15,4 @@ if ($logout == "logout"){ } else { echo '
Something went wrong, you haven\'t been logged out!

Please click HERE to try again
'; } -include_once ('footer.php'); ?> \ No newline at end of file diff --git a/style.css b/style.css index e28db87..9e4c799 100644 --- a/style.css +++ b/style.css @@ -10,9 +10,11 @@ a.navlink:link { color: #003366; font-weight: bold; text-decoration: none; } a.navlink:visited { color: #003366; font-weight: bold; text-decoration: none; } a.navlink:hover { color: #CCCCCC; font-weight: bold; text-decoration: none; } -td { +table td { font-family: Tahoma; font-size: 13px; + display: table-cell; vertical-align: center; + text-align: center; } .title { From 569bbc592e2fede7528909dda9c7c5c92c31f1f5 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Sat, 4 Aug 2018 15:00:05 -1000 Subject: [PATCH 06/97] register account, manage titles --- register.php | 31 +++++++++++++++++++++++++ titlemanager.php | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 register.php create mode 100644 titlemanager.php diff --git a/register.php b/register.php new file mode 100644 index 0000000..cfa4b50 --- /dev/null +++ b/register.php @@ -0,0 +1,31 @@ + + + + +connect_errno){ + die ('Unable to connect to database [' . $db->connect_errno . ']'); +} +if (is_null($newuser)){ + // this block contains the code to fill out the form + echo '
'; + include_once ('includes/account-registration.php'); + echo '

'; +} else { + include_once ('includes/verifications.php'); + // this block validates input, and if passed, inserts it into the database + $hashedpass = password_hash($_POST['userpass1'], PASSWORD_DEFAULT); + $stmt = $con->prepare("INSERT INTO userinfo (username, userpass, usermail) VALUES (?, ?, ?)"); + $stmt->bind_param("sss", $username, $hashedpass, $verifyemail); + $stmt->execute(); + echo '
Account created, please login to continue

'; + session_destroy(); + exit(); +} +echo '
Back to home page
'; +include_once ('footer.php'); +?> \ No newline at end of file diff --git a/titlemanager.php b/titlemanager.php new file mode 100644 index 0000000..90d8919 --- /dev/null +++ b/titlemanager.php @@ -0,0 +1,70 @@ +connect_errno){ + die ('Unable to connect to database [' . $db->connect_errno . ']'); +} +if ($_SESSION['title'] == "repeat") { + $_POST['title'] = "addsubtitle"; + unset($_SESSION['title']); +} +if ($_SESSION['admin'] == 1) { + echo '
'; + if ($_POST['title'] == "addtitle") { + // included file contains all the code to add a new title + include_once ('includes/title-add.php'); + } else if ($_POST['title'] == "titlesubmit") { + // included file contains all the code to submit a new title + include_once ('includes/title-submit.php'); + } else if ($_POST['title'] == "modtitle") { + // included file contains all the code to edit a title + include_once ('includes/title-editor.php'); + } else if ($_POST['title'] == "updatetitle") { + // this section doesn't require human interaction + include_once ('includes/title-update.php'); + } else if ($_POST['title'] == "addsubtitle") { + // included file contains all code to add the title ranks and points required + include_once ('includes/titleranks-add.php'); + } else if ($_POST['title'] == "titleranksubmit") { + // this section doesn't require human interaction + include_once ('includes/titleranks-submit.php'); + } else { + unset($_SESSION['tid']); + echo 'Add titles

'; + echo 'Modify titles


'; + echo 'Add title ranks and points to

'; + echo 'Edit / Delete subtitle & points (code goes here)

'; + // now to view the last 5 title entries in the database + echo 'Here is the last 5 titles entered into the database, newest entry is on top:
'; + echo ''; + $stmtview = $con->prepare("SELECT * FROM gwtitles ORDER BY titlenameid DESC LIMIT 5"); + $stmtview->execute(); + $result = $stmtview->get_result(); + while ($row = $result->fetch_assoc()) { + $tid = $row['titlenameid']; + $tname = $row['titlename']; + $ttype = $row['titletype']; + echo ''; + } + $stmtview->close(); + echo '
titleidtitlenametitletypetitletype
' . $tid . '' . $tname . '' . $ttype . ''; + if ($ttype == "0") { + echo 'account'; + } else if ($ttype == "1") { + echo 'character'; + } else { + echo 'Anything other than a 0 or 1 means something broke!'; + include_once ('footer.php'); + exit(); + } + echo '

If anything looks off, please fix it!

'; + } +} +include_once ('footer.php'); +?> \ No newline at end of file From 850231d4a521cc2dae2af5e2ec4fc01bfb2461f4 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Sat, 4 Aug 2018 15:42:42 -1000 Subject: [PATCH 07/97] dded title max rank --- includes/title-add.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/title-add.php b/includes/title-add.php index 396dbe6..90bab29 100644 --- a/includes/title-add.php +++ b/includes/title-add.php @@ -1,5 +1,6 @@ '; -echo ''; +echo '
Title NameTitle Type
Account
Character
'; +echo ''; +echo ''; echo '
Title NameTitle Type
Account
Character

'; ?> \ No newline at end of file From 24a66a96444581c21ec817d475c0497d320e000d Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Sat, 4 Aug 2018 15:44:41 -1000 Subject: [PATCH 08/97] fixed table header --- includes/title-add.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/title-add.php b/includes/title-add.php index 90bab29..16f31ab 100644 --- a/includes/title-add.php +++ b/includes/title-add.php @@ -1,5 +1,5 @@ '; +echo '
Title NameTitle Type
'; echo ''; echo ''; echo '
Title NameTitle TypeMax Rank
Account
Character

'; From 868c711d9dd4df6891afdfb95b0fa751cb698430 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Sat, 4 Aug 2018 16:01:25 -1000 Subject: [PATCH 09/97] added title max rank to editor and associated support --- includes/title-editor.php | 5 +++-- includes/title-submit.php | 9 +++++---- includes/title-update.php | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/includes/title-editor.php b/includes/title-editor.php index 5ceb51a..86c3466 100644 --- a/includes/title-editor.php +++ b/includes/title-editor.php @@ -1,6 +1,6 @@ '; -echo ''; +echo '
titlenameidtitlenametitletype
'; $stmtview = $con->prepare("SELECT * FROM gwtitles WHERE titlenameid = ?"); $stmtview->bind_param("i", $_POST['tid']); $stmtview->execute(); @@ -9,6 +9,7 @@ while ($row = $result->fetch_assoc()) { $tid = $row['titlenameid']; $tname = $row['titlename']; $ttype = $row['titletype']; + $tmr = $row['titlemaxrank']; echo ''; + echo 'value="1">Character'; } $stmtview->close(); echo '
titlenameidtitlenametitletypetitlemaxrank
'; echo 'fetch_assoc()) { if ($ttype == 1) { echo 'checked '; } - echo 'value="1">Character
Delete title?


'; diff --git a/includes/title-submit.php b/includes/title-submit.php index cef8a57..7284c43 100644 --- a/includes/title-submit.php +++ b/includes/title-submit.php @@ -1,6 +1,6 @@ prepare("INSERT INTO gwtitles (titlename, titletype) VALUES (?, ?)"); -$stmtins->bind_param("si", $_POST['titlename'], $_POST['titletype']); +$stmtins = $con->prepare("INSERT INTO gwtitles (titlename, titletype, titlemaxrank) VALUES (?, ?, ?)"); +$stmtins->bind_param("sii", $_POST['titlename'], $_POST['titletype'], $_POST['titlemaxrank']); $stmtins->execute(); $stmtins->close(); echo 'New title added!

'; @@ -11,8 +11,9 @@ while ($row = $result->fetch_assoc()) { $tid = $row['titlenameid']; $tname = $row['titlename']; $ttype = $row['titletype']; - echo ''; - echo '
titleidtitlenametitletype
' . $tid . '' . $tname . '' . $ttype . '

'; + $tmr = $row['titlemaxrank']; + echo ''; + echo '
titleidtitlenametitletypetitlemaxrank
' . $tid . '' . $tname . '' . $ttype . '' . $tmr . '

'; } $stmtview->close(); echo 'Return to title manager'; diff --git a/includes/title-update.php b/includes/title-update.php index 4773de2..db790d8 100644 --- a/includes/title-update.php +++ b/includes/title-update.php @@ -15,8 +15,8 @@ if (isset($_POST['deltitle'])) { } } else { // this section updates the title name - $stmtupd = $con->prepare("UPDATE gwtitles SET titlename = ?, titletype = ? WHERE titlenameid = ?"); - $stmtupd->bind_param("sii", $_POST['titlename'], $_POST['titletype'], $_POST['titlenameid']); + $stmtupd = $con->prepare("UPDATE gwtitles SET titlename = ?, titletype = ?, titlemaxrank = ? WHERE titlenameid = ?"); + $stmtupd->bind_param("siii", $_POST['titlename'], $_POST['titletype'], $_POST['titlemaxrank'], $_POST['titlenameid']); $stmtupd->execute(); $stmtupd->close(); echo 'Title updated, redirecting!'; From 84246dae50e7d16fa2a21bb6e8ca8e0535469aeb Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Sun, 5 Aug 2018 09:12:55 -1000 Subject: [PATCH 10/97] made the title selector and last 5 show the maximum rank for the title --- includes/title-select.php | 3 ++- titlemanager.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/title-select.php b/includes/title-select.php index f274625..544cb4f 100644 --- a/includes/title-select.php +++ b/includes/title-select.php @@ -5,7 +5,8 @@ $result = $stmtview->get_result(); while ($row = $result->fetch_assoc()) { $tid = $row['titlenameid']; $tname = $row['titlename']; - echo ''; + $tnr = $row['titlemaxrank']; + echo ''; } $stmtview->close(); ?> \ No newline at end of file diff --git a/titlemanager.php b/titlemanager.php index 90d8919..3ee45a7 100644 --- a/titlemanager.php +++ b/titlemanager.php @@ -50,7 +50,8 @@ if ($_SESSION['admin'] == 1) { $tid = $row['titlenameid']; $tname = $row['titlename']; $ttype = $row['titletype']; - echo '' . $tid . '' . $tname . '' . $ttype . ''; + $tmr = $row['titlemaxrank']; + echo '' . $tid . '' . $tname . ' (' . $tmr . ')' . $ttype . ''; if ($ttype == "0") { echo 'account'; } else if ($ttype == "1") { From d2da78912c6009cb9094bc34d40cfede2f0bf731 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Sun, 5 Aug 2018 10:46:07 -1000 Subject: [PATCH 11/97] now displays what title you're working with --- includes/titleranks-add.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/includes/titleranks-add.php b/includes/titleranks-add.php index 5d2f93d..363b48b 100644 --- a/includes/titleranks-add.php +++ b/includes/titleranks-add.php @@ -12,9 +12,19 @@ mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); if (isset($_SESSION['tid'])) { $_POST['tid'] = $_SESSION['tid']; -} else { - echo 'The session data isn\'t set, using post data instead!
'; } + +$stmtname = $con->prepare("SELECT titlename FROM gwtitles WHERE titlenameid = ?"); +$stmtname->bind_param("i", $_POST['tid']); +$stmtname->execute(); +$stmtname->store_result(); +$stmtname->bind_result($gwtn); +while ($stmtname->fetch()) { + echo 'Adding rank to title ' . $gwtn . '

'; +} +$stmtname->free_result(); +$stmtname->close(); + echo '
'; echo '
Title Rank NameTitle PointsRank Level
'; echo '

'; From de5c42cd8acde53e1f1af83d2b23e45b1deb5bff Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Sun, 5 Aug 2018 12:12:17 -1000 Subject: [PATCH 12/97] prepping for notifying going past the maximum ranbk --- includes/titleranks-add.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/titleranks-add.php b/includes/titleranks-add.php index 363b48b..324f7d8 100644 --- a/includes/titleranks-add.php +++ b/includes/titleranks-add.php @@ -14,13 +14,13 @@ if (isset($_SESSION['tid'])) { $_POST['tid'] = $_SESSION['tid']; } -$stmtname = $con->prepare("SELECT titlename FROM gwtitles WHERE titlenameid = ?"); +$stmtname = $con->prepare("SELECT titlename, titlemaxrank FROM gwtitles WHERE titlenameid = ?"); $stmtname->bind_param("i", $_POST['tid']); $stmtname->execute(); $stmtname->store_result(); -$stmtname->bind_result($gwtn); +$stmtname->bind_result($gwtn, $gwtmr); while ($stmtname->fetch()) { - echo 'Adding rank to title ' . $gwtn . '

'; + echo 'Adding rank to title ' . $gwtn . '
It\'s current maximum rank is ' . $gwtmr . '
'; } $stmtname->free_result(); $stmtname->close(); From c321790d40adaa1fafe4d1b1691601fc46dff8a7 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Mon, 6 Aug 2018 07:16:58 -1000 Subject: [PATCH 13/97] auto added the next rank in the titlerank field --- includes/titleranks-add.php | 8 +++++++- includes/titleranks-submit.php | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/includes/titleranks-add.php b/includes/titleranks-add.php index 324f7d8..ec4c1a9 100644 --- a/includes/titleranks-add.php +++ b/includes/titleranks-add.php @@ -14,6 +14,12 @@ if (isset($_SESSION['tid'])) { $_POST['tid'] = $_SESSION['tid']; } +if (isset($_SESSION['tr'])) { + $_POST['titlerank'] = $_SESSION['tr'] + 1; +} else { + $_POST['titlerank'] = 0; +} + $stmtname = $con->prepare("SELECT titlename, titlemaxrank FROM gwtitles WHERE titlenameid = ?"); $stmtname->bind_param("i", $_POST['tid']); $stmtname->execute(); @@ -26,7 +32,7 @@ $stmtname->free_result(); $stmtname->close(); echo '
'; -echo ''; echo '
Title Rank NameTitle PointsRank Level
'; +echo '

'; echo 'Here are the currently associated title ranks, starting with rank 1:
'; diff --git a/includes/titleranks-submit.php b/includes/titleranks-submit.php index 7e4db9c..c45daf5 100644 --- a/includes/titleranks-submit.php +++ b/includes/titleranks-submit.php @@ -8,6 +8,7 @@ $stmtstins->execute(); $stmtstins->close(); $_SESSION['title'] = "repeat"; $_SESSION['tid'] = $_POST['titlenameid']; +$_SESSION['tr'] = $_POST['titlerank']; echo 'Title rank added, redirecting!'; header ("Refresh:1; url=titlemanager.php"); ?> \ No newline at end of file From 970cbb7075d6042d82fe3309f6048733febddd1f Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Mon, 6 Aug 2018 07:38:37 -1000 Subject: [PATCH 14/97] had to unset a session variable related to sub title ranks --- titlemanager.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/titlemanager.php b/titlemanager.php index 3ee45a7..00f409e 100644 --- a/titlemanager.php +++ b/titlemanager.php @@ -9,6 +9,8 @@ if ($con->connect_errno){ if ($_SESSION['title'] == "repeat") { $_POST['title'] = "addsubtitle"; unset($_SESSION['title']); +} else { + unset($_SESSION['tr']); } if ($_SESSION['admin'] == 1) { echo '
'; From ca7209adcb92d7647ea90d1a12e2bdc0307855d1 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Mon, 6 Aug 2018 10:51:49 -1000 Subject: [PATCH 15/97] added place holder pages to kill off the 404s courtesy of the main page --- addaccounts.php | 6 ++++++ changeaccounts.php | 6 ++++++ listchars.php | 7 +++++++ updateaccountstats.php | 6 ++++++ updatecharstats.php | 6 ++++++ 5 files changed, 31 insertions(+) create mode 100644 addaccounts.php create mode 100644 changeaccounts.php create mode 100644 listchars.php create mode 100644 updateaccountstats.php create mode 100644 updatecharstats.php diff --git a/addaccounts.php b/addaccounts.php new file mode 100644 index 0000000..b4b079b --- /dev/null +++ b/addaccounts.php @@ -0,0 +1,6 @@ +user page'; +include_once ('footer.php'); +?> \ No newline at end of file diff --git a/changeaccounts.php b/changeaccounts.php new file mode 100644 index 0000000..112b62c --- /dev/null +++ b/changeaccounts.php @@ -0,0 +1,6 @@ +user page'; +include_once ('footer.php'); +?> \ No newline at end of file diff --git a/listchars.php b/listchars.php new file mode 100644 index 0000000..cee6437 --- /dev/null +++ b/listchars.php @@ -0,0 +1,7 @@ +
'; +echo 'Return to your user page'; +include_once ('footer.php'); +?> \ No newline at end of file diff --git a/updateaccountstats.php b/updateaccountstats.php new file mode 100644 index 0000000..07a137f --- /dev/null +++ b/updateaccountstats.php @@ -0,0 +1,6 @@ +user page'; +include_once ('footer.php'); +?> \ No newline at end of file diff --git a/updatecharstats.php b/updatecharstats.php new file mode 100644 index 0000000..29f5371 --- /dev/null +++ b/updatecharstats.php @@ -0,0 +1,6 @@ +user page'; +include_once ('footer.php'); +?> \ No newline at end of file From 0b07df8d8f8e24058a728bf4a6e1fe149f6a35c8 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Mon, 6 Aug 2018 12:04:02 -1000 Subject: [PATCH 16/97] added javascript to make life easier --- index.php | 2 +- titlemanager.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.php b/index.php index 96579d6..223b954 100644 --- a/index.php +++ b/index.php @@ -10,4 +10,4 @@ if (isset($_SESSION['userid'])){ echo 'Add Guild Wars account here
'; } include_once ('footer.php'); -?> +?> \ No newline at end of file diff --git a/titlemanager.php b/titlemanager.php index 00f409e..25d3f03 100644 --- a/titlemanager.php +++ b/titlemanager.php @@ -35,12 +35,12 @@ if ($_SESSION['admin'] == 1) { } else { unset($_SESSION['tid']); echo 'Add titles

'; - echo 'Modify titles


'; - echo 'Add title ranks and points to


'; + echo 'Add title ranks and points to

'; + echo '
'; echo 'Edit / Delete subtitle & points (code goes here)

'; // now to view the last 5 title entries in the database echo 'Here is the last 5 titles entered into the database, newest entry is on top:
'; From cf434362cab1ec8b1daff446f0991aa003cce966 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Mon, 6 Aug 2018 13:47:30 -1000 Subject: [PATCH 17/97] change post variable to regular variable --- includes/titleranks-add.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/titleranks-add.php b/includes/titleranks-add.php index ec4c1a9..a9655a1 100644 --- a/includes/titleranks-add.php +++ b/includes/titleranks-add.php @@ -15,9 +15,9 @@ if (isset($_SESSION['tid'])) { } if (isset($_SESSION['tr'])) { - $_POST['titlerank'] = $_SESSION['tr'] + 1; + $tr = $_SESSION['tr'] + 1; } else { - $_POST['titlerank'] = 0; + $tr = 0; } $stmtname = $con->prepare("SELECT titlename, titlemaxrank FROM gwtitles WHERE titlenameid = ?"); @@ -26,13 +26,13 @@ $stmtname->execute(); $stmtname->store_result(); $stmtname->bind_result($gwtn, $gwtmr); while ($stmtname->fetch()) { - echo 'Adding rank to title ' . $gwtn . '
It\'s current maximum rank is ' . $gwtmr . '
'; + echo 'Adding rank to title ' . $gwtn . '
The maximum rank achievable in game is ' . $gwtmr . '
'; } $stmtname->free_result(); $stmtname->close(); echo '
'; -echo ''; +echo ''; echo '
Title Rank NameTitle PointsRank Level

'; echo 'Here are the currently associated title ranks, starting with rank 1:
'; From 363afb6945d38bc8c7997bd008ea24d66966d913 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Mon, 6 Aug 2018 14:16:54 -1000 Subject: [PATCH 18/97] made first title selectable, pre filled 1st sub-rank with a 1 if no sub-ranks have been entered yet --- includes/titleranks-add.php | 14 +++++++++++++- titlemanager.php | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/includes/titleranks-add.php b/includes/titleranks-add.php index a9655a1..214bbbd 100644 --- a/includes/titleranks-add.php +++ b/includes/titleranks-add.php @@ -17,7 +17,19 @@ if (isset($_SESSION['tid'])) { if (isset($_SESSION['tr'])) { $tr = $_SESSION['tr'] + 1; } else { - $tr = 0; + $trank = $con->prepare("SELECT MAX(strank) FROM gwsubtitles WHERE titlenameid = ?"); + $trank->bind_param("i", $_POST['tid']); + $trank->execute(); + $trank->store_result(); + $trank->bind_result($gwstmr); + while ($trank->fetch()) { + if (is_null($gwstmr)) { + $tr = 1; + } else { + $tr = $gwstmr; + echo 'variable tr is set to: ' . $tr . '
'; + } + } } $stmtname = $con->prepare("SELECT titlename, titlemaxrank FROM gwtitles WHERE titlenameid = ?"); diff --git a/titlemanager.php b/titlemanager.php index 25d3f03..188c356 100644 --- a/titlemanager.php +++ b/titlemanager.php @@ -35,10 +35,10 @@ if ($_SESSION['admin'] == 1) { } else { unset($_SESSION['tid']); echo 'Add titles

'; - echo 'Modify titles


'; - echo 'Add title ranks and points to

'; echo 'Edit / Delete subtitle & points (code goes here)

'; From 12c35bef110c39ccc282fa7669ab68544399f933 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Mon, 6 Aug 2018 14:22:22 -1000 Subject: [PATCH 19/97] can no longer modify rank level, worded 2nd select option better --- includes/titleranks-add.php | 2 +- titlemanager.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/titleranks-add.php b/includes/titleranks-add.php index 214bbbd..371d5d6 100644 --- a/includes/titleranks-add.php +++ b/includes/titleranks-add.php @@ -44,7 +44,7 @@ $stmtname->free_result(); $stmtname->close(); echo '
'; -echo ''; +echo ''; echo '
Title Rank NameTitle PointsRank Level

'; echo 'Here are the currently associated title ranks, starting with rank 1:
'; diff --git a/titlemanager.php b/titlemanager.php index 188c356..6875b95 100644 --- a/titlemanager.php +++ b/titlemanager.php @@ -38,7 +38,7 @@ if ($_SESSION['admin'] == 1) { echo 'Modify titles


'; - echo 'Add title ranks and points to

'; echo 'Edit / Delete subtitle & points (code goes here)

'; From c474ab68991a4f3c8860dff1c03d41175dee1168 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Mon, 6 Aug 2018 14:34:11 -1000 Subject: [PATCH 20/97] fixed title rank being set to same as last rank entered --- includes/titleranks-add.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/includes/titleranks-add.php b/includes/titleranks-add.php index 371d5d6..4e53e45 100644 --- a/includes/titleranks-add.php +++ b/includes/titleranks-add.php @@ -26,8 +26,7 @@ if (isset($_SESSION['tr'])) { if (is_null($gwstmr)) { $tr = 1; } else { - $tr = $gwstmr; - echo 'variable tr is set to: ' . $tr . '
'; + $tr = $gwstmr + 1; } } } From a850ae0c32489bc60a70b1c76072af8d50c4f9db Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Mon, 6 Aug 2018 15:24:59 -1000 Subject: [PATCH 21/97] removed something stupid --- footer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/footer.php b/footer.php index 095b9bf..84d9980 100644 --- a/footer.php +++ b/footer.php @@ -1,9 +1,9 @@ -
+

'; + echo '


'; } ?> - - \ No newline at end of file + + \ No newline at end of file From 94dc001e2c22bf3eb448e409891fc90825110d70 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Mon, 6 Aug 2018 15:25:42 -1000 Subject: [PATCH 22/97] prepping for title rank editing --- includes/title-update.php | 1 - includes/titleranks-add.php | 10 ++++++---- includes/titleranks-editor.php | 4 ++++ titlemanager.php | 6 ++++-- 4 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 includes/titleranks-editor.php diff --git a/includes/title-update.php b/includes/title-update.php index db790d8..2ef5891 100644 --- a/includes/title-update.php +++ b/includes/title-update.php @@ -22,5 +22,4 @@ if (isset($_POST['deltitle'])) { echo 'Title updated, redirecting!'; header ("Refresh:1; url=titlemanager.php"); } -//echo 'Return to title manager'; //this line needs to go away soon ?> \ No newline at end of file diff --git a/includes/titleranks-add.php b/includes/titleranks-add.php index 4e53e45..30dc1bf 100644 --- a/includes/titleranks-add.php +++ b/includes/titleranks-add.php @@ -10,6 +10,8 @@ mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); # investigate if we can put multiple input boxes and loop through them to insert into the database # https://stackoverflow.com/questions/34469482/how-to-insert-multiple-inputs-into-the-database-using-the-power-of-php +unset($_SESSION['title']); + if (isset($_SESSION['tid'])) { $_POST['tid'] = $_SESSION['tid']; } @@ -47,7 +49,7 @@ echo '
'; echo 'Here are the currently associated title ranks, starting with rank 1:
'; -echo ''; +echo '
stnameidtitlenameidstnamestpointsstrank
'; $stmtview = $con->prepare("SELECT * FROM gwsubtitles WHERE titlenameid = ? ORDER BY strank ASC"); $stmtview->bind_param("i", $_POST['tid']); $stmtview->execute(); @@ -58,9 +60,9 @@ while ($row = $result->fetch_assoc()) { $stname = $row['stname']; $stpoints = $row['stpoints']; $strank = $row['strank']; - echo ''; + echo ''; } $stmtview->close(); -echo '
stnameidtitlenameidstnamestpointsstrankEdit
' . $stnid . '' . $tnid . '' . $stname . '' . number_format($stpoints) . '' . $strank . '
' . $stnid . '' . $tnid . '' . $stname . '' . number_format($stpoints) . '' . $strank . '

If anything looks off, please fix it!

'; -echo 'Return to title manager'; //this line needs to go away soon. Maybe? +echo '

If anything looks off, please fix it!

'; +echo 'Return to title manager'; ?> \ No newline at end of file diff --git a/includes/titleranks-editor.php b/includes/titleranks-editor.php new file mode 100644 index 0000000..4b748e4 --- /dev/null +++ b/includes/titleranks-editor.php @@ -0,0 +1,4 @@ +
'; +echo 'Return to title manager'; +?> \ No newline at end of file diff --git a/titlemanager.php b/titlemanager.php index 6875b95..ccdc32e 100644 --- a/titlemanager.php +++ b/titlemanager.php @@ -32,6 +32,9 @@ if ($_SESSION['admin'] == 1) { } else if ($_POST['title'] == "titleranksubmit") { // this section doesn't require human interaction include_once ('includes/titleranks-submit.php'); + } else if ($_POST['title'] == "modsubtitle") { + // included file contains all code to edit a title rank + include_once ('includes/titleranks-editor.php'); } else { unset($_SESSION['tid']); echo 'Add titles

'; @@ -40,8 +43,7 @@ if ($_SESSION['admin'] == 1) { echo '

'; echo 'Add title ranks and points to

'; - echo 'Edit / Delete subtitle & points (code goes here)

'; + echo '

'; // now to view the last 5 title entries in the database echo 'Here is the last 5 titles entered into the database, newest entry is on top:
'; echo ''; From 1cfc60dad9540cad552c025048e662e06e847c4d Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Mon, 6 Aug 2018 16:37:48 -1000 Subject: [PATCH 23/97] editing title ranks is broken still --- includes/titleranks-add.php | 1 + includes/titleranks-editor.php | 43 +++++++++++++++++++++++++++++++++++++++++- titlemanager.php | 2 +- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/includes/titleranks-add.php b/includes/titleranks-add.php index 30dc1bf..6ccef1e 100644 --- a/includes/titleranks-add.php +++ b/includes/titleranks-add.php @@ -63,6 +63,7 @@ while ($row = $result->fetch_assoc()) { echo ''; } $stmtview->close(); +$_SESSION['tid'] = $_POST['tid']; echo '
titleidtitlenametitletypetitletype
' . $stnid . '' . $tnid . '' . $stname . '' . number_format($stpoints) . '' . $strank . '


If anything looks off, please fix it!

'; echo 'Return to title manager'; ?> \ No newline at end of file diff --git a/includes/titleranks-editor.php b/includes/titleranks-editor.php index 4b748e4..1bad404 100644 --- a/includes/titleranks-editor.php +++ b/includes/titleranks-editor.php @@ -1,4 +1,45 @@
'; + +# delete this block when shit finally works. +ini_set('display_errors', 'on'); +error_reporting(E_ALL); +mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); +# delete the above when shit finally works + +$tid = $_SESSION['tid']; +echo 'the session tid number is: ' . $_SESSION['tid'] . '
'; + +$stid = array(); +foreach ($_POST['editstitle'] as $tredit) { + $stid[] = (int)$tredit; +} +$stid = implode(',', $stid); +echo 'the value of stid is now: ' . $stid . '
'; +$sredit = $con->prepare("SELECT * FROM gwsubtitles WHERE titlenameid = ? AND stnameid IN (?)"); +$sredit->bind_param("is", $tid, $stid); +$sredit->execute(); +$sredit->store_result(); +$sredit->bind_result($gwtid, $gwstid); +while ($sredit->fetch()) { + echo 'farts
'; +} +$sredit->free_result(); +$sredit->close(); + +// keep this section +/* if (isset($_POST['editstitle'])) { + $sredit = $con->prepare("SELECT * FROM gwsubtitles WHERE stnameid = ? AND titlenameid = ?"); + foreach ($_POST['editstitle'] as $tredit) { + $sredit->bind_param("ii", $tid, $tredit); + $sredit->execute(); + $sredit->store_result(); + $sredit->bindresult( + echo 'the value is: ' . $tredit . '
'; + } +} else { + echo 'nothing is set??
'; +} +*/ +echo '
code to mod title ranks via an include goes here

'; echo 'Return to title manager'; ?> \ No newline at end of file diff --git a/titlemanager.php b/titlemanager.php index ccdc32e..88c8c7c 100644 --- a/titlemanager.php +++ b/titlemanager.php @@ -41,7 +41,7 @@ if ($_SESSION['admin'] == 1) { echo 'Modify titles


'; - echo 'Add title ranks and points to


'; // now to view the last 5 title entries in the database From 7db29117da362e61c56668619a381167243f5cac Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Tue, 7 Aug 2018 09:37:14 -1000 Subject: [PATCH 24/97] got rid of undefined variables clogging up the web server log file --- footer.php | 2 +- header.php | 12 ++++++++++-- login.php | 4 +++- logout.php | 11 +++++------ 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/footer.php b/footer.php index 84d9980..adfd3d3 100644 --- a/footer.php +++ b/footer.php @@ -2,7 +2,7 @@

'; + echo '


'; } ?> diff --git a/header.php b/header.php index 6f2e7d6..7a6b1c0 100644 --- a/header.php +++ b/header.php @@ -3,7 +3,9 @@

'; echo 'If you haven\'t registered an account yet,
please click here to create one.
'; } else { - echo '' . $pagetitle . '
'; + echo ''; + if (isset($pagetitle)) { + echo $pagetitle; + } else { + echo 'GWST'; + } + echo '
'; echo '(Home) (Options) '; if ($_SESSION['admin'] == 1){ echo'(Administration) '; diff --git a/login.php b/login.php index e6ed1f0..6c80c33 100644 --- a/login.php +++ b/login.php @@ -9,7 +9,9 @@ You have been logged out ...
Returning to login screen in a few seconds
'; -} else if (isset($_POST['logout'])){ - session_unset(); - session_destroy(); - header("refresh:2;url=index.php"); - echo '
You have been logged out ...
Returning to login screen in a few seconds
'; } else { echo '
Something went wrong, you haven\'t been logged out!

Please click HERE to try again
'; } From b0b0e71c1f204daedd864279652926651b6c2731 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Tue, 7 Aug 2018 09:49:54 -1000 Subject: [PATCH 25/97] more undefined index fixes --- titlemanager.php | 56 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/titlemanager.php b/titlemanager.php index 88c8c7c..b68d55a 100644 --- a/titlemanager.php +++ b/titlemanager.php @@ -6,35 +6,39 @@ $con = mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME if ($con->connect_errno){ die ('Unable to connect to database [' . $db->connect_errno . ']'); } -if ($_SESSION['title'] == "repeat") { - $_POST['title'] = "addsubtitle"; - unset($_SESSION['title']); -} else { - unset($_SESSION['tr']); +if (isset($_SESSION['title'])) { + if ($_SESSION['title'] == "repeat") { + $_POST['title'] = "addsubtitle"; + unset($_SESSION['title']); + } else { + unset($_SESSION['tr']); + } } if ($_SESSION['admin'] == 1) { echo '
'; - if ($_POST['title'] == "addtitle") { - // included file contains all the code to add a new title - include_once ('includes/title-add.php'); - } else if ($_POST['title'] == "titlesubmit") { - // included file contains all the code to submit a new title - include_once ('includes/title-submit.php'); - } else if ($_POST['title'] == "modtitle") { - // included file contains all the code to edit a title - include_once ('includes/title-editor.php'); - } else if ($_POST['title'] == "updatetitle") { - // this section doesn't require human interaction - include_once ('includes/title-update.php'); - } else if ($_POST['title'] == "addsubtitle") { - // included file contains all code to add the title ranks and points required - include_once ('includes/titleranks-add.php'); - } else if ($_POST['title'] == "titleranksubmit") { - // this section doesn't require human interaction - include_once ('includes/titleranks-submit.php'); - } else if ($_POST['title'] == "modsubtitle") { - // included file contains all code to edit a title rank - include_once ('includes/titleranks-editor.php'); + if (isset($_POST['title'])) { + if ($_POST['title'] == "addtitle") { + // included file contains all the code to add a new title + include_once ('includes/title-add.php'); + } else if ($_POST['title'] == "titlesubmit") { + // included file contains all the code to submit a new title + include_once ('includes/title-submit.php'); + } else if ($_POST['title'] == "modtitle") { + // included file contains all the code to edit a title + include_once ('includes/title-editor.php'); + } else if ($_POST['title'] == "updatetitle") { + // this section doesn't require human interaction + include_once ('includes/title-update.php'); + } else if ($_POST['title'] == "addsubtitle") { + // included file contains all code to add the title ranks and points required + include_once ('includes/titleranks-add.php'); + } else if ($_POST['title'] == "titleranksubmit") { + // this section doesn't require human interaction + include_once ('includes/titleranks-submit.php'); + } else if ($_POST['title'] == "modsubtitle") { + // included file contains all code to edit a title rank + include_once ('includes/titleranks-editor.php'); + } } else { unset($_SESSION['tid']); echo 'Add titles

'; From d0ed4b8cd885bbc211408606e744d4278a3198b8 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Tue, 7 Aug 2018 10:38:59 -1000 Subject: [PATCH 26/97] fixed bug with pre-loading the next rank after what's saved in the database --- includes/title-update.php | 5 ++++- titlemanager.php | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/title-update.php b/includes/title-update.php index 2ef5891..e06fdd4 100644 --- a/includes/title-update.php +++ b/includes/title-update.php @@ -9,8 +9,11 @@ if (isset($_POST['deltitle'])) { $stmtdel = $con->prepare("DELETE FROM gwtitles WHERE titlenameid = ?"); $stmtdel->bind_param("i", $_POST['titlenameid']); $stmtdel->execute(); + $stmtdelst = $con->prepare("DELETE FROM gwsubtitles WHERE titlenameid = ?"); + $stmtdelst->bind_param("i", $_POST['titlenameid']); + $stmtdelst->execute(); $stmtdel->close(); - echo 'Title has been deleted, redirecting!'; + echo 'The title and associated title ranks have been deleted, redirecting!'; header ("Refresh:1; url=titlemanager.php"); } } else { diff --git a/titlemanager.php b/titlemanager.php index b68d55a..537cc6f 100644 --- a/titlemanager.php +++ b/titlemanager.php @@ -41,6 +41,7 @@ if ($_SESSION['admin'] == 1) { } } else { unset($_SESSION['tid']); + unset($_SESSION['tr']); echo 'Add titles

'; echo 'Modify titles
'; + echo ''; + echo ''; } -*/ -echo '
code to mod title ranks via an include goes here

'; +echo '
'; +echo '

'; echo 'Return to title manager'; ?> \ No newline at end of file diff --git a/includes/titleranks-update.php b/includes/titleranks-update.php new file mode 100644 index 0000000..00eb256 --- /dev/null +++ b/includes/titleranks-update.php @@ -0,0 +1,6 @@ +'; +echo 'delete the specified title rank(s), but require a verification page!

'; + +echo 'Return to title manager'; +?> \ No newline at end of file From 4e5eb922cbba3f9fa8ecbcbe2f4f3cc89f2c11b2 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Tue, 7 Aug 2018 12:50:07 -1000 Subject: [PATCH 28/97] added support for actually update title ranks --- titlemanager.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/titlemanager.php b/titlemanager.php index 537cc6f..e9c444c 100644 --- a/titlemanager.php +++ b/titlemanager.php @@ -38,6 +38,9 @@ if ($_SESSION['admin'] == 1) { } else if ($_POST['title'] == "modsubtitle") { // included file contains all code to edit a title rank include_once ('includes/titleranks-editor.php'); + } else if ($_POST['title'] == "updatesubtitle") { + // this sectionupdates modified title ranks in the database, or deletes them + include_once ('includes/titleranks-update.php'); } } else { unset($_SESSION['tid']); @@ -50,9 +53,9 @@ if ($_SESSION['admin'] == 1) { include ('includes/title-select.php'); echo '

'; // now to view the last 5 title entries in the database - echo 'Here is the last 5 titles entered into the database, newest entry is on top:
'; + echo 'Here is the last 15 titles entered into the database, newest entry is on top:
'; echo ''; - $stmtview = $con->prepare("SELECT * FROM gwtitles ORDER BY titlenameid DESC LIMIT 5"); + $stmtview = $con->prepare("SELECT * FROM gwtitles ORDER BY titlenameid DESC LIMIT 15"); $stmtview->execute(); $result = $stmtview->get_result(); while ($row = $result->fetch_assoc()) { From 95034c50100c5098c5700e9151a42186f2795908 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Tue, 7 Aug 2018 15:09:37 -1000 Subject: [PATCH 29/97] not sure what I fixed/changed here --- titlemanager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/titlemanager.php b/titlemanager.php index e9c444c..98ac47b 100644 --- a/titlemanager.php +++ b/titlemanager.php @@ -49,7 +49,7 @@ if ($_SESSION['admin'] == 1) { echo 'Modify titles


'; - echo 'Add title ranks and points to


'; // now to view the last 5 title entries in the database From 7a51a8def29fe2f48c4e6aa9dc84ecdec76399b9 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Tue, 7 Aug 2018 15:09:59 -1000 Subject: [PATCH 30/97] can now edit multiple title ranks at once --- includes/titleranks-editor.php | 11 +++-------- includes/titleranks-update.php | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/includes/titleranks-editor.php b/includes/titleranks-editor.php index 14d793f..469c6bd 100644 --- a/includes/titleranks-editor.php +++ b/includes/titleranks-editor.php @@ -6,21 +6,16 @@ error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); # delete the above when shit finally works -# $tid = $_SESSION['tid'] = titlenameid from database -# $stid = $_POST['editstitle'] = stnameid from database and it should return an array of numbers - echo '
titleidtitlenametitletypetitletype
'; //save this line!!! - $ph = implode(",", $_POST['editstitle']); - $sredit = $con->prepare("SELECT * FROM gwsubtitles WHERE titlenameid = ? AND stnameid IN ($ph)"); $sredit->bind_param("i", $_SESSION['tid']); $sredit->execute(); $result = $sredit->get_result(); while ($row = $result->fetch_assoc()) { - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; } echo '
stnameidtitlenameidstnamestpointsstrank

'; echo '

'; diff --git a/includes/titleranks-update.php b/includes/titleranks-update.php index 00eb256..5dd6d7a 100644 --- a/includes/titleranks-update.php +++ b/includes/titleranks-update.php @@ -1,6 +1,42 @@ '; -echo 'delete the specified title rank(s), but require a verification page!

'; +# delete this block when shit finally works. +ini_set('display_errors', 'on'); +error_reporting(E_ALL); +mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); +# delete the above when shit finally works + +if (isset($_POST['delsubtitle'])) { + if ($_POST['delsubtitle'] =="yes") { + // this title makes you verify that you want to delete this title + echo '
Please check the box to verify you want to delete: ' . $_POST['titlename'] . ' '; + echo '


'; + } else if ($_POST['delsubtitle'] == "iamsure") { + // this section actually deletes the title rank(s) + # need to deal with array data eventually + $stmtdel = $con->prepare("DELETE FROM gwsubtitles WHERE titlenameid = ?"); + $stmtdel->bind_param("i", $_POST['titlenameid']); + $stmtdel->execute(); + $stmtdel->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"); +} echo 'Return to title manager'; ?> \ No newline at end of file From eb5cb2d1aee16f8ab48e8ca52f2c38244e457c63 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Tue, 7 Aug 2018 15:23:55 -1000 Subject: [PATCH 31/97] fixed minor formatting --- includes/title-update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/title-update.php b/includes/title-update.php index e06fdd4..17e85a1 100644 --- a/includes/title-update.php +++ b/includes/title-update.php @@ -1,6 +1,6 @@ Please check the box to verify you want to delete: ' . $_POST['titlename'] . ' '; echo '

'; From 69db1aa93c53e04ad00762e85a831fa5047904c1 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Tue, 7 Aug 2018 16:10:16 -1000 Subject: [PATCH 32/97] can now delete selected title ranks --- includes/titleranks-editor.php | 4 ++-- includes/titleranks-update.php | 28 +++++++++++++++------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/includes/titleranks-editor.php b/includes/titleranks-editor.php index 469c6bd..c1ba101 100644 --- a/includes/titleranks-editor.php +++ b/includes/titleranks-editor.php @@ -6,7 +6,7 @@ error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); # delete the above when shit finally works -echo '
'; //save this line!!! +echo '
stnameidtitlenameidstnamestpointsstrank
'; $ph = implode(",", $_POST['editstitle']); $sredit = $con->prepare("SELECT * FROM gwsubtitles WHERE titlenameid = ? AND stnameid IN ($ph)"); $sredit->bind_param("i", $_SESSION['tid']); @@ -15,7 +15,7 @@ $result = $sredit->get_result(); while ($row = $result->fetch_assoc()) { echo ''; echo ''; - echo ''; + echo ''; } echo '
stnameidtitlenameidstnamestpointsstrankDelete?

'; echo '

'; diff --git a/includes/titleranks-update.php b/includes/titleranks-update.php index 5dd6d7a..5871e93 100644 --- a/includes/titleranks-update.php +++ b/includes/titleranks-update.php @@ -7,20 +7,22 @@ mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); # delete the above when shit finally works if (isset($_POST['delsubtitle'])) { - if ($_POST['delsubtitle'] =="yes") { - // this title makes you verify that you want to delete this title - echo '
Please check the box to verify you want to delete: ' . $_POST['titlename'] . ' '; - echo '


'; - } else if ($_POST['delsubtitle'] == "iamsure") { - // this section actually deletes the title rank(s) - # need to deal with array data eventually - $stmtdel = $con->prepare("DELETE FROM gwsubtitles WHERE titlenameid = ?"); - $stmtdel->bind_param("i", $_POST['titlenameid']); - $stmtdel->execute(); - $stmtdel->close(); - echo 'Title rank(s) have been deleted, redirecting!'; - header ("Refresh:1; url=titlemanager.php"); + echo 'the post delsubtitle might be an array??
'; + echo '
';
+	print_r($_POST['delsubtitle']);
+	print_r($_POST['stnameid']);
+	echo '
'; + 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 = ?")) { From 632c21f96d3d20c93d5a7b2df812daecd1a3972a Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Tue, 7 Aug 2018 16:26:36 -1000 Subject: [PATCH 33/97] fixed clicking on edit title ranks with no title ranks actually selected --- includes/titleranks-editor.php | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/includes/titleranks-editor.php b/includes/titleranks-editor.php index c1ba101..9dbb0c3 100644 --- a/includes/titleranks-editor.php +++ b/includes/titleranks-editor.php @@ -6,18 +6,23 @@ error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); # delete the above when shit finally works -echo '
'; -$ph = implode(",", $_POST['editstitle']); -$sredit = $con->prepare("SELECT * FROM gwsubtitles WHERE titlenameid = ? AND stnameid IN ($ph)"); -$sredit->bind_param("i", $_SESSION['tid']); -$sredit->execute(); -$result = $sredit->get_result(); -while ($row = $result->fetch_assoc()) { - echo ''; - echo ''; - echo ''; +if (isset($_POST['editstitle'])) { + echo '
stnameidtitlenameidstnamestpointsstrankDelete?
'; + $ph = implode(",", $_POST['editstitle']); + $sredit = $con->prepare("SELECT * FROM gwsubtitles WHERE titlenameid = ? AND stnameid IN ($ph)"); + $sredit->bind_param("i", $_SESSION['tid']); + $sredit->execute(); + $result = $sredit->get_result(); + while ($row = $result->fetch_assoc()) { + echo ''; + echo ''; + echo ''; + } + echo '
stnameidtitlenameidstnamestpointsstrankDelete?

'; + echo '

'; + echo 'Return to title manager'; +} else { + echo 'No title ranks selected! Please press the back button on your browser to return to the previous page.

'; + echo 'Return to title manager'; } -echo '
'; -echo '

'; -echo 'Return to title manager'; ?> \ No newline at end of file From e702d0030347f180daae1fcab83d30b2f2dc571a Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Tue, 7 Aug 2018 23:47:02 -1000 Subject: [PATCH 34/97] enforced max in game title rank --- includes/titleranks-add.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/includes/titleranks-add.php b/includes/titleranks-add.php index 6ccef1e..dc6e0fb 100644 --- a/includes/titleranks-add.php +++ b/includes/titleranks-add.php @@ -40,13 +40,18 @@ $stmtname->store_result(); $stmtname->bind_result($gwtn, $gwtmr); while ($stmtname->fetch()) { echo 'Adding rank to title ' . $gwtn . '
The maximum rank achievable in game is ' . $gwtmr . '
'; + if ($tr > $gwtmr) { + echo '
No more ranks can be added!

'; + } else { + echo '
'; + echo ''; + echo '
Title Rank NameTitle PointsRank Level

'; + } } $stmtname->free_result(); $stmtname->close(); -echo '
'; -echo ''; -echo '
Title Rank NameTitle PointsRank Level

'; + echo 'Here are the currently associated title ranks, starting with rank 1:
'; echo '
'; From b5259d7e0896d0ddd8d18d5cc1c8330685759a5e Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Tue, 7 Aug 2018 23:51:05 -1000 Subject: [PATCH 35/97] internal formatting --- includes/titleranks-add.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/includes/titleranks-add.php b/includes/titleranks-add.php index dc6e0fb..1f24f7c 100644 --- a/includes/titleranks-add.php +++ b/includes/titleranks-add.php @@ -51,8 +51,6 @@ while ($stmtname->fetch()) { $stmtname->free_result(); $stmtname->close(); - - echo 'Here are the currently associated title ranks, starting with rank 1:
'; echo '
stnameidtitlenameidstnamestpointsstrankEdit
'; $stmtview = $con->prepare("SELECT * FROM gwsubtitles WHERE titlenameid = ? ORDER BY strank ASC"); From 6378bbf3f5ba5f72971a88919e8a9bffc9c635d6 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 00:13:11 -1000 Subject: [PATCH 36/97] formatting fun --- includes/titleranks-add.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/titleranks-add.php b/includes/titleranks-add.php index 1f24f7c..8df1c6d 100644 --- a/includes/titleranks-add.php +++ b/includes/titleranks-add.php @@ -45,7 +45,7 @@ while ($stmtname->fetch()) { } else { echo '
stnameidtitlenameidstnamestpointsstrankEdit
'; echo ''; - echo '
Title Rank NameTitle PointsRank Level

'; + echo '

'; } } $stmtname->free_result(); From 53779bfda40614800d303bc30817ee235e6d2ba2 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 09:41:43 -1000 Subject: [PATCH 37/97] added html options for better usability --- header.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/header.php b/header.php index 7a6b1c0..50d5556 100644 --- a/header.php +++ b/header.php @@ -1,6 +1,6 @@ - - + + connect_errno){ } if (!$userid){ echo 'Please login first
Aloha, and welcome to my Guild Wars stats tracker. Please login below.
'; - echo '
'; - echo '
Username:
Password:
'; + echo ''; + echo '
Username:
Password:
'; echo '


'; echo 'If you haven\'t registered an account yet,
please click here to create one.
'; } else { From 65bd1f014f726b08d34d3c8c8426e7f4317acb4b Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 09:45:04 -1000 Subject: [PATCH 38/97] starting account options page --- preferences.php | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 preferences.php diff --git a/preferences.php b/preferences.php new file mode 100644 index 0000000..2e8cd80 --- /dev/null +++ b/preferences.php @@ -0,0 +1,6 @@ +Change e-mail and / or password

'; +include_once ('footer.php'); +?> \ No newline at end of file From 2e97d3219ba4db6750b7e2da2e84630216625d52 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 10:24:20 -1000 Subject: [PATCH 39/97] fixed undefined variable log spam --- register.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/register.php b/register.php index cfa4b50..48196a4 100644 --- a/register.php +++ b/register.php @@ -3,14 +3,16 @@ connect_errno){ die ('Unable to connect to database [' . $db->connect_errno . ']'); } -if (is_null($newuser)){ +if (empty($_POST['reguser'])){ // this block contains the code to fill out the form echo '
'; include_once ('includes/account-registration.php'); From ac2e8a7ab1b7a238693cccd4c7930b793c9fb111 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 10:29:06 -1000 Subject: [PATCH 40/97] removed a no longer needed line --- register.php | 1 - 1 file changed, 1 deletion(-) diff --git a/register.php b/register.php index 48196a4..8a7d22f 100644 --- a/register.php +++ b/register.php @@ -7,7 +7,6 @@ if (session_status() == PHP_SESSION_NONE) { session_start(); } include_once ('connect.php'); -//$newuser = $_POST['reguser']; $con = mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME); if ($con->connect_errno){ die ('Unable to connect to database [' . $db->connect_errno . ']'); From d7786f4356acd8c24a289920c143073681457d8f Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 10:35:08 -1000 Subject: [PATCH 41/97] removed old comments --- includes/titleranks-add.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/includes/titleranks-add.php b/includes/titleranks-add.php index 8df1c6d..74b2e56 100644 --- a/includes/titleranks-add.php +++ b/includes/titleranks-add.php @@ -5,11 +5,6 @@ error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); # delete the above when shit finally works -# use "$_POST['tid']" to show title ranks already associated with the selected title -# and above that list put the input boxes for text and number_format -# investigate if we can put multiple input boxes and loop through them to insert into the database -# https://stackoverflow.com/questions/34469482/how-to-insert-multiple-inputs-into-the-database-using-the-power-of-php - unset($_SESSION['title']); if (isset($_SESSION['tid'])) { From 49f36dc8e90d150fed3764307b9bedc9311742cf Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 10:56:34 -1000 Subject: [PATCH 42/97] working on letting a user update their email address in the database --- includes/update-email.php | 3 +++ preferences.php | 21 ++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 includes/update-email.php diff --git a/includes/update-email.php b/includes/update-email.php new file mode 100644 index 0000000..6f8e655 --- /dev/null +++ b/includes/update-email.php @@ -0,0 +1,3 @@ +
'; +?> \ No newline at end of file diff --git a/preferences.php b/preferences.php index 2e8cd80..c2c6762 100644 --- a/preferences.php +++ b/preferences.php @@ -1,6 +1,25 @@ Change e-mail and / or password

'; +if (!empty($_POST['usermail'])) { + //this section contains code to update the users e-mail address, maybe via an include? + include_once ('includes/update-email.php'); +} else { + //should get rid of this whole else statement, or use it to display an error? + echo 'this should probably be the !empty section instead
'; + echo 'the post usermail vaiable should be blank: ' . $_POST['usermail'] . ' <- Is there a blank spot to the left?
'; +} +echo '

Change e-mail and / or password



'; + +// listing all session variables currently set for debugging purposes +echo '
';
+var_dump($_SESSION);
+echo '


'; +// delete the above 3 lines when done + +echo '
'; +echo ''; +echo ''; +echo '
Update e-mail address

'; include_once ('footer.php'); ?> \ No newline at end of file From d03a6c2306b0adc2fc74747849142f2a3c32d190 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 11:33:31 -1000 Subject: [PATCH 43/97] made code sane --- includes/verifications.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/includes/verifications.php b/includes/verifications.php index 24f4d06..b071058 100644 --- a/includes/verifications.php +++ b/includes/verifications.php @@ -30,20 +30,23 @@ function validateUsername($uname) { #################### # verifying the username doesn't already exist in the database -$username = mysqli_real_escape_string($con, $_POST['username']); -validateUsername($username); +if (!empty($_POST['username'])) { + $username = mysqli_real_escape_string($con, $_POST['username']); + validateUsername($username); +} #################### # verifying the e-mail address is in a valid format -$verifyemail = validateEmail($_POST['useremail']); -if (empty($verifyemail)) { - echo '
This address: ' . $_POST['useremail'] . ' is not a valid e-mail address!
Please verify and type it again.
'; - include_once ('footer.php'); - exit(); +if (!empty($_POST['useremail'])) { + $verifyemail = validateEmail($_POST['useremail']); + if (empty($verifyemail)) { + echo '
This address: ' . $_POST['useremail'] . ' is not a valid e-mail address!
Please verify and type it again.
'; + include_once ('footer.php'); + exit(); + } + usedEmail($_POST['useremail']); } -usedEmail($_POST['useremail']); - #################### # verifying passwords match each other From 7949e3f8c1933b908ad311081b8535542bc157a2 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 11:58:00 -1000 Subject: [PATCH 44/97] users can now change their email address --- includes/update-email.php | 10 +++++++++- preferences.php | 13 +++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/includes/update-email.php b/includes/update-email.php index 6f8e655..1a19546 100644 --- a/includes/update-email.php +++ b/includes/update-email.php @@ -1,3 +1,11 @@
'; +include_once ('verifications.php'); +echo 'the useremail variable is: ' . $_POST['useremail'] . '
'; +echo 'the userid variable is: ' . $_SESSION['userid'] . '
'; +$updmail = $con->prepare("UPDATE userinfo SET usermail = ? WHERE userid = ?"); +$updmail->bind_param("si", $_POST['useremail'], $_SESSION['userid']); +$updmail->execute(); +$_SESSION['usermail'] = $_POST['useremail']; +echo 'Email address updated, redirecting.'; +header ("Refresh:2; url=preferences.php"); ?> \ No newline at end of file diff --git a/preferences.php b/preferences.php index c2c6762..3b053c8 100644 --- a/preferences.php +++ b/preferences.php @@ -1,25 +1,22 @@ '; - echo 'the post usermail vaiable should be blank: ' . $_POST['usermail'] . ' <- Is there a blank spot to the left?
'; } -echo '

Change e-mail and / or password



'; +echo '

Change e-mail and / or password

'; // listing all session variables currently set for debugging purposes echo '
';
 var_dump($_SESSION);
-echo '


'; +echo '
'; // delete the above 3 lines when done echo '
'; echo ''; -echo ''; +echo ''; echo '
Update e-mail address

'; include_once ('footer.php'); ?> \ No newline at end of file From 64f201c6044487bcd6ddd19a7aacdbcc2cc8bf87 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 12:19:26 -1000 Subject: [PATCH 45/97] added warning caption about deletions their precedence over edits --- includes/titleranks-editor.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/titleranks-editor.php b/includes/titleranks-editor.php index 9dbb0c3..8533fb5 100644 --- a/includes/titleranks-editor.php +++ b/includes/titleranks-editor.php @@ -7,7 +7,8 @@ mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); # delete the above when shit finally works if (isset($_POST['editstitle'])) { - echo '
'; + echo '
stnameidtitlenameidstnamestpointsstrankDelete?
'; + echo ''; $ph = implode(",", $_POST['editstitle']); $sredit = $con->prepare("SELECT * FROM gwsubtitles WHERE titlenameid = ? AND stnameid IN ($ph)"); $sredit->bind_param("i", $_SESSION['tid']); From 15db593bdfcc68f00d8acf54475bf27a1c35a540 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 12:20:20 -1000 Subject: [PATCH 46/97] removed debug code --- includes/titleranks-update.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/includes/titleranks-update.php b/includes/titleranks-update.php index 5871e93..427cce6 100644 --- a/includes/titleranks-update.php +++ b/includes/titleranks-update.php @@ -7,11 +7,6 @@ mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); # delete the above when shit finally works if (isset($_POST['delsubtitle'])) { - echo 'the post delsubtitle might be an array??
'; - echo '
';
-	print_r($_POST['delsubtitle']);
-	print_r($_POST['stnameid']);
-	echo '
'; 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++) { @@ -22,7 +17,7 @@ if (isset($_POST['delsubtitle'])) { $delst->close(); } echo 'Title rank(s) have been deleted, redirecting!'; - //header ("Refresh:1; url=titlemanager.php"); + 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 = ?")) { @@ -40,5 +35,4 @@ if (isset($_POST['delsubtitle'])) { echo 'Title rank(s) updated, redirecting!'; header ("Refresh:1; url=titlemanager.php"); } -echo 'Return to title manager'; ?> \ No newline at end of file From 4bb8321d76dc9fa48a6087ea5fbc5d9994819263 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 12:20:57 -1000 Subject: [PATCH 47/97] changed header redirect speed I think --- includes/update-email.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/includes/update-email.php b/includes/update-email.php index 1a19546..eddcf2f 100644 --- a/includes/update-email.php +++ b/includes/update-email.php @@ -1,11 +1,9 @@ '; -echo 'the userid variable is: ' . $_SESSION['userid'] . '
'; $updmail = $con->prepare("UPDATE userinfo SET usermail = ? WHERE userid = ?"); $updmail->bind_param("si", $_POST['useremail'], $_SESSION['userid']); $updmail->execute(); $_SESSION['usermail'] = $_POST['useremail']; -echo 'Email address updated, redirecting.'; +echo 'E-mail address updated, redirecting.'; header ("Refresh:2; url=preferences.php"); ?> \ No newline at end of file From 5d3b8b81ee6c5a3860fb3d72f2fcda342b8b02e7 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 12:21:50 -1000 Subject: [PATCH 48/97] trying to fix an undefined index error still broken --- includes/verifications.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/includes/verifications.php b/includes/verifications.php index b071058..921f94e 100644 --- a/includes/verifications.php +++ b/includes/verifications.php @@ -49,10 +49,11 @@ if (!empty($_POST['useremail'])) { #################### # verifying passwords match each other - -if (($_POST['userpass1']) != ($_POST['userpass2'])) { - echo '
The passwords don\'t match!
Please try again!'; - include_once ('footer.php'); - exit(); +if (!empty($_POST['userpass1'] && $_POST['userpass2'])) { + if (($_POST['userpass1']) != ($_POST['userpass2'])) { + echo '
The passwords don\'t match!
Please try again!'; + include_once ('footer.php'); + exit(); + } } ?> \ No newline at end of file From 2a7f1b59b5ee3e4a7f65a7dfbd5cacc7a717becb Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 12:22:38 -1000 Subject: [PATCH 49/97] I forget what I changed here :( --- preferences.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preferences.php b/preferences.php index 3b053c8..cdb9cb2 100644 --- a/preferences.php +++ b/preferences.php @@ -6,7 +6,7 @@ if (!empty($_POST['useremail'])) { //this section contains code to update the users e-mail address, maybe via an include? include_once ('includes/update-email.php'); } -echo '

Change e-mail and / or password

'; +echo '

Change e-mail or password

'; // listing all session variables currently set for debugging purposes echo '
';

From d8947f2664200d41f6be633a9cdaaae958b0961e Mon Sep 17 00:00:00 2001
From: mauirixxx 
Date: Wed, 8 Aug 2018 14:14:55 -1000
Subject: [PATCH 50/97] made this file usable from more then 1 page

---
 includes/verifications.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/includes/verifications.php b/includes/verifications.php
index 921f94e..07d489b 100644
--- a/includes/verifications.php
+++ b/includes/verifications.php
@@ -51,7 +51,7 @@ if (!empty($_POST['useremail'])) {
 # verifying passwords match each other
 if (!empty($_POST['userpass1'] && $_POST['userpass2'])) {
 	if (($_POST['userpass1']) != ($_POST['userpass2'])) {
-		echo '
The passwords don\'t match!
Please try again!'; + echo '
The passwords don\'t match!
Please try again!'; include_once ('footer.php'); exit(); } From 3a80d80b4d9e5a7d483ad584a454756d962c794b Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 15:22:27 -1000 Subject: [PATCH 51/97] closed connection to database server --- includes/titleranks-editor.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/titleranks-editor.php b/includes/titleranks-editor.php index 8533fb5..2af48d2 100644 --- a/includes/titleranks-editor.php +++ b/includes/titleranks-editor.php @@ -19,6 +19,7 @@ if (isset($_POST['editstitle'])) { echo '
'; echo ''; } + $sredit->close(); echo '
Deleting takes precedence over edits - edits will have to be remade after submission
stnameidtitlenameidstnamestpointsstrankDelete?

'; echo '

'; echo 'Return to title manager'; From b5e7d4e9bf75272594d29c579d784fdca4cb092b Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 15:23:06 -1000 Subject: [PATCH 52/97] fixed wording & formatting --- includes/update-email.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/includes/update-email.php b/includes/update-email.php index eddcf2f..b3089ba 100644 --- a/includes/update-email.php +++ b/includes/update-email.php @@ -4,6 +4,5 @@ $updmail = $con->prepare("UPDATE userinfo SET usermail = ? WHERE userid = ?"); $updmail->bind_param("si", $_POST['useremail'], $_SESSION['userid']); $updmail->execute(); $_SESSION['usermail'] = $_POST['useremail']; -echo 'E-mail address updated, redirecting.'; -header ("Refresh:2; url=preferences.php"); +echo 'E-mail address updated.
'; ?> \ No newline at end of file From ddc9359a786511a8312b917aedbef86ab39b39fe Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 15:24:23 -1000 Subject: [PATCH 53/97] added a note to myself to delete a line later --- preferences.php | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/preferences.php b/preferences.php index cdb9cb2..54566af 100644 --- a/preferences.php +++ b/preferences.php @@ -6,6 +6,14 @@ if (!empty($_POST['useremail'])) { //this section contains code to update the users e-mail address, maybe via an include? include_once ('includes/update-email.php'); } + +if (!empty($_POST['oldpass'])) { + echo 'if the oldpass is set, execute code here (this line will go away from preferences.php!)
'; + include_once ('includes/update-password.php'); +} else { + echo 'if post oldpass is NOT set, then this else statement can go away.
'; +} + echo '

Change e-mail or password

'; // listing all session variables currently set for debugging purposes @@ -14,9 +22,33 @@ var_dump($_SESSION); echo '
'; // delete the above 3 lines when done +// update e-mail address form echo '
'; echo ''; echo ''; -echo '
Update e-mail address

'; +echo '

'; + +// update password form +echo << + + + + + + +
Old Password
New password
Verify password
+ +UPDPASS; include_once ('footer.php'); ?> \ No newline at end of file From c036f6eba8e03100cf0d24d5ee6f4e31ef62c80a Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 15:26:48 -1000 Subject: [PATCH 54/97] forgot to close the password form --- preferences.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preferences.php b/preferences.php index 54566af..ad81fb0 100644 --- a/preferences.php +++ b/preferences.php @@ -48,7 +48,7 @@ echo << - + UPDPASS; include_once ('footer.php'); ?> \ No newline at end of file From d14d47e75d9e44c9aa10097f2c9527db8c09eec3 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 15:29:48 -1000 Subject: [PATCH 55/97] cleaned up preferences for production use --- preferences.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/preferences.php b/preferences.php index ad81fb0..7050a4c 100644 --- a/preferences.php +++ b/preferences.php @@ -3,25 +3,17 @@ $pagetitle = "Account options"; include_once ('header.php'); if (!empty($_POST['useremail'])) { - //this section contains code to update the users e-mail address, maybe via an include? + //this section contains code to update the users e-mail address include_once ('includes/update-email.php'); } if (!empty($_POST['oldpass'])) { - echo 'if the oldpass is set, execute code here (this line will go away from preferences.php!)
'; + // this section contains code to update the users password after verifying the old password first include_once ('includes/update-password.php'); -} else { - echo 'if post oldpass is NOT set, then this else statement can go away.
'; } echo '

Change e-mail or password

'; -// listing all session variables currently set for debugging purposes -echo '
';
-var_dump($_SESSION);
-echo '

'; -// delete the above 3 lines when done - // update e-mail address form echo '
'; echo ''; From b12392e74b46cecd22dff1f1e372974cbb4205c8 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 15:31:33 -1000 Subject: [PATCH 56/97] finished code to update a users password --- includes/update-password.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 includes/update-password.php diff --git a/includes/update-password.php b/includes/update-password.php new file mode 100644 index 0000000..4ced42b --- /dev/null +++ b/includes/update-password.php @@ -0,0 +1,21 @@ +prepare("SELECT userpass FROM userinfo WHERE userid = ?"); +$verifypass->bind_param("i", $_SESSION['userid']); +$verifypass->execute(); +$result = $verifypass->get_result(); +while ($row = $result->fetch_assoc()) { + $vp = password_verify ($_POST['oldpass'],$row['userpass']); + if ($vp) { + $hp = password_hash($_POST['userpass1'], PASSWORD_DEFAULT); + echo 'Verified old password, updating to new password!
'; + $updpass = $con->prepare("UPDATE userinfo SET userpass = ? WHERE userid = ?"); + $updpass->bind_param("si", $hp, $_SESSION['userid']); + $updpass->execute(); + echo 'Password updated!
'; + $updpass->close(); + } else { + echo 'Old password doesn\'t match, password is NOT updated!
'; + } +} +?> \ No newline at end of file From a630342bb4eca27735dff3d60e6247353a13e492 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 16:00:34 -1000 Subject: [PATCH 57/97] prepping for preferred gw account, and character associated with that account --- preferences.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/preferences.php b/preferences.php index 7050a4c..0cad550 100644 --- a/preferences.php +++ b/preferences.php @@ -14,6 +14,12 @@ if (!empty($_POST['oldpass'])) { echo '

Change e-mail or password

'; +// select which GW account you want to default to +# needed code: select accid from table gwaccounts, store it in prefacc in table userinfo + +// select which character from your GW account you want to default to +# needed code: select charrid from table gwchars selected by accid + // update e-mail address form echo '
Update e-mail address
'; echo ''; From 78be10320a0fd830658eb5867827a9b6e6bae25d Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 16:16:50 -1000 Subject: [PATCH 58/97] center text input accross the site --- style.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/style.css b/style.css index 9e4c799..2c4c3d5 100644 --- a/style.css +++ b/style.css @@ -50,4 +50,8 @@ label { img.resize { width:220px; height:300px; +} + +input { + text-align: center; } \ No newline at end of file From bf0ba8cf3b172f6960a9b53131d2a4c6ee4e84f7 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 8 Aug 2018 16:31:04 -1000 Subject: [PATCH 59/97] can now add account names, still need to view current names --- addaccounts.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/addaccounts.php b/addaccounts.php index b4b079b..8fe1d0e 100644 --- a/addaccounts.php +++ b/addaccounts.php @@ -1,6 +1,26 @@ user page'; + +if (!empty($_POST['accemail'])) { + $addacc = $con->prepare("INSERT INTO gwaccounts (userid, accemail) VALUES (?, ?)"); + $addacc->bind_param("is", $_SESSION['userid'], $_POST['accemail']); + $addacc->execute(); + $addacc->close(); + echo 'New account added, returning to editor.'; + header ("Refresh:1; url=addaccounts.php"); + exit(); +} + +echo '
Update e-mail address
'; +echo ''; +echo ''; +echo '
Add a new Guild Wars account e-mail
'; + +echo ''; +echo ''; +// grab account name from database and loop it in here as a read only bit + +echo '
Return to your user page'; include_once ('footer.php'); ?> \ No newline at end of file From 306aa3f19bc353998de194259fc8cbfcaf77694f Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Thu, 9 Aug 2018 00:51:42 -1000 Subject: [PATCH 60/97] list current accounts tied to user --- addaccounts.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/addaccounts.php b/addaccounts.php index 8fe1d0e..e9c4875 100644 --- a/addaccounts.php +++ b/addaccounts.php @@ -15,12 +15,21 @@ if (!empty($_POST['accemail'])) { echo '
Current Guild Wars accounts
Account name
'; echo ''; echo ''; -echo '
Add a new Guild Wars account e-mail
'; +echo '

'; -echo ''; +echo '
Current Guild Wars accounts
'; echo ''; // grab account name from database and loop it in here as a read only bit +$acclist = $con->prepare("SELECT accemail FROM gwaccounts WHERE userid = ?"); +$acclist->bind_param("i", $_SESSION['userid']); +$acclist->execute(); +$result = $acclist->get_result(); +while ($row = $result->fetch_assoc()) { + echo ''; +} +$acclist->close(); +echo '
Current Guild Wars accounts
Account name
' . $row['accemail'] . '
'; echo '
Return to your user page'; include_once ('footer.php'); ?> \ No newline at end of file From 23618bf8fd34615d8c5e83a00ef0686135eb65a2 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Thu, 9 Aug 2018 07:33:09 -1000 Subject: [PATCH 61/97] can select a specific account, but not do anything with it yet --- preferences.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/preferences.php b/preferences.php index 0cad550..b8d6872 100644 --- a/preferences.php +++ b/preferences.php @@ -12,10 +12,25 @@ if (!empty($_POST['oldpass'])) { include_once ('includes/update-password.php'); } +if (!empty($_POST['prefacc'])) { + //this section contains code to set the users preferred game account + #include_once ('includes/set-prefacc.php'); + echo 'this line will go away once the include file is completed!
'; +} echo '

Change e-mail or password

'; // select which GW account you want to default to # needed code: select accid from table gwaccounts, store it in prefacc in table userinfo +echo '
'; +echo '
Preferred GW account
'; // select which character from your GW account you want to default to # needed code: select charrid from table gwchars selected by accid From 1d2ad0d6f6e5ac131a476bcdc059a772e205ea0b Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Thu, 9 Aug 2018 10:19:17 -1000 Subject: [PATCH 62/97] save GW account preferences in session data --- login.php | 4 ++++ preferences.php | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/login.php b/login.php index 6c80c33..5427746 100644 --- a/login.php +++ b/login.php @@ -27,6 +27,10 @@ if ($verifypass) { $_SESSION['username'] = $row[1]; $_SESSION['usermail'] = $row[3]; $_SESSION['admin'] = $row[4]; + $_SESSION['prefaccid'] = $row[5]; + $_SESSION['prefaccname'] = $row[6]; + $_SESSION['prefcharid'] = $row[7]; + $_SESSION['prefcharname'] = $row[8]; include_once ('header.php'); header("refresh:1;url=index.php"); echo '
You have successfully logged in!
'; diff --git a/preferences.php b/preferences.php index b8d6872..4be2289 100644 --- a/preferences.php +++ b/preferences.php @@ -22,7 +22,8 @@ echo '

Change e-mail or password

'; // select which GW account you want to default to # needed code: select accid from table gwaccounts, store it in prefacc in table userinfo echo '
'; -echo '
Preferred GW account
'; +echo '
'; // select which character from your GW account you want to default to # needed code: select charrid from table gwchars selected by accid From 247281fa9dbe8bc2f48edb7506dd1999d779bb4a Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Thu, 9 Aug 2018 13:12:11 -1000 Subject: [PATCH 63/97] selecting preferred game account completed --- changeaccounts.php | 6 ------ includes/set-prefacc.php | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) delete mode 100644 changeaccounts.php create mode 100644 includes/set-prefacc.php diff --git a/changeaccounts.php b/changeaccounts.php deleted file mode 100644 index 112b62c..0000000 --- a/changeaccounts.php +++ /dev/null @@ -1,6 +0,0 @@ -user page'; -include_once ('footer.php'); -?> \ No newline at end of file diff --git a/includes/set-prefacc.php b/includes/set-prefacc.php new file mode 100644 index 0000000..0592145 --- /dev/null +++ b/includes/set-prefacc.php @@ -0,0 +1,25 @@ +prepare("UPDATE userinfo SET prefaccid = 0, prefaccname = 'No default selected' WHERE userid = ?"); + $nap->bind_param("i", $_SESSION['userid']); + $nap->execute(); + $nap->close(); + $_SESSION['prefaccid'] = "0"; + $_SESSION['prefaccname'] = "No default selected"; + echo 'Account preference update - no preferred account selected.
'; +} else { + $sap = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE accid = ? AND userid = ?"); + $sap->bind_param("ii", $_POST['prefaccid'], $_SESSION['userid']); + $sap->execute(); + $result = $sap->get_result(); + while ($row = $result->fetch_assoc()) { + $uap = $con->prepare("UPDATE userinfo SET prefaccid = ?, prefaccname = ? WHERE userid = ?"); + $uap->bind_param("isi", $_POST['prefaccid'], $row['accemail'], $_SESSION['userid']); + $uap->execute(); + $uap->close(); + $_SESSION['prefaccid'] = $row['accid']; + $_SESSION['prefaccname'] = $row['accemail']; + } + echo 'Guild Wars preferred account updated!
'; +} +?> \ No newline at end of file From 04a71dfa6bc0f68f06fc6b1c981241b6f9756f7d Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Thu, 9 Aug 2018 13:13:08 -1000 Subject: [PATCH 64/97] removed account change placeholder, since it can be set in preferences now --- index.php | 1 - 1 file changed, 1 deletion(-) diff --git a/index.php b/index.php index 223b954..e22918d 100644 --- a/index.php +++ b/index.php @@ -6,7 +6,6 @@ if (isset($_SESSION['userid'])){ echo 'Update character stats here

'; echo 'Update account stats here

'; echo 'View individual character stats here

'; //make this a drop down list later - echo 'Change Guild Wars account here
'; //make this a drop down list later echo 'Add Guild Wars account here
'; } include_once ('footer.php'); From 6bed38654eed7589f2f25bceb6ae00e6acc3a41e Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Thu, 9 Aug 2018 13:13:59 -1000 Subject: [PATCH 65/97] completed game account preferrence setting --- preferences.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/preferences.php b/preferences.php index 4be2289..dc9d96e 100644 --- a/preferences.php +++ b/preferences.php @@ -12,26 +12,24 @@ if (!empty($_POST['oldpass'])) { include_once ('includes/update-password.php'); } -if (!empty($_POST['prefacc'])) { +if (!empty($_POST['setacc'])) { //this section contains code to set the users preferred game account - #include_once ('includes/set-prefacc.php'); - echo 'this line will go away once the include file is completed!
'; + include_once ('includes/set-prefacc.php'); } echo '

Change e-mail or password

'; // select which GW account you want to default to -# needed code: select accid from table gwaccounts, store it in prefacc in table userinfo -echo '
'; -echo '
Preferred GW account
'; +echo '
Current preferred account: ' .$_SESSION['prefaccname'] . '

'; +echo '

'; // select which character from your GW account you want to default to # needed code: select charrid from table gwchars selected by accid From 4f43ccd9dc489db12641a0dfc2626e7ea1572fc2 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Thu, 9 Aug 2018 13:41:07 -1000 Subject: [PATCH 66/97] spell check ftw --- preferences.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preferences.php b/preferences.php index dc9d96e..8c3a1e5 100644 --- a/preferences.php +++ b/preferences.php @@ -21,7 +21,7 @@ echo '

Change e-mail or password

'; // select which GW account you want to default to echo '
'; echo '
Current preferred account: ' .$_SESSION['prefaccname'] . '
'; From 65997efd611eab6d81f751223a4af9d89f5ee16a Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Thu, 9 Aug 2018 15:31:53 -1000 Subject: [PATCH 68/97] trying to show no character names found in table if there's no character names found in the database --- addaccounts.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/addaccounts.php b/addaccounts.php index e9c4875..5f861ce 100644 --- a/addaccounts.php +++ b/addaccounts.php @@ -20,14 +20,41 @@ echo '


'; echo ''; echo ''; // grab account name from database and loop it in here as a read only bit -$acclist = $con->prepare("SELECT accemail FROM gwaccounts WHERE userid = ?"); +$acclist = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE userid = ?"); $acclist->bind_param("i", $_SESSION['userid']); $acclist->execute(); $result = $acclist->get_result(); while ($row = $result->fetch_assoc()) { - echo ''; + echo ''; } $acclist->close(); +echo '
Current Guild Wars accounts
Account name
' . $row['accemail'] . '
'; + if ($row['accid'] == $_SESSION['prefaccid']) { + echo '' . $row['accemail'] . ''; + } else { + echo $row['accemail']; + } + echo '

'; +echo ''; +$lc = $con->prepare("SELECT charid, charname FROM gwchars WHERE accid = ?"); +$lc->bind_param("i", $_SESSION['prefaccid']); +$lc->execute(); +$res2 = $lc->get_result(); + +while ($row2 = $res2->fetch_assoc()) { + echo ''; +} + +/*} else { + echo ''; + echo ''; +}*/ echo '
Available characters
'; + if ($row2['charid'] == $_SESSION['prefcharid']) { + echo '' . $row2['charname'] . ''; + } else { + echo $row2['charname']; + } + echo '
' . count($row2) . ' results!
No characters found!
'; echo '
Return to your user page'; From ab2f1169dc41212d601e8d3539ca9af2ed54993d Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Thu, 9 Aug 2018 15:32:36 -1000 Subject: [PATCH 69/97] fixed undefined variable index error popping up when nobody is logged in --- footer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/footer.php b/footer.php index 166e8d7..4966fec 100644 --- a/footer.php +++ b/footer.php @@ -1,7 +1,9 @@
'; -echo '
| Preferred game account: ' . $_SESSION['prefaccname'] . ' | Preferred character: ' . $_SESSION['prefcharname'] . ' |

'; +if (isset($_SESSION['prefaccname']) && ($_SESSION['prefcharname'])) { + echo '
| Currently selected game account: ' . $_SESSION['prefaccname'] . ' | Current character: ' . $_SESSION['prefcharname'] . ' |

'; +} // the footer just adds a logout button at the bottom of every page for the currently logged in user if (isset($_SESSION['userid']) && ($_SESSION['username'])) { echo '


'; From 7c2e5f38f925e8783b463c306f6c4bf43a9564de Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Thu, 9 Aug 2018 15:33:51 -1000 Subject: [PATCH 70/97] re-ordered the links I think? --- index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index e22918d..bc46fa8 100644 --- a/index.php +++ b/index.php @@ -3,10 +3,10 @@ $pagetitle = "Guild Wars Stats Tracker"; include_once ('header.php'); if (isset($_SESSION['userid'])){ + echo 'View individual character stats here

'; //make this a drop down list later echo 'Update character stats here

'; echo 'Update account stats here

'; - echo 'View individual character stats here

'; //make this a drop down list later - echo 'Add Guild Wars account here
'; + echo 'Add Guild Wars accounts and characters here
'; } include_once ('footer.php'); ?> \ No newline at end of file From 373f9a348c3d344535f59386c99dda2109b70a63 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Thu, 9 Aug 2018 22:11:21 -1000 Subject: [PATCH 71/97] adding code to delete characters --- addaccounts.php | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/addaccounts.php b/addaccounts.php index 5f861ce..b2ca3ba 100644 --- a/addaccounts.php +++ b/addaccounts.php @@ -12,10 +12,21 @@ if (!empty($_POST['accemail'])) { exit(); } +if (!empty($_POST['delchar'])) { + echo 'removing selected character(s) from selected account
'; + $delchar = $con->prepare("DELETE FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?"); + $delchar->bind_param("iii", $_POST['charid'], $_POST['accid'], $_SESSION['userid']); + $delchar->execute(); + $delchar->close(); + echo 'Need to figure out code to delete stats related to this character still!
'; + //header ("Refresh:1; url=addacounts.php"); + //exit(); +} + echo '
'; -echo ''; -echo ''; -echo '
Add a new Guild Wars account e-mail


'; +echo 'Add a new Guild Wars account e-mail or alias'; +echo ''; +echo '
'; echo ''; echo ''; @@ -35,27 +46,22 @@ while ($row = $result->fetch_assoc()) { } $acclist->close(); echo '
Current Guild Wars accounts
Account name

'; -echo ''; + +echo '
Available characters
'; +echo ''; $lc = $con->prepare("SELECT charid, charname FROM gwchars WHERE accid = ?"); $lc->bind_param("i", $_SESSION['prefaccid']); $lc->execute(); $res2 = $lc->get_result(); - while ($row2 = $res2->fetch_assoc()) { - echo ''; + echo ''; } - -/*} else { - echo ''; - echo ''; -}*/ - echo '
Available characters
charidcharnameDelete?
'; + echo '
' . $row2['charid'] . ''; if ($row2['charid'] == $_SESSION['prefcharid']) { echo '' . $row2['charname'] . ''; } else { echo $row2['charname']; } - echo '
' . count($row2) . ' results!
No characters found!
'; echo '
Return to your user page'; include_once ('footer.php'); From 4fc4ab4bca9cd579203268831e1c67af85a3719d Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Thu, 9 Aug 2018 22:11:48 -1000 Subject: [PATCH 72/97] added link to character creation page --- index.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index bc46fa8..7925576 100644 --- a/index.php +++ b/index.php @@ -3,10 +3,11 @@ $pagetitle = "Guild Wars Stats Tracker"; include_once ('header.php'); if (isset($_SESSION['userid'])){ - echo 'View individual character stats here

'; //make this a drop down list later - echo 'Update character stats here

'; - echo 'Update account stats here

'; - echo 'Add Guild Wars accounts and characters here
'; + echo 'View individual character stats here

'; //make this a drop down list later + echo 'Update character stats here

'; + echo 'Update account stats here

'; + echo 'Add Guild Wars accounts and manage characters here

'; + echo 'Add a new character to track
'; } include_once ('footer.php'); ?> \ No newline at end of file From db046d299e4c4073fe8ccb567a3a0e9a005885e8 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Thu, 9 Aug 2018 23:26:55 -1000 Subject: [PATCH 73/97] tried to set submit button color, can now delete characters --- addcharacters.php | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 addcharacters.php diff --git a/addcharacters.php b/addcharacters.php new file mode 100644 index 0000000..14c50ac --- /dev/null +++ b/addcharacters.php @@ -0,0 +1,10 @@ +'; +echo ''; +echo ''; +echo '
Add character to account: ' . $_SESSION['prefaccname'] . '

'; +include_once ('footer.php'); +?> \ No newline at end of file From 9ed42c7313be9ba8ab0aaa31e1af54d205c4dddf Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Fri, 10 Aug 2018 01:18:07 -1000 Subject: [PATCH 74/97] webt to sleep don't remember --- addaccounts.php | 42 +++++++++++++++++++++++++++++------------- addcharacters.php | 2 +- style.css | 8 +++++++- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/addaccounts.php b/addaccounts.php index b2ca3ba..4b01219 100644 --- a/addaccounts.php +++ b/addaccounts.php @@ -2,6 +2,12 @@ $pagetitle = "Add a Guild Wars account to track"; include_once ('header.php'); +# delete this block when shit finally works. +ini_set('display_errors', 'on'); +error_reporting(E_ALL); +mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); +# delete the above when shit finally works + if (!empty($_POST['accemail'])) { $addacc = $con->prepare("INSERT INTO gwaccounts (userid, accemail) VALUES (?, ?)"); $addacc->bind_param("is", $_SESSION['userid'], $_POST['accemail']); @@ -14,13 +20,22 @@ if (!empty($_POST['accemail'])) { if (!empty($_POST['delchar'])) { echo 'removing selected character(s) from selected account
'; - $delchar = $con->prepare("DELETE FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?"); - $delchar->bind_param("iii", $_POST['charid'], $_POST['accid'], $_SESSION['userid']); - $delchar->execute(); - $delchar->close(); - echo 'Need to figure out code to delete stats related to this character still!
'; - //header ("Refresh:1; url=addacounts.php"); - //exit(); + if ($delchar = $con->prepare("DELETE FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?")) { + $delchar->bind_param("iii", $delcharid, $delaccid, $_SESSION['userid']); + for ($i = 0; $i < count($_POST['delchar']); $i++) { + $delcharid = $_POST['charid'][$i]; + $delaccid = $_POST['accid'][$i]; + $delchar->execute(); + } + $delchar->close(); + } + $nap = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?"); + $nap->bind_param("i", $_SESSION['userid']); + $nap->execute(); + $nap->close(); + $_SESSION['prefcharid'] = "0"; + $_SESSION['prefcharname'] = "No default selected"; + echo 'Character deleted - no preferred character selected.

'; } echo '
'; @@ -47,22 +62,23 @@ while ($row = $result->fetch_assoc()) { $acclist->close(); echo '

'; -echo ''; -echo ''; -$lc = $con->prepare("SELECT charid, charname FROM gwchars WHERE accid = ?"); +echo '
Available characters
charidcharnameDelete?
'; +echo ''; +$lc = $con->prepare("SELECT charid, accid, charname FROM gwchars WHERE accid = ?"); $lc->bind_param("i", $_SESSION['prefaccid']); $lc->execute(); $res2 = $lc->get_result(); while ($row2 = $res2->fetch_assoc()) { - echo ''; + echo ''; + echo ''; } -echo '
Available characters
charidaccidcharnameDelete?
' . $row2['charid'] . ''; + echo '
'; if ($row2['charid'] == $_SESSION['prefcharid']) { echo '' . $row2['charname'] . ''; } else { echo $row2['charname']; } - echo '
'; +echo '

'; echo '
Return to your user page'; include_once ('footer.php'); ?> \ No newline at end of file diff --git a/addcharacters.php b/addcharacters.php index 14c50ac..7379645 100644 --- a/addcharacters.php +++ b/addcharacters.php @@ -2,7 +2,7 @@ $pagetitle = "Add Characters"; include_once ('header.php'); echo 'add a new character!'; -echo '
'; +echo '
'; echo ''; echo ''; echo '
Add character to account: ' . $_SESSION['prefaccname'] . '

'; diff --git a/style.css b/style.css index 2c4c3d5..8a8eedc 100644 --- a/style.css +++ b/style.css @@ -28,7 +28,7 @@ ul, li{ padding:0 0 0 15px; } -.column{ +.column { float: left; margin: 0 20px 0 0; } @@ -54,4 +54,10 @@ img.resize { input { text-align: center; +} + +input[type=submit] { + background-color: #4CAF50; + border: none; + color: white; } \ No newline at end of file From 7019e2b5c2c30bdbe87e285c8e9310dd2343f49a Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Fri, 10 Aug 2018 08:25:33 -1000 Subject: [PATCH 75/97] cleaned up file --- includes/titleranks-submit.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/includes/titleranks-submit.php b/includes/titleranks-submit.php index c45daf5..8bb44c9 100644 --- a/includes/titleranks-submit.php +++ b/includes/titleranks-submit.php @@ -1,7 +1,4 @@ prepare("INSERT INTO gwsubtitles (titlenameid, stname, stpoints, strank) VALUES (?, ?, ?, ?)"); $stmtstins->bind_param("isii", $_POST['titlenameid'], $_POST['titlerankname'], $_POST['titlepoints'], $_POST['titlerank']); $stmtstins->execute(); From ef75015cb674b70c4c7f62aa1eed2351888ef374 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Fri, 10 Aug 2018 17:31:40 -1000 Subject: [PATCH 76/97] add character creation to account creation page. modified supporting files --- addaccounts.php | 19 +++++++++++++++++++ addcharacters.php | 10 ---------- includes/addcharacters-submit.php | 16 ++++++++++++++++ index.php | 1 - 4 files changed, 35 insertions(+), 11 deletions(-) delete mode 100644 addcharacters.php create mode 100644 includes/addcharacters-submit.php diff --git a/addaccounts.php b/addaccounts.php index 4b01219..c20d3f7 100644 --- a/addaccounts.php +++ b/addaccounts.php @@ -38,6 +38,10 @@ if (!empty($_POST['delchar'])) { echo 'Character deleted - no preferred character selected.

'; } +if (!empty($_POST['newcharname'])) { + include_once ('includes/addcharacters-submit.php'); +} + echo '
'; echo ''; echo ''; @@ -62,6 +66,21 @@ while ($row = $result->fetch_assoc()) { $acclist->close(); echo '
Add a new Guild Wars account e-mail or alias

'; +// add characters here +echo ''; +echo ''; +echo ''; +echo ''; +echo '
Add character to account: ' . $_SESSION['prefaccname'] . '
Character nameBirthdateProfession

'; + echo '
'; echo ''; $lc = $con->prepare("SELECT charid, accid, charname FROM gwchars WHERE accid = ?"); diff --git a/addcharacters.php b/addcharacters.php deleted file mode 100644 index 7379645..0000000 --- a/addcharacters.php +++ /dev/null @@ -1,10 +0,0 @@ -
Available characters
charidaccidcharnameDelete?
'; -echo ''; -echo ''; -echo '
Add character to account: ' . $_SESSION['prefaccname'] . '

'; -include_once ('footer.php'); -?> \ No newline at end of file diff --git a/includes/addcharacters-submit.php b/includes/addcharacters-submit.php new file mode 100644 index 0000000..65f4865 --- /dev/null +++ b/includes/addcharacters-submit.php @@ -0,0 +1,16 @@ +prepare("INSERT INTO gwchars (accid, userid, charname, birthdate, profid) VALUES (?, ?, ?, ?, ?)"); +$ac->bind_param("iissi", $_SESSION['prefaccid'], $_SESSION['userid'], $_POST['newcharname'], $_POST['bdate'], $_POST['profid']); +$ac->execute(); +$ac->close(); +echo $_POST['newcharname'] . ' added to your account!

'; + +?> \ No newline at end of file diff --git a/index.php b/index.php index 7925576..dd901f0 100644 --- a/index.php +++ b/index.php @@ -7,7 +7,6 @@ if (isset($_SESSION['userid'])){ echo 'Update character stats here

'; echo 'Update account stats here

'; echo 'Add Guild Wars accounts and manage characters here

'; - echo 'Add a new character to track
'; } include_once ('footer.php'); ?> \ No newline at end of file From 34c256edce92a2ef4fae2e57bdffebbc37c09be8 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Fri, 10 Aug 2018 18:35:46 -1000 Subject: [PATCH 77/97] added simple check for logged in status, more stuff for character selection --- addaccounts.php | 4 +- adminlanding.php | 12 ++-- includes/addcharacters-submit.php | 15 ++-- includes/set-prefacc.php | 44 ++++++------ includes/set-prefchar.php | 5 ++ preferences.php | 23 +++++- titlemanager.php | 143 +++++++++++++++++++------------------- 7 files changed, 138 insertions(+), 108 deletions(-) create mode 100644 includes/set-prefchar.php diff --git a/addaccounts.php b/addaccounts.php index c20d3f7..aaf139f 100644 --- a/addaccounts.php +++ b/addaccounts.php @@ -1,7 +1,8 @@ fetch_assoc()) { } echo '
'; echo '
Return to your user page'; +} include_once ('footer.php'); ?> \ No newline at end of file diff --git a/adminlanding.php b/adminlanding.php index 81025d4..ef2840f 100644 --- a/adminlanding.php +++ b/adminlanding.php @@ -1,10 +1,12 @@ Welcome to the admin area!

'; -echo 'Title creator / editor here (work in progress)

'; -echo 'User editor here (not working yet)
'; +if (isset($_SESSION['userid'])){ + unset($_SESSION['title']); + unset($_SESSION['tid']); + echo '
Welcome to the admin area!

'; + echo 'Title creator / editor here (work in progress)

'; + echo 'User editor here (not working yet)
'; +} include_once ('footer.php'); ?> \ No newline at end of file diff --git a/includes/addcharacters-submit.php b/includes/addcharacters-submit.php index 65f4865..820cc0a 100644 --- a/includes/addcharacters-submit.php +++ b/includes/addcharacters-submit.php @@ -6,11 +6,12 @@ error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); # delete the above when shit finally works -// $ac = AddCharacter -$ac = $con->prepare("INSERT INTO gwchars (accid, userid, charname, birthdate, profid) VALUES (?, ?, ?, ?, ?)"); -$ac->bind_param("iissi", $_SESSION['prefaccid'], $_SESSION['userid'], $_POST['newcharname'], $_POST['bdate'], $_POST['profid']); -$ac->execute(); -$ac->close(); -echo $_POST['newcharname'] . ' added to your account!

'; - +if (isset($_SESSION['userid'])){ + // $ac = AddCharacter + $ac = $con->prepare("INSERT INTO gwchars (accid, userid, charname, birthdate, profid) VALUES (?, ?, ?, ?, ?)"); + $ac->bind_param("iissi", $_SESSION['prefaccid'], $_SESSION['userid'], $_POST['newcharname'], $_POST['bdate'], $_POST['profid']); + $ac->execute(); + $ac->close(); + echo $_POST['newcharname'] . ' added to your account!

'; +} ?> \ No newline at end of file diff --git a/includes/set-prefacc.php b/includes/set-prefacc.php index 0592145..eabe45d 100644 --- a/includes/set-prefacc.php +++ b/includes/set-prefacc.php @@ -1,25 +1,27 @@ prepare("UPDATE userinfo SET prefaccid = 0, prefaccname = 'No default selected' WHERE userid = ?"); - $nap->bind_param("i", $_SESSION['userid']); - $nap->execute(); - $nap->close(); - $_SESSION['prefaccid'] = "0"; - $_SESSION['prefaccname'] = "No default selected"; - echo 'Account preference update - no preferred account selected.
'; -} else { - $sap = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE accid = ? AND userid = ?"); - $sap->bind_param("ii", $_POST['prefaccid'], $_SESSION['userid']); - $sap->execute(); - $result = $sap->get_result(); - while ($row = $result->fetch_assoc()) { - $uap = $con->prepare("UPDATE userinfo SET prefaccid = ?, prefaccname = ? WHERE userid = ?"); - $uap->bind_param("isi", $_POST['prefaccid'], $row['accemail'], $_SESSION['userid']); - $uap->execute(); - $uap->close(); - $_SESSION['prefaccid'] = $row['accid']; - $_SESSION['prefaccname'] = $row['accemail']; +if (isset($_SESSION['userid'])) { + if ($_POST['prefaccid'] == "nopref") { + $nap = $con->prepare("UPDATE userinfo SET prefaccid = 0, prefaccname = 'No default selected' WHERE userid = ?"); + $nap->bind_param("i", $_SESSION['userid']); + $nap->execute(); + $nap->close(); + $_SESSION['prefaccid'] = "0"; + $_SESSION['prefaccname'] = "No default selected"; + echo 'Account preference update - no preferred account selected.
'; + } else { + $sap = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE accid = ? AND userid = ?"); + $sap->bind_param("ii", $_POST['prefaccid'], $_SESSION['userid']); + $sap->execute(); + $result = $sap->get_result(); + while ($row = $result->fetch_assoc()) { + $uap = $con->prepare("UPDATE userinfo SET prefaccid = ?, prefaccname = ? WHERE userid = ?"); + $uap->bind_param("isi", $_POST['prefaccid'], $row['accemail'], $_SESSION['userid']); + $uap->execute(); + $uap->close(); + $_SESSION['prefaccid'] = $row['accid']; + $_SESSION['prefaccname'] = $row['accemail']; + } + echo 'Guild Wars preferred account updated!
'; } - echo 'Guild Wars preferred account updated!
'; } ?> \ No newline at end of file diff --git a/includes/set-prefchar.php b/includes/set-prefchar.php new file mode 100644 index 0000000..f640c5e --- /dev/null +++ b/includes/set-prefchar.php @@ -0,0 +1,5 @@ +'; +} +?> \ No newline at end of file diff --git a/preferences.php b/preferences.php index 8c3a1e5..9664f27 100644 --- a/preferences.php +++ b/preferences.php @@ -1,7 +1,8 @@ Change e-mail or password'; // select which GW account you want to default to @@ -32,6 +39,19 @@ while ($row = $resacc->fetch_assoc()) { echo '
'; // select which character from your GW account you want to default to +echo 'the session prefaccid is: ' . $_SESSION['prefaccid'] . '
'; +echo 'the session userid is: ' .$_SESSION['userid'] . '
'; +echo '
'; +echo '
Current preferred character: ' .$_SESSION['prefcharname'] . '

'; # needed code: select charrid from table gwchars selected by accid // update e-mail address form @@ -62,5 +82,6 @@ echo << UPDPASS; +} include_once ('footer.php'); ?> \ No newline at end of file diff --git a/titlemanager.php b/titlemanager.php index 98ac47b..a21ee55 100644 --- a/titlemanager.php +++ b/titlemanager.php @@ -1,82 +1,79 @@ connect_errno){ - die ('Unable to connect to database [' . $db->connect_errno . ']'); -} -if (isset($_SESSION['title'])) { - if ($_SESSION['title'] == "repeat") { - $_POST['title'] = "addsubtitle"; - unset($_SESSION['title']); - } else { - unset($_SESSION['tr']); - } -} -if ($_SESSION['admin'] == 1) { - echo '
'; - if (isset($_POST['title'])) { - if ($_POST['title'] == "addtitle") { - // included file contains all the code to add a new title - include_once ('includes/title-add.php'); - } else if ($_POST['title'] == "titlesubmit") { - // included file contains all the code to submit a new title - include_once ('includes/title-submit.php'); - } else if ($_POST['title'] == "modtitle") { - // included file contains all the code to edit a title - include_once ('includes/title-editor.php'); - } else if ($_POST['title'] == "updatetitle") { - // this section doesn't require human interaction - include_once ('includes/title-update.php'); - } else if ($_POST['title'] == "addsubtitle") { - // included file contains all code to add the title ranks and points required - include_once ('includes/titleranks-add.php'); - } else if ($_POST['title'] == "titleranksubmit") { - // this section doesn't require human interaction - include_once ('includes/titleranks-submit.php'); - } else if ($_POST['title'] == "modsubtitle") { - // included file contains all code to edit a title rank - include_once ('includes/titleranks-editor.php'); - } else if ($_POST['title'] == "updatesubtitle") { - // this sectionupdates modified title ranks in the database, or deletes them - include_once ('includes/titleranks-update.php'); - } - } else { - unset($_SESSION['tid']); - unset($_SESSION['tr']); - echo 'Add titles

'; - echo 'Modify titles


'; - echo 'Add or modify title ranks and points


'; - // now to view the last 5 title entries in the database - echo 'Here is the last 15 titles entered into the database, newest entry is on top:
'; - echo ''; - $stmtview = $con->prepare("SELECT * FROM gwtitles ORDER BY titlenameid DESC LIMIT 15"); - $stmtview->execute(); - $result = $stmtview->get_result(); - while ($row = $result->fetch_assoc()) { - $tid = $row['titlenameid']; - $tname = $row['titlename']; - $ttype = $row['titletype']; - $tmr = $row['titlemaxrank']; - echo '
titleidtitlenametitletypetitletype
' . $tid . '' . $tname . ' (' . $tmr . ')' . $ttype . ''; - if ($ttype == "0") { - echo 'account'; - } else if ($ttype == "1") { - echo 'character'; +if (isset($_SESSION['userid'])){ + if (isset($_SESSION['title'])) { + if ($_SESSION['title'] == "repeat") { + $_POST['title'] = "addsubtitle"; + unset($_SESSION['title']); } else { - echo 'Anything other than a 0 or 1 means something broke!'; - include_once ('footer.php'); - exit(); + unset($_SESSION['tr']); + } + } + if ($_SESSION['admin'] == 1) { + echo '
'; + if (isset($_POST['title'])) { + if ($_POST['title'] == "addtitle") { + // included file contains all the code to add a new title + include_once ('includes/title-add.php'); + } else if ($_POST['title'] == "titlesubmit") { + // included file contains all the code to submit a new title + include_once ('includes/title-submit.php'); + } else if ($_POST['title'] == "modtitle") { + // included file contains all the code to edit a title + include_once ('includes/title-editor.php'); + } else if ($_POST['title'] == "updatetitle") { + // this section doesn't require human interaction + include_once ('includes/title-update.php'); + } else if ($_POST['title'] == "addsubtitle") { + // included file contains all code to add the title ranks and points required + include_once ('includes/titleranks-add.php'); + } else if ($_POST['title'] == "titleranksubmit") { + // this section doesn't require human interaction + include_once ('includes/titleranks-submit.php'); + } else if ($_POST['title'] == "modsubtitle") { + // included file contains all code to edit a title rank + include_once ('includes/titleranks-editor.php'); + } else if ($_POST['title'] == "updatesubtitle") { + // this sectionupdates modified title ranks in the database, or deletes them + include_once ('includes/titleranks-update.php'); + } + } else { + unset($_SESSION['tid']); + unset($_SESSION['tr']); + echo 'Add titles

'; + echo 'Modify titles


'; + echo 'Add or modify title ranks and points


'; + // now to view the last 5 title entries in the database + echo 'Here is the last 15 titles entered into the database, newest entry is on top:
'; + echo ''; + $stmtview = $con->prepare("SELECT * FROM gwtitles ORDER BY titlenameid DESC LIMIT 15"); + $stmtview->execute(); + $result = $stmtview->get_result(); + while ($row = $result->fetch_assoc()) { + $tid = $row['titlenameid']; + $tname = $row['titlename']; + $ttype = $row['titletype']; + $tmr = $row['titlemaxrank']; + echo ''; } - echo ''; + $stmtview->close(); + echo '
titleidtitlenametitletypetitletype
' . $tid . '' . $tname . ' (' . $tmr . ')' . $ttype . ''; + if ($ttype == "0") { + echo 'account'; + } else if ($ttype == "1") { + echo 'character'; + } else { + echo 'Anything other than a 0 or 1 means something broke!'; + include_once ('footer.php'); + exit(); + } + echo '

If anything looks off, please fix it!

'; } - $stmtview->close(); - echo '

If anything looks off, please fix it!

'; } } include_once ('footer.php'); From b4f26cded1bb982546661b7c2ca1ddc908fa5e9a Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Sat, 11 Aug 2018 09:17:13 -1000 Subject: [PATCH 78/97] select preferred character, removed some debug code --- addaccounts.php | 7 ------- includes/set-prefacc.php | 6 ++++++ includes/set-prefchar.php | 24 +++++++++++++++++++++++- preferences.php | 3 +-- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/addaccounts.php b/addaccounts.php index aaf139f..25975cb 100644 --- a/addaccounts.php +++ b/addaccounts.php @@ -3,12 +3,6 @@ $pagetitle = "Add a Guild Wars account to track"; include_once ('header.php'); if (isset($_SESSION['userid'])){ -# delete this block when shit finally works. -ini_set('display_errors', 'on'); -error_reporting(E_ALL); -mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); -# delete the above when shit finally works - if (!empty($_POST['accemail'])) { $addacc = $con->prepare("INSERT INTO gwaccounts (userid, accemail) VALUES (?, ?)"); $addacc->bind_param("is", $_SESSION['userid'], $_POST['accemail']); @@ -50,7 +44,6 @@ echo '
'; echo ''; echo ''; -// grab account name from database and loop it in here as a read only bit $acclist = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE userid = ?"); $acclist->bind_param("i", $_SESSION['userid']); $acclist->execute(); diff --git a/includes/set-prefacc.php b/includes/set-prefacc.php index eabe45d..57ffd59 100644 --- a/includes/set-prefacc.php +++ b/includes/set-prefacc.php @@ -21,6 +21,12 @@ if (isset($_SESSION['userid'])) { $_SESSION['prefaccid'] = $row['accid']; $_SESSION['prefaccname'] = $row['accemail']; } + $ncp = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?"); + $ncp->bind_param("i", $_SESSION['userid']); + $ncp->execute(); + $ncp->close(); + $_SESSION['prefcharid'] = "0"; + $_SESSION['prefcharname'] = "No default selected"; echo 'Guild Wars preferred account updated!
'; } } diff --git a/includes/set-prefchar.php b/includes/set-prefchar.php index f640c5e..fa1b448 100644 --- a/includes/set-prefchar.php +++ b/includes/set-prefchar.php @@ -1,5 +1,27 @@ '; + if ($_POST['prefcharid'] == "nopref") { + $ncp = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?"); + $ncp->bind_param("i", $_SESSION['userid']); + $ncp->execute(); + $ncp->close(); + $_SESSION['prefcharid'] = "0"; + $_SESSION['prefcharname'] = "No default selected"; + echo 'Character preference update - no preferred character selected.
'; + } else { + $scp = $con->prepare("SELECT charid, charname FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?"); + $scp->bind_param("iii", $_POST['prefcharid'], $_SESSION['prefaccid'], $_SESSION['userid']); + $scp->execute(); + $result = $scp->get_result(); + while ($row = $result->fetch_assoc()) { + $uap = $con->prepare("UPDATE userinfo SET prefcharid = ?, prefcharname = ? WHERE userid = ?"); + $uap->bind_param("isi", $_POST['prefcharid'], $row['charname'], $_SESSION['userid']); + $uap->execute(); + $uap->close(); + $_SESSION['prefcharid'] = $row['charid']; + $_SESSION['prefcharname'] = $row['charname']; + } + echo 'Guild Wars preferred character updated!
'; + } } ?> \ No newline at end of file diff --git a/preferences.php b/preferences.php index 9664f27..1e46854 100644 --- a/preferences.php +++ b/preferences.php @@ -23,7 +23,7 @@ if (!empty($_POST['setchar'])) { include_once ('includes/set-prefchar.php'); } -echo '

Change e-mail or password

'; +echo '

Set preferred account & character, or change e-mail or password

'; // select which GW account you want to default to echo '
Current Guild Wars accounts
Account name
'; @@ -52,7 +52,6 @@ while ($row2 = $reschar->fetch_assoc()) { echo ''; } echo '
Current preferred account: ' .$_SESSION['prefaccname'] . '

'; -# needed code: select charrid from table gwchars selected by accid // update e-mail address form echo '
'; From 66ba0e2580456b2345d5b0a18ebc32f698de4619 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Sun, 12 Aug 2018 10:59:47 -1000 Subject: [PATCH 79/97] character selection QoL improvements and other stuff --- addaccounts.php | 161 ++++++++++++++++++-------------------- includes/addaccount-submit.php | 11 +++ includes/addcharacters-submit.php | 16 ++-- includes/del-character.php | 21 +++++ includes/getaccountstats.php | 23 ++++++ includes/session-debug.php | 7 ++ includes/session-dump.php | 4 + preferences.php | 2 - style.css | 12 ++- updateaccountstats.php | 8 +- 10 files changed, 166 insertions(+), 99 deletions(-) create mode 100644 includes/addaccount-submit.php create mode 100644 includes/del-character.php create mode 100644 includes/getaccountstats.php create mode 100644 includes/session-debug.php create mode 100644 includes/session-dump.php diff --git a/addaccounts.php b/addaccounts.php index 25975cb..29ed9aa 100644 --- a/addaccounts.php +++ b/addaccounts.php @@ -1,98 +1,91 @@ prepare("INSERT INTO gwaccounts (userid, accemail) VALUES (?, ?)"); - $addacc->bind_param("is", $_SESSION['userid'], $_POST['accemail']); - $addacc->execute(); - $addacc->close(); - echo 'New account added, returning to editor.'; - header ("Refresh:1; url=addaccounts.php"); - exit(); -} + if (!empty($_POST['accemail'])) { + // this section contains the code to add a new game account to track + include_once ('includes/addaccount-submit.php'); + } -if (!empty($_POST['delchar'])) { - echo 'removing selected character(s) from selected account
'; - if ($delchar = $con->prepare("DELETE FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?")) { - $delchar->bind_param("iii", $delcharid, $delaccid, $_SESSION['userid']); - for ($i = 0; $i < count($_POST['delchar']); $i++) { - $delcharid = $_POST['charid'][$i]; - $delaccid = $_POST['accid'][$i]; - $delchar->execute(); - } - $delchar->close(); + if (!empty($_POST['delcharid'])) { + // this section contains code to delete the selected characters + include_once ('includes/del-character.php'); } - $nap = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?"); - $nap->bind_param("i", $_SESSION['userid']); - $nap->execute(); - $nap->close(); - $_SESSION['prefcharid'] = "0"; - $_SESSION['prefcharname'] = "No default selected"; - echo 'Character deleted - no preferred character selected.

'; -} -if (!empty($_POST['newcharname'])) { - include_once ('includes/addcharacters-submit.php'); -} + if (!empty($_POST['newcharname'])) { + // this section contains code to insert a new character into the database + include_once ('includes/addcharacters-submit.php'); + } -echo '
'; -echo ''; -echo ''; -echo '
Add a new Guild Wars account e-mail or alias

'; + echo '
'; + echo ''; + echo ''; + echo '
Add a new Guild Wars account e-mail or alias

'; -echo ''; -echo ''; -$acclist = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE userid = ?"); -$acclist->bind_param("i", $_SESSION['userid']); -$acclist->execute(); -$result = $acclist->get_result(); -while ($row = $result->fetch_assoc()) { - echo ''; -} -$acclist->close(); -echo '
Current Guild Wars accounts
Account name
'; - if ($row['accid'] == $_SESSION['prefaccid']) { - echo '' . $row['accemail'] . ''; - } else { - echo $row['accemail']; - } - echo '

'; + echo ''; + echo ''; + $acclist = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE userid = ?"); + $acclist->bind_param("i", $_SESSION['userid']); + $acclist->execute(); + $result = $acclist->get_result(); + while ($row = $result->fetch_assoc()) { + echo ''; + } + $acclist->close(); + echo '
Current Guild Wars accounts
Account namePreferred?
'; + echo '

'; -// add characters here -echo '
'; -echo ''; -echo ''; -echo ''; -echo '
Add character to account: ' . $_SESSION['prefaccname'] . '
Character nameBirthdateProfession

'; + // add characters here + echo '
'; + echo ''; + echo ''; + echo ''; + echo '
Add character to account: ' . $_SESSION['prefaccname'] . '
Character nameBirthdateProfession

'; -echo '
'; -echo ''; -$lc = $con->prepare("SELECT charid, accid, charname FROM gwchars WHERE accid = ?"); -$lc->bind_param("i", $_SESSION['prefaccid']); -$lc->execute(); -$res2 = $lc->get_result(); -while ($row2 = $res2->fetch_assoc()) { - echo ''; - echo ''; -} -echo '
Available characters
charidaccidcharnameDelete?
'; - if ($row2['charid'] == $_SESSION['prefcharid']) { - echo '' . $row2['charname'] . ''; - } else { - echo $row2['charname']; - } - echo '

'; -echo '
Return to your user page'; + echo '
'; + echo ''; + $lc = $con->prepare("SELECT charid, accid, charname, profid, profcolor FROM gwchars WHERE accid = ?"); + $lc->bind_param("i", $_SESSION['prefaccid']); + $lc->execute(); + $res2 = $lc->get_result(); + while ($row2 = $res2->fetch_assoc()) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo '
Available characters
charidaccidcharnamePreferredDelete?

'; + echo '
Return to your user page'; } include_once ('footer.php'); ?> \ No newline at end of file diff --git a/includes/addaccount-submit.php b/includes/addaccount-submit.php new file mode 100644 index 0000000..b8efe28 --- /dev/null +++ b/includes/addaccount-submit.php @@ -0,0 +1,11 @@ +prepare("INSERT INTO gwaccounts (userid, accemail) VALUES (?, ?)"); + $addacc->bind_param("is", $_SESSION['userid'], $_POST['accemail']); + $addacc->execute(); + $addacc->close(); + echo 'New account added, returning to editor.'; + header ("Refresh:1; url=addaccounts.php"); + exit(); +} +?> \ No newline at end of file diff --git a/includes/addcharacters-submit.php b/includes/addcharacters-submit.php index 820cc0a..100b390 100644 --- a/includes/addcharacters-submit.php +++ b/includes/addcharacters-submit.php @@ -1,15 +1,13 @@ prepare("SELECT profcolor FROM gwprofessions WHERE profid = ?"); + $pc->bind_param("i", $_POST['profid']); + $pc->execute(); + $profcolor = $pc->get_result()->fetch_object()->profcolor; // $ac = AddCharacter - $ac = $con->prepare("INSERT INTO gwchars (accid, userid, charname, birthdate, profid) VALUES (?, ?, ?, ?, ?)"); - $ac->bind_param("iissi", $_SESSION['prefaccid'], $_SESSION['userid'], $_POST['newcharname'], $_POST['bdate'], $_POST['profid']); + $ac = $con->prepare("INSERT INTO gwchars (accid, userid, charname, birthdate, profid, profcolor) VALUES (?, ?, ?, ?, ?, ?)"); + $ac->bind_param("iissis", $_SESSION['prefaccid'], $_SESSION['userid'], $_POST['newcharname'], $_POST['bdate'], $_POST['profid'], $profcolor); $ac->execute(); $ac->close(); echo $_POST['newcharname'] . ' added to your account!

'; diff --git a/includes/del-character.php b/includes/del-character.php new file mode 100644 index 0000000..feb8222 --- /dev/null +++ b/includes/del-character.php @@ -0,0 +1,21 @@ +'; + if ($delchar = $con->prepare("DELETE FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?")) { + $delchar->bind_param("iii", $delcharid, $delaccid, $_SESSION['userid']); + for ($i = 0; $i < count($_POST['delcharid']); $i++) { + $delcharid = $_POST['delcharid'][$i]; + $delaccid = $_POST['accid'][$i]; + $delchar->execute(); + } + $delchar->close(); + } + $nap = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?"); + $nap->bind_param("i", $_SESSION['userid']); + $nap->execute(); + $nap->close(); + $_SESSION['prefcharid'] = "0"; + $_SESSION['prefcharname'] = "No default selected"; + echo 'Character(s) deleted - no preferred character selected.

'; +} +?> \ No newline at end of file diff --git a/includes/getaccountstats.php b/includes/getaccountstats.php new file mode 100644 index 0000000..4500c9f --- /dev/null +++ b/includes/getaccountstats.php @@ -0,0 +1,23 @@ +Account wide stats'; +echo 'Title NameTitle PointsCurrent RankPoints RemainingNext Rank'; +// $gas = GetAccountStats +$gas = $con->prepare("SELECT * FROM gwaccstats WHERE userid = ? AND accid = ?;"); +$gas->bind_param("ii", $_SESSION['prefaccid'], $_SESSION['userid']); +$gas->execute(); +$result = $gas->get_result(); +while ($row = $result->fetch_assoc()) { + echo '' . $row['currentstrankname'] . '' . $row['titlepoints'] . '' . $row['currentstrank'] . ''; + echo ''; + $pr = ($row['nextstrankpoints'] - $row['titlepoints']); + if ($pr < 0) { + echo 'Maximum rank achieved!'; + } else { + echo $pr; + } + echo ''; + echo '' . $row['nextstrank'] . ''; +} +$gas->close(); +echo ''; +?> \ No newline at end of file diff --git a/includes/session-debug.php b/includes/session-debug.php new file mode 100644 index 0000000..9700053 --- /dev/null +++ b/includes/session-debug.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/includes/session-dump.php b/includes/session-dump.php new file mode 100644 index 0000000..20f65ec --- /dev/null +++ b/includes/session-dump.php @@ -0,0 +1,4 @@ +' . print_r($_SESSION, true) . '
'; +echo 'Post variables:
' . print_r($_POST, true) . '

'; +?> \ No newline at end of file diff --git a/preferences.php b/preferences.php index 1e46854..4df06c5 100644 --- a/preferences.php +++ b/preferences.php @@ -39,8 +39,6 @@ while ($row = $resacc->fetch_assoc()) { echo '
'; // select which character from your GW account you want to default to -echo 'the session prefaccid is: ' . $_SESSION['prefaccid'] . '
'; -echo 'the session userid is: ' .$_SESSION['userid'] . '
'; echo '
'; echo ''; -echo ''; -// $gas = GetAccountStats -$gas = $con->prepare("SELECT * FROM gwaccstats WHERE userid = ? AND accid = ?;"); -$gas->bind_param("ii", $_SESSION['prefaccid'], $_SESSION['userid']); -$gas->execute(); -$result = $gas->get_result(); -while ($row = $result->fetch_assoc()) { - echo ''; - echo '
Current preferred character: ' .$_SESSION['prefcharname'] . '
Account wide stats
Title NameTitle PointsCurrent RankPoints RemainingNext Rank
' . $row['currentstrankname'] . '' . $row['titlepoints'] . '' . $row['currentstrank'] . ''; - $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 ''; + echo ''; + // $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 ''; + echo ''; } - echo ''; - echo ''; + $gas->close(); + echo '
Account wide stats
TitleTitle RankTitle PointsCurrent RankPoints RemainingNext Rank
' . $titlename . '' . $row['currentstrankname'] . '' . number_format($row['titlepoints']) . '' . $row['currentstrank'] . '' . $pr . '' . $stname . '
' . $row['nextstrank'] . '

'; } -$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 ''; + echo 'Select account title to update:

'; + $ats->close(); + } else { + echo '
'; + 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 From 8db262f4df980b2e25df77ab7b14a0379ef8b8a5 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Tue, 14 Aug 2018 16:20:50 -1000 Subject: [PATCH 81/97] added percentage complete bars, and now calculates the overall percentage completed of a title --- includes/getaccountstats.php | 15 +++++++++++---- includes/update-titleranks.php | 16 ++++++++++++---- style.css | 4 +++- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/includes/getaccountstats.php b/includes/getaccountstats.php index ce5241a..af438a7 100644 --- a/includes/getaccountstats.php +++ b/includes/getaccountstats.php @@ -4,9 +4,9 @@ // remove the above 2 lines if (isset($_SESSION['userid'])) { echo ''; - echo ''; + echo ''; // $gas = GetAccountStats - $gas = $con->prepare("SELECT * FROM gwaccstats WHERE userid = ? AND accid = ?"); + $gas = $con->prepare("SELECT * FROM gwaccstats WHERE userid = ? AND accid = ? ORDER BY currentstrank DESC, percent ASC"); $gas->bind_param("ii", $_SESSION['userid'], $_SESSION['prefaccid']); $gas->execute(); $result = $gas->get_result(); @@ -34,8 +34,15 @@ if (isset($_SESSION['userid'])) { $row['currentstrankname'] = "No title earned yet!"; $row['currentstrank'] = "0"; } - echo ''; - echo ''; + if ($row['percent'] > 100) { + $ohp = 100; + } else { + $ohp = $row['percent']; + } + echo ''; + echo ''; } $gas->close(); echo '
Account wide stats
TitleTitle RankTitle PointsCurrent RankPoints RemainingNext Rank
TitleTitle RankTitle PointsCurrent RankPoints RemainingMax Title %Next Rank
' . $titlename . '' . $row['currentstrankname'] . '' . number_format($row['titlepoints']) . '' . $row['currentstrank'] . '' . $pr . '' . $stname . '
' . $titlename . '' . $row['currentstrankname'] . '' . number_format($row['titlepoints']) . '' . $row['currentstrank'] . '' . $pr . '
'; + echo $ohp; + echo '% completed
' . $stname . '

'; diff --git a/includes/update-titleranks.php b/includes/update-titleranks.php index eab365a..a729efd 100644 --- a/includes/update-titleranks.php +++ b/includes/update-titleranks.php @@ -15,17 +15,25 @@ if (isset($_SESSION['userid'])) { $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 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 = $con->prepare("UPDATE gwaccstats SET stnameid = ?, titlepoints = ?, currentstrankname = ?, currentstrank = ?, percent = ? WHERE titlenameid = ? AND accid = ? AND userid = ?"); + $urs->bind_param("iisiiiii", $stnameid, $_POST['titlepoints'], $stname, $strank, $progress, $_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 = $con->prepare("INSERT INTO gwaccstats (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->execute(); $irs->close(); echo 'Title entered!

'; diff --git a/style.css b/style.css index d6811ec..e6babb0 100644 --- a/style.css +++ b/style.css @@ -66,4 +66,6 @@ input { submitLink:focus { outline: none; } -} \ No newline at end of file + +.percentbar { background:#CCCCCC; border:1px solid #666666; height:10px; } +.percentbar div { background: #28B8C0; height: 10px; } \ No newline at end of file From 9ab168c4f61a2705b624c506455763d61b6b0250 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Wed, 15 Aug 2018 23:11:31 -1000 Subject: [PATCH 82/97] deleting an account deletes ALL characters AND account stats --- addaccounts.php | 14 ++++++++++---- adminlanding.php | 3 ++- includes/del-account.php | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 includes/del-account.php diff --git a/addaccounts.php b/addaccounts.php index 29ed9aa..a4e7b7b 100644 --- a/addaccounts.php +++ b/addaccounts.php @@ -19,6 +19,11 @@ if (isset($_SESSION['userid'])) { // this section contains the code to add a new game account to track include_once ('includes/addaccount-submit.php'); } + + if (!empty($_POST['delaccid'])) { + // this section containts the code to delete an account + include_once ('includes/del-account.php'); + } if (!empty($_POST['delcharid'])) { // this section contains code to delete the selected characters @@ -35,8 +40,8 @@ if (isset($_SESSION['userid'])) { echo ''; echo '
'; - echo ''; - echo ''; + echo '
Current Guild Wars accounts
Account namePreferred?
'; + echo ''; $acclist = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE userid = ?"); $acclist->bind_param("i", $_SESSION['userid']); $acclist->execute(); @@ -47,10 +52,11 @@ if (isset($_SESSION['userid'])) { if ($row['accid'] == $_SESSION['prefaccid']) { echo ' checked'; } - echo '>'; + //delete account array in delaccid[] + echo '>'; } $acclist->close(); - echo '
Current Guild Wars accounts
Account namePreferred?Delete ?

'; + echo '
'; // add characters here echo '
'; diff --git a/adminlanding.php b/adminlanding.php index ef2840f..ba900e4 100644 --- a/adminlanding.php +++ b/adminlanding.php @@ -6,7 +6,8 @@ if (isset($_SESSION['userid'])){ unset($_SESSION['tid']); echo '
Welcome to the admin area!

'; echo 'Title creator / editor here (work in progress)

'; - echo 'User editor here (not working yet)
'; + echo 'User editor here (not working yet)

'; + include_once ('includes/session-dump.php'); } include_once ('footer.php'); ?> \ No newline at end of file diff --git a/includes/del-account.php b/includes/del-account.php new file mode 100644 index 0000000..1463964 --- /dev/null +++ b/includes/del-account.php @@ -0,0 +1,49 @@ +prepare("SELECT charid, accid FROM gwchars WHERE accid IN ($gaccid) AND userid = ?"); + $gci->bind_param("i", $_SESSION['userid']); + $gci->execute(); + $gciresults = $gci->get_result(); + while ($gcirow = $gciresults->fetch_assoc()) { + $delchar = $con->prepare("DELETE FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?"); + $delchar->bind_param("iii", $gcirow['charid'], $gcirow['accid'], $_SESSION['userid']); + $delchar->execute(); + $delchar->close(); + // $dac = Delete Account Stats + $dac = $con->prepare("DELETE FROM gwaccstats WHERE accid = ? AND userid = ?"); + $dac->bind_param("ii", $gcirow['accid'], $_SESSION['userid']); + $dac->execute(); + $dac->close();/* + // $dcs = Delete Character Stats + $dcs = $con->prepare("DELETE FROM gwcharstats WHERE charid = ? AND accid = ? AND userid = ?"); + $dcs->bind_param("iii", $gcirow['charid'], $gcirow['accid'], $_SESSION['userid']); + $dcs->execute(); + $dcs->close(); */ + } + $gci->close(); + //this should be the last SQL query to run! + $delacc = $con->prepare("DELETE FROM gwaccounts WHERE accid IN ($gaccid) AND userid = ?"); + $delacc->bind_param("i", $_SESSION['userid']); + $delacc->execute(); + $delacc->close(); + // $nap = No Account Preference + $nap = $con->prepare("UPDATE userinfo SET prefaccid = 0, prefaccname = 'No default selected' WHERE userid = ?"); + $nap->bind_param("i", $_SESSION['userid']); + $nap->execute(); + $nap->close(); + $_SESSION['prefaccid'] = "0"; + $_SESSION['preaccname'] = "No default selected"; + echo 'Account(s) deleted - no preferred account selected.

'; + // $ncp = No Character Preference + $ncp = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?"); + $ncp->bind_param("i", $_SESSION['userid']); + $ncp->execute(); + $ncp->close(); + $_SESSION['prefcharid'] = "0"; + $_SESSION['prefcharname'] = "No default selected"; + echo 'All characters related to the account have been deleted - no preferred character selected.

'; +} +?> \ No newline at end of file From 1900ba4c22d81553905439064c385af479f32e8f Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Thu, 16 Aug 2018 13:23:54 -1000 Subject: [PATCH 83/97] added session userid validation; can now select characters from the header file --- addaccounts.php | 14 +---- header-list-chars.php | 13 +++++ header.php | 11 +++- includes/del-character.php | 3 +- includes/getaccountstats.php | 3 -- includes/set-prefacc.php | 18 ++++--- includes/set-prefchar.php | 8 +-- includes/title-add.php | 10 ++-- includes/title-editor.php | 52 ++++++++++--------- includes/title-select.php | 20 ++++---- includes/title-submit.php | 36 +++++++------ includes/title-update.php | 48 ++++++++--------- includes/titleranks-add.php | 114 +++++++++++++++++++---------------------- includes/titleranks-editor.php | 47 ++++++++--------- includes/titleranks-submit.php | 20 ++++---- includes/update-email.php | 14 ++--- includes/update-password.php | 36 +++++++------ style.css | 14 ++++- titlemanager.php | 12 ++--- 19 files changed, 261 insertions(+), 232 deletions(-) create mode 100644 header-list-chars.php diff --git a/addaccounts.php b/addaccounts.php index a4e7b7b..d3692ca 100644 --- a/addaccounts.php +++ b/addaccounts.php @@ -1,45 +1,35 @@
'; echo ''; echo ''; echo '
Add a new Guild Wars account e-mail or alias

'; - echo '
'; echo ''; $acclist = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE userid = ?"); @@ -57,7 +47,6 @@ if (isset($_SESSION['userid'])) { } $acclist->close(); echo '
Current Guild Wars accounts
Account namePreferred?Delete ?

'; - // add characters here echo '
'; echo ''; @@ -72,7 +61,6 @@ if (isset($_SESSION['userid'])) { } echo ''; echo '
Add character to account: ' . $_SESSION['prefaccname'] . '

'; - echo '
'; echo ''; $lc = $con->prepare("SELECT charid, accid, charname, profid, profcolor FROM gwchars WHERE accid = ?"); diff --git a/header-list-chars.php b/header-list-chars.php new file mode 100644 index 0000000..54bd98b --- /dev/null +++ b/header-list-chars.php @@ -0,0 +1,13 @@ +prepare("SELECT charid, charname, profid FROM gwchars WHERE accid = ? AND userid = ? ORDER BY charname"); + $cls->bind_param("ii", $_SESSION['prefaccid'], $_SESSION['userid']); + $cls->execute(); + $clsres = $cls->get_result(); + while ($clsrow = $clsres->fetch_assoc()) { + echo ''; + } + $cls->close(); +} +?> \ No newline at end of file diff --git a/header.php b/header.php index 50d5556..d3ed9f1 100644 --- a/header.php +++ b/header.php @@ -26,10 +26,19 @@ if (!$userid){ echo 'GWST'; } echo '
'; + if (!empty($_POST['prefcharid'])) { + //this section contains code to the users preferred character + include_once ('includes/set-prefchar.php'); + } + echo ''; echo '(Home) (Options) '; if ($_SESSION['admin'] == 1){ echo'(Administration) '; } - echo '(Logout ' . $_SESSION['username'] . ')

'; + echo '(Logout ' . $_SESSION['username'] . ') ()

'; } ?> \ No newline at end of file diff --git a/includes/del-character.php b/includes/del-character.php index feb8222..706b93a 100644 --- a/includes/del-character.php +++ b/includes/del-character.php @@ -1,6 +1,5 @@ '; if ($delchar = $con->prepare("DELETE FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?")) { $delchar->bind_param("iii", $delcharid, $delaccid, $_SESSION['userid']); for ($i = 0; $i < count($_POST['delcharid']); $i++) { @@ -10,12 +9,14 @@ if (isset($_SESSION['userid'])) { } $delchar->close(); } + // need to delete associate character stats as well. TODO $nap = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?"); $nap->bind_param("i", $_SESSION['userid']); $nap->execute(); $nap->close(); $_SESSION['prefcharid'] = "0"; $_SESSION['prefcharname'] = "No default selected"; + $_SESSION['charprofid'] = "0"; echo 'Character(s) deleted - no preferred character selected.

'; } ?> \ No newline at end of file diff --git a/includes/getaccountstats.php b/includes/getaccountstats.php index af438a7..a6359ae 100644 --- a/includes/getaccountstats.php +++ b/includes/getaccountstats.php @@ -1,7 +1,4 @@
'; echo ''; diff --git a/includes/set-prefacc.php b/includes/set-prefacc.php index 57ffd59..da83f4b 100644 --- a/includes/set-prefacc.php +++ b/includes/set-prefacc.php @@ -1,6 +1,7 @@ prepare("UPDATE userinfo SET prefaccid = 0, prefaccname = 'No default selected' WHERE userid = ?"); $nap->bind_param("i", $_SESSION['userid']); $nap->execute(); @@ -9,6 +10,7 @@ if (isset($_SESSION['userid'])) { $_SESSION['prefaccname'] = "No default selected"; echo 'Account preference update - no preferred account selected.
'; } else { + // $sap = Select AccountID Preferrence $sap = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE accid = ? AND userid = ?"); $sap->bind_param("ii", $_POST['prefaccid'], $_SESSION['userid']); $sap->execute(); @@ -21,13 +23,15 @@ if (isset($_SESSION['userid'])) { $_SESSION['prefaccid'] = $row['accid']; $_SESSION['prefaccname'] = $row['accemail']; } - $ncp = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?"); - $ncp->bind_param("i", $_SESSION['userid']); - $ncp->execute(); - $ncp->close(); - $_SESSION['prefcharid'] = "0"; - $_SESSION['prefcharname'] = "No default selected"; - echo 'Guild Wars preferred account updated!
'; + $sap->close(); } + $ncp = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?"); + $ncp->bind_param("i", $_SESSION['userid']); + $ncp->execute(); + $ncp->close(); + $_SESSION['prefcharid'] = "0"; + $_SESSION['prefcharname'] = "No default selected"; + $_SESSION['charprofid'] = "0"; + echo 'Guild Wars preferred account updated!
'; } ?> \ No newline at end of file diff --git a/includes/set-prefchar.php b/includes/set-prefchar.php index fa1b448..8d791cd 100644 --- a/includes/set-prefchar.php +++ b/includes/set-prefchar.php @@ -1,15 +1,17 @@ prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?"); $ncp->bind_param("i", $_SESSION['userid']); $ncp->execute(); $ncp->close(); $_SESSION['prefcharid'] = "0"; $_SESSION['prefcharname'] = "No default selected"; - echo 'Character preference update - no preferred character selected.
'; + $_SESSION['charprofid'] = "0"; } else { - $scp = $con->prepare("SELECT charid, charname FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?"); + // $scp = Selected CharID Preferrence + $scp = $con->prepare("SELECT charid, charname, profid FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?"); $scp->bind_param("iii", $_POST['prefcharid'], $_SESSION['prefaccid'], $_SESSION['userid']); $scp->execute(); $result = $scp->get_result(); @@ -20,8 +22,8 @@ if (isset($_SESSION['userid'])) { $uap->close(); $_SESSION['prefcharid'] = $row['charid']; $_SESSION['prefcharname'] = $row['charname']; + $_SESSION['charprofid'] = $row['profid']; } - echo 'Guild Wars preferred character updated!
'; } } ?> \ No newline at end of file diff --git a/includes/title-add.php b/includes/title-add.php index 16f31ab..6cc4b71 100644 --- a/includes/title-add.php +++ b/includes/title-add.php @@ -1,6 +1,8 @@
Available characters
charidaccidcharnamePreferredDelete?
Account wide stats
TitleTitle RankTitle PointsCurrent RankPoints RemainingMax Title %Next Rank
'; -echo ''; -echo ''; -echo '
Title NameTitle TypeMax Rank
Account
Character

'; +if (isset($_SESSION['userid'])) { + echo '
'; + echo ''; + echo ''; + echo '
Title NameTitle TypeMax Rank
Account
Character

'; +} ?> \ No newline at end of file diff --git a/includes/title-editor.php b/includes/title-editor.php index 86c3466..de4fca7 100644 --- a/includes/title-editor.php +++ b/includes/title-editor.php @@ -1,29 +1,31 @@ '; -echo ''; -$stmtview = $con->prepare("SELECT * FROM gwtitles WHERE titlenameid = ?"); -$stmtview->bind_param("i", $_POST['tid']); -$stmtview->execute(); -$result = $stmtview->get_result(); -while ($row = $result->fetch_assoc()) { - $tid = $row['titlenameid']; - $tname = $row['titlename']; - $ttype = $row['titletype']; - $tmr = $row['titlemaxrank']; - echo '
titlenameidtitlenametitletypetitlemaxrank
'; - echo ''; + echo ''; + $stmtview = $con->prepare("SELECT * FROM gwtitles WHERE titlenameid = ?"); + $stmtview->bind_param("i", $_POST['tid']); + $stmtview->execute(); + $result = $stmtview->get_result(); + while ($row = $result->fetch_assoc()) { + $tid = $row['titlenameid']; + $tname = $row['titlename']; + $ttype = $row['titletype']; + $tmr = $row['titlemaxrank']; + echo ''; } - echo 'value="0">Account
'; - echo 'Character'; + $stmtview->close(); + echo '
titlenameidtitlenametitletypetitlemaxrank
'; + echo 'Account
'; + echo 'Character
Delete title?


'; + echo '
'; + echo 'Return to title manager'; } -$stmtview->close(); -echo '
Delete title?


'; -echo '
'; -echo 'Return to title manager'; ?> \ No newline at end of file diff --git a/includes/title-select.php b/includes/title-select.php index 544cb4f..d159ded 100644 --- a/includes/title-select.php +++ b/includes/title-select.php @@ -1,12 +1,14 @@ prepare("SELECT * FROM gwtitles ORDER BY titlename"); -$stmtview->execute(); -$result = $stmtview->get_result(); -while ($row = $result->fetch_assoc()) { - $tid = $row['titlenameid']; - $tname = $row['titlename']; - $tnr = $row['titlemaxrank']; - echo ''; +if (isset($_SESSION['userid'])) { + $stmtview = $con->prepare("SELECT * FROM gwtitles ORDER BY titlename"); + $stmtview->execute(); + $result = $stmtview->get_result(); + while ($row = $result->fetch_assoc()) { + $tid = $row['titlenameid']; + $tname = $row['titlename']; + $tnr = $row['titlemaxrank']; + echo ''; + } + $stmtview->close(); } -$stmtview->close(); ?> \ No newline at end of file diff --git a/includes/title-submit.php b/includes/title-submit.php index 7284c43..0ad33f9 100644 --- a/includes/title-submit.php +++ b/includes/title-submit.php @@ -1,20 +1,22 @@ prepare("INSERT INTO gwtitles (titlename, titletype, titlemaxrank) VALUES (?, ?, ?)"); -$stmtins->bind_param("sii", $_POST['titlename'], $_POST['titletype'], $_POST['titlemaxrank']); -$stmtins->execute(); -$stmtins->close(); -echo 'New title added!

'; -$stmtview = $con->prepare("SELECT * FROM gwtitles ORDER BY titlenameid DESC LIMIT 1"); -$stmtview->execute(); -$result = $stmtview->get_result(); -while ($row = $result->fetch_assoc()) { - $tid = $row['titlenameid']; - $tname = $row['titlename']; - $ttype = $row['titletype']; - $tmr = $row['titlemaxrank']; - echo ''; - echo '
titleidtitlenametitletypetitlemaxrank
' . $tid . '' . $tname . '' . $ttype . '' . $tmr . '

'; +if (isset($_SESSION['userid'])) { + $stmtins = $con->prepare("INSERT INTO gwtitles (titlename, titletype, titlemaxrank) VALUES (?, ?, ?)"); + $stmtins->bind_param("sii", $_POST['titlename'], $_POST['titletype'], $_POST['titlemaxrank']); + $stmtins->execute(); + $stmtins->close(); + echo 'New title added!

'; + $stmtview = $con->prepare("SELECT * FROM gwtitles ORDER BY titlenameid DESC LIMIT 1"); + $stmtview->execute(); + $result = $stmtview->get_result(); + while ($row = $result->fetch_assoc()) { + $tid = $row['titlenameid']; + $tname = $row['titlename']; + $ttype = $row['titletype']; + $tmr = $row['titlemaxrank']; + echo ''; + echo '
titleidtitlenametitletypetitlemaxrank
' . $tid . '' . $tname . '' . $ttype . '' . $tmr . '

'; + } + $stmtview->close(); + echo 'Return to title manager'; } -$stmtview->close(); -echo 'Return to title manager'; ?> \ No newline at end of file diff --git a/includes/title-update.php b/includes/title-update.php index 17e85a1..8b8c6c5 100644 --- a/includes/title-update.php +++ b/includes/title-update.php @@ -1,28 +1,30 @@ Please check the box to verify you want to delete: ' . $_POST['titlename'] . ' '; - echo '

'; - } else if ($_POST['deltitle'] == "iamsure") { - // this section actually deletes the title - $stmtdel = $con->prepare("DELETE FROM gwtitles WHERE titlenameid = ?"); - $stmtdel->bind_param("i", $_POST['titlenameid']); - $stmtdel->execute(); - $stmtdelst = $con->prepare("DELETE FROM gwsubtitles WHERE titlenameid = ?"); - $stmtdelst->bind_param("i", $_POST['titlenameid']); - $stmtdelst->execute(); - $stmtdel->close(); - echo 'The title and associated title ranks have been deleted, redirecting!'; +if (isset($_SESSION['userid'])) { + if (isset($_POST['deltitle'])) { + if ($_POST['deltitle'] == "yes") { + // this title makes you verify that you want to delete this title + echo '
Please check the box to verify you want to delete: ' . $_POST['titlename'] . ' '; + echo '


'; + } else if ($_POST['deltitle'] == "iamsure") { + // this section actually deletes the title + $stmtdel = $con->prepare("DELETE FROM gwtitles WHERE titlenameid = ?"); + $stmtdel->bind_param("i", $_POST['titlenameid']); + $stmtdel->execute(); + $stmtdelst = $con->prepare("DELETE FROM gwsubtitles WHERE titlenameid = ?"); + $stmtdelst->bind_param("i", $_POST['titlenameid']); + $stmtdelst->execute(); + $stmtdel->close(); + echo 'The title and associated title ranks have been deleted, redirecting!'; + header ("Refresh:1; url=titlemanager.php"); + } + } else { + // this section updates the title name + $stmtupd = $con->prepare("UPDATE gwtitles SET titlename = ?, titletype = ?, titlemaxrank = ? WHERE titlenameid = ?"); + $stmtupd->bind_param("siii", $_POST['titlename'], $_POST['titletype'], $_POST['titlemaxrank'], $_POST['titlenameid']); + $stmtupd->execute(); + $stmtupd->close(); + echo 'Title updated, redirecting!'; header ("Refresh:1; url=titlemanager.php"); } -} else { - // this section updates the title name - $stmtupd = $con->prepare("UPDATE gwtitles SET titlename = ?, titletype = ?, titlemaxrank = ? WHERE titlenameid = ?"); - $stmtupd->bind_param("siii", $_POST['titlename'], $_POST['titletype'], $_POST['titlemaxrank'], $_POST['titlenameid']); - $stmtupd->execute(); - $stmtupd->close(); - echo 'Title updated, redirecting!'; - header ("Refresh:1; url=titlemanager.php"); } ?> \ No newline at end of file diff --git a/includes/titleranks-add.php b/includes/titleranks-add.php index 74b2e56..0559e33 100644 --- a/includes/titleranks-add.php +++ b/includes/titleranks-add.php @@ -1,67 +1,59 @@ prepare("SELECT MAX(strank) FROM gwsubtitles WHERE titlenameid = ?"); - $trank->bind_param("i", $_POST['tid']); - $trank->execute(); - $trank->store_result(); - $trank->bind_result($gwstmr); - while ($trank->fetch()) { - if (is_null($gwstmr)) { - $tr = 1; +if (isset($_SESSION['userid'])) { + unset($_SESSION['title']); + if (isset($_SESSION['tid'])) { + $_POST['tid'] = $_SESSION['tid']; + } + if (isset($_SESSION['tr'])) { + $tr = $_SESSION['tr'] + 1; + } else { + $trank = $con->prepare("SELECT MAX(strank) FROM gwsubtitles WHERE titlenameid = ?"); + $trank->bind_param("i", $_POST['tid']); + $trank->execute(); + $trank->store_result(); + $trank->bind_result($gwstmr); + while ($trank->fetch()) { + if (is_null($gwstmr)) { + $tr = 1; + } else { + $tr = $gwstmr + 1; + } + } + } + $stmtname = $con->prepare("SELECT titlename, titlemaxrank FROM gwtitles WHERE titlenameid = ?"); + $stmtname->bind_param("i", $_POST['tid']); + $stmtname->execute(); + $stmtname->store_result(); + $stmtname->bind_result($gwtn, $gwtmr); + while ($stmtname->fetch()) { + echo 'Adding rank to title ' . $gwtn . '
The maximum rank achievable in game is ' . $gwtmr . '
'; + if ($tr > $gwtmr) { + echo '
No more ranks can be added!

'; } else { - $tr = $gwstmr + 1; + echo '
'; + echo ''; + echo '
Title Rank NameTitle PointsRank Level


'; } } + $stmtname->free_result(); + $stmtname->close(); + echo 'Here are the currently associated title ranks, starting with rank 1:
'; + echo '
'; + $stmtview = $con->prepare("SELECT * FROM gwsubtitles WHERE titlenameid = ? ORDER BY strank ASC"); + $stmtview->bind_param("i", $_POST['tid']); + $stmtview->execute(); + $result = $stmtview->get_result(); + while ($row = $result->fetch_assoc()) { + $stnid = $row['stnameid']; + $tnid = $row['titlenameid']; + $stname = $row['stname']; + $stpoints = $row['stpoints']; + $strank = $row['strank']; + echo ''; + } + $stmtview->close(); + $_SESSION['tid'] = $_POST['tid']; + echo '
stnameidtitlenameidstnamestpointsstrankEdit
' . $stnid . '' . $tnid . '' . $stname . '' . number_format($stpoints) . '' . $strank . '


If anything looks off, please fix it!

'; + echo 'Return to title manager'; } - -$stmtname = $con->prepare("SELECT titlename, titlemaxrank FROM gwtitles WHERE titlenameid = ?"); -$stmtname->bind_param("i", $_POST['tid']); -$stmtname->execute(); -$stmtname->store_result(); -$stmtname->bind_result($gwtn, $gwtmr); -while ($stmtname->fetch()) { - echo 'Adding rank to title ' . $gwtn . '
The maximum rank achievable in game is ' . $gwtmr . '
'; - if ($tr > $gwtmr) { - echo '
No more ranks can be added!

'; - } else { - echo '
'; - echo ''; - echo '
Title Rank NameTitle PointsRank Level


'; - } -} -$stmtname->free_result(); -$stmtname->close(); - -echo 'Here are the currently associated title ranks, starting with rank 1:
'; -echo '
'; -$stmtview = $con->prepare("SELECT * FROM gwsubtitles WHERE titlenameid = ? ORDER BY strank ASC"); -$stmtview->bind_param("i", $_POST['tid']); -$stmtview->execute(); -$result = $stmtview->get_result(); -while ($row = $result->fetch_assoc()) { - $stnid = $row['stnameid']; - $tnid = $row['titlenameid']; - $stname = $row['stname']; - $stpoints = $row['stpoints']; - $strank = $row['strank']; - echo ''; -} -$stmtview->close(); -$_SESSION['tid'] = $_POST['tid']; -echo '
stnameidtitlenameidstnamestpointsstrankEdit
' . $stnid . '' . $tnid . '' . $stname . '' . number_format($stpoints) . '' . $strank . '


If anything looks off, please fix it!

'; -echo 'Return to title manager'; ?> \ No newline at end of file diff --git a/includes/titleranks-editor.php b/includes/titleranks-editor.php index 2af48d2..60846df 100644 --- a/includes/titleranks-editor.php +++ b/includes/titleranks-editor.php @@ -1,30 +1,25 @@ '; - echo ''; - $ph = implode(",", $_POST['editstitle']); - $sredit = $con->prepare("SELECT * FROM gwsubtitles WHERE titlenameid = ? AND stnameid IN ($ph)"); - $sredit->bind_param("i", $_SESSION['tid']); - $sredit->execute(); - $result = $sredit->get_result(); - while ($row = $result->fetch_assoc()) { - echo ''; - echo ''; - echo ''; +if (isset($_SESSION['userid'])) { + if (isset($_POST['editstitle'])) { + echo '
Deleting takes precedence over edits - edits will have to be remade after submission
stnameidtitlenameidstnamestpointsstrankDelete?
'; + echo ''; + $ph = implode(",", $_POST['editstitle']); + $sredit = $con->prepare("SELECT * FROM gwsubtitles WHERE titlenameid = ? AND stnameid IN ($ph)"); + $sredit->bind_param("i", $_SESSION['tid']); + $sredit->execute(); + $result = $sredit->get_result(); + while ($row = $result->fetch_assoc()) { + echo ''; + echo ''; + echo ''; + } + $sredit->close(); + echo '
Deleting takes precedence over edits - edits will have to be remade after submission
stnameidtitlenameidstnamestpointsstrankDelete?

'; + echo '

'; + echo 'Return to title manager'; + } else { + echo 'No title ranks selected! Please press the back button on your browser to return to the previous page.

'; + echo 'Return to title manager'; } - $sredit->close(); - echo '
'; - echo '

'; - echo 'Return to title manager'; -} else { - echo 'No title ranks selected! Please press the back button on your browser to return to the previous page.

'; - echo 'Return to title manager'; } ?> \ No newline at end of file diff --git a/includes/titleranks-submit.php b/includes/titleranks-submit.php index 8bb44c9..14e2317 100644 --- a/includes/titleranks-submit.php +++ b/includes/titleranks-submit.php @@ -1,11 +1,13 @@ prepare("INSERT INTO gwsubtitles (titlenameid, stname, stpoints, strank) VALUES (?, ?, ?, ?)"); -$stmtstins->bind_param("isii", $_POST['titlenameid'], $_POST['titlerankname'], $_POST['titlepoints'], $_POST['titlerank']); -$stmtstins->execute(); -$stmtstins->close(); -$_SESSION['title'] = "repeat"; -$_SESSION['tid'] = $_POST['titlenameid']; -$_SESSION['tr'] = $_POST['titlerank']; -echo 'Title rank added, redirecting!'; -header ("Refresh:1; url=titlemanager.php"); +if (isset($_SESSION['userid'])) { + $stmtstins = $con->prepare("INSERT INTO gwsubtitles (titlenameid, stname, stpoints, strank) VALUES (?, ?, ?, ?)"); + $stmtstins->bind_param("isii", $_POST['titlenameid'], $_POST['titlerankname'], $_POST['titlepoints'], $_POST['titlerank']); + $stmtstins->execute(); + $stmtstins->close(); + $_SESSION['title'] = "repeat"; + $_SESSION['tid'] = $_POST['titlenameid']; + $_SESSION['tr'] = $_POST['titlerank']; + echo 'Title rank added, redirecting!'; + header ("Refresh:1; url=titlemanager.php"); +} ?> \ No newline at end of file diff --git a/includes/update-email.php b/includes/update-email.php index b3089ba..2a2ad27 100644 --- a/includes/update-email.php +++ b/includes/update-email.php @@ -1,8 +1,10 @@ prepare("UPDATE userinfo SET usermail = ? WHERE userid = ?"); -$updmail->bind_param("si", $_POST['useremail'], $_SESSION['userid']); -$updmail->execute(); -$_SESSION['usermail'] = $_POST['useremail']; -echo 'E-mail address updated.
'; +if (isset($_SESSION['userid'])) { + include_once ('verifications.php'); + $updmail = $con->prepare("UPDATE userinfo SET usermail = ? WHERE userid = ?"); + $updmail->bind_param("si", $_POST['useremail'], $_SESSION['userid']); + $updmail->execute(); + $_SESSION['usermail'] = $_POST['useremail']; + echo 'E-mail address updated.
'; +} ?> \ No newline at end of file diff --git a/includes/update-password.php b/includes/update-password.php index 4ced42b..d15a46f 100644 --- a/includes/update-password.php +++ b/includes/update-password.php @@ -1,21 +1,23 @@ prepare("SELECT userpass FROM userinfo WHERE userid = ?"); -$verifypass->bind_param("i", $_SESSION['userid']); -$verifypass->execute(); -$result = $verifypass->get_result(); -while ($row = $result->fetch_assoc()) { - $vp = password_verify ($_POST['oldpass'],$row['userpass']); - if ($vp) { - $hp = password_hash($_POST['userpass1'], PASSWORD_DEFAULT); - echo 'Verified old password, updating to new password!
'; - $updpass = $con->prepare("UPDATE userinfo SET userpass = ? WHERE userid = ?"); - $updpass->bind_param("si", $hp, $_SESSION['userid']); - $updpass->execute(); - echo 'Password updated!
'; - $updpass->close(); - } else { - echo 'Old password doesn\'t match, password is NOT updated!
'; +if (isset($_SESSION['userid'])) { + include_once ('verifications.php'); + $verifypass = $con->prepare("SELECT userpass FROM userinfo WHERE userid = ?"); + $verifypass->bind_param("i", $_SESSION['userid']); + $verifypass->execute(); + $result = $verifypass->get_result(); + while ($row = $result->fetch_assoc()) { + $vp = password_verify ($_POST['oldpass'],$row['userpass']); + if ($vp) { + $hp = password_hash($_POST['userpass1'], PASSWORD_DEFAULT); + echo 'Verified old password, updating to new password!
'; + $updpass = $con->prepare("UPDATE userinfo SET userpass = ? WHERE userid = ?"); + $updpass->bind_param("si", $hp, $_SESSION['userid']); + $updpass->execute(); + echo 'Password updated!
'; + $updpass->close(); + } else { + echo 'Old password doesn\'t match, password is NOT updated!
'; + } } } ?> \ No newline at end of file diff --git a/style.css b/style.css index e6babb0..07e5490 100644 --- a/style.css +++ b/style.css @@ -68,4 +68,16 @@ submitLink:focus { } .percentbar { background:#CCCCCC; border:1px solid #666666; height:10px; } -.percentbar div { background: #28B8C0; height: 10px; } \ No newline at end of file +.percentbar div { background: #28B8C0; height: 10px; } + +select *.profession-0 { background-color: #FFF; } +select *.profession-1 { background-color: #FF8; } +select *.profession-2 { background-color: #CF9; } +select *.profession-3 { background-color: #ACF; } +select *.profession-4 { background-color: #9FC; } +select *.profession-5 { background-color: #DAF; } +select *.profession-6 { background-color: #FBB; } +select *.profession-7 { background-color: #FCE; } +select *.profession-8 { background-color: #BFF; } +select *.profession-9 { background-color: #FC9; } +select *.profession-10 { background-color: #DDF; } diff --git a/titlemanager.php b/titlemanager.php index a21ee55..7a6e8ce 100644 --- a/titlemanager.php +++ b/titlemanager.php @@ -4,13 +4,13 @@ include_once ('header.php'); if (isset($_SESSION['userid'])){ if (isset($_SESSION['title'])) { if ($_SESSION['title'] == "repeat") { - $_POST['title'] = "addsubtitle"; - unset($_SESSION['title']); - } else { - unset($_SESSION['tr']); - } + $_POST['title'] = "addsubtitle"; + unset($_SESSION['title']); + } else { + unset($_SESSION['tr']); } - if ($_SESSION['admin'] == 1) { + } + if ($_SESSION['admin'] == 1) { echo '
'; if (isset($_POST['title'])) { if ($_POST['title'] == "addtitle") { From 8c4e34b764f03ffdea01ffe1e52ebf6a271aaf1f Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Thu, 16 Aug 2018 16:09:02 -1000 Subject: [PATCH 84/97] added account selector to header --- header-list-accounts.php | 13 +++++ header.php | 15 ++++- preferences.php | 142 ++++++++++++++++++++++------------------------- style.css | 6 ++ updatecharstats.php | 4 +- 5 files changed, 101 insertions(+), 79 deletions(-) create mode 100644 header-list-accounts.php diff --git a/header-list-accounts.php b/header-list-accounts.php new file mode 100644 index 0000000..b21affc --- /dev/null +++ b/header-list-accounts.php @@ -0,0 +1,13 @@ +prepare("SELECT accid, accemail FROM gwaccounts WHERE userid = ?"); + $als->bind_param("i", $_SESSION['userid']); + $als->execute(); + $alsres = $als->get_result(); + while ($alsrow = $alsres->fetch_assoc()) { + echo ''; + } + $als->close(); +} +?> \ No newline at end of file diff --git a/header.php b/header.php index d3ed9f1..4854ae8 100644 --- a/header.php +++ b/header.php @@ -26,6 +26,10 @@ if (!$userid){ echo 'GWST'; } echo '
'; + if (!empty($_POST['prefaccid'])) { + //this section contains code to set the users preferred game account + include_once ('includes/set-prefacc.php'); + } if (!empty($_POST['prefcharid'])) { //this section contains code to the users preferred character include_once ('includes/set-prefchar.php'); @@ -35,10 +39,15 @@ if (!$userid){ if ($_SESSION['admin'] == 1){ echo'(Administration) '; } - echo '(Logout ' . $_SESSION['username'] . ') ('; + echo ''; + echo ''; + include_once ('header-list-accounts.php'); + echo ') '; + echo '()

'; + echo ') (Logout ' . $_SESSION['username'] . ')

'; } ?> \ No newline at end of file diff --git a/preferences.php b/preferences.php index 4df06c5..b99bc25 100644 --- a/preferences.php +++ b/preferences.php @@ -2,83 +2,75 @@ $pagetitle = "Account options"; include_once ('header.php'); if (isset($_SESSION['userid'])){ - -if (!empty($_POST['useremail'])) { - //this section contains code to update the users e-mail address - include_once ('includes/update-email.php'); -} - -if (!empty($_POST['oldpass'])) { - // this section contains code to update the users password after verifying the old password first - include_once ('includes/update-password.php'); -} - -if (!empty($_POST['setacc'])) { - //this section contains code to set the users preferred game account - include_once ('includes/set-prefacc.php'); -} - -if (!empty($_POST['setchar'])) { - //this section contains code to the users preferred character - include_once ('includes/set-prefchar.php'); -} - -echo '

Set preferred account & character, or change e-mail or password

'; - -// select which GW account you want to default to -echo '
'; -echo '
Current preferred account: ' .$_SESSION['prefaccname'] . '

'; - -// select which character from your GW account you want to default to -echo '
'; -echo '
Current preferred character: ' .$_SESSION['prefcharname'] . '

'; - -// update e-mail address form -echo '
'; -echo ''; -echo ''; -echo '
Update e-mail address


'; - -// update password form -echo << - - - - - - -
Old Password
New password
Verify password
+ + UPDPASS; } - - -UPDPASS; } include_once ('footer.php'); ?> \ No newline at end of file diff --git a/style.css b/style.css index 07e5490..33b593e 100644 --- a/style.css +++ b/style.css @@ -70,6 +70,12 @@ submitLink:focus { .percentbar { background:#CCCCCC; border:1px solid #666666; height:10px; } .percentbar div { background: #28B8C0; height: 10px; } +select.header { + /*background: rgb(255, 255, 255); + background: rgba(255, 255, 255, 0.2);*/ + color: red; +} + select *.profession-0 { background-color: #FFF; } select *.profession-1 { background-color: #FF8; } select *.profession-2 { background-color: #CF9; } diff --git a/updatecharstats.php b/updatecharstats.php index 29f5371..e6a62d4 100644 --- a/updatecharstats.php +++ b/updatecharstats.php @@ -1,6 +1,8 @@ user page'; +if (isset($_SESSION['userid'])) { + echo 'Return to your user page'; +} include_once ('footer.php'); ?> \ No newline at end of file From a779024c05a7dccfb894f45448674a17ecbaeb28 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Thu, 16 Aug 2018 16:19:41 -1000 Subject: [PATCH 85/97] removed useless file, included MySQL/MariaDB database setup script --- listchars.php | 7 ---- sql-init/db-setup.sql | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 7 deletions(-) delete mode 100644 listchars.php create mode 100644 sql-init/db-setup.sql diff --git a/listchars.php b/listchars.php deleted file mode 100644 index cee6437..0000000 --- a/listchars.php +++ /dev/null @@ -1,7 +0,0 @@ -
'; -echo 'Return to your user page'; -include_once ('footer.php'); -?> \ No newline at end of file diff --git a/sql-init/db-setup.sql b/sql-init/db-setup.sql new file mode 100644 index 0000000..44ac691 --- /dev/null +++ b/sql-init/db-setup.sql @@ -0,0 +1,93 @@ +/*Table structure for table `gwaccounts` */ + +CREATE TABLE `gwaccounts` ( + `accid` int(11) NOT NULL AUTO_INCREMENT COMMENT 'this key will be bound by charrid in table gwchars', + `userid` int(11) DEFAULT NULL, + `accemail` varchar(50) DEFAULT NULL, + PRIMARY KEY (`accid`) +) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; + +/*Table structure for table `gwaccstats` */ + +CREATE TABLE `gwaccstats` ( + `titlenameid` int(11) DEFAULT NULL, + `stnameid` int(2) DEFAULT NULL, + `titlepoints` int(11) DEFAULT NULL, + `currentstrankname` varchar(37) DEFAULT NULL, + `currentstrank` int(11) DEFAULT NULL, + `percent` int(3) DEFAULT NULL, + `accid` int(11) DEFAULT NULL, + `userid` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +/*Table structure for table `gwchars` */ + +CREATE TABLE `gwchars` ( + `charid` int(11) NOT NULL AUTO_INCREMENT, + `accid` int(11) DEFAULT NULL, + `userid` int(11) DEFAULT NULL, + `charname` varchar(19) DEFAULT NULL, + `birthdate` date DEFAULT NULL, + `profid` int(2) DEFAULT NULL, + `profcolor` char(7) NOT NULL DEFAULT '#45b39d', + PRIMARY KEY (`charid`) +) ENGINE=InnoDB AUTO_INCREMENT=74 DEFAULT CHARSET=latin1; + +/*Table structure for table `gwcharstats` */ + +CREATE TABLE `gwcharstats` ( + `titlenameid` int(11) DEFAULT NULL, + `stnameid` int(2) DEFAULT NULL, + `titlepoinsts` int(11) DEFAULT NULL, + `currentstrankname` varchar(37) DEFAULT NULL, + `currentstrank` int(11) DEFAULT NULL, + `percent` int(3) DEFAULT NULL, + `charid` int(11) DEFAULT NULL, + `accid` int(11) DEFAULT NULL, + `userid` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +/*Table structure for table `gwprofessions` */ + +CREATE TABLE `gwprofessions` ( + `profid` int(2) NOT NULL AUTO_INCREMENT, + `profession` varchar(12) DEFAULT NULL, + `profcolor` char(4) DEFAULT NULL, + PRIMARY KEY (`profid`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1; + +/*Table structure for table `gwsubtitles` */ + +CREATE TABLE `gwsubtitles` ( + `stnameid` int(11) NOT NULL AUTO_INCREMENT, + `titlenameid` int(11) DEFAULT NULL COMMENT 'should be grabbed from the gwtitles table', + `stname` varchar(50) DEFAULT NULL, + `stpoints` int(11) DEFAULT NULL, + `strank` int(11) DEFAULT NULL, + PRIMARY KEY (`stnameid`) +) ENGINE=InnoDB AUTO_INCREMENT=304 DEFAULT CHARSET=latin1; + +/*Table structure for table `gwtitles` */ + +CREATE TABLE `gwtitles` ( + `titlenameid` int(2) NOT NULL AUTO_INCREMENT, + `titlename` varchar(40) DEFAULT NULL, + `titletype` int(1) DEFAULT NULL COMMENT '0 = account, 1 = character', + `titlemaxrank` int(2) DEFAULT NULL, + PRIMARY KEY (`titlenameid`) +) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=latin1; + +/*Table structure for table `userinfo` */ + +CREATE TABLE `userinfo` ( + `userid` int(11) NOT NULL AUTO_INCREMENT, + `username` varchar(30) DEFAULT NULL, + `userpass` varchar(255) DEFAULT NULL, + `usermail` varchar(50) DEFAULT NULL, + `admin` int(1) NOT NULL DEFAULT '0' COMMENT 'it''s either a 0 or 1', + `prefaccid` int(11) NOT NULL DEFAULT '0' COMMENT 'sets which GW account to default to upon login', + `prefaccname` varchar(50) DEFAULT 'No default selected' COMMENT 'name or alias of account', + `prefcharid` int(11) NOT NULL DEFAULT '0' COMMENT 'sets which GW character you want to default to', + `prefcharname` char(19) DEFAULT 'No default selected', + PRIMARY KEY (`userid`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1; From 10fc019e1eda484cfc7b0b430650770023b041ca Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Thu, 16 Aug 2018 23:25:54 -1000 Subject: [PATCH 86/97] individual stat tracking is completed --- header.php | 9 ++++---- includes/getaccountstats.php | 4 ++-- includes/getcharstats.php | 47 ++++++++++++++++++++++++++++++++++++++ includes/update-chartitleranks.php | 42 ++++++++++++++++++++++++++++++++++ updateaccountstats.php | 2 +- updatecharstats.php | 29 ++++++++++++++++++++++- 6 files changed, 125 insertions(+), 8 deletions(-) create mode 100644 includes/getcharstats.php create mode 100644 includes/update-chartitleranks.php 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 '(Home) (Options) '; - if ($_SESSION['admin'] == 1){ - echo'(Administration) '; - } echo '() (Logout ' . $_SESSION['username'] . ')


'; + 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 'TitleTitle RankTitle PointsCurrent RankPoints RemainingMax 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 '
'; echo 'Select account title to update: '; + // $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 ''; + } + echo '

'; + $cts->close(); + } else { + echo '
'; + echo '
'; + } + echo 'Current character stats for: ' . $_SESSION['prefcharname'] . '
'; + include_once ('includes/getcharstats.php'); + echo 'Return to your user page
'; } include_once ('footer.php'); ?> \ No newline at end of file From b8b8aa27ea4d944f4b3a64a0bd29000c2c0c9bcb Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Fri, 17 Aug 2018 10:15:55 -1000 Subject: [PATCH 87/97] initial back end support for auto populated titles --- includes/title-add.php | 4 ++-- includes/title-editor.php | 12 +++++++++--- includes/title-submit.php | 14 +++++++++----- includes/title-update.php | 7 +++++-- titlemanager.php | 13 ++++++++++++- 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/includes/title-add.php b/includes/title-add.php index 6cc4b71..5ffd134 100644 --- a/includes/title-add.php +++ b/includes/title-add.php @@ -1,8 +1,8 @@ '; + echo '
Title NameTitle TypeMax Rank
'; echo ''; - echo ''; + echo ''; echo '
Title NameTitle TypeMax RankAuto filled?
Account
Character

'; } ?> \ No newline at end of file diff --git a/includes/title-editor.php b/includes/title-editor.php index de4fca7..d62ed49 100644 --- a/includes/title-editor.php +++ b/includes/title-editor.php @@ -1,7 +1,7 @@ '; - echo ''; + echo '
titlenameidtitlenametitletypetitlemaxrank
'; $stmtview = $con->prepare("SELECT * FROM gwtitles WHERE titlenameid = ?"); $stmtview->bind_param("i", $_POST['tid']); $stmtview->execute(); @@ -10,7 +10,8 @@ if (isset($_SESSION['userid'])) { $tid = $row['titlenameid']; $tname = $row['titlename']; $ttype = $row['titletype']; - $tmr = $row['titlemaxrank']; + $tmr = $row['titlemaxrank']; + $taf = $row['autofilled']; echo ''; + echo 'value="1">Character'; } $stmtview->close(); echo '
titlenameidtitlenametitletypetitlemaxrankautofilled
'; echo 'Character
'; + echo '
Delete title?


'; diff --git a/includes/title-submit.php b/includes/title-submit.php index 0ad33f9..525f3e0 100644 --- a/includes/title-submit.php +++ b/includes/title-submit.php @@ -1,7 +1,10 @@ prepare("INSERT INTO gwtitles (titlename, titletype, titlemaxrank) VALUES (?, ?, ?)"); - $stmtins->bind_param("sii", $_POST['titlename'], $_POST['titletype'], $_POST['titlemaxrank']); + if (!isset($_POST['autofill'])) { + $_POST['autofill'] = "0"; + } + $stmtins = $con->prepare("INSERT INTO gwtitles (titlename, titletype, titlemaxrank, autofilled) VALUES (?, ?, ?, ?)"); + $stmtins->bind_param("siii", $_POST['titlename'], $_POST['titletype'], $_POST['titlemaxrank'], $_POST['autofill']); $stmtins->execute(); $stmtins->close(); echo 'New title added!

'; @@ -12,9 +15,10 @@ if (isset($_SESSION['userid'])) { $tid = $row['titlenameid']; $tname = $row['titlename']; $ttype = $row['titletype']; - $tmr = $row['titlemaxrank']; - echo ''; - echo '
titleidtitlenametitletypetitlemaxrank
' . $tid . '' . $tname . '' . $ttype . '' . $tmr . '

'; + $tmr = $row['titlemaxrank']; + $taf = $row['autofilled']; + echo ''; + echo '
titleidtitlenametitletypetitlemaxrankautofilled
' . $tid . '' . $tname . '' . $ttype . '' . $tmr . '' . $taf . '

'; } $stmtview->close(); echo 'Return to title manager'; diff --git a/includes/title-update.php b/includes/title-update.php index 8b8c6c5..d46ce3c 100644 --- a/includes/title-update.php +++ b/includes/title-update.php @@ -18,9 +18,12 @@ if (isset($_SESSION['userid'])) { header ("Refresh:1; url=titlemanager.php"); } } else { + if (!isset($_POST['autofill'])) { + $_POST['autofill'] = "0"; + } // this section updates the title name - $stmtupd = $con->prepare("UPDATE gwtitles SET titlename = ?, titletype = ?, titlemaxrank = ? WHERE titlenameid = ?"); - $stmtupd->bind_param("siii", $_POST['titlename'], $_POST['titletype'], $_POST['titlemaxrank'], $_POST['titlenameid']); + $stmtupd = $con->prepare("UPDATE gwtitles SET titlename = ?, titletype = ?, titlemaxrank = ?, autofilled = ? WHERE titlenameid = ?"); + $stmtupd->bind_param("siiii", $_POST['titlename'], $_POST['titletype'], $_POST['titlemaxrank'], $_POST['autofill'], $_POST['titlenameid']); $stmtupd->execute(); $stmtupd->close(); echo 'Title updated, redirecting!'; diff --git a/titlemanager.php b/titlemanager.php index 7a6e8ce..693f567 100644 --- a/titlemanager.php +++ b/titlemanager.php @@ -50,7 +50,7 @@ if (isset($_SESSION['userid'])){ echo '

'; // now to view the last 5 title entries in the database echo 'Here is the last 15 titles entered into the database, newest entry is on top:
'; - echo ''; + echo '
titleidtitlenametitletypetitletype
'; $stmtview = $con->prepare("SELECT * FROM gwtitles ORDER BY titlenameid DESC LIMIT 15"); $stmtview->execute(); $result = $stmtview->get_result(); @@ -59,6 +59,7 @@ if (isset($_SESSION['userid'])){ $tname = $row['titlename']; $ttype = $row['titletype']; $tmr = $row['titlemaxrank']; + $taf = $row['autofilled']; echo ''; } $stmtview->close(); From 298c09ce6cccaa48b20140f419e07e9394323413 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Fri, 17 Aug 2018 16:44:02 -1000 Subject: [PATCH 88/97] deleting an account deletes ALL characters from the account, and ALL stats related to both the account and characters --- includes/del-account.php | 4 ++-- includes/del-character.php | 8 +++++++- preferences.php | 3 +-- updatecharstats.php | 8 ++++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/includes/del-account.php b/includes/del-account.php index 1463964..2455388 100644 --- a/includes/del-account.php +++ b/includes/del-account.php @@ -16,12 +16,12 @@ if (isset($_SESSION['userid'])) { $dac = $con->prepare("DELETE FROM gwaccstats WHERE accid = ? AND userid = ?"); $dac->bind_param("ii", $gcirow['accid'], $_SESSION['userid']); $dac->execute(); - $dac->close();/* + $dac->close(); // $dcs = Delete Character Stats $dcs = $con->prepare("DELETE FROM gwcharstats WHERE charid = ? AND accid = ? AND userid = ?"); $dcs->bind_param("iii", $gcirow['charid'], $gcirow['accid'], $_SESSION['userid']); $dcs->execute(); - $dcs->close(); */ + $dcs->close(); } $gci->close(); //this should be the last SQL query to run! diff --git a/includes/del-character.php b/includes/del-character.php index 706b93a..44c12d4 100644 --- a/includes/del-character.php +++ b/includes/del-character.php @@ -9,7 +9,13 @@ if (isset($_SESSION['userid'])) { } $delchar->close(); } - // need to delete associate character stats as well. TODO + // $dcs = Delete Character Stats + $gcharid = implode(", ", $_POST['delcharid']); + $dcs = $con->prepare("DELETE FROM gwcharstats WHERE charid IN ($gcharid) AND accid = ? AND userid = ?"); + $dcs->bind_param("ii", $_SESSION['prefaccid'], $_SESSION['userid']); + $dcs->execute(); + $dcs->close(); + // set preferred character to none $nap = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?"); $nap->bind_param("i", $_SESSION['userid']); $nap->execute(); diff --git a/preferences.php b/preferences.php index b99bc25..7ede41b 100644 --- a/preferences.php +++ b/preferences.php @@ -69,8 +69,7 @@ if (isset($_SESSION['userid'])){ } - UPDPASS; - } +UPDPASS; } include_once ('footer.php'); ?> \ No newline at end of file diff --git a/updatecharstats.php b/updatecharstats.php index fb68ac6..596f1ad 100644 --- a/updatecharstats.php +++ b/updatecharstats.php @@ -5,7 +5,11 @@ if (isset($_SESSION['userid'])) { if (!isset($_POST['chartitle'])) { $_POST['chartitle'] = "notselected"; } - + if ($_SESSION['prefcharid'] == "0") { + echo 'Please select a character from the menu above to add stats to before continuing'; + include_once ('footer.php'); + exit(); + } if (isset($_POST['titlepoints'])) { // include file just updates the database include_once ('includes/update-chartitleranks.php'); @@ -15,7 +19,7 @@ if (isset($_SESSION['userid'])) { echo '
'; echo 'Select character title to update:
'; + echo ''; + 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 ''; + echo ''; + } + $gccres->close(); + echo '
titleidtitlenametitletypetitletypeautofilledautofilled
' . $tid . '' . $tname . ' (' . $tmr . ')' . $ttype . ''; if ($ttype == "0") { echo 'account'; @@ -69,6 +70,16 @@ if (isset($_SESSION['userid'])){ include_once ('footer.php'); exit(); } + echo '' . $taf . ''; + if ($taf == "0") { + echo 'no'; + } else if ($taf == "1") { + echo 'yes'; + } else { + echo 'Anything other than a 0 or 1 means something broke!'; + include_once ('footer.php'); + exit(); + } echo '
Titles progress
TitleTitle RankTitle PointsCurrent RankPoints RemainingMax Title %Next Rank
' . $titlename . '' . $row['currentstrankname'] . '' . number_format($row['titlepoints']) . '' . $row['currentstrank'] . '' . $pr . '
'; + echo $ohp; + echo '% completed
' . $stname . '

'; +} +?> \ No newline at end of file diff --git a/includes/getaccountstats.php b/includes/getaccountstats.php index 9ab32cd..30f334b 100644 --- a/includes/getaccountstats.php +++ b/includes/getaccountstats.php @@ -3,7 +3,7 @@ if (isset($_SESSION['userid'])) { echo ''; echo ''; // $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->execute(); $result = $gas->get_result(); diff --git a/includes/getcharstats.php b/includes/getcharstats.php index faa792c..0fccf56 100644 --- a/includes/getcharstats.php +++ b/includes/getcharstats.php @@ -3,7 +3,7 @@ if (isset($_SESSION['userid'])) { echo '
Account wide stats
TitleTitle RankTitle PointsCurrent RankPoints RemainingMax Title %Next Rank
'; echo ''; // $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->execute(); $result = $gcs->get_result(); diff --git a/includes/update-chartitleranks.php b/includes/update-chartitleranks.php index 91eca2d..0b9dafc 100644 --- a/includes/update-chartitleranks.php +++ b/includes/update-chartitleranks.php @@ -2,7 +2,7 @@ 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 = $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->execute(); $cfr->bind_result($r1); @@ -25,14 +25,14 @@ if (isset($_SESSION['userid'])) { $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 = $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->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 = $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->execute(); $irs->close(); diff --git a/includes/update-titleranks.php b/includes/update-titleranks.php index a729efd..222c1ec 100644 --- a/includes/update-titleranks.php +++ b/includes/update-titleranks.php @@ -2,7 +2,7 @@ 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 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->execute(); $cfr->bind_result($r1); @@ -25,14 +25,14 @@ if (isset($_SESSION['userid'])) { $progress = ceil(($_POST['titlepoints'] / $pmr) * 100); if ($r1 > 0) { // $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->execute(); $urs->close(); echo 'Title has been updated!

'; } else { // $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->execute(); $irs->close(); diff --git a/index.php b/index.php index dd901f0..68fa6b2 100644 --- a/index.php +++ b/index.php @@ -3,10 +3,7 @@ $pagetitle = "Guild Wars Stats Tracker"; include_once ('header.php'); if (isset($_SESSION['userid'])){ - echo 'View individual character stats here

'; //make this a drop down list later - echo 'Update character stats here

'; - echo 'Update account stats here

'; - echo 'Add Guild Wars accounts and manage characters here

'; + include_once ('includes/current-character.php'); } include_once ('footer.php'); ?> \ No newline at end of file diff --git a/updateaccountstats.php b/updateaccountstats.php index 218c42e..cc90ea0 100644 --- a/updateaccountstats.php +++ b/updateaccountstats.php @@ -13,7 +13,7 @@ if (isset($_SESSION['userid'])) { if ($_POST['acctitle'] == "notselected") { echo ''; - echo 'Select account title to update: '; // $ats = Account Title Select $ats = $con->prepare("SELECT titlenameid, titlename FROM gwtitles WHERE titletype = 0 ORDER BY titlename"); $ats->execute(); From 876aac1140072349e8404062c8d1964b928f9253 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Sun, 19 Aug 2018 23:46:34 -1000 Subject: [PATCH 90/97] fix for issue #12 --- includes/del-account.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/del-account.php b/includes/del-account.php index 2455388..52899b9 100644 --- a/includes/del-account.php +++ b/includes/del-account.php @@ -13,12 +13,13 @@ if (isset($_SESSION['userid'])) { $delchar->execute(); $delchar->close(); // $dac = Delete Account Stats - $dac = $con->prepare("DELETE FROM gwaccstats WHERE accid = ? AND userid = ?"); + echo 'the error from $gcirow-accid is: ' . $gcirow['accid'] . '
'; + $dac = $con->prepare("DELETE FROM gwstats WHERE charid = 0 AND accid = ? AND userid = ?"); $dac->bind_param("ii", $gcirow['accid'], $_SESSION['userid']); $dac->execute(); $dac->close(); // $dcs = Delete Character Stats - $dcs = $con->prepare("DELETE FROM gwcharstats WHERE charid = ? AND accid = ? AND userid = ?"); + $dcs = $con->prepare("DELETE FROM gwstats WHERE charid = ? AND accid = ? AND userid = ?"); $dcs->bind_param("iii", $gcirow['charid'], $gcirow['accid'], $_SESSION['userid']); $dcs->execute(); $dcs->close(); @@ -35,7 +36,7 @@ if (isset($_SESSION['userid'])) { $nap->execute(); $nap->close(); $_SESSION['prefaccid'] = "0"; - $_SESSION['preaccname'] = "No default selected"; + $_SESSION['prefaccname'] = "No default selected"; echo 'Account(s) deleted - no preferred account selected.

'; // $ncp = No Character Preference $ncp = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?"); @@ -44,6 +45,7 @@ if (isset($_SESSION['userid'])) { $ncp->close(); $_SESSION['prefcharid'] = "0"; $_SESSION['prefcharname'] = "No default selected"; + $_SESSION['charprofid'] = "0"; echo 'All characters related to the account have been deleted - no preferred character selected.

'; } ?> \ No newline at end of file From f48d441343534f2148d076a13a006c757c555295 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Sun, 19 Aug 2018 23:47:26 -1000 Subject: [PATCH 91/97] formatted caption better --- includes/current-character.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/current-character.php b/includes/current-character.php index 51d44f3..146e99d 100644 --- a/includes/current-character.php +++ b/includes/current-character.php @@ -1,6 +1,6 @@
'; + echo '
Character stats
TitleTitle RankTitle PointsCurrent RankPoints RemainingMax Title %Next Rank
Titles progress
'; echo ''; if ($_SESSION['prefcharid'] == "0") { // $gcc = Get Current Character stats From 7e29ca51d4f91d6953b225c778ad3b5fdeb0c1a0 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Mon, 20 Aug 2018 22:57:40 -1000 Subject: [PATCH 92/97] can now specify which title shall be the "GWAMM" max title tracker. there can be only 1! --- adminlanding.php | 1 + includes/title-add.php | 4 ++-- includes/title-editor.php | 21 +++++++++++++++++---- includes/title-submit.php | 21 ++++++++++++++++++--- includes/title-update.php | 21 ++++++++++++++++++--- 5 files changed, 56 insertions(+), 12 deletions(-) diff --git a/adminlanding.php b/adminlanding.php index ba900e4..d4014b1 100644 --- a/adminlanding.php +++ b/adminlanding.php @@ -7,6 +7,7 @@ if (isset($_SESSION['userid'])){ echo '
Welcome to the admin area!

'; echo 'Title creator / editor here (work in progress)

'; echo 'User editor here (not working yet)

'; + echo 'testing gwamm and autofilled titles theories Legendary GWAMM

'; include_once ('includes/session-dump.php'); } include_once ('footer.php'); diff --git a/includes/title-add.php b/includes/title-add.php index 5ffd134..50576af 100644 --- a/includes/title-add.php +++ b/includes/title-add.php @@ -1,8 +1,8 @@
Titles progress for ' . $_SESSION['prefcharname'] . '
TitleTitle RankTitle PointsCurrent RankPoints RemainingMax Title %Next Rank
'; + echo '
Title NameTitle TypeMax RankAuto filled?
'; echo ''; - echo ''; + echo ''; echo '
Title NameTitle TypeMax RankAuto filled?GWAMM?
Account
Character

'; } ?> \ No newline at end of file diff --git a/includes/title-editor.php b/includes/title-editor.php index d62ed49..683c855 100644 --- a/includes/title-editor.php +++ b/includes/title-editor.php @@ -1,7 +1,7 @@ '; - echo ''; + echo '
titlenameidtitlenametitletypetitlemaxrankautofilled
'; $stmtview = $con->prepare("SELECT * FROM gwtitles WHERE titlenameid = ?"); $stmtview->bind_param("i", $_POST['tid']); $stmtview->execute(); @@ -11,7 +11,8 @@ if (isset($_SESSION['userid'])) { $tname = $row['titlename']; $ttype = $row['titletype']; $tmr = $row['titlemaxrank']; - $taf = $row['autofilled']; + $taf = $row['autofilled']; + $tg = $row['gwamm']; // $tg = Title GWAMM tracking echo ''; } $stmtview->close(); - echo '
titlenameidtitlenametitletypetitlemaxrankautofilledgwamm
'; echo 'Character'; - echo '
Delete title?


'; + echo ''; + echo '
The current GWAMM title is: '; + // $ggt = Get GWAMM Title + $ggt = $con->prepare("SELECT titlename FROM gwtitles WHERE gwamm = '1'"); + $ggt->execute(); + $ggt->bind_result($gwamm); + $ggt->fetch(); + $ggt->close(); + echo $gwamm . '
Delete title?


'; echo '
'; echo 'Return to title manager'; } diff --git a/includes/title-submit.php b/includes/title-submit.php index 525f3e0..73aaf8c 100644 --- a/includes/title-submit.php +++ b/includes/title-submit.php @@ -1,10 +1,25 @@ prepare("INSERT INTO gwtitles (titlename, titletype, titlemaxrank, autofilled) VALUES (?, ?, ?, ?)"); - $stmtins->bind_param("siii", $_POST['titlename'], $_POST['titletype'], $_POST['titlemaxrank'], $_POST['autofill']); + if (!isset($_POST['gwamm'])) { + $_POST['gwamm'] == 0; + } else { + // $ggid = Get Gwamm ID + $ggid = $con->prepare("SELECT titlenameid FROM gwtitles WHERE gwamm = 1"); + $ggid->execute(); + $ggid->bind_result($gwammid); + $ggid->fetch(); + $ggid->close(); + // $rg = Remove GWAMM + $rg = $con->prepare("UPDATE gwtitles SET gwamm = 0 WHERE titlenameid = ?"); + $rg->bind_param("i", $gwammid); + $rg->execute(); + $rg->close(); + } + $stmtins = $con->prepare("INSERT INTO gwtitles (titlename, titletype, titlemaxrank, autofilled, gwamm) VALUES (?, ?, ?, ?, ?)"); + $stmtins->bind_param("siiii", $_POST['titlename'], $_POST['titletype'], $_POST['titlemaxrank'], $_POST['autofill'], $_POST['gwamm']); $stmtins->execute(); $stmtins->close(); echo 'New title added!

'; diff --git a/includes/title-update.php b/includes/title-update.php index d46ce3c..7158458 100644 --- a/includes/title-update.php +++ b/includes/title-update.php @@ -19,11 +19,26 @@ if (isset($_SESSION['userid'])) { } } else { if (!isset($_POST['autofill'])) { - $_POST['autofill'] = "0"; + $_POST['autofill'] == 0; + } + if (!isset($_POST['gwamm'])) { + $_POST['gwamm'] == 0; + } else { + // $ggid = Get Gwamm ID from current GWAMM holder + $ggid = $con->prepare("SELECT titlenameid FROM gwtitles WHERE gwamm = 1"); + $ggid->execute(); + $ggid->bind_result($gwammid); + $ggid->fetch(); + $ggid->close(); + // $rg = Remove GWAMM + $rg = $con->prepare("UPDATE gwtitles SET gwamm = 0 WHERE titlenameid = ?"); + $rg->bind_param("i", $gwammid); + $rg->execute(); + $rg->close(); } // this section updates the title name - $stmtupd = $con->prepare("UPDATE gwtitles SET titlename = ?, titletype = ?, titlemaxrank = ?, autofilled = ? WHERE titlenameid = ?"); - $stmtupd->bind_param("siiii", $_POST['titlename'], $_POST['titletype'], $_POST['titlemaxrank'], $_POST['autofill'], $_POST['titlenameid']); + $stmtupd = $con->prepare("UPDATE gwtitles SET titlename = ?, titletype = ?, titlemaxrank = ?, autofilled = ?, gwamm = ? WHERE titlenameid = ?"); + $stmtupd->bind_param("siiiii", $_POST['titlename'], $_POST['titletype'], $_POST['titlemaxrank'], $_POST['autofill'], $_POST['gwamm'], $_POST['titlenameid']); $stmtupd->execute(); $stmtupd->close(); echo 'Title updated, redirecting!'; From 3a57656a350a90ecaedb5b3d90eb097b51c13e03 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Tue, 21 Aug 2018 10:38:18 -1000 Subject: [PATCH 93/97] fix for issue #14 --- updateaccountstats.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/updateaccountstats.php b/updateaccountstats.php index cc90ea0..e9d6e7c 100644 --- a/updateaccountstats.php +++ b/updateaccountstats.php @@ -5,7 +5,11 @@ if (isset($_SESSION['userid'])) { if (!isset($_POST['acctitle'])) { $_POST['acctitle'] = "notselected"; } - + if ($_SESSION['prefaccid'] == "0") { + echo 'Please select an account from the menu above to add stats to before continuing'; + include_once ('footer.php'); + exit(); + } if (isset($_POST['titlepoints'])) { // include file just updates the database include_once ('includes/update-titleranks.php'); From a57a917a74603221a62ab1b3b733e022787f6ee5 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Tue, 21 Aug 2018 12:26:09 -1000 Subject: [PATCH 94/97] half of issue #10 (kind of a big deal auto populate) complete --- includes/current-character.php | 6 ++-- includes/update-chartitleranks.php | 1 + includes/update-gwamm.php | 58 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 includes/update-gwamm.php diff --git a/includes/current-character.php b/includes/current-character.php index 146e99d..b9f6fc3 100644 --- a/includes/current-character.php +++ b/includes/current-character.php @@ -4,12 +4,12 @@ if (isset($_SESSION['userid'])){ echo 'TitleTitle RankTitle PointsCurrent RankPoints RemainingMax Title %Next Rank'; 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 = $con->prepare("SELECT * FROM gwstats WHERE charid = 0 AND accid = ? AND userid = ? ORDER BY currentstrank DESC, percent DESC"); $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 = $con->prepare("SELECT * FROM gwstats WHERE charid IN (0, ?) AND accid = ? AND userid = ? ORDER BY currentstrank DESC, percent DESC"); + $gcc->bind_param("iii", $_SESSION['prefcharid'], $_SESSION['prefaccid'], $_SESSION['userid']); } $gcc->execute(); $gccres = $gcc->get_result(); diff --git a/includes/update-chartitleranks.php b/includes/update-chartitleranks.php index 0b9dafc..6c6f52a 100644 --- a/includes/update-chartitleranks.php +++ b/includes/update-chartitleranks.php @@ -38,5 +38,6 @@ if (isset($_SESSION['userid'])) { $irs->close(); echo 'Title entered!

'; } + include_once ('update-gwamm.php'); } ?> \ No newline at end of file diff --git a/includes/update-gwamm.php b/includes/update-gwamm.php new file mode 100644 index 0000000..58dd34d --- /dev/null +++ b/includes/update-gwamm.php @@ -0,0 +1,58 @@ +prepare("SELECT titlenameid FROM gwtitles WHERE gwamm = 1"); + $ggid->execute(); + $ggid->bind_result($gwammid); + $ggid->fetch(); + $ggid->close(); + if ($gwammid == NULL) { + echo 'No title has been set for GWAMM status - please do so -->NOW<--
'; + include_once ('footer.php'); + exit(); + } else { + // $ggr Get Gwamm Rank + $ggr = $con->prepare("SELECT COUNT(*) FROM gwstats WHERE charid IN (0, ?) AND gwamm = 0 AND percent >= 100 AND accid = ? AND userid = ?"); + $ggr->bind_param("iii", $_SESSION['prefcharid'], $_SESSION['prefaccid'], $_SESSION['userid']); + $ggr->execute(); + $ggr->bind_result($gwamm); + $ggr->fetch(); + $ggr->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", $gwammid, $gwamm); + $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", $gwammid); + $gpc->execute(); + $gpc->bind_result($pmr); //$pmr = Percentage Max Rank + $gpc->fetch(); + $gpc->close(); + $progress = ceil(($gwamm / $pmr) * 100); + // $gcg = Get Character GWAMM (to see if we're tracking the GWAMM title or not) + $gcg = $con->prepare("SELECT COUNT(*) FROM gwstats WHERE titlenameid = ? AND charid = ? AND accid = ? AND userid = ?"); + $gcg->bind_param("iiii", $gwammid, $_SESSION['prefcharid'], $_SESSION['prefaccid'], $_SESSION['userid']); + $gcg->execute(); + $gcg->bind_result($cgs); // $cgs = Character GWAMM Status + $gcg->fetch(); + $gcg->close(); + if ($cgs > 0) { + // $ugt = Update GWAMM Title + $ugt = $con->prepare("UPDATE gwstats SET stnameid = ?, titlepoints = ?, currentstrankname = ?, currentstrank = ?, percent = ? WHERE titlenameid = ? AND charid = ? AND accid = ? AND userid = ?"); + $ugt->bind_param("iisiiiiii", $stnameid, $gwamm, $stname, $strank, $progress, $gwammid, $_SESSION['prefcharid'], $_SESSION['prefaccid'], $_SESSION['userid']); + $ugt->execute(); + $ugt->close(); + } else { + // $igt = Insert GWAMM Title + $igt = $con->prepare("INSERT INTO gwstats (titlenameid, stnameid, titlepoints, currentstrankname, currentstrank, percent, gwamm, charid, accid, userid) VALUES (?, ?, ?, ?, ?, ?, 1, ?, ?, ?)"); + $igt->bind_param("iiisiiiii", $gwammid, $stnameid, $gwamm, $stname, $strank, $progress, $_SESSION['prefcharid'], $_SESSION['prefaccid'], $_SESSION['userid']); + $igt->execute(); + $igt->close(); + } + } +} +?> \ No newline at end of file From 4e1148531bcca7ffb9b35b032f1b8eb735c48dbf Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Tue, 21 Aug 2018 12:26:58 -1000 Subject: [PATCH 95/97] re-ordered the header to something that doesn't resemble stupid. --- header.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/header.php b/header.php index c7a8955..51a3d37 100644 --- a/header.php +++ b/header.php @@ -50,7 +50,7 @@ if (!$userid){ echo'(Administration) '; } echo '(Logout ' . $_SESSION['username'] . ')
'; - echo '(Update character titles) (Update account titles) '; + echo '(Update account titles) (Update character titles) '; echo '(Manage accounts & characters)

'; } ?> \ No newline at end of file From fa8e8056ac85168dec4728c18e78e4f7ae33e038 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Tue, 21 Aug 2018 15:39:50 -1000 Subject: [PATCH 96/97] i don't rememebr what these changes were oops --- addaccounts.php | 4 ++-- adminlanding.php | 2 +- includes/del-account.php | 1 - includes/title-update.php | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/addaccounts.php b/addaccounts.php index d3692ca..715b164 100644 --- a/addaccounts.php +++ b/addaccounts.php @@ -31,13 +31,13 @@ if (isset($_SESSION['userid'])) { echo ''; echo '
'; echo '
'; - echo ''; + echo ''; $acclist = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE userid = ?"); $acclist->bind_param("i", $_SESSION['userid']); $acclist->execute(); $result = $acclist->get_result(); while ($row = $result->fetch_assoc()) { - echo '
Current Guild Wars accounts
Account namePreferred?Delete ?
accidAccount namePreferred?Delete ?
'; + echo '
'; echo '
Welcome to the admin area!

'; echo 'Title creator / editor here (work in progress)

'; echo 'User editor here (not working yet)

'; - echo 'testing gwamm and autofilled titles theories Legendary GWAMM

'; + echo 'testing autofilled title theories: Legendary title testGWAMM

'; include_once ('includes/session-dump.php'); } include_once ('footer.php'); diff --git a/includes/del-account.php b/includes/del-account.php index 52899b9..104a44a 100644 --- a/includes/del-account.php +++ b/includes/del-account.php @@ -13,7 +13,6 @@ if (isset($_SESSION['userid'])) { $delchar->execute(); $delchar->close(); // $dac = Delete Account Stats - echo 'the error from $gcirow-accid is: ' . $gcirow['accid'] . '
'; $dac = $con->prepare("DELETE FROM gwstats WHERE charid = 0 AND accid = ? AND userid = ?"); $dac->bind_param("ii", $gcirow['accid'], $_SESSION['userid']); $dac->execute(); diff --git a/includes/title-update.php b/includes/title-update.php index 7158458..e1dc9c4 100644 --- a/includes/title-update.php +++ b/includes/title-update.php @@ -2,7 +2,7 @@ if (isset($_SESSION['userid'])) { if (isset($_POST['deltitle'])) { if ($_POST['deltitle'] == "yes") { - // this title makes you verify that you want to delete this title + // this section makes you verify that you really want to delete this title echo 'Please check the box to verify you want to delete: ' . $_POST['titlename'] . ' '; echo '

'; } else if ($_POST['deltitle'] == "iamsure") { From cfae286e844250b1515b9bcd337bd902e984f86f Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Thu, 23 Aug 2018 12:22:40 -1000 Subject: [PATCH 97/97] Upload files to 'sql-init' updated sql init script --- sql-init/db-setup.sql | 54 ++++++++++++++++++++------------------------------- 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/sql-init/db-setup.sql b/sql-init/db-setup.sql index 44ac691..ed192f5 100644 --- a/sql-init/db-setup.sql +++ b/sql-init/db-setup.sql @@ -1,23 +1,8 @@ -/*Table structure for table `gwaccounts` */ - CREATE TABLE `gwaccounts` ( - `accid` int(11) NOT NULL AUTO_INCREMENT COMMENT 'this key will be bound by charrid in table gwchars', + `accid` int(11) NOT NULL AUTO_INCREMENT COMMENT 'this key will be bound by charid in table gwchars', `userid` int(11) DEFAULT NULL, `accemail` varchar(50) DEFAULT NULL, PRIMARY KEY (`accid`) -) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; - -/*Table structure for table `gwaccstats` */ - -CREATE TABLE `gwaccstats` ( - `titlenameid` int(11) DEFAULT NULL, - `stnameid` int(2) DEFAULT NULL, - `titlepoints` int(11) DEFAULT NULL, - `currentstrankname` varchar(37) DEFAULT NULL, - `currentstrank` int(11) DEFAULT NULL, - `percent` int(3) DEFAULT NULL, - `accid` int(11) DEFAULT NULL, - `userid` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*Table structure for table `gwchars` */ @@ -31,31 +16,32 @@ CREATE TABLE `gwchars` ( `profid` int(2) DEFAULT NULL, `profcolor` char(7) NOT NULL DEFAULT '#45b39d', PRIMARY KEY (`charid`) -) ENGINE=InnoDB AUTO_INCREMENT=74 DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +/*Table structure for table `gwprofessions` */ + +CREATE TABLE `gwprofessions` ( + `profid` int(2) NOT NULL AUTO_INCREMENT, + `profession` varchar(12) DEFAULT NULL, + `profcolor` char(4) DEFAULT NULL, + PRIMARY KEY (`profid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*Table structure for table `gwcharstats` */ +/*Table structure for table `gwstats` */ -CREATE TABLE `gwcharstats` ( +CREATE TABLE `gwstats` ( `titlenameid` int(11) DEFAULT NULL, `stnameid` int(2) DEFAULT NULL, - `titlepoinsts` int(11) DEFAULT NULL, + `titlepoints` int(11) DEFAULT NULL, `currentstrankname` varchar(37) DEFAULT NULL, `currentstrank` int(11) DEFAULT NULL, `percent` int(3) DEFAULT NULL, - `charid` int(11) DEFAULT NULL, + `gwamm` int(1) NOT NULL DEFAULT '0', + `charid` int(11) NOT NULL DEFAULT '0', `accid` int(11) DEFAULT NULL, `userid` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*Table structure for table `gwprofessions` */ - -CREATE TABLE `gwprofessions` ( - `profid` int(2) NOT NULL AUTO_INCREMENT, - `profession` varchar(12) DEFAULT NULL, - `profcolor` char(4) DEFAULT NULL, - PRIMARY KEY (`profid`) -) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1; - /*Table structure for table `gwsubtitles` */ CREATE TABLE `gwsubtitles` ( @@ -65,7 +51,7 @@ CREATE TABLE `gwsubtitles` ( `stpoints` int(11) DEFAULT NULL, `strank` int(11) DEFAULT NULL, PRIMARY KEY (`stnameid`) -) ENGINE=InnoDB AUTO_INCREMENT=304 DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*Table structure for table `gwtitles` */ @@ -74,8 +60,10 @@ CREATE TABLE `gwtitles` ( `titlename` varchar(40) DEFAULT NULL, `titletype` int(1) DEFAULT NULL COMMENT '0 = account, 1 = character', `titlemaxrank` int(2) DEFAULT NULL, + `autofilled` int(1) NOT NULL DEFAULT '0' COMMENT '0 = no, 1 = yes', + `gwamm` int(1) NOT NULL DEFAULT '0' COMMENT '0 = no, 1 = yes', PRIMARY KEY (`titlenameid`) -) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*Table structure for table `userinfo` */ @@ -90,4 +78,4 @@ CREATE TABLE `userinfo` ( `prefcharid` int(11) NOT NULL DEFAULT '0' COMMENT 'sets which GW character you want to default to', `prefcharname` char(19) DEFAULT 'No default selected', PRIMARY KEY (`userid`) -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; \ No newline at end of file