delAccount.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. if (file_exists("config.php")) {
  3. include 'config.php';
  4. } else {
  5. die("config.php must exist within the installation root folder!");
  6. }
  7. // Deletes passed in user account from database
  8. // Unless the actual delete command fails, success should be 1... we don't care if the account doesn't exist.
  9. $success = 1;
  10. $errorCount = 0;
  11. if (isset($errors)) {
  12. unset($errors);
  13. }
  14. if (isset($_GET['username'])) {
  15. $userToDelete = $_GET['username'];
  16. }
  17. if (!isset($userToDelete)) {
  18. $errorCount++;
  19. $errors[] = "No username was passed to the form.";
  20. } else {
  21. $SQL = "SELECT ftpusername FROM ftpaccounts WHERE ftpusername = '$userToDelete'";
  22. $Result = mysql_query($SQL, $connection);
  23. if ($Result !== FALSE) {
  24. $row = mysql_fetch_row($Result);
  25. $unameDeleted = $row[0];
  26. }
  27. if (isset($unameDeleted)) {
  28. $SQL = "DELETE FROM ftpaccounts WHERE ftpusername = '$userToDelete'";
  29. $Result = mysql_query($SQL, $connection);
  30. if ($Result !== FALSE) {
  31. if ($unameDeleted === "none") {
  32. $errorCount++;
  33. $errors[] = "The specified user $userToDelete does not exist within the databse. No actions were taken!";
  34. } else {
  35. $success = 1;
  36. }
  37. } else {
  38. $errorCount++;
  39. $errors[] = "Error code " . mysql_errno($connection) . ": " . mysql_error($connection);
  40. $success = 0;
  41. }
  42. }
  43. }
  44. // Log errors
  45. if ($errorCount > 0) {
  46. addToLog($errors);
  47. }
  48. // Return value:
  49. echo $success;
  50. ?>