Parcourir la source

character selection QoL improvements and other stuff

pull/16/head
mauirixxx il y a 7 ans
Parent
révision
66ba0e2580
10 fichiers modifiés avec 166 ajouts et 99 suppressions
  1. +77
    -84
      addaccounts.php
  2. +11
    -0
      includes/addaccount-submit.php
  3. +7
    -9
      includes/addcharacters-submit.php
  4. +21
    -0
      includes/del-character.php
  5. +23
    -0
      includes/getaccountstats.php
  6. +7
    -0
      includes/session-debug.php
  7. +4
    -0
      includes/session-dump.php
  8. +0
    -2
      preferences.php
  9. +9
    -3
      style.css
  10. +7
    -1
      updateaccountstats.php

+ 77
- 84
addaccounts.php Voir le fichier

@@ -1,98 +1,91 @@
<?php
$pagetitle = "Add a Guild Wars account to track";
include_once ('header.php');
if (isset($_SESSION['userid'])){
if (isset($_SESSION['userid'])) {
//include_once ('includes/session-debug.php');
//include_once ('includes/session-dump.php');
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'])) {
$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();
}
if (!empty($_POST['accemail'])) {
// this section contains the code to add a new game account to track
include_once ('includes/addaccount-submit.php');
}

if (!empty($_POST['delchar'])) {
echo 'removing selected character(s) from selected account<br />';
if ($delchar = $con->prepare("DELETE FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?")) {
$delchar->bind_param("iii", $delcharid, $delaccid, $_SESSION['userid']);
for ($i = 0; $i < count($_POST['delchar']); $i++) {
$delcharid = $_POST['charid'][$i];
$delaccid = $_POST['accid'][$i];
$delchar->execute();
}
$delchar->close();
if (!empty($_POST['delcharid'])) {
// this section contains code to delete the selected characters
include_once ('includes/del-character.php');
}
$nap = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?");
$nap->bind_param("i", $_SESSION['userid']);
$nap->execute();
$nap->close();
$_SESSION['prefcharid'] = "0";
$_SESSION['prefcharname'] = "No default selected";
echo 'Character deleted - no preferred character selected.<br /><br />';
}

if (!empty($_POST['newcharname'])) {
include_once ('includes/addcharacters-submit.php');
}
if (!empty($_POST['newcharname'])) {
// this section contains code to insert a new character into the database
include_once ('includes/addcharacters-submit.php');
}

echo '<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>';
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 '<table border="1"><caption style="white-space: nowrap; overflow: hidden;">Current Guild Wars accounts</caption>';
echo '<tr><th>Account name</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>';
if ($row['accid'] == $_SESSION['prefaccid']) {
echo '<b>' . $row['accemail'] . '</b>';
} else {
echo $row['accemail'];
}
echo '</td></tr>';
}
$acclist->close();
echo '</table><br />';
echo '<table border="1"><caption style="white-space: nowrap; overflow: hidden;">Current Guild Wars accounts</caption>';
echo '<tr><th>Account name</th><th>Preferred?</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><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';
}
echo '></div></td></tr>';
}
$acclist->close();
echo '</form></table><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 />';
// 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>Delete?</td></tr>';
$lc = $con->prepare("SELECT charid, accid, charname FROM gwchars WHERE accid = ?");
$lc->bind_param("i", $_SESSION['prefaccid']);
$lc->execute();
$res2 = $lc->get_result();
while ($row2 = $res2->fetch_assoc()) {
echo '<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><td>';
if ($row2['charid'] == $_SESSION['prefcharid']) {
echo '<b>' . $row2['charname'] . '</b>';
} else {
echo $row2['charname'];
}
echo '</td><td><input type="checkbox" name="delchar[]" value="' . $row2['charid'] . '"></td></tr>';
}
echo '</table><input type="submit" value="Delete selected characters"></form><br />';
echo '<br />Return to your <a href="index.php" class="navlink">user</a> page';
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');
?>

+ 11
- 0
includes/addaccount-submit.php Voir le fichier

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

+ 7
- 9
includes/addcharacters-submit.php Voir le fichier

