delAccount.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 && countSQLResult($Result) == 1) {
  25. $row = getSQLRowArray($Result);
  26. $unameDeleted = $row[0];
  27. }else{
  28. $errorCount++;
  29. $errors[] = "The specified user $userToDelete does not exist within the databse. No actions were taken!";
  30. }
  31. if (isset($unameDeleted)) {
  32. $SQL = "DELETE FROM ftpaccounts WHERE ftpusername = '$userToDelete'";
  33. $Result = execSQL($SQL, $connection);
  34. if ($Result !== FALSE) {
  35. $success = 1;
  36. } else {
  37. $errorCount++;
  38. $errors[] = getSQLError($connection);
  39. $success = 0;
  40. }
  41. }
  42. }
  43. // Log errors
  44. if ($errorCount > 0) {
  45. addToLog($errors);
  46. }
  47. // Return value:
  48. echo $success;
  49. ?>