diff --git a/addaccounts.php b/addaccounts.php new file mode 100644 index 0000000..715b164 --- /dev/null +++ b/addaccounts.php @@ -0,0 +1,85 @@ +'; + 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
accidAccount namePreferred?Delete ?
'; + echo '

'; + // 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, 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/adminlanding.php b/adminlanding.php new file mode 100644 index 0000000..8aa744a --- /dev/null +++ b/adminlanding.php @@ -0,0 +1,14 @@ +Welcome to the admin area!

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

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

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

'; + include_once ('includes/session-dump.php'); +} +include_once ('footer.php'); +?> \ No newline at end of file diff --git a/connection.php-sample b/connect.php-sample similarity index 71% rename from connection.php-sample rename to connect.php-sample index e182191..7f6f27f 100644 --- a/connection.php-sample +++ b/connect.php-sample @@ -2,5 +2,5 @@ define ("DATABASE_HOST", "localhost"); define ("DATABASE_USER", "not-root"); define ("DATABASE_PASS", "strong-password-here"); -define ("DATABASE_NAME", "gwstatstracker"); +define ("DATABASE_NAME", "cool_database_name_here"); ?> diff --git a/footer.php b/footer.php index b1a0dbb..4966fec 100644 --- a/footer.php +++ b/footer.php @@ -1,8 +1,13 @@ - + '; +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 '

'; + echo '


'; } ?> - - \ No newline at end of file + + \ No newline at end of file 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-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 ffaad99..51a3d37 100644 --- a/header.php +++ b/header.php @@ -1,23 +1,56 @@ - - + + 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 ''; + if (isset($pagetitle)) { + echo $pagetitle; + } else { + 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'); + } + echo '
'; + echo '(Home) (Options) '; + echo '() '; + echo '() '; + if ($_SESSION['admin'] == 1){ + echo'(Administration) '; + } + echo '(Logout ' . $_SESSION['username'] . ')

'; + echo '(Update account titles) (Update character titles) '; + echo '(Manage accounts & characters)

'; } ?> \ No newline at end of file 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/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 new file mode 100644 index 0000000..100b390 --- /dev/null +++ b/includes/addcharacters-submit.php @@ -0,0 +1,15 @@ +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, 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!

'; +} +?> \ No newline at end of file diff --git a/includes/current-character.php b/includes/current-character.php new file mode 100644 index 0000000..b9f6fc3 --- /dev/null +++ b/includes/current-character.php @@ -0,0 +1,53 @@ +Titles progress for ' . $_SESSION['prefcharname'] . ''; + 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 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 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(); + 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 '' . $titlename . '' . $row['currentstrankname'] . '' . number_format($row['titlepoints']) . '' . $row['currentstrank'] . ''; + echo '' . $pr . '
'; + echo $ohp; + echo '% completed' . $stname . ''; + } + $gccres->close(); + echo '
'; +} +?> \ No newline at end of file diff --git a/includes/del-account.php b/includes/del-account.php new file mode 100644 index 0000000..104a44a --- /dev/null +++ b/includes/del-account.php @@ -0,0 +1,50 @@ +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 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 gwstats 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['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 = ?"); + $ncp->bind_param("i", $_SESSION['userid']); + $ncp->execute(); + $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 diff --git a/includes/del-character.php b/includes/del-character.php new file mode 100644 index 0000000..44c12d4 --- /dev/null +++ b/includes/del-character.php @@ -0,0 +1,28 @@ +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(); + } + // $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(); + $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 new file mode 100644 index 0000000..30f334b --- /dev/null +++ b/includes/getaccountstats.php @@ -0,0 +1,47 @@ +Account wide stats'; + echo 'TitleTitle RankTitle PointsCurrent RankPoints RemainingMax Title %Next Rank'; + // $gas = GetAccountStats + $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(); + 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 . ''; + } + $gas->close(); + echo '
'; +} +?> \ No newline at end of file diff --git a/includes/getcharstats.php b/includes/getcharstats.php new file mode 100644 index 0000000..0fccf56 --- /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 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(); + 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/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/includes/set-prefacc.php b/includes/set-prefacc.php new file mode 100644 index 0000000..da83f4b --- /dev/null +++ b/includes/set-prefacc.php @@ -0,0 +1,37 @@ +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 = 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(); + $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']; + } + $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 new file mode 100644 index 0000000..8d791cd --- /dev/null +++ b/includes/set-prefchar.php @@ -0,0 +1,29 @@ +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"; + } else { + // $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(); + 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']; + $_SESSION['charprofid'] = $row['profid']; + } + } +} +?> \ No newline at end of file diff --git a/includes/title-add.php b/includes/title-add.php new file mode 100644 index 0000000..50576af --- /dev/null +++ b/includes/title-add.php @@ -0,0 +1,8 @@ +'; + 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 new file mode 100644 index 0000000..683c855 --- /dev/null +++ b/includes/title-editor.php @@ -0,0 +1,50 @@ +'; + 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']; + $taf = $row['autofilled']; + $tg = $row['gwamm']; // $tg = Title GWAMM tracking + echo ''; + } + $stmtview->close(); + echo '
titlenameidtitlenametitletypetitlemaxrankautofilledgwamm
'; + echo 'Account
'; + echo 'Character
'; + 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'; +} +?> \ No newline at end of file diff --git a/includes/title-select.php b/includes/title-select.php new file mode 100644 index 0000000..d159ded --- /dev/null +++ b/includes/title-select.php @@ -0,0 +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 ''; + } + $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..73aaf8c --- /dev/null +++ b/includes/title-submit.php @@ -0,0 +1,41 @@ +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!

