Guest User

Untitled

a guest
Dec 6th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2. // include environment related files
  3. include_once '../inc/env.inc.php';
  4.  
  5. // will return JSON response
  6. header('Content-type: application/json');
  7.  
  8. WEApplication::serviceAvailabilityCheck();
  9.  
  10. $secretDev = isset($_POST['secret_dev']) ? $_POST['secret_dev'] : '';
  11. $pending = isset($_POST['pending']) ? $_POST['pending'] : 0;
  12.  
  13. if ($secretDev != _WE_SECRET_DEV_KEY_) {
  14. die('{"result":"ERROR","code":"1","error":"Incorrect secret key"}');
  15. }
  16.  
  17. // Successful response
  18. $JSON = '{';
  19. $JSON .= '"result":"OK",';
  20. $JSON .= '"shops":[';
  21. $shops= WEShop::shops(array('pending'=>$pending));
  22. $i=0;
  23. foreach ($shops as $shop) {
  24. if ($i>0) {
  25. $JSON.=',';
  26. }
  27. ++$i;
  28. $JSON.=$shop->propertiesAsJSON();
  29. }
  30. $JSON.='],';
  31. $JSON .= '"teams":[';
  32. $teams= WETeam::getTeams();
  33. $i=0;
  34. foreach ($teams as $team) {
  35. if ($i>0) {
  36. $JSON.=',';
  37. }
  38. ++$i;
  39. $JSON.=$team->propertiesAsJSON();
  40. }
  41. $JSON.=']}';
  42.  
  43.  
  44. echo $JSON;
Add Comment
Please, Sign In to add comment