<?php
	session_start();
	require('../../admin/incl/const.php');
	require('../../admin/class/database.php');
	require('../../admin/class/access_groups.php');

	if(!isset($_SESSION['user'])) {
		header('Location: ../../login.php');
		exit;
	}

	$database = new Database(DB_HOST, DB_NAME, DB_USER, DB_PASS, DB_PORT, DB_SCMA);

	$map_id  = MAP_ID;
	$acc_obj = new access_group_Class($database->getConn(), $_SESSION['user']->id);

	$usr_grps = $acc_obj->getByUserId($_SESSION['user']->id);
	if(!count($usr_grps)){
		die('Sorry, no access group!');
	}

	$usr_grps = $acc_obj->getGroupMapGroups(array_keys($usr_grps));
	if(!count($usr_grps) || !isset($usr_grps[$map_id])){
			die('Sorry, access not allowed!');
	}

	// https://shop.chicagotvguides.com/geoserver/wms?service=WMS&request=GetFeatureInfo&version=1.1.1&layers=topp%3Astates&styles=&format=image%2Fpng&transparent=true&continuousWorld=true&tiled=true&info_format=text%2Fhtml&width=1374&height=852&srs=EPSG%3A3857&bbox=-12983287.876406899%2C1633917.916623927%2C-6261721.357121639%2C5801876.194958019&query_layers=topp%3Astates&X=653&Y=285
	const BASE_URL = 'BASE_URL_VALUE';
	readfile(BASE_URL.'?'.$_SERVER['QUERY_STRING']);
	
	/*define("COOKIE_FILE", "/tmp/cookie.txt");
	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, BASE_URL.'?'.$_SERVER['QUERY_STRING']);
	curl_setopt($curl, CURLOPT_COOKIEJAR, COOKIE_FILE);
	curl_setopt($curl, CURLOPT_USERPWD, "admin:geoserver");
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 0);
	curl_setopt($curl, CURLOPT_FORBID_REUSE, TRUE);
	//curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array('Connection: close'));
	$result = curl_exec($curl);
	curl_close($curl);*/
?>