updatePass.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. // Updates ftpuser's password
  9. $success = 0;
  10. $errorCount = 0;
  11. if (isset($errors)) {
  12. unset($errors);
  13. }
  14. if (isset($_GET['username'])) {
  15. $ftp_username = $_GET['username'];
  16. }
  17. if (isset($_GET['password'])) {
  18. $ftp_pass = trim($_GET['password']);
  19. }
  20. if (!isset($ftp_username) || !isset($ftp_pass)) {
  21. $errorCount++;
  22. $errors[] = "No FTP accounts could be modified! Updated username and password were not sent by the OGP upload functions.";
  23. } else {
  24. if ($errorCount == 0) {
  25. // Security checks
  26. $ftp_password_db = escapeSQLStr($ftp_pass, $connection);
  27. $ftp_username_db = escapeSQLStr($ftp_username, $connection);
  28. $SQL = "SELECT * FROM ftpaccounts WHERE ftpusername = '$ftp_username_db'";
  29. $Result = execSQL($SQL, $connection);
  30. if ($Result !== FALSE) {
  31. $count = countSQLResult($Result);
  32. if ($count != 1) {
  33. $errorCount++;
  34. $errors[] = "The account information was not updated because the FTP username $ftp_old_username never existed in the first place and cannot be modified";
  35. } else {
  36. if ($row = getSQLRow($Result)) {
  37. $recordID = $row['id'];
  38. }
  39. // Update user's password data into DB:
  40. $SQL = "UPDATE ftpaccounts SET password=password('$ftp_password_db') WHERE ftpusername='$ftp_username_db'";
  41. $Result = execSQL($SQL, $connection);
  42. if ($Result !== FALSE) {
  43. $success = 1;
  44. } else {
  45. $errorCount++;
  46. $errors[] = getSQLError($connection);
  47. }
  48. }
  49. } else {
  50. $errorCount++;
  51. $errors[] = getSQLError($connection);
  52. }
  53. }
  54. }
  55. // Log errors
  56. if ($errorCount > 0) {
  57. addToLog($errors);
  58. }
  59. // Return value:
  60. echo $success;
  61. ?>