set_permissions.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. # echo $_POST["oldpasswd"];
  3. # echo $_POST["username"];
  4. # echo $_POST["path"];
  5. if( $_POST["oldpasswd"] != "ja5ooYiPec8sheic9eeboothoo9auTie")
  6. {
  7. echo "wrong pass";
  8. # die;
  9. }
  10. # sudo chown root /home/share/vsftpd/passwd
  11. #exec ("/usr/bin/sudo chown root /home/share/vsftpd/passwd");
  12. if( isset( $_POST["fixpermissions"]))
  13. {
  14. exec ("/usr/bin/sudo /bin/chown root /home/share/vsftpd/passwd /home/share/vsftpd/users/*");
  15. echo "permissions fixed";
  16. die;
  17. }
  18. if( isset( $_POST["write"]) ){
  19. $stringData = "write_enable=YES\n";
  20. }
  21. else {
  22. $stringData = "write_enable=NO\n";
  23. }
  24. # File formart
  25. # write_enable=YES
  26. # local_root=/home/share/write/public
  27. # xferlog_file=/home/share/vsftpd/log/madhu
  28. #
  29. $myFile = "/home/share/vsftpd/users/".$_POST["username"];
  30. $fh = fopen($myFile, 'w') or die("can't open file");
  31. echo "creating ".$myFile." with content:<br/>";
  32. fwrite($fh, $stringData);
  33. echo $stringData."<br/>\n";
  34. $stringData = "local_root=/home/share/".$_POST["path"]."/\n";
  35. fwrite($fh, $stringData);
  36. echo $stringData."<br/>\n";
  37. #$stringData = "xferlog_file=/home/share/vsftpd/log/".$_POST["username"].".log\n";
  38. #fwrite($fh, $stringData);
  39. #echo $stringData."<br/>\n";
  40. fclose($fh);
  41. exec ("/bin/chmod 660 /home/share/vsftpd/users/".$_POST["username"]);
  42. exec ("/usr/bin/sudo /bin/chown root /home/share/vsftpd/passwd /home/share/vsftpd/users/*");
  43. ?>