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.
 
 
 
 
 

98 linhas
4.2 KiB

  1. <?php
  2. $pagetitle = "Add a Guild Wars account to track";
  3. include_once ('header.php');
  4. if (isset($_SESSION['userid'])){
  5. if (!empty($_POST['accemail'])) {
  6. $addacc = $con->prepare("INSERT INTO gwaccounts (userid, accemail) VALUES (?, ?)");
  7. $addacc->bind_param("is", $_SESSION['userid'], $_POST['accemail']);
  8. $addacc->execute();
  9. $addacc->close();
  10. echo 'New account added, returning to editor.';
  11. header ("Refresh:1; url=addaccounts.php");
  12. exit();
  13. }
  14. if (!empty($_POST['delchar'])) {
  15. echo 'removing selected character(s) from selected account<br />';
  16. if ($delchar = $con->prepare("DELETE FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?")) {
  17. $delchar->bind_param("iii", $delcharid, $delaccid, $_SESSION['userid']);
  18. for ($i = 0; $i < count($_POST['delchar']); $i++) {
  19. $delcharid = $_POST['charid'][$i];
  20. $delaccid = $_POST['accid'][$i];
  21. $delchar->execute();
  22. }
  23. $delchar->close();
  24. }
  25. $nap = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?");
  26. $nap->bind_param("i", $_SESSION['userid']);
  27. $nap->execute();
  28. $nap->close();
  29. $_SESSION['prefcharid'] = "0";
  30. $_SESSION['prefcharname'] = "No default selected";
  31. echo 'Character deleted - no preferred character selected.<br /><br />';
  32. }
  33. if (!empty($_POST['newcharname'])) {
  34. include_once ('includes/addcharacters-submit.php');
  35. }
  36. echo '<form action="addaccounts.php" method="post"><table>';
  37. echo '<caption>Add a new Guild Wars account e-mail or alias</caption>';
  38. echo '<tr><td><input type="text" name="accemail" size="35" required></td><td><input type="submit" value="Add account"></td></tr>';
  39. echo '</table></form><br />';
  40. echo '<table border="1"><caption style="white-space: nowrap; overflow: hidden;">Current Guild Wars accounts</caption>';
  41. echo '<tr><th>Account name</th></tr>';
  42. $acclist = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE userid = ?");
  43. $acclist->bind_param("i", $_SESSION['userid']);
  44. $acclist->execute();
  45. $result = $acclist->get_result();
  46. while ($row = $result->fetch_assoc()) {
  47. echo '<tr><td>';
  48. if ($row['accid'] == $_SESSION['prefaccid']) {
  49. echo '<b>' . $row['accemail'] . '</b>';
  50. } else {
  51. echo $row['accemail'];
  52. }
  53. echo '</td></tr>';
  54. }
  55. $acclist->close();
  56. echo '</table><br />';
  57. // add characters here
  58. echo '<form action="addaccounts.php" method="post"><table>';
  59. echo '<caption style="white-space: nowrap; overflow: hidden;">Add character to account: ' . $_SESSION['prefaccname'] . '</caption>';
  60. echo '<tr><th>Character name</th><th>Birthdate</th><th>Profession</th></tr>';
  61. 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>';
  62. // $gp = Get Profession
  63. $gp = $con->prepare("SELECT profid, profession FROM gwprofessions");
  64. $gp->execute();
  65. $result = $gp->get_result();
  66. while ($row = $result->fetch_assoc()) {
  67. echo '<option value=' . $row['profid'] . '>' . $row['profession'] . '</option>';
  68. }
  69. echo '</td></tr>';
  70. echo '<tr><td colspan="3"><input type="submit" value="Add character"></td></tr></table></form><br />';
  71. echo '<form action="addaccounts.php" method="post"><table border="1"><caption style="white-space: nowrap; overflow: hidden;">Available characters</caption>';
  72. echo '<tr><td>charid</td><td>accid</td><td>charname</td><td>Delete?</td></tr>';
  73. $lc = $con->prepare("SELECT charid, accid, charname FROM gwchars WHERE accid = ?");
  74. $lc->bind_param("i", $_SESSION['prefaccid']);
  75. $lc->execute();
  76. $res2 = $lc->get_result();
  77. while ($row2 = $res2->fetch_assoc()) {
  78. echo '<tr><td><input type="text" readonly size="4" name="charid[]" value="' . $row2['charid'] . '"></td>';
  79. echo '<td><input type="text" readonly size="4" name=accid[]" value="' . $row2['accid'] . '"</td><td>';
  80. if ($row2['charid'] == $_SESSION['prefcharid']) {
  81. echo '<b>' . $row2['charname'] . '</b>';
  82. } else {
  83. echo $row2['charname'];
  84. }
  85. echo '</td><td><input type="checkbox" name="delchar[]" value="' . $row2['charid'] . '"></td></tr>';
  86. }
  87. echo '</table><input type="submit" value="Delete selected characters"></form><br />';
  88. echo '<br />Return to your <a href="index.php" class="navlink">user</a> page';
  89. }
  90. include_once ('footer.php');
  91. ?>