| @@ -0,0 +1,85 @@ | |||
| <?php | |||
| $pagetitle = "Add a Guild Wars account to track"; | |||
| include_once ('header.php'); | |||
| if (isset($_SESSION['userid'])) { | |||
| if (!empty($_POST['prefcharid'])) { | |||
| //this section contains code to the users preferred character | |||
| include_once ('includes/set-prefchar.php'); | |||
| } | |||
| if (!empty($_POST['prefaccid'])) { | |||
| //this section contains code to set the users preferred game account | |||
| include_once ('includes/set-prefacc.php'); | |||
| } | |||
| 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['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 | |||
| include_once ('includes/del-character.php'); | |||
| } | |||
| if (!empty($_POST['newcharname'])) { | |||
| // this section contains code to insert a new character into the database | |||
| include_once ('includes/addcharacters-submit.php'); | |||
| } | |||
| echo '<form action="addaccounts.php" method="post"><table>'; | |||
| echo '<caption>Add a new Guild Wars account e-mail or alias</caption>'; | |||
| echo '<tr><td><input type="text" name="accemail" size="35" required></td><td><input type="submit" value="Add account"></td></tr>'; | |||
| echo '</table></form><br />'; | |||
| echo '<form action="addaccounts.php" method="post"><table border="1"><caption style="white-space: nowrap; overflow: hidden;">Current Guild Wars accounts</caption>'; | |||
| echo '<tr><th>accid</th><th>Account name</th><th>Preferred?</th><th>Delete ?</th></tr>'; | |||
| $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 '<tr><td><input type="text" readonly size="4" value="' . $row['accid'] . '"></td><td><form action="addaccounts.php" method="post"><input type="submit" class="submitLink" value="' . $row['accemail'] . '">'; | |||
| echo '</td><td><div class="radio"><input type="radio" name="prefaccid" value="'. $row['accid'] . '"'; | |||
| if ($row['accid'] == $_SESSION['prefaccid']) { | |||
| echo ' checked'; | |||
| } | |||
| //delete account array in delaccid[] | |||
| echo '></div></td><td><input type="checkbox" name="delaccid[]" value="' . $row['accid'] . '"></td></tr>'; | |||
| } | |||
| $acclist->close(); | |||
| echo '</form></table><input type="submit" value="Modify selected accounts"></form><br />'; | |||
| // add characters here | |||
| echo '<form action="addaccounts.php" method="post"><table>'; | |||
| echo '<caption style="white-space: nowrap; overflow: hidden;">Add character to account: ' . $_SESSION['prefaccname'] . '</caption>'; | |||
| echo '<tr><th>Character name</th><th>Birthdate</th><th>Profession</th></tr>'; | |||
| echo '<tr><td><input type="text" name="newcharname" size="19" required autofocus></td><td><input type="date" name="bdate" placeholder="2005-04-28"></td><td><select name="profid" required>'; | |||
| // $gp = Get Profession | |||
| $gp = $con->prepare("SELECT profid, profession FROM gwprofessions"); | |||
| $gp->execute(); | |||
| $result = $gp->get_result(); | |||
| while ($row = $result->fetch_assoc()) { | |||
| echo '<option value=' . $row['profid'] . '>' . $row['profession'] . '</option>'; | |||
| } | |||
| echo '</td></tr>'; | |||
| echo '<tr><td colspan="3"><input type="submit" value="Add character"></td></tr></table></form><br />'; | |||
| echo '<form action="addaccounts.php" method="post"><table border="1"><caption style="white-space: nowrap; overflow: hidden;">Available characters</caption>'; | |||
| echo '<tr><td>charid</td><td>accid</td><td>charname</td><td>Preferred</td><td>Delete?</td></tr>'; | |||
| $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 '<tr><td><input type="text" readonly size="4" name="charid[]" value="' . $row2['charid'] . '"></td>'; | |||
| echo '<td><input type="text" readonly size="4" name="accid[]" value="' . $row2['accid'] . '"></td>'; | |||
| echo '<td style="background-color:' . ($row2['profcolor']) . '"><form action="addaccounts.php" method="post"><input type="submit" class="submitLink" value="' . $row2['charname'] . '"></td>'; | |||
| echo '<td><div class="radio"><input type="radio" name="prefcharid" value="' . $row2['charid'] . '"'; | |||
| if ($row2['charid'] == $_SESSION['prefcharid']) { | |||
| echo ' checked'; | |||
| } | |||
| echo '></div></td>'; | |||
| echo '<td><input type="checkbox" name="delcharid[]" value="' . $row2['charid'] . '"></td></tr>'; | |||
| } | |||
| echo '</form></table><input type="submit" value="Modify selected characters"></form><br />'; | |||
| echo '<br />Return to your <a href="index.php" class="navlink">user</a> page'; | |||
| } | |||
| include_once ('footer.php'); | |||
| ?> | |||
| @@ -0,0 +1,14 @@ | |||
| <?php | |||
| $pagetitle = "Admin Area"; | |||
| include_once ('header.php'); | |||
| if (isset($_SESSION['userid'])){ | |||
| unset($_SESSION['title']); | |||
| unset($_SESSION['tid']); | |||
| echo '<center>Welcome to the admin area!<br /><br />'; | |||
| echo 'Title creator / editor <a href="titlemanager.php" class="navlink">here</a> (work in progress)<br /><br />'; | |||
| echo 'User editor <a href="" class="navlink">here</a> (not working yet)<br /><br />'; | |||
| echo 'testing autofilled title theories: <a href="autofilled.php" class="navlink">Legendary title testGWAMM</a><br /><br />'; | |||
| include_once ('includes/session-dump.php'); | |||
| } | |||
| include_once ('footer.php'); | |||
| ?> | |||
| @@ -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"); | |||
| ?> | |||
| @@ -1,8 +1,13 @@ | |||
| </CENTER> | |||
| </center> | |||
| <?php | |||
| echo '<hr>'; | |||
| if (isset($_SESSION['prefaccname']) && ($_SESSION['prefcharname'])) { | |||
| echo '<center>| Currently selected game account: <b>' . $_SESSION['prefaccname'] . '</b> | Current character: <b>' . $_SESSION['prefcharname'] . '</b> |</center><br />'; | |||
| } | |||
| // 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 '<BR /><BR /><CENTER><FORM METHOD="POST" ACTION="logout.php"><INPUT TYPE="HIDDEN" NAME="logout"><INPUT TYPE="SUBMIT" VALUE="Logout"></FORM></CENTER>'; | |||
| echo '<center><br /><br /><form method="post" action="logout.php"><input type="hidden" name="action" value="logout" ><input type="submit" value="Logout"></form></center>'; | |||
| } | |||
| ?> | |||
| </BODY> | |||
| </HTML> | |||
| </body> | |||
| </html> | |||
| @@ -0,0 +1,13 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])) { | |||
| // $als = Account List Select | |||
| $als = $con->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 '<option value="' . $alsrow['accid'] . '">' . $alsrow['accemail'] . '</option>'; | |||
| } | |||
| $als->close(); | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,13 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])) { | |||
| // $cls = Character List Select | |||
| $cls = $con->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 '<option class="profession-' . $clsrow['profid'] . '" value="' . $clsrow['charid'] . '">' . $clsrow['charname'] . '</option>'; | |||
| } | |||
| $cls->close(); | |||
| } | |||
| ?> | |||
| @@ -1,23 +1,56 @@ | |||
| <!DOCTYPE html> | |||
| <HTML> | |||
| <HEAD> | |||
| <html> | |||
| <head> | |||
| <link rel="stylesheet" type="text/css" href="style.css"> | |||
| <?php | |||
| session_start(); | |||
| $uname = (isset($_SESSION['username']) ? $_SESSION['username'] : null); | |||
| if (session_status() == PHP_SESSION_NONE) { | |||
| session_start(); | |||
| } | |||
| $userid = (isset($_SESSION['userid']) ? $_SESSION['userid'] : null); | |||
| include_once ('connection.php'); | |||
| $con = @new mysqli(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME); | |||
| include_once ('connect.php'); | |||
| $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 (!$userid){ | |||
| echo '<TITLE>Please login first</TITLE></HEAD><BODY>'; | |||
| echo '<CENTER><FORM ACTION="login.php" METHOD="POST">Username:<INPUT TYPE="TEXT" NAME="username" SIZE="20"><BR />'; | |||
| echo 'Password:<INPUT TYPE="PASSWORD" NAME="password" SIZE="20"><BR />'; | |||
| echo '<INPUT TYPE="SUBMIT" VALUE="Login ..."></FORM></CENTER>'; | |||
| echo '<title>Please login first</title></head><body><center>Aloha, and welcome to my Guild Wars stats tracker. Please login below.<hr>'; | |||
| echo '<form action="login.php" method="post"><table border="0"><tr><td>Username:</td><td><input type="text" name="username" size="20" autofocus required></td></tr>'; | |||
| echo '<tr><td>Password:</td><td><input type="password" name="password" size="20" required></td></tr></table>'; | |||
| echo '<input type="submit" value="Login ..."></form><br /><br />'; | |||
| echo 'If you haven\'t registered an account yet,<br />please click <a href="register.php" class="navlink">here</a> to create one.<br />'; | |||
| } else { | |||
| echo '<TITLE>' . $pagetitle . '</TITLE></HEAD><BODY><CENTER>'; | |||
| echo '(<A HREF="index.php" CLASS="navlink">Home</A>) (<A HREF="search.php" CLASS="navlink">SEARCH</A>) (<A HREF="logout.php?action=logout" CLASS="navlink">Logout ' . $uname . '</A>)<HR><BR / >'; | |||
| echo '<title>'; | |||
| if (isset($pagetitle)) { | |||
| echo $pagetitle; | |||
| } else { | |||
| echo 'GWST'; | |||
| } | |||
| echo '</title></head><body><center>'; | |||
| 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 '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">'; | |||
| echo '(<a href="index.php" class="navlink">Home</a>) (<a href="preferences.php" class="navlink">Options</a>) '; | |||
| echo '(<select name="prefaccid" onchange="this.form.submit()">'; | |||
| echo '<option class="header" value="' . $_SESSION['prefaccid'] . '">' . $_SESSION['prefaccname'] . '</option>'; | |||
| echo '<option value="nopref">No default selected</option>'; | |||
| include_once ('header-list-accounts.php'); | |||
| echo '</select>)<noscript><input type="submit" value="Preferrence"></noscript> '; | |||
| echo '(<select name="prefcharid" onchange="this.form.submit()">'; | |||
| echo '<option "class="header" value="' . $_SESSION['prefcharid'] . '">' . $_SESSION['prefcharname'] . '</option>'; | |||
| echo '<option value="nopref">No default selected</option>'; | |||
| include_once ('header-list-chars.php'); | |||
| echo '</select>)<noscript><input type="submit" value="Preferrence"></noscript> '; | |||
| if ($_SESSION['admin'] == 1){ | |||
| echo'(<a href="adminlanding.php" class="navlink">Administration</a>) '; | |||
| } | |||
| echo '(<a href="logout.php?action=logout" class="navlink">Logout ' . $_SESSION['username'] . '</a>)</form><hr>'; | |||
| echo '(<a href="updateaccountstats.php" class="navlink">Update account titles</a>) (<a href="updatecharstats.php" class="navlink">Update character titles</a>) '; | |||
| echo '(<a href="addaccounts.php" class="navlink">Manage accounts & characters</a>)<br /><br />'; | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,23 @@ | |||
| <form action="register.php" method="post"> | |||
| <table border="1"> | |||
| <tr><th colspan="2">Username desired</th></tr> | |||
| <tr><td colspan="2"><input type="text" size="45" required="required" name="username"></td></tr> | |||
| <tr><th colspan="2">E-Mail address</th></tr> | |||
| <tr><td colspan="2"><input type="text" size="45" required="required" name="useremail"></td></tr> | |||
| <tr><th>Password</th><th>Verify password</th></tr> | |||
| <tr><td><input type="password" required="required" name="userpass1" id="up1"></td><td><input type="password" required="required" name="userpass2" id="up2"></td></tr> | |||
| </table> | |||
| <script type="text/javascript"> | |||
| function Validate() { | |||
| var userpass1 = document.getElementById("up1").value; | |||
| var userpass2 = document.getElementById("up2").value; | |||
| if (userpass1 != userpass2) { | |||
| alert("Passwords do not match."); | |||
| return false; | |||
| } | |||
| return true; | |||
| } | |||
| </script> | |||
| <input type="hidden" name="reguser" value="1"> | |||
| <input type="submit" name="submission" value="Go! Go! Go!" onclick="return Validate()" id="btnSubmit"> | |||
| </form> | |||
| @@ -0,0 +1,11 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])) { | |||
| $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(); | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,15 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])){ | |||
| // $pc = ProfessionColor | |||
| $pc = $con->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!<br /><br />'; | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,53 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])){ | |||
| echo '<table border="1"><caption>Titles progress for <b>' . $_SESSION['prefcharname'] . '</b></caption>'; | |||
| echo '<tr><th>Title</th><th>Title Rank</th><th>Title Points</th><th>Current Rank</th><th>Points Remaining</th><th>Max Title %</th><th>Next Rank</th></tr>'; | |||
| 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 '<tr><td style="width:175px;">' . $titlename . '</td><td style="width:210px;">' . $row['currentstrankname'] . '</td><td style="width:100px;">' . number_format($row['titlepoints']) . '</td><td style="width:70px;">' . $row['currentstrank'] . '</td>'; | |||
| echo '<td style="width:100px;">' . $pr . '</td><td><div class="percentbar" style="width:100px;"><div style="width:' . $ohp . 'px;"></div></div>'; | |||
| echo $ohp; | |||
| echo '% completed</td><td>' . $stname . '</td></tr>'; | |||
| } | |||
| $gccres->close(); | |||
| echo '</table><br />'; | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,50 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])) { | |||
| // get all the character id's related to the selected account id's | |||
| // $gci = Get Character ID's | |||
| $gaccid = implode(", ", $_POST['delaccid']); | |||
| $gci = $con->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.<br /><br />'; | |||
| // $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.<br /><br />'; | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,28 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])) { | |||
| 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(); | |||
| } | |||
| // $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.<br /><br />'; | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,47 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])) { | |||
| echo '<table border="1"><caption>Account wide stats</caption>'; | |||
| echo '<tr><th>Title</th><th>Title Rank</th><th>Title Points</th><th>Current Rank</th><th>Points Remaining</th><th>Max Title %</th><th>Next Rank</th></tr>'; | |||
| // $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 '<tr><td style="width:150px;">' . $titlename . '</td><td style="width:200px;">' . $row['currentstrankname'] . '</td><td style="width:100px;">' . number_format($row['titlepoints']) . '</td><td style="width:70px;">' . $row['currentstrank'] . '</td>'; | |||
| echo '<td style="width:100px;">' . $pr . '</td><td><div class="percentbar" style="width:100px;"><div style="width:' . $ohp . 'px;"></div></div>'; | |||
| echo $ohp; | |||
| echo '% completed</td><td>' . $stname . '</td></tr>'; | |||
| } | |||
| $gas->close(); | |||
| echo '</table><br />'; | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,47 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])) { | |||
| echo '<table border="1"><caption>Character stats</caption>'; | |||
| echo '<tr><th>Title</th><th>Title Rank</th><th>Title Points</th><th>Current Rank</th><th>Points Remaining</th><th>Max Title %</th><th>Next Rank</th></tr>'; | |||
| // $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 '<tr><td style="width:175px;">' . $titlename . '</td><td style="width:210px;">' . $row['currentstrankname'] . '</td><td style="width:100px;">' . number_format($row['titlepoints']) . '</td><td style="width:70px;">' . $row['currentstrank'] . '</td>'; | |||
| echo '<td style="width:100px;">' . $pr . '</td><td><div class="percentbar" style="width:100px;"><div style="width:' . $ohp . 'px;"></div></div>'; | |||
| echo $ohp; | |||
| echo '% completed</td><td>' . $stname . '</td></tr>'; | |||
| } | |||
| $gcs->close(); | |||
| echo '</table><br />'; | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,7 @@ | |||
| <?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 | |||
| ?> | |||
| @@ -0,0 +1,4 @@ | |||
| <?php | |||
| echo 'Session variables: <pre>' . print_r($_SESSION, true) . '</pre><br />'; | |||
| echo 'Post variables: <pre>' . print_r($_POST, true) . '</pre></br />'; | |||
| ?> | |||
| @@ -0,0 +1,37 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])) { | |||
| if ($_POST['prefaccid'] == "nopref") { | |||
| // $nap = No AccountID Preferrence | |||
| $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.<br />'; | |||
| } 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! <br />'; | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,29 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])) { | |||
| if ($_POST['prefcharid'] == "nopref") { | |||
| // $ncp = No CharID Preferrence | |||
| $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"; | |||
| } 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']; | |||
| } | |||
| } | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,8 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])) { | |||
| echo '<form action="titlemanager.php" method="post"><table border="1"><tr><th>Title Name</th><th>Title Type</th><th>Max Rank</th><th>Auto filled?</th><td>GWAMM?</td></tr>'; | |||
| echo '<tr><td><input type="text" name="titlename" placeholder="Friend of the Kurzicks" required autofocus></td><td style="text-align:left"><input type="radio" name="titletype" value="0" checked> Account<br /><input type="radio" name="titletype" value="1">Character</td>'; | |||
| echo '<td><input type="number" name="titlemaxrank" min="0" max="15"></td><td><input type="checkbox" name="autofill" value="1"></td><td><input type="chckbox" name="gwamm" value="1"></td></tr>'; | |||
| echo '</table><br /><input type="hidden" name="title" value="titlesubmit"><input type="submit" value="Add new title ..."></form>'; | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,50 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])) { | |||
| echo '<form action="titlemanager.php" method="post">'; | |||
| echo '<table border="1"><tr><th>titlenameid</th><th>titlename</th><th>titletype</th><th>titlemaxrank</th><th>autofilled</th><th>gwamm</th></tr>'; | |||
| $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 '<tr><td><input readonly size="3" name="titlenameid" value="' . $tid . '"></td><td><input size="40" type="text" name="titlename" value="' . $tname . '"></td><td style="text-align:left">'; | |||
| echo '<input type="radio" name="titletype" '; | |||
| if ($ttype == 0) { | |||
| echo 'checked '; | |||
| } | |||
| echo 'value="0">Account<br />'; | |||
| echo '<input type="radio" name="titletype" '; | |||
| if ($ttype == 1) { | |||
| echo 'checked '; | |||
| } | |||
| echo 'value="1">Character</td><td><input type="number" name="titlemaxrank" min="1" max="15" value="' . $tmr . '"></td><td>'; | |||
| echo '<input type="checkbox" name="autofill" value="1" '; | |||
| if ($taf == 1) { | |||
| echo 'checked'; | |||
| } | |||
| echo '></td><td><input type="checkbox" name="gwamm" value="1" '; | |||
| if ($tg == 1) { | |||
| echo 'checked'; | |||
| } | |||
| echo '></td></tr>'; | |||
| } | |||
| $stmtview->close(); | |||
| echo '</table><table><tr><td>The current GWAMM title is: <b>'; | |||
| // $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 . '</b></td></tr>'; | |||
| echo '<tr><th>Delete title?</th></tr><tr><td><input type="checkbox" name="deltitle" value="yes"></td></tr></table><br /><br />'; | |||
| echo '<input type="hidden" name="title" value="updatetitle"><input type="submit" value="Modify title ..."></form><br />'; | |||
| echo 'Return to <a href="titlemanager.php" class="navlink">title manager</a>'; | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,14 @@ | |||
| <?php | |||
| 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 '<option value="' . $tid . '">' . $tname . ' (' . $tnr . ')</option>'; | |||
| } | |||
| $stmtview->close(); | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,41 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])) { | |||
| if (!isset($_POST['autofill'])) { | |||
| $_POST['autofill'] == 0; | |||
| } | |||
| 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!<br /><br />'; | |||
| $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 '<table border="1"><tr><th>titleid</th><th>titlename</th><th>titletype</th><th>titlemaxrank</th><th>autofilled</th></tr>'; | |||
| echo '<tr><td>' . $tid . '</td><td>' . $tname . '</td><td>' . $ttype . '</td><td>' . $tmr . '</td><td>' . $taf . '</tr></table><br />'; | |||
| } | |||
| $stmtview->close(); | |||
| echo 'Return to <a href="titlemanager.php" class="navlink">title manager</a>'; | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,48 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])) { | |||
| if (isset($_POST['deltitle'])) { | |||
| if ($_POST['deltitle'] == "yes") { | |||
| // this section makes you verify that you really want to delete this title | |||
| echo '<form action="titlemanager.php" method="post">Please check the box to verify you want to delete: <b>' . $_POST['titlename'] . '</b> <input type="checkbox" name="deltitle" value="iamsure">'; | |||
| echo '<input type="hidden" name="titlenameid" value="' . $_POST['titlenameid'] . '"><input type="hidden" name="title" value="updatetitle"><input type="submit" value="Delete title"></form><br /><br />'; | |||
| } 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"); | |||
| } | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,59 @@ | |||
| <?php | |||
| 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 <b>' . $gwtn . '</b><br />The maximum rank achievable in game is ' . $gwtmr . '<br />'; | |||
| if ($tr > $gwtmr) { | |||
| echo '<br />No more ranks can be added!<br /><br />'; | |||
| } else { | |||
| echo '<form action="titlemanager.php" method="post"><table border="1"><tr><th>Title Rank Name</th><th>Title Points</th><th>Rank Level</th></tr>'; | |||
| echo '<tr><td><input type="text" name="titlerankname" required autofocus></td><td><input type="number" name="titlepoints" required></td><td><input type="number" readonly name="titlerank" min="1" max="15" value="' . $tr . '"></tr>'; | |||
| echo '</table><br /><input type="hidden" name="title" value="titleranksubmit"><input type="hidden" name="titlenameid" value="' . $_POST['tid'] . '"><input type="submit" value="Add title rank ..."></form><br />'; | |||
| } | |||
| } | |||
| $stmtname->free_result(); | |||
| $stmtname->close(); | |||
| echo 'Here are the currently associated title ranks, starting with rank 1:<br />'; | |||
| echo '<form action="titlemanager.php" method="post"><table border="1"><tr><th>stnameid</th><th>titlenameid</th><th>stname</th><th>stpoints</th><th>strank</th><th>Edit</th></tr>'; | |||
| $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 '<tr><td>' . $stnid . '<td>' . $tnid . '</td><td>' . $stname . '</td><td>' . number_format($stpoints) . '</td><td>' . $strank . '</td><td><input type="checkbox" name="editstitle[]" value="' . $stnid . '"></td></tr>'; | |||
| } | |||
| $stmtview->close(); | |||
| $_SESSION['tid'] = $_POST['tid']; | |||
| echo '</table><br /><input type="hidden" name="title" value="modsubtitle"><input type="submit" value="Edit selected titles"></form><br />If anything looks off, please fix it!<br /><br />'; | |||
| echo 'Return to <a href="titlemanager.php" class="navlink">title manager</a>'; | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,25 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])) { | |||
| if (isset($_POST['editstitle'])) { | |||
| echo '<form action="titlemanager.php" method="post"><table border="1"><caption>Deleting takes precedence over edits - edits will have to be remade after submission</caption>'; | |||
| echo '<tr><th>stnameid</th><th>titlenameid</th><th>stname</th><th>stpoints</th><th>strank</th><th>Delete?</th></tr>'; | |||
| $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 '<tr><td><input type="text" readonly size="4" name="stnameid[]" value="' . $row['stnameid']. '"></td><td><input type="text" readonly size="4" name="titlenameid[]" value="' . $row['titlenameid'] . '"></td>'; | |||
| echo '<td><input type="text" name="stname[]" value="' . $row['stname'] . '"></td><td><input type="number" min="1" name="stpoints[]" value="' . $row['stpoints'] . '"></td>'; | |||
| echo '<td><input type="number" size="4" min="1" max="15" name="strank[]" value="' . $row['strank'] . '"></td><td><input type="checkbox" name="delsubtitle[]" value="' . $row['stnameid'] . '"></td></tr>'; | |||
| } | |||
| $sredit->close(); | |||
| echo '</table><br /><input type="hidden" name="title" value="updatesubtitle"><input type="submit" value="Modify title rank(s)"></form>'; | |||
| echo '<br /><br />'; | |||
| echo 'Return to <a href="titlemanager.php" class="navlink">title manager</a>'; | |||
| } else { | |||
| echo 'No title ranks selected! Please press the back button on your browser to return to the previous page.<br /><br />'; | |||
| echo 'Return to <a href="titlemanager.php" class="navlink">title manager</a>'; | |||
| } | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,13 @@ | |||
| <?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"); | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,33 @@ | |||
| <?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"); | |||
| } | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,43 @@ | |||
| <?php | |||
| 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 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!<br /><br />'; | |||
| } 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!<br /></br />'; | |||
| } | |||
| include_once ('update-gwamm.php'); | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,10 @@ | |||
| <?php | |||
| 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.<br />'; | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,58 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])){ | |||
| // $ggid = Get Gwamm ID | |||
| $ggid = $con->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 --><a href="titlemanager.php" class="navlink">NOW</a><--<br />'; | |||
| 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(); | |||
| } | |||
| } | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,23 @@ | |||
| <?php | |||
| 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!<br />'; | |||
| $updpass = $con->prepare("UPDATE userinfo SET userpass = ? WHERE userid = ?"); | |||
| $updpass->bind_param("si", $hp, $_SESSION['userid']); | |||
| $updpass->execute(); | |||
| echo 'Password updated!<br />'; | |||
| $updpass->close(); | |||
| } else { | |||
| echo 'Old password doesn\'t match, password is NOT updated!<br />'; | |||
| } | |||
| } | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,42 @@ | |||
| <?php | |||
| 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 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!<br /><br />'; | |||
| } 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!<br /></br />'; | |||
| } | |||
| } | |||
| ?> | |||
| @@ -0,0 +1,59 @@ | |||
| <?php | |||
| # this function verifies that the e-mail address passed doesn't contain any illegal characters | |||
| function validateEmail($email) { | |||
| return filter_var($email, FILTER_VALIDATE_EMAIL); | |||
| } | |||
| # this function verifies the desired e-mail address doesn't already exist in the database | |||
| function usedEmail($usedemail) { | |||
| $con = mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME); | |||
| $sqlemailcheck = "SELECT usermail FROM userinfo WHERE userinfo.usermail = '" . $usedemail . "'"; | |||
| $results = mysqli_query($con, $sqlemailcheck); | |||
| if (mysqli_num_rows($results) >= 1) { | |||
| echo '<hr><center>This e-mail address is already registered, please click on the forgot password link.<br /><a href="register.php" class="navlink">Please try again!</a><hr><br />'; | |||
| 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 '<center>This username has already been taken, please choose another one<br /><a href="register.php" class="navlink">Please try again!</a><br />'; | |||
| 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 '<center>This address: ' . $_POST['useremail'] . ' is not a valid e-mail address!<br />Please verify and type it again.<br />'; | |||
| 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 '<center>The passwords don\'t match!<br />Please try again!'; | |||
| include_once ('footer.php'); | |||
| exit(); | |||
| } | |||
| } | |||
| ?> | |||
| @@ -1,12 +1,9 @@ | |||
| <!-- this is the main directory of the site, which links to the various content pages --> | |||
| <?php | |||
| $pagetitle = "Guild Wars Stats Tracker"; | |||
| include_once ('header.php'); | |||
| if (isset($_SESSION['userid'])){ | |||
| echo 'Update character stats <A HREF="updatecharstats.php" CLASS="navlink">here</A><BR /><BR />'; | |||
| echo 'Update account stats <A HREF="updateaccountstats.php" CLASS="navlink">here</A><BR /><BR />'; | |||
| echo 'View individual character stats <A HREF="listchars.php" CLASS="navlink">here</A><BR /><BR />'; //make this a drop down list later | |||
| echo 'Change Guild Wars account <A HREF="changeaccounts.php" CLASS="navlink">here</A><BR />'; //make this a drop down list later | |||
| echo 'Add Guild Wars account <a href="addaccounts.php" class="navlink">here</a><br />'; | |||
| include_once ('includes/current-character.php'); | |||
| } | |||
| include_once ('footer.php'); | |||
| ?> | |||
| @@ -7,33 +7,35 @@ | |||
| <BODY> | |||
| <CENTER> | |||
| <?php | |||
| include_once ('connection.php'); | |||
| require "lib/password.php"; | |||
| $con = new mysqli(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME); | |||
| session_start(); | |||
| include_once ('connect.php'); | |||
| $con = mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME); | |||
| if (session_status() == PHP_SESSION_NONE) { | |||
| session_start(); | |||
| } | |||
| $username = mysqli_real_escape_string($con, $_POST['username']); | |||
| $password = mysqli_real_escape_string($con, $_POST['password']); | |||
| # $password = sha1($password); //this is the original line of code, just found sha1isn't any better than md5 | |||
| $passhash = password_hash($password, PASSWORD_BCRYPT, array("cost" => 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 ...<BR />Returning to index in a few seconds</CENTER>'; | |||
| } else { | |||
| echo 'That was not a valid username or password!<BR /><BR />'; | |||
| echo 'Please try again <A HREF="index.php" CLASS="navlink">here</A></CENTER>'; | |||
| } | |||
| $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 '<center>You have successfully logged in!<br />'; | |||
| } else { | |||
| echo 'The username or password provided don\'t match!<br />Please <a href="index.php" class="navlink">try again</a><br />'; | |||
| exit(); | |||
| } | |||
| include_once ('footer.php'); | |||
| ?> | |||
| @@ -1,19 +1,17 @@ | |||
| <?php | |||
| $pagetitle = "Logging Out"; | |||
| include_once ('header.php'); | |||
| $logout = $_GET['action']; | |||
| if (isset($_GET['action'])) { | |||
| $logout = $_GET['action']; | |||
| } else { | |||
| $logout = $_POST['action']; | |||
| } | |||
| if ($logout == "logout"){ | |||
| session_unset(); | |||
| session_destroy(); | |||
| header("refresh:2;url=index.php"); | |||
| echo '<CENTER>You have been logged out ...<BR />Returning to login screen in a few seconds</CENTER>'; | |||
| } else if (isset($_POST['logout'])){ | |||
| session_unset(); | |||
| session_destroy(); | |||
| header("refresh:2;url=index.php"); | |||
| echo '<CENTER>You have been logged out ...<BR />Returning to login screen in a few seconds</CENTER>'; | |||
| } else { | |||
| echo '<CENTER>Something went wrong, you haven\'t been logged out!<BR /><BR />Please click <A HREF="logout.php" CLASS="navlink">HERE</A> to try again</CENTER>'; | |||
| } | |||
| include_once ('footer.php'); | |||
| ?> | |||
| @@ -0,0 +1,75 @@ | |||
| <?php | |||
| $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 '<h3>Set preferred account & character, or change e-mail or password</h3>'; | |||
| // select which GW account you want to default to | |||
| echo '<form action="preferences.php" method="post"><table border="1"><caption style="white-space: nowrap; overflow: hidden;">Current preferred account: <b>' .$_SESSION['prefaccname'] . '</b></caption>'; | |||
| echo '<tr><td><select name="prefaccid">'; | |||
| echo '<option value="nopref">Prefer no default</option>'; | |||
| $prefacc = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE userid = ?"); | |||
| $prefacc->bind_param("i", $_SESSION['userid']); | |||
| $prefacc->execute(); | |||
| $resacc = $prefacc->get_result(); | |||
| while ($row = $resacc->fetch_assoc()) { | |||
| echo '<option value="' . $row['accid'] . '">' . $row['accemail'] . '</option>'; | |||
| } | |||
| echo '</td><td><input type="submit" value="Set account"></td></tr></select></table><input type="hidden" name="setacc" value="update"></form><br />'; | |||
| // select which character from your GW account you want to default to | |||
| echo '<form action="preferences.php" method="post"><table border="1"><caption style="white-space: nowrap; overflow: hidden;">Current preferred character: <b>' .$_SESSION['prefcharname'] . '</b></caption>'; | |||
| echo '<tr><td><select name="prefcharid">'; | |||
| echo '<option value="nopref">Prefer no default</option>'; | |||
| $prefchar = $con->prepare("SELECT charid, charname FROM gwchars WHERE accid = ? AND userid = ?"); | |||
| $prefchar->bind_param("ii", $_SESSION['prefaccid'], $_SESSION['userid']); | |||
| $prefchar->execute(); | |||
| $reschar = $prefchar->get_result(); | |||
| while ($row2 = $reschar->fetch_assoc()) { | |||
| echo '<option value="' . $row2['charid'] . '">' . $row2['charname'] . '</option>'; | |||
| } | |||
| echo '</td><td><input type="submit" value="Set character"></td></tr></select></table><input type="hidden" name="setchar" value="updatechar"></form><br />'; | |||
| // update e-mail address form | |||
| echo '<form action="preferences.php" method="post"><table border="1">'; | |||
| echo '<caption>Update e-mail address</caption>'; | |||
| echo '<tr><td><input type="text" name="useremail" value="' . $_SESSION['usermail'] . '"></td><td><input type="submit" value="Update e-mail"></td></tr>'; | |||
| echo '</table></form><br /><br />'; | |||
| // update password form | |||
| echo <<<UPDPASS | |||
| <form action="preferences.php" method="post"><table border="1"> | |||
| <tr><th>Old Password</th><tr> | |||
| <tr><td><input type="password" name="oldpass" required></td></tr> | |||
| <tr><th>New password</th></tr> | |||
| <tr><td><input type="password" required="required" name="userpass1" id="up1"></td></tr> | |||
| <tr><th>Verify password</th></tr> | |||
| <tr><td><input type="password" required="required" name="userpass2" id="up2"></td></tr> | |||
| </table><script type="text/javascript"> | |||
| function Validate() { | |||
| var userpass1 = document.getElementById("up1").value; | |||
| var userpass2 = document.getElementById("up2").value; | |||
| if (userpass1 != userpass2) { | |||
| alert("Passwords do not match."); | |||
| return false; | |||
| } | |||
| return true; | |||
| } | |||
| </script> | |||
| <input type="submit" name="submission" value="Update password" onclick="return Validate()" id="btnSubmit"></form> | |||
| UPDPASS; | |||
| } | |||
| include_once ('footer.php'); | |||
| ?> | |||
| @@ -0,0 +1,32 @@ | |||
| <!DOCTYPE html> | |||
| <html> | |||
| <head> | |||
| <link rel="stylesheet" type="text/css" href="style.css"> | |||
| <?php | |||
| if (session_status() == PHP_SESSION_NONE) { | |||
| session_start(); | |||
| } | |||
| include_once ('connect.php'); | |||
| $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 (empty($_POST['reguser'])){ | |||
| // this block contains the code to fill out the form | |||
| echo '<center>'; | |||
| include_once ('includes/account-registration.php'); | |||
| echo '</center><br />'; | |||
| } 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 '<center>Account created, please <a href="index.php">login</a> to continue<br /><br />'; | |||
| session_destroy(); | |||
| exit(); | |||
| } | |||
| echo '<center>Back to <a href="index.php" class="navlink">home page</a><br />'; | |||
| include_once ('footer.php'); | |||
| ?> | |||
| @@ -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; | |||
| @@ -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; | |||
| } | |||
| } | |||
| 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; } | |||
| @@ -0,0 +1,91 @@ | |||
| <?php | |||
| $pagetitle = "Title Editor"; | |||
| 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']); | |||
| } | |||
| } | |||
| if ($_SESSION['admin'] == 1) { | |||
| echo '<br />'; | |||
| 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 <form action="titlemanager.php" method="post"><input type="hidden" name="title" value="addtitle"><input type="submit" value="Add title"></form><br />'; | |||
| echo 'Modify titles <form action="titlemanager.php" method="post"><input type="hidden" name="title" value="modtitle"><select name="tid" onchange="this.form.submit()"><option selected disabled>Select title</option>'; | |||
| include ('includes/title-select.php'); | |||
| echo '</select><noscript><input type="submit" value="Modify Title"></noscript></form><br /><br />'; | |||
| echo 'Add or modify title ranks and points <form action="titlemanager.php" method="post"><input type="hidden" name="title" value="addsubtitle"><select name="tid" onchange="this.form.submit()"><option selected disabled>Add title rank(s)</option>'; | |||
| include ('includes/title-select.php'); | |||
| echo '</select><noscript><input type="submit" value="Add title rank"></noscript></form><br /><br />'; | |||
| // 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:<br />'; | |||
| echo '<table border="1"><tr><th>titleid</th><th>titlename</th><th>titletype</th><th>titletype</th><th>autofilled</th><th>autofilled</th></tr>'; | |||
| $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 '<tr><td>' . $tid . '</td><td>' . $tname . ' (' . $tmr . ')</td><td>' . $ttype . '</td><td>'; | |||
| 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 '</td><td>' . $taf . '</td><td>'; | |||
| 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 '</td></tr>'; | |||
| } | |||
| $stmtview->close(); | |||
| echo '</table><br />If anything looks off, please fix it!<br /><br />'; | |||
| } | |||
| } | |||
| } | |||
| include_once ('footer.php'); | |||
| ?> | |||
| @@ -0,0 +1,39 @@ | |||
| <?php | |||
| $pagetitle = "Update account wide stats"; | |||
| include_once ('header.php'); | |||
| 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'); | |||
| } | |||
| if ($_POST['acctitle'] == "notselected") { | |||
| echo '<form action="updateaccountstats.php" method="post">'; | |||
| echo 'Select account title to update: <select name="acctitle" onchange="this.form.submit()">'; | |||
| // $ats = Account Title Select | |||
| $ats = $con->prepare("SELECT titlenameid, titlename FROM gwtitles WHERE titletype = 0 ORDER BY titlename"); | |||
| $ats->execute(); | |||
| $result = $ats->get_result(); | |||
| while ($row = $result->fetch_assoc()) { | |||
| echo '<option value="' . $row['titlenameid'] . '">' . $row['titlename'] . '</option>'; | |||
| } | |||
| echo '</select><input type="submit" value="Select title"></form><br />'; | |||
| $ats->close(); | |||
| } else { | |||
| echo '<form action="updateaccountstats.php" method="post"><input type="hidden" name="titlenameid" value="' . $_POST['acctitle'] .'">'; | |||
| echo '<input type="number" name="titlepoints" required autofocus><input type="submit" value="Update points"></form>'; | |||
| } | |||
| echo 'Current account stats for: <b>' . $_SESSION['prefaccname'] . '</b><br />'; | |||
| include_once ('includes/getaccountstats.php'); | |||
| echo 'Return to your <a href="index.php" class="navlink">user</a> page<br />'; | |||
| } | |||
| include_once ('footer.php'); | |||
| ?> | |||
| @@ -0,0 +1,39 @@ | |||
| <?php | |||
| $pagetitle = "Update character stats"; | |||
| include_once ('header.php'); | |||
| 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'); | |||
| } | |||
| if ($_POST['chartitle'] == "notselected") { | |||
| echo '<form action="updatecharstats.php" method="post">'; | |||
| echo 'Select character title to update: <select name="chartitle" onchange="this.form.submit()">'; | |||
| // $cts = Character Title Select | |||
| $cts = $con->prepare("SELECT titlenameid, titlename FROM gwtitles WHERE titletype = 1 AND autofilled = 0 ORDER BY titlename"); | |||
| $cts->execute(); | |||
| $result = $cts->get_result(); | |||
| while ($row = $result->fetch_assoc()) { | |||
| echo '<option value="' . $row['titlenameid'] . '">' . $row['titlename'] . '</option>'; | |||
| } | |||
| echo '</select><input type="submit" value="Select title"></form><br />'; | |||
| $cts->close(); | |||
| } else { | |||
| echo '<form action="updatecharstats.php" method="post"><input type="hidden" name="titlenameid" value="' . $_POST['chartitle'] .'">'; | |||
| echo '<input type="number" step="0.1" name="titlepoints" required autofocus><noscript><input type="submit" value="Update points"></noscript></form>'; | |||
| } | |||
| echo 'Current character stats for: <b>' . $_SESSION['prefcharname'] . '</b><br />'; | |||
| include_once ('includes/getcharstats.php'); | |||
| echo 'Return to your <a href="index.php" class="navlink">user</a> page<br />'; | |||
| } | |||
| include_once ('footer.php'); | |||
| ?> | |||