Guild Wars stat tracking The idea behind this is to track multiple characters individual stats as well as account stats.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

105 строки
4.5 KiB

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