Guild Wars stat tracking The idea behind this is to track multiple characters individual stats as well as account stats.
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

84 righe
3.5 KiB

  1. <?php
  2. $pagetitle = "Add a Guild Wars account to track";
  3. include_once ('header.php');
  4. # delete this block when shit finally works.
  5. ini_set('display_errors', 'on');
  6. error_reporting(E_ALL);
  7. mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
  8. # delete the above when shit finally works
  9. if (!empty($_POST['accemail'])) {
  10. $addacc = $con->prepare("INSERT INTO gwaccounts (userid, accemail) VALUES (?, ?)");
  11. $addacc->bind_param("is", $_SESSION['userid'], $_POST['accemail']);
  12. $addacc->execute();
  13. $addacc->close();
  14. echo 'New account added, returning to editor.';
  15. header ("Refresh:1; url=addaccounts.php");
  16. exit();
  17. }
  18. if (!empty($_POST['delchar'])) {
  19. echo 'removing selected character(s) from selected account<br />';
  20. if ($delchar = $con->prepare("DELETE FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?")) {
  21. $delchar->bind_param("iii", $delcharid, $delaccid, $_SESSION['userid']);
  22. for ($i = 0; $i < count($_POST['delchar']); $i++) {
  23. $delcharid = $_POST['charid'][$i];
  24. $delaccid = $_POST['accid'][$i];
  25. $delchar->execute();
  26. }
  27. $delchar->close();
  28. }
  29. $nap = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?");
  30. $nap->bind_param("i", $_SESSION['userid']);
  31. $nap->execute();
  32. $nap->close();
  33. $_SESSION['prefcharid'] = "0";
  34. $_SESSION['prefcharname'] = "No default selected";
  35. echo 'Character deleted - no preferred character selected.<br /><br />';
  36. }
  37. echo '<form action="addaccounts.php" method="post"><table>';
  38. echo '<caption>Add a new Guild Wars account e-mail or alias</caption>';
  39. echo '<tr><td><input type="text" name="accemail" size="35" required></td><td><input type="submit" value="Add account"></td></tr>';
  40. echo '</table></form><br />';
  41. echo '<table border="1"><caption style="white-space: nowrap; overflow: hidden;">Current Guild Wars accounts</caption>';
  42. echo '<tr><th>Account name</th></tr>';
  43. // grab account name from database and loop it in here as a read only bit
  44. $acclist = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE userid = ?");
  45. $acclist->bind_param("i", $_SESSION['userid']);
  46. $acclist->execute();
  47. $result = $acclist->get_result();
  48. while ($row = $result->fetch_assoc()) {
  49. echo '<tr><td>';
  50. if ($row['accid'] == $_SESSION['prefaccid']) {
  51. echo '<b>' . $row['accemail'] . '</b>';
  52. } else {
  53. echo $row['accemail'];
  54. }
  55. echo '</td></tr>';
  56. }
  57. $acclist->close();
  58. echo '</table><br />';
  59. echo '<form action="addaccounts.php" method="post"><table border="1"><caption style="white-space: nowrap; overflow: hidden;">Available characters</caption>';
  60. echo '<tr><td>charid</td><td>accid</td><td>charname</td><td>Delete?</td></tr>';
  61. $lc = $con->prepare("SELECT charid, accid, charname FROM gwchars WHERE accid = ?");
  62. $lc->bind_param("i", $_SESSION['prefaccid']);
  63. $lc->execute();
  64. $res2 = $lc->get_result();
  65. while ($row2 = $res2->fetch_assoc()) {
  66. echo '<tr><td><input type="text" readonly size="4" name="charid[]" value="' . $row2['charid'] . '"></td>';
  67. echo '<td><input type="text" readonly size="4" name=accid[]" value="' . $row2['accid'] . '"</td><td>';
  68. if ($row2['charid'] == $_SESSION['prefcharid']) {
  69. echo '<b>' . $row2['charname'] . '</b>';
  70. } else {
  71. echo $row2['charname'];
  72. }
  73. echo '</td><td><input type="checkbox" name="delchar[]" value="' . $row2['charid'] . '"></td></tr>';
  74. }
  75. echo '</table><input type="submit" value="Delete selected characters"></form><br />';
  76. echo '<br />Return to your <a href="index.php" class="navlink">user</a> page';
  77. include_once ('footer.php');
  78. ?>