| @@ -19,6 +19,11 @@ if (isset($_SESSION['userid'])) { | |||||
| // this section contains the code to add a new game account to track | // this section contains the code to add a new game account to track | ||||
| include_once ('includes/addaccount-submit.php'); | include_once ('includes/addaccount-submit.php'); | ||||
| } | } | ||||
| if (!empty($_POST['delaccid'])) { | |||||
| // this section containts the code to delete an account | |||||
| include_once ('includes/del-account.php'); | |||||
| } | |||||
| if (!empty($_POST['delcharid'])) { | if (!empty($_POST['delcharid'])) { | ||||
| // this section contains code to delete the selected characters | // this section contains code to delete the selected characters | ||||
| @@ -35,8 +40,8 @@ if (isset($_SESSION['userid'])) { | |||||
| echo '<tr><td><input type="text" name="accemail" size="35" required></td><td><input type="submit" value="Add account"></td></tr>'; | 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></form><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>'; | |||||
| echo '<form action="addaccounts.php" method="post"><table border="1"><caption style="white-space: nowrap; overflow: hidden;">Current Guild Wars accounts</caption>'; | |||||
| echo '<tr><th>Account name</th><th>Preferred?</th><th>Delete ?</th></tr>'; | |||||
| $acclist = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE userid = ?"); | $acclist = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE userid = ?"); | ||||
| $acclist->bind_param("i", $_SESSION['userid']); | $acclist->bind_param("i", $_SESSION['userid']); | ||||
| $acclist->execute(); | $acclist->execute(); | ||||
| @@ -47,10 +52,11 @@ if (isset($_SESSION['userid'])) { | |||||
| if ($row['accid'] == $_SESSION['prefaccid']) { | if ($row['accid'] == $_SESSION['prefaccid']) { | ||||
| echo ' checked'; | echo ' checked'; | ||||
| } | } | ||||
| echo '></div></td></tr>'; | |||||
| //delete account array in delaccid[] | |||||
| echo '></div></td><td><input type="checkbox" name="delaccid[]" value="' . $row['accid'] . '"></td></tr>'; | |||||
| } | } | ||||
| $acclist->close(); | $acclist->close(); | ||||
| echo '</form></table><br />'; | |||||
| echo '</form></table><input type="submit" value="Modify selected accounts"></form><br />'; | |||||
| // add characters here | // add characters here | ||||
| echo '<form action="addaccounts.php" method="post"><table>'; | echo '<form action="addaccounts.php" method="post"><table>'; | ||||
| @@ -6,7 +6,8 @@ if (isset($_SESSION['userid'])){ | |||||
| unset($_SESSION['tid']); | unset($_SESSION['tid']); | ||||
| echo '<center>Welcome to the admin area!<br /><br />'; | echo '<center>Welcome to the admin area!<br /><br />'; | ||||
| echo 'Title creator / editor <a href="titlemanager.php" class="navlink">here</a> (work in progress)<br /><br />'; | echo 'Title creator / editor <a href="titlemanager.php" class="navlink">here</a> (work in progress)<br /><br />'; | ||||
| echo 'User editor <a href="" class="navlink">here</a> (not working yet)<br />'; | |||||
| echo 'User editor <a href="" class="navlink">here</a> (not working yet)<br /><br />'; | |||||
| include_once ('includes/session-dump.php'); | |||||
| } | } | ||||
| include_once ('footer.php'); | include_once ('footer.php'); | ||||
| ?> | ?> | ||||
| @@ -0,0 +1,49 @@ | |||||
| <?php | |||||
| if (isset($_SESSION['userid'])) { | |||||
| // get all the character id's related to the selected account id's | |||||
| // $gci = Get Character ID's | |||||
| $gaccid = implode(", ", $_POST['delaccid']); | |||||
| $gci = $con->prepare("SELECT charid, accid FROM gwchars WHERE accid IN ($gaccid) AND userid = ?"); | |||||
| $gci->bind_param("i", $_SESSION['userid']); | |||||
| $gci->execute(); | |||||
| $gciresults = $gci->get_result(); | |||||
| while ($gcirow = $gciresults->fetch_assoc()) { | |||||
| $delchar = $con->prepare("DELETE FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?"); | |||||
| $delchar->bind_param("iii", $gcirow['charid'], $gcirow['accid'], $_SESSION['userid']); | |||||
| $delchar->execute(); | |||||
| $delchar->close(); | |||||
| // $dac = Delete Account Stats | |||||
| $dac = $con->prepare("DELETE FROM gwaccstats WHERE accid = ? AND userid = ?"); | |||||
| $dac->bind_param("ii", $gcirow['accid'], $_SESSION['userid']); | |||||
| $dac->execute(); | |||||
| $dac->close();/* | |||||
| // $dcs = Delete Character Stats | |||||
| $dcs = $con->prepare("DELETE FROM gwcharstats WHERE charid = ? AND accid = ? AND userid = ?"); | |||||
| $dcs->bind_param("iii", $gcirow['charid'], $gcirow['accid'], $_SESSION['userid']); | |||||
| $dcs->execute(); | |||||
| $dcs->close(); */ | |||||
| } | |||||
| $gci->close(); | |||||
| //this should be the last SQL query to run! | |||||
| $delacc = $con->prepare("DELETE FROM gwaccounts WHERE accid IN ($gaccid) AND userid = ?"); | |||||
| $delacc->bind_param("i", $_SESSION['userid']); | |||||
| $delacc->execute(); | |||||
| $delacc->close(); | |||||
| // $nap = No Account Preference | |||||
| $nap = $con->prepare("UPDATE userinfo SET prefaccid = 0, prefaccname = 'No default selected' WHERE userid = ?"); | |||||
| $nap->bind_param("i", $_SESSION['userid']); | |||||
| $nap->execute(); | |||||
| $nap->close(); | |||||
| $_SESSION['prefaccid'] = "0"; | |||||
| $_SESSION['preaccname'] = "No default selected"; | |||||
| echo 'Account(s) deleted - no preferred account selected.<br /><br />'; | |||||
| // $ncp = No Character Preference | |||||
| $ncp = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?"); | |||||
| $ncp->bind_param("i", $_SESSION['userid']); | |||||
| $ncp->execute(); | |||||
| $ncp->close(); | |||||
| $_SESSION['prefcharid'] = "0"; | |||||
| $_SESSION['prefcharname'] = "No default selected"; | |||||
| echo 'All characters related to the account have been deleted - no preferred character selected.<br /><br />'; | |||||
| } | |||||
| ?> | |||||