return_cpee.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. date_default_timezone_set('Europe/Vienna');
  3. $date = date('d/m/Y h:i:s a', time());
  4. error_log("RETURN CPEE", 3, 'logs.log');
  5. error_log($date, 3, 'logs.log');
  6. error_log($_GET, 3, 'logs.log');
  7. error_log("\r\n", 3, 'logs.log');
  8. $opts = array('http' =>
  9. array(
  10. 'method' => 'PUT',
  11. 'header' => 'Content-type: application/json',
  12. 'content' => json_encode(array(
  13. "result"=>$_GET))
  14. )
  15. );
  16. $filename ='../callbacks/'. $_GET['id'].'.txt';
  17. $fContent = file_get_contents($filename);
  18. $fin = json_decode($fContent,true);
  19. $link = $fin[0]['HTTP_CPEE_CALLBACK'].'/';
  20. $context = stream_context_create($opts);
  21. $result = file_get_contents($link, false, $context);
  22. error_log("send PUT", 3, 'logs.log');
  23. error_log($date, 3, 'logs.log');
  24. error_log("\r\n", 3, 'logs.log');
  25. print_r($result);
  26. # delete file
  27. unlink($filename);
  28. # delete item in DTC list (in db bool marker 0 or 1)
  29. $data = file_get_contents('../callbacks/DTC_EVENT.txt');
  30. $dtc = json_decode($data, true);
  31. foreach ($dtc as $key => $value) {
  32. if (in_array($_GET['id'], $value)) {
  33. unset($dtc[$key]);
  34. }
  35. }
  36. $dtc = json_encode(array_values($dtc), JSON_PRETTY_PRINT);
  37. file_put_contents('../callbacks/DTC_EVENT.txt', $dtc);
  38. header("Location: http://192.168.20.133:8080/PHP/forms/start.html");
  39. exit;
  40. ?>