Guild Wars stat tracking The idea behind this is to track multiple characters individual stats as well as account stats.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

103 linhas
4.4 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. if (!empty($_POST['newcharname'])) {
  38. include_once ('includes/addcharacters-submit.php');
  39. }
  40. echo '<form action="addaccounts.php" method="post"><table>';
  41. echo '<caption>Add a new Guild Wars account e-mail or alias</caption>';
  42. echo '<tr><td><input type="text" name="accemail" size="35" required></td><td><input type="submit" value="Add account"></td></tr>';
  43. echo '</table></form><br />';
  44. echo '<table border="1"><caption style="white-space: nowrap; overflow: hidden;">Current Guild Wars accounts</caption>';
  45. echo '<tr><th>Account name</th></tr>';
  46. // grab account name from database and loop it in here as a read only bit
  47. $acclist = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE userid = ?");
  48. $acclist->bind_param("i", $_SESSION['userid']);
  49. $acclist->execute();
  50. $result = $acclist->get_result();
  51. while ($row = $result->fetch_assoc()) {
  52. echo '<tr><td>';
  53. if ($row['accid'] == $_SESSION['prefaccid']) {
  54. echo '<b>' . $row['accemail'] . '</b>';
  55. } else {
  56. echo $row['accemail'];
  57. }
  58. echo '</td></tr>';
  59. }
  60. $acclist->close();
  61. echo '</table><br />';
  62. // add characters here
  63. echo '<form action="addaccounts.php" method="post"><table>';
  64. echo '<caption style="white-space: nowrap; overflow: hidden;">Add character to account: ' . $_SESSION['prefaccname'] . '</caption>';
  65. echo '<tr><th>Character name</th><th>Birthdate</th><th>Profession</th></tr>';
  66. 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>';
  67. // $gp = Get Profession
  68. $gp = $con->prepare("SELECT profid, profession FROM gwprofessions");
  69. $gp->execute();
  70. $result = $gp->get_result();
  71. while ($row = $result->fetch_assoc()) {
  72. echo '<option value=' . $row['profid'] . '>' . $row['profession'] . '</option>';
  73. }
  74. echo '</td></tr>';
  75. echo '<tr><td colspan="3"><input type="submit" value="Add character"></td></tr></table></form><br />';
  76. echo '<form action="addaccounts.php" method="post"><table border="1"><caption style="white-space: nowrap; overflow: hidden;">Available characters</caption>';
  77. echo '<tr><td>charid</td><td>accid</td><td>charname</td><td>Delete?</td></tr>';
  78. $lc = $con->prepare("SELECT charid, accid, charname FROM gwchars WHERE accid = ?");
  79. $lc->bind_param("i", $_SESSION['prefaccid']);
  80. $lc->execute();
  81. $res2 = $lc->get_result();
  82. while ($row2 = $res2->fetch_assoc()) {
  83. echo '<tr><td><input type="text" readonly size="4" name="charid[]" value="' . $row2['charid'] . '"></td>';
  84. echo '<td><input type="text" readonly size="4" name=accid[]" value="' . $row2['accid'] . '"</td><td>';
  85. if ($row2['charid'] == $_SESSION['prefcharid']) {
  86. echo '<b>' . $row2['charname'] . '</b>';
  87. } else {
  88. echo $row2['charname'];
  89. }
  90. echo '</td><td><input type="checkbox" name="delchar[]" value="' . $row2['charid'] . '"></td></tr>';
  91. }
  92. echo '</table><input type="submit" value="Delete selected characters"></form><br />';
  93. echo '<br />Return to your <a href="index.php" class="navlink">user</a> page';
  94. include_once ('footer.php');
  95. ?>