showAccount.php 1.8 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. if (isset($_GET['username'])) {
  15. $ftp_account = $_GET['username'];
  16. }
  17. if (!isset($connection)) {
  18. die("Problem setting up connection!");
  19. } else
  20. if (isset($ftp_account)) {
  21. $SQL = "SELECT ftpusername, homedir FROM ftpaccounts WHERE ftpusername = '$ftp_account'";
  22. $Result = mysql_query($SQL, $connection);
  23. if ($Result !== FALSE) {
  24. $count = mysql_num_rows($Result);
  25. if ($count == 1) {
  26. if ($row = mysql_fetch_assoc($Result)) {
  27. // Only show custom entries... do not allow to modify EHCP accounts.
  28. if (!empty($row['homedir'])) {
  29. $countNotNull++;
  30. $username = $row['ftpusername'];
  31. $dir = $row['homedir'];
  32. $user_details.= "Username" . " : " . $username . "\n";
  33. $user_details.= "Directory" . " : " . $dir . "\n";
  34. }
  35. }
  36. if ($countNotNull == 0) {
  37. $errorCount++;
  38. $errors[] = "There are no custom FTP accounts yet in the EHCP database!";
  39. }
  40. } else {
  41. $errorCount++;
  42. $errors[] = "No FTP accounts exist with the given username of $ftp_account";
  43. }
  44. } else {
  45. $errorCount++;
  46. $errors[] = "Error code " . mysql_errno($connection) . ": " . mysql_error($connection);
  47. }
  48. // Log errors
  49. if ($errorCount > 0) {
  50. addToLog($errors);
  51. }
  52. }
  53. // Return the user list
  54. echo $user_details;
  55. ?>