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');