delAccount.php 1.5 KB

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