'; + $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']; + $taf = $row['autofilled']; + echo ''; + echo '
titleidtitlenametitletypetitlemaxrankautofilled
' . $tid . '' . $tname . '' . $ttype . '' . $tmr . '' . $taf . '

'; + } + $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..e1dc9c4 --- /dev/null +++ b/includes/title-update.php @@ -0,0 +1,48 @@ +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 { + if (!isset($_POST['autofill'])) { + $_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 = ?, 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!'; + header ("Refresh:1; url=titlemanager.php"); + } +} +?> \ No newline at end of file diff --git a/includes/titleranks-add.php b/includes/titleranks-add.php new file mode 100644 index 0000000..0559e33 --- /dev/null +++ b/includes/titleranks-add.php @@ -0,0 +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; + } 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 { + 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 new file mode 100644 index 0000000..60846df --- /dev/null +++ b/includes/titleranks-editor.php @@ -0,0 +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 ''; + } + $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'; + } +} +?> \ No newline at end of file diff --git a/includes/titleranks-submit.php b/includes/titleranks-submit.php new file mode 100644 index 0000000..14e2317 --- /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']; + $_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/titleranks-update.php b/includes/titleranks-update.php new file mode 100644 index 0000000..2e0a42a --- /dev/null +++ b/includes/titleranks-update.php @@ -0,0 +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"); + } +} +?> \ No newline at end of file diff --git a/includes/update-chartitleranks.php b/includes/update-chartitleranks.php new file mode 100644 index 0000000..6c6f52a --- /dev/null +++ b/includes/update-chartitleranks.php @@ -0,0 +1,43 @@ +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); + $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 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 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(); + echo 'Title entered!

'; + } + include_once ('update-gwamm.php'); +} +?> \ No newline at end of file diff --git a/includes/update-email.php b/includes/update-email.php new file mode 100644 index 0000000..2a2ad27 --- /dev/null +++ b/includes/update-email.php @@ -0,0 +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.
'; +} +?> \ 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 diff --git a/includes/update-password.php b/includes/update-password.php new file mode 100644 index 0000000..d15a46f --- /dev/null +++ b/includes/update-password.php @@ -0,0 +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!
'; + } + } +} +?> \ No newline at end of file diff --git a/includes/update-titleranks.php b/includes/update-titleranks.php new file mode 100644 index 0000000..222c1ec --- /dev/null +++ b/includes/update-titleranks.php @@ -0,0 +1,42 @@ +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); + $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 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 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(); + echo 'Title entered!

