Guest User

Untitled

a guest
Apr 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. public function storesAction()
  2. {
  3.  
  4.  
  5. if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  6. $body = @file_get_contents('php://input');
  7. $json = json_decode($body, true);
  8.  
  9.  
  10. if (isset($json['version'])) {
  11. $client_cache_version = @$json['version'];
  12. $db = $this->getInvokeArg('bootstrap')->getPluginResource('db')->getDbAdapter();
  13. $sql = $db->quoteInto('SELECT * FROM stores where version_modified > ', $client_cache_version);
  14. $results = $db->fetchAll($sql);
  15.  
  16.  
  17. $version_sql = $db->quoteInto('SELECT max(version_modified) as version FROM stores');
  18. $version_results = $db->fetchAll($version_sql);
  19.  
  20. $count = array(
  21. 'count' => sizeof($results)
  22. );
  23.  
  24. array_push($results, $version_results['0']);
  25.  
  26. array_push($results, $count);
  27. //ob_start("ob_gzhandler");
  28.  
  29. header('HTTP/1.1 200 Stores list');
  30. echo json_encode($results);
  31. exit;
  32.  
  33. }else {
  34.  
  35.  
  36. header('HTTP/1.1 400 Bad Request');
  37.  
  38. exit;
  39. }
  40.  
  41. }else{
  42.  
  43.  
  44. header('HTTP/1.1 400 Bad Request');
  45. exit;
  46. }
  47.  
  48.  
  49. }
Add Comment
Please, Sign In to add comment