Browse Source

added account selector to header

pull/16/head
mauirixxx 7 years ago
parent
commit
8c4e34b764
5 changed files with 101 additions and 79 deletions
  1. +13
    -0
      header-list-accounts.php
  2. +12
    -3
      header.php
  3. +67
    -75
      preferences.php
  4. +6
    -0
      style.css
  5. +3
    -1
      updatecharstats.php

+ 13
- 0
header-list-accounts.php View File

@@ -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();
}
?>

+ 12
- 3
header.php View File

@@ -26,6 +26,10 @@ if (!$userid){
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');
@@ -35,10 +39,15 @@ if (!$userid){
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>) (<select name="prefcharid" onchange="this.form.submit()">';
echo '<option class="profession-' . $_SESSION['charprofid'] . '" value="' . $_SESSION['prefcharid'] . '">' . $_SESSION['prefcharname'] . '</option>';
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="Select Character"></noscript></form><hr><br / >';
echo '</select>)<noscript><input type="submit" value="Preferrence"></noscript> (<a href="logout.php?action=logout" class="navlink">Logout ' . $_SESSION['username'] . '</a>)</form><hr><br / >';
}
?>

+ 67
- 75
preferences.php View File

@@ -2,83 +2,75 @@
$pagetitle = "Account options";
include_once ('header.php');
if (isset($_SESSION['userid'])){
if (!empty($_POST['useremail'])) {
//this section contains code to update the users e-mail address
include_once ('includes/update-email.php');
}

if (!empty($_POST['oldpass'])) {
// this section contains code to update the users password after verifying the old password first
include_once ('includes/update-password.php');
}

if (!empty($_POST['setacc'])) {
//this section contains code to set the users preferred game account
include_once ('includes/set-prefacc.php');
}

if (!empty($_POST['setchar'])) {
//this section contains code to the users preferred character
include_once ('includes/set-prefchar.php');
}

echo '<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;
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;
}
return true;
</script>
<input type="submit" name="submission" value="Update password" onclick="return Validate()" id="btnSubmit"></form>
UPDPASS;
}
</script>
<input type="submit" name="submission" value="Update password" onclick="return Validate()" id="btnSubmit"></form>
UPDPASS;
}
include_once ('footer.php');
?>

+ 6
- 0
style.css View File

@@ -70,6 +70,12 @@ submitLink:focus {
.percentbar { background:#CCCCCC; border:1px solid #666666; height:10px; }
.percentbar div { background: #28B8C0; height: 10px; }

select.header {
/*background: rgb(255, 255, 255);
background: rgba(255, 255, 255, 0.2);*/
color: red;
}

select *.profession-0 { background-color: #FFF; }
select *.profession-1 { background-color: #FF8; }
select *.profession-2 { background-color: #CF9; }


+ 3
- 1
updatecharstats.php View File

@@ -1,6 +1,8 @@
<?php
$pagetitle = "Update character stats";
include_once ('header.php');
echo 'Return to your <a href="index.php" class="navlink">user</a> page';
if (isset($_SESSION['userid'])) {
echo 'Return to your <a href="index.php" class="navlink">user</a> page';
}
include_once ('footer.php');
?>

Loading…
Cancel
Save