Advertisement
kyleAI_13

Untitled

Sep 21st, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.49 KB | None | 0 0
  1. <?php //header('Content-type: application/json; charset=utf8'); header("Access-Control-Allow-Origin: *");
  2.  
  3. if (isset($_GET['_MAPS'])) die(file_get_contents("http://localhost/inc/api/listMaps.api?".http_build_query($_GET)));
  4. if (isset($_GET['_VARIANTS'])) die(file_get_contents("http://localhost/inc/api/listVariants.api?".http_build_query($_GET)));
  5. if (isset($_GET['_SCREENSHOTS'])) die(file_get_contents("http://localhost/inc/api/listMedia.api?".http_build_query($_GET)));
  6.  
  7. $getM=json_decode(file_get_contents("http://localhost/inc/api/listMaps.api?".http_build_query($_GET)),true);
  8. $getS=json_decode(file_get_contents("http://localhost/inc/api/listMedia.api?".http_build_query($_GET)),true);
  9. $getV=json_decode(file_get_contents("http://localhost/inc/api/listVariants.api?".http_build_query($_GET)),true);
  10. /* its because I'm including the http_build_query individually which breaks how this needs to be formatted,
  11. eventually i need to remove the build query part, and do some magical foreach (this as that) {etc}
  12. This idea was to use `date` `author` `user` to sort/filter them by common key values, since all 3 arrays above contain them.
  13. i need some sort of sort() method, to order/filter them by date, user, author, etc as if this one one large SQL table */
  14.  
  15. $GetM = (isset($getM['MAP_RESULTS'])) ? $getM['MAP_RESULTS'] : $getM;
  16. $GetS = (isset($getS['MEDIA_RESULTS'])) ? $getS['MEDIA_RESULTS'] : $getS;
  17. $GetV = (isset($getV['FILE_RESULTS'])) ? $getV['FILE_RESULTS'] : $getV;
  18. $merge=[]; $merge = array($GetM) + array($GetV) + array($GetS);
  19. //error_reporting(E_ERROR | E_WARNING | E_PARSE);
  20. foreach ($merge as $key => $value) {
  21.     $date[$key] = $value['date'];
  22.     $edit[$key] = $value['edited'];
  23.     $upd[$key] = $value['updated'];
  24.     $views[$key] = $value['views'];
  25.     $votes[$key] = $value['votes'];
  26.     $cmnts[$key] = $value['replies'];
  27.     $auth[$key] = $value['Author'];
  28.     $uid[$key] = $value['uid'];
  29.     $dewid[$key] = $value['dewid'];
  30. } //print_r($merge, JSON_PRETTY_PRINT);
  31. if (isset($_GET['order']) && !empty($_GET['order'])) {
  32.     if ($_GET['order']=='views') array_multisort($views, SORT_ASC, $merge);
  33.     if ($_GET['order']=='updated') array_multisort($upd, SORT_ASC, $merge);
  34.     if ($_GET['order']=='edited') array_multisort($edit, SORT_ASC, $merge);
  35.     if ($_GET['order']=='votes') array_multisort($votes, SORT_ASC, $merge);
  36.     if ($_GET['order']=='replies') array_multisort($cmnts, SORT_ASC, $merge);
  37. } else array_multisort($date, SORT_DESC, $edit, SORT_DESC, $merge);
  38. print_r($merge, JSON_PRETTY_PRINT); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement