action.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <html><body>
  2. <?php
  3. $client_pub_key_b64=""; // Invalid base64
  4. $client_pub_key_header="Mitigator-Client-Public-Key";
  5. $headers=getallheaders(); // TODO: Error-checking: could be null - treat same way as if header n$
  6. if(array_key_exists($client_pub_key_header, $headers))
  7. {
  8. $client_pub_key_b64=$headers[$client_pub_key_header];
  9. }
  10. else if(array_key_exists(strtolower( $client_pub_key_header), $headers)) // TODO: NASTY BUG HERE$
  11. {
  12. $client_pub_key_b64=$headers[ strtolower( $client_pub_key_header ) ];
  13. }
  14. // echo $client_pub_key_b64;
  15. $ip_args = array($client_pub_key_b64);
  16. if ($_SERVER["REQUEST_METHOD"] === "POST") {
  17. foreach ($_POST as $key => $value) {
  18. array_push($ip_args, $value);
  19. // print_r( $ip_args );
  20. }
  21. }
  22. $ret_obj = php_decrypt_wrapper($ip_args);
  23. $is_success = $ret_obj->success;
  24. if($is_success === "true")
  25. {
  26. $fields = $ret_obj->fields;
  27. $no_of_fields=count($fields);
  28. foreach ($fields as $key => $value) {
  29. echo $value . " ";
  30. }
  31. }
  32. else
  33. echo "Could not decrypt.";
  34. ?>
  35. </body></html>