showAccount.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. // Returns the information of ONE custom ftpuser
  3. // Only custom users are setup when tying into the EHCP FTP API
  4. $countNotNull = 0;
  5. $user_details = "";
  6. $success = 0;
  7. $errorCount = 0;
  8. if (isset($errors)) {
  9. unset($errors);
  10. }
  11. if (!isset($connection)) {
  12. include "config.php";
  13. }
  14. include_once 'db_functions.php';
  15. if (isset($_GET['username'])) {
  16. $ftp_account = $_GET['username'];
  17. }
  18. if (!isset($connection)) {
  19. die("Problem setting up connection!");
  20. } else
  21. if (isset($ftp_account)) {
  22. $SQL = "SELECT ftpusername, homedir FROM ftpaccounts WHERE ftpusername = '$ftp_account'";
  23. $Result = execSQL($SQL, $connection);
  24. if ($Result !== FALSE) {
  25. $count = countSQLResult($Result);
  26. if ($count == 1) {
  27. if ($row = getSQLRow($Result)) {
  28. // Only show custom entries... do not allow to modify EHCP accounts.
  29. if (!empty($row['homedir'])) {
  30. $countNotNull++;
  31. $username = $row['ftpusername'];
  32. $dir = $row['homedir'];
  33. $user_details.= "Username" . " : " . $username . "\n";
  34. $user_details.= "Directory" . " : " . $dir . "\n";
  35. }
  36. }
  37. if ($countNotNull == 0) {
  38. $errorCount++;
  39. $errors[] = "There are no custom FTP accounts yet in the EHCP database!";
  40. }
  41. } else {
  42. $errorCount++;
  43. $errors[] = "No FTP accounts exist with the given username of $ftp_account";
  44. }
  45. } else {
  46. $errorCount++;
  47. $errors[] = getSQLError($connection);
  48. $success = 0;
  49. }
  50. // Log errors
  51. if ($errorCount > 0) {
  52. addToLog($errors);
  53. }
  54. }
  55. // Return the user list
  56. echo $user_details;
  57. ?>