pushmessages.php 958 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. //REQUEST_METHOD
  3. $requestMethod = (string)filter_input(INPUT_SERVER, "REQUEST_METHOD");
  4. if ($requestMethod != "POST") {
  5. die("Wrong request method!");
  6. }
  7. //userHint
  8. $userHintResolved = PHP_STR;
  9. $userHint = substr((string)filter_input(INPUT_POST, "userHint"), 0, 50);
  10. if ($userHint == PHP_STR) {
  11. die("Wrong user hint!");
  12. } else {
  13. $found=false;
  14. foreach ($CONFIG['AUTH'] as $key => $val) {
  15. if ($userHint==$val['USERNAME']) {
  16. $userHintResolved = $key;
  17. $found=true;
  18. break;
  19. }
  20. }
  21. if (!$found) {
  22. die("Invalid chat!");
  23. }
  24. }
  25. $pwd = $CONFIG['AUTH'][$userHintResolved]['REPO_FOLDER'];
  26. $curPath = APP_REPO_PATH . DIRECTORY_SEPARATOR . $pwd;
  27. $mysha = PHP_STR;
  28. $amsgs = file($curPath . DIRECTORY_SEPARATOR . ".HMM_history");
  29. if (count($amsgs) > 0) {
  30. $val = rtrim($amsgs[count($amsgs)-1],"\n");
  31. $mysha = hash("sha256", $val . APP_SALT, false);
  32. }
  33. echo json_encode([200, $mysha]);