From 66ba0e2580456b2345d5b0a18ebc32f698de4619 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Sun, 12 Aug 2018 10:59:47 -1000 Subject: [PATCH] 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 '
Current preferred character: ' .$_SESSION['prefcharname'] . '