updatePass.php 2.2 KB

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