'; + } +} +?> \ No newline at end of file diff --git a/includes/verifications.php b/includes/verifications.php new file mode 100644 index 0000000..07d489b --- /dev/null +++ b/includes/verifications.php @@ -0,0 +1,59 @@ += 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 +if (!empty($_POST['username'])) { + $username = mysqli_real_escape_string($con, $_POST['username']); + validateUsername($username); +} + +#################### +# verifying the e-mail address is in a valid format +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']); +} + +#################### +# 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!'; + include_once ('footer.php'); + exit(); + } +} +?> \ No newline at end of file diff --git a/index.php b/index.php index a1bd06d..68fa6b2 100644 --- a/index.php +++ b/index.php @@ -1,12 +1,9 @@ + 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 ('includes/current-character.php'); } include_once ('footer.php'); ?> \ No newline at end of file diff --git a/login.php b/login.php index 6ebb8d2..5427746 100644 --- a/login.php +++ b/login.php @@ -7,33 +7,35 @@
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]; + $_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!
'; +} 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..62e09ee 100644 --- a/logout.php +++ b/logout.php @@ -1,19 +1,17 @@ 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
'; } -include_once ('footer.php'); ?> \ No newline at end of file diff --git a/preferences.php b/preferences.php new file mode 100644 index 0000000..7ede41b --- /dev/null +++ b/preferences.php @@ -0,0 +1,75 @@ +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; +} +include_once ('footer.php'); +?> \ No newline at end of file diff --git a/register.php b/register.php new file mode 100644 index 0000000..8a7d22f --- /dev/null +++ b/register.php @@ -0,0 +1,32 @@ + + + + +connect_errno){ + die ('Unable to connect to database [' . $db->connect_errno . ']'); +} +if (empty($_POST['reguser'])){ + // 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/sql-init/db-setup.sql b/sql-init/db-setup.sql new file mode 100644 index 0000000..ed192f5 --- /dev/null +++ b/sql-init/db-setup.sql @@ -0,0 +1,81 @@ +CREATE TABLE `gwaccounts` ( + `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 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 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 `gwstats` */ + +CREATE TABLE `gwstats` ( + `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, + `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 `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 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, + `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 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 DEFAULT CHARSET=latin1; \ No newline at end of file diff --git a/style.css b/style.css index e28db87..33b593e 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 { @@ -26,7 +28,7 @@ ul, li{ padding:0 0 0 15px; } -.column{ +.column { float: left; margin: 0 20px 0 0; } @@ -48,4 +50,40 @@ label { img.resize { width:220px; height:300px; -} \ No newline at end of file +} + +input { + text-align: center; +} + +.submitLink { + background-color: transparent; + text-decoration: underline; + border: none; + color: #003366; + cursor: pointer; +} +submitLink:focus { + outline: none; +} + +.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; } +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 new file mode 100644 index 0000000..693f567 --- /dev/null +++ b/titlemanager.php @@ -0,0 +1,91 @@ +'; + 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']; + $taf = $row['autofilled']; + echo ''; + } + $stmtview->close(); + echo '
titleidtitlenametitletypetitletypeautofilledautofilled
' . $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 '' . $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 '

If anything looks off, please fix it!

'; + } + } +} +include_once ('footer.php'); +?> \ No newline at end of file diff --git a/updateaccountstats.php b/updateaccountstats.php new file mode 100644 index 0000000..e9d6e7c --- /dev/null +++ b/updateaccountstats.php @@ -0,0 +1,39 @@ +'; + 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
'; +} +include_once ('footer.php'); +?> \ No newline at end of file diff --git a/updatecharstats.php b/updatecharstats.php new file mode 100644 index 0000000..596f1ad --- /dev/null +++ b/updatecharstats.php @@ -0,0 +1,39 @@ +'; + echo 'Select character title to update:
'; + $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