Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php //header('Content-type: application/json; charset=utf8'); header("Access-Control-Allow-Origin: *");
- if (isset($_GET['_MAPS'])) die(file_get_contents("http://localhost/inc/api/listMaps.api?".http_build_query($_GET)));
- if (isset($_GET['_VARIANTS'])) die(file_get_contents("http://localhost/inc/api/listVariants.api?".http_build_query($_GET)));
- if (isset($_GET['_SCREENSHOTS'])) die(file_get_contents("http://localhost/inc/api/listMedia.api?".http_build_query($_GET)));
- $getM=json_decode(file_get_contents("http://localhost/inc/api/listMaps.api?".http_build_query($_GET)),true);
- $getS=json_decode(file_get_contents("http://localhost/inc/api/listMedia.api?".http_build_query($_GET)),true);
- $getV=json_decode(file_get_contents("http://localhost/inc/api/listVariants.api?".http_build_query($_GET)),true);
- /* its because I'm including the http_build_query individually which breaks how this needs to be formatted,
- eventually i need to remove the build query part, and do some magical foreach (this as that) {etc}
- This idea was to use `date` `author` `user` to sort/filter them by common key values, since all 3 arrays above contain them.
- i need some sort of sort() method, to order/filter them by date, user, author, etc as if this one one large SQL table */
- $GetM = (isset($getM['MAP_RESULTS'])) ? $getM['MAP_RESULTS'] : $getM;
- $GetS = (isset($getS['MEDIA_RESULTS'])) ? $getS['MEDIA_RESULTS'] : $getS;
- $GetV = (isset($getV['FILE_RESULTS'])) ? $getV['FILE_RESULTS'] : $getV;
- $merge=[]; $merge = array($GetM) + array($GetV) + array($GetS);
- //error_reporting(E_ERROR | E_WARNING | E_PARSE);
- foreach ($merge as $key => $value) {
- $date[$key] = $value['date'];
- $edit[$key] = $value['edited'];
- $upd[$key] = $value['updated'];
- $views[$key] = $value['views'];
- $votes[$key] = $value['votes'];
- $cmnts[$key] = $value['replies'];
- $auth[$key] = $value['Author'];
- $uid[$key] = $value['uid'];
- $dewid[$key] = $value['dewid'];
- } //print_r($merge, JSON_PRETTY_PRINT);
- if (isset($_GET['order']) && !empty($_GET['order'])) {
- if ($_GET['order']=='views') array_multisort($views, SORT_ASC, $merge);
- if ($_GET['order']=='updated') array_multisort($upd, SORT_ASC, $merge);
- if ($_GET['order']=='edited') array_multisort($edit, SORT_ASC, $merge);
- if ($_GET['order']=='votes') array_multisort($votes, SORT_ASC, $merge);
- if ($_GET['order']=='replies') array_multisort($cmnts, SORT_ASC, $merge);
- } else array_multisort($date, SORT_DESC, $edit, SORT_DESC, $merge);
- print_r($merge, JSON_PRETTY_PRINT); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement