set_passwd_action.php 907 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. header('Content-Type: application/json; charset=UTF-8');
  3. if ($_SERVER['REQUEST_METHOD'] == "GET") {
  4. create();
  5. } else if ($_SERVER['REQUEST_METHOD'] == "POST") {
  6. create();
  7. }
  8. //
  9. function create() {
  10. $json = json_decode(file_get_contents("valid_info"), true);
  11. /*
  12. $json['admin'] = md5($_REQUEST['passwd']);
  13. $json['superPhihong'] = md5('1231231238');
  14. */
  15. $json[$_REQUEST['user']]=md5($_REQUEST['passwd']);
  16. file_put_contents("/var/www/valid_info", json_encode($json));
  17. exec("yes | cp -vf /var/www/valid_info /Storage/valid_info",$output,$return_var);
  18. if(count($output)!=0){
  19. $jsone['result'] = "Success";
  20. $jsone['message'] = $json;
  21. echo json_encode($jsone);
  22. exit;
  23. }
  24. else{
  25. $jsone['result'] = "Error";
  26. $jsone['message'] = "Something went wrong on machine";
  27. echo json_encode($jsone);
  28. return false;
  29. exit;
  30. }
  31. // echo "OK";
  32. }
  33. ?>