@@ -1,15 +1,13 @@
<?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

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) VALUES (?, ?, ?, ?, ?)");
$ac->bind_param("iissi", $_SESSION['prefaccid'], $_SESSION['userid'], $_POST['newcharname'], $_POST['bdate'], $_POST['profid']);
$ac = $con->prepare("INSERT INTO gwchars (accid, userid, charname, birthdate, profid, profcolor) VALUES (?, ?, ?, ?, ?, ?)");
$ac->bind_param("iissis", $_SESSION['prefaccid'], $_SESSION['userid'], $_POST['newcharname'], $_POST['bdate'], $_POST['profid'], $profcolor);
$ac->execute();
$ac->close();
echo $_POST['newcharname'] . ' added to your account!<br /><br />';


+ 21
- 0
includes/del-character.php Voir le fichier

@@ -0,0 +1,21 @@
<?php
if (isset($_SESSION['userid'])) {
//echo 'removing selected character(s) from selected account<br />';
if ($delchar = $con->prepare("DELETE FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?")) {
$delchar->bind_param("iii", $delcharid, $delaccid, $_SESSION['userid']);
for ($i = 0; $i < count($_POST['delcharid']); $i++) {
$delcharid = $_POST['delcharid'][$i];
$delaccid = $_POST['accid'][$i];
$delchar->execute();
}
$delchar->close();
}
$nap = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?");
$nap->bind_param("i", $_SESSION['userid']);
$nap->execute();
$nap->close();
$_SESSION['prefcharid'] = "0";
$_SESSION['prefcharname'] = "No default selected";
echo 'Character(s) deleted - no preferred character selected.<br /><br />';
}
?>

+ 23
- 0
includes/getaccountstats.php Voir le fichier

@@ -0,0 +1,23 @@
<?php
echo '<table border="1"><caption>Account wide stats</caption>';
echo '<tr><th>Title Name</th><th>Title Points</th><th>Current Rank</th><th>Points Remaining</th><th>Next Rank</th></tr>';
// $gas = GetAccountStats
$gas = $con->prepare("SELECT * FROM gwaccstats WHERE userid = ? AND accid = ?;");
$gas->bind_param("ii", $_SESSION['prefaccid'], $_SESSION['userid']);
$gas->execute();
$result = $gas->get_result();
while ($row = $result->fetch_assoc()) {
echo '<tr><td>' . $row['currentstrankname'] . '</td><td>' . $row['titlepoints'] . '</td><td>' . $row['currentstrank'] . '</td>';
echo '<td>';
$pr = ($row['nextstrankpoints'] - $row['titlepoints']);
if ($pr < 0) {
echo 'Maximum rank achieved!';
} else {
echo $pr;
}
echo '</td>';
echo '<td>' . $row['nextstrank'] . '</td></tr>';
}
$gas->close();
echo '</table>';
?>

+ 7
- 0
includes/session-debug.php Voir le fichier

@@ -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
?>

+ 4
- 0
includes/session-dump.php Voir le fichier

@@ -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
- 2
preferences.php Voir le fichier

@@ -39,8 +39,6 @@ while ($row = $resacc->fetch_assoc()) {
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 'the session prefaccid is: ' . $_SESSION['prefaccid'] . '<br/>';
echo 'the session userid is: ' .$_SESSION['userid'] . '<br/>';
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>';


+ 9
- 3
style.css Voir le fichier

@@ -56,8 +56,14 @@ input {
text-align: center;
}

input[type=submit] {
background-color: #4CAF50;
.submitLink {
background-color: transparent;
text-decoration: underline;
border: none;
color: white;
color: #003366;
cursor: pointer;
}
submitLink:focus {
outline: none;
}
}

+ 7
- 1
updateaccountstats.php Voir le fichier

@@ -1,6 +1,12 @@
<?php
$pagetitle = "Update account wide stats";
include_once ('header.php');
echo 'Return to your <a href="index.php" class="navlink">user</a> page';
if (isset($_SESSION['userid'])) {
include_once ('includes/session-debug.php');
include_once ('includes/session-dump.php');
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';
}
include_once ('footer.php');
?>

Chargement…
Annuler
Enregistrer