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: *");
- require_once "../core.php"; error_reporting(E_ALL & ~E_NOTICE);
- $filter = ''; $and = ''; $WHERE .= ""; $LIMIT = ''; $_PAGE[] =''; $ORDER = 'ORDER by `date` DESC'; $oBY = '';
- if (isset($_GET['o']) && $_GET['o'] != 'views') {
- $oBY = preg_replace('/[^0-9a-zA-Z_-]/', '', $_GET['o']);
- $ORDER = "ORDER BY `{$oBY}` DESC";
- }
- if (isset($_GET['gtype']) && !empty($_GET['gtype'])) {
- $filter = preg_replace('/[^ \w0-9a-zA-Z_-]/', '', $_GET['gtype']);
- $WHERE .= " AND `gametype` = '{$filter}'";
- }
- if (isset($_GET['map']) && !empty($_GET['map'])) {
- $filter = preg_replace('/[^ \w0-9a-zA-Z_-]/', '', $_GET['map']);
- $WHERE .= " AND `map` = '{$filter}'";
- }
- if (isset($_GET['creator']) && !empty($_GET['creator'])) {
- $filter = preg_replace('/[^ \w0-9a-zA-Z_-]/', '', $_GET['creator']);
- $WHERE .= " AND `creator` = '{$filter}'";
- }
- if (isset($_GET['uid']) && !empty($_GET['uid'])) {
- $filter = preg_replace('/[^ \w0-9a-zA-Z_-]/', '', $_GET['uid']);
- $WHERE .= " AND `uid` = '{$filter}'";
- }
- if (isset($_GET['p']) && is_numeric($_GET['p']) && isset($_GET['r']) && is_numeric($_GET['r'])) {
- $p = (int) $_GET['p'] -1;
- $r = (int) $_GET['r'];
- $s = ($p) ? ($p * $r) : 0;
- $LIMIT = "LIMIT {$s}, {$r}";
- $tcount = $_SQL->query("SELECT uid FROM `maps` WHERE public != 'n' {$WHERE}") or die($_SQL->error);
- $total = $tcount->num_rows;
- $page['totalMaps'] = "$total";
- $page['currentPage'] = "".($p+1)."";
- $begResult = $s + 1;
- $endResult = $s + $r; if ($endResult > $total) { $endResult = $total; }
- $page['results'] = "".$begResult."-".$endResult." out of ".$page['totalMaps'];
- $tc = $_SQL->query("SELECT uid FROM `maps` WHERE public != 'n' {$WHERE} {$LIMIT}") or die($_SQL->error);
- $t = $tc->num_rows;
- $page['mapsOnPage'] = "$t";
- if ($page['mapsOnPage'] > 0 && $page['mapsOnPage'] < $r) {$page['pagesPossible'] = $page['currentPage'];}
- else { $page['pagesPossible'] = "".ceil($total / $r).""; }
- $_PAGE[] = $page;
- }
- if (!isset($_GET['map']) && !isset($_GET['creator']) && !isset($_GET['uid']) && !isset($_GET['gtype']) && isset($_GET['search']) && preg_match('/^[a-z0-9.\-\_]+$/i', $_GET['search'])) {
- $sql = $_SQL->query("SELECT *, NULL as url FROM `maps` WHERE `title` LIKE '%{$_GET['search']}%' OR `creator` LIKE '%{$_GET['search']}%' OR `map` LIKE '%{$_GET['search']}%' OR `gametype` LIKE '%{$_GET['search']}%' AND (public != 'n' {$WHERE}) {$ORDER} {$LIMIT}") or die($_SQL->error);
- if ($sql->num_rows < 1) { $sql = $_SQL->query("SELECT *, NULL as url FROM `maps` WHERE public != 'n' {$WHERE} {$ORDER} {$LIMIT}") or die($_SQL->error); }
- } else { $sql = $_SQL->query("SELECT *, NULL as url FROM `maps` WHERE public != 'n' {$WHERE} {$ORDER} {$LIMIT}") or die($_SQL->error); }
- if (isset ($_GET['o']) && $_GET['o'] == 'views') {
- $sql = $_SQL->query("SELECT m.*, COUNT(v.id) AS views FROM maps AS m LEFT JOIN views AS v ON v.map_id=m.id WHERE public != 'n' {$WHERE} GROUP BY m.id ORDER BY views DESC {$LIMIT}") or die($_SQL->error);
- }
- while ($forge = $sql->fetch_assoc()) {
- $submitter = $_SQL->query("SELECT uname FROM users WHERE id = '{$forge['uid']}'");
- $sub = $submitter->fetch_assoc(); $forge['submitter'] = $sub['uname'];
- $forge['url'] = "//halovau.lt/forge.php?dl&id=".$forge['id'].""; $forgeIMG = $forge['img'];
- $map = preg_replace('/[^ \w0-9a-zA-Z_-]/', '', $forge['map']);
- $forgeIMG = $forge['img']; if (empty($forge['img'])) { $forgeIMG = "/css/images/".preg_replace('/\s+/', '', $map).".jpg"; }
- $forgeIMG0 = str_replace('/css/', '//halovau.lt/css/', $forgeIMG);
- $forgeIMG2 = str_replace('http://halovau.lt//halovau.lt/css/', '//halovau.lt/css/', $forgeIMG0);
- if ($forge['img'] != Thumb($forge['img'])) { $forge['thumbnail'] = Thumb($forge['img']); }
- $forge['img'] = str_replace(' ', '', $forgeIMG2);
- $forgePub = removeBB($forge['info']);
- $forgePub = preg_replace('/:[\s\S]+?:/', '', $forgePub);
- $forge['cleanInfo'] = str_replace('Posted on HaloShare', '', $forgePub);
- $forgeI = str_replace("\\\"", '"', $forge['info']);
- $forge['info'] = bb_parse(htmlentities($forgeI));
- if ($forge['map'] == 'diamondback') {
- $forgeQuote = "Hot winds blow over what should be a dead moon. A reminder of the power Forerunners once wielded."; }
- if ($forge['map'] == 'edge') {
- $forgeQuote = "The remote frontier world of Partition has provided this ancient databank with the safety of seclusion."; }
- if ($forge['map'] == 'guardian') {
- $forgeQuote = "Millennia of tending has produced trees as ancient as the Forerunner structures they have grown around."; }
- if ($forge['map'] == 'icebox') {
- $forgeQuote = "Downtown Tyumen's Precinct 13 offers an ideal context for urban combat training."; }
- if ($forge['map'] == 'narrows') {
- $forgeQuote = "Without cooling systems such as these, excess heat from the Ark's forges would render the construct uninhabitable."; }
- if ($forge['map'] == 'reactor') {
- $forgeQuote = "Being constructed just prior to the Invasion, its builders had to evacuate before it was completed."; }
- if ($forge['map'] == 'standoff') {
- $forgeQuote = "Once, nearby telescopes listened for a message from the stars. Now, these silos contain our prepared response."; }
- if ($forge['map'] == 'the pit') {
- $forgeQuote = "Software simulations are held in contempt by the veteran instructors who run these training facilities."; }
- if ($forge['map'] == 'valhalla') {
- $forgeQuote = "The crew of V-398 barely survived their unplanned landing in this gorge, but they know they are not alone."; }
- if ($forge['map'] == 'last resort') {
- $forgeQuote = "Remote industrial sites like this one are routinely requisitioned & used as part of Spartan training exercises."; }
- if ($forge['map'] == 'high ground') {
- $forgeQuote = "A relic of older conflicts, this base was reactivated after the New Mombasa Slipspace Event."; }
- if ($forge['map'] == 'sandtrap') {
- $forgeQuote = "Although the Brute occupiers have been driven from this ancient structure, they left plenty to remember them by."; }
- if ($forge['map'] == 'flatgrass') {
- $forgeQuote = "Modders offering a plain flat map with an extended pallet of items ideal for Forge."; }
- $forge['tdr'] = $forgeQuote;
- $forge['gametype'] = ucwords($forge['gametype']);
- preg_match_all('/https?:\/\/drive.google.com\/open\?id\=([0-9A-Za-z-_]+)/si', $forge['cleanInfo'], $matches);
- $driveLinks = array_map(function($match) {
- return "https://drive.google.com/uc?export=download&id=" .$match[1];
- }, $matches);
- $forge['gtypeURLs'] = $driveLinks;
- $forge['variantName'] = strtok($forge['title'], ':');
- if ($forge['variantName'] == $forge['title']) { $forge['variantName'] = ''; }
- $forge['map'] = ucwords($map);
- $forgeV = $_SQL->query("SELECT * FROM views WHERE map_id = '".$forge['id']."'");
- $forge['views'] = "$forgeV->num_rows";
- $toRemove = substr($forge['title'], 0, strpos($forge['title'], ":")).': ';
- $forge['title'] = str_replace($toRemove, '', $forge['title']);
- if (isset($_USER['name']) && !empty($forge['directURL']) && $forge['public'] != 'r' || $_USER['group'] > 2) { $forge['directURL'] = "//dewsha.re".$forge['directURL']."sandbox.map"; }
- else { $forge['directURL'] = ''; }
- $_FORGE[] = $forge;
- }
- $pageJson1 = json_encode($_PAGE, JSON_PRETTY_PRINT);
- $pageJsonX = str_replace('"",', '
- "PAGE_RESULTS":', $pageJson1);
- $pageJson2 = str_replace('[
- ', '{
- ', $pageJsonX);
- $pageJson = str_replace(']', ',', $pageJson2);
- $mapsJson1 = json_encode($_FORGE, JSON_PRETTY_PRINT);
- $mapsJsonX = str_replace("\\/", "/", $mapsJson1);
- $mapsJson = str_replace('tdr', 'mapQuote', $mapsJsonX);
- if (isset($_GET['p']) AND is_numeric($_GET['p']) OR $_FORGE['mapsOnPage'] > 0) {
- print_r("".$pageJson."
- \"MAP_RESULTS\":
- ".$mapsJson."
- }");
- } else { print_r(rtrim($mapsJson)); }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment