outputFormat is not valid.
';
die();
}
$outputFormat = $testMatch;
$testMatch = NULL;
}
if (isset($_REQUEST["maxObjects"]) & $_REQUEST["maxObjects"] != "") {
$testMatch = $_REQUEST["maxObjects"];
$pattern = '/^[0-9]*$/';
if (!preg_match($pattern,$testMatch)){
echo 'maxObjects is not valid.
';
die();
}
$maxObjects = (integer)$testMatch;
if ($maxObjects > 15){
echo 'Number of objects are too much, at maximum 15 ojects are allowed.
';
die();
}
$testMatch = NULL;
}
if (isset($_REQUEST["maxAge"]) & $_REQUEST["maxAge"] != "") {
$testMatch = $_REQUEST["maxAge"];
$pattern = '/^[0-9]*$/';
if (!preg_match($pattern,$testMatch)){
echo 'maxAge is not valid.
';
die();
}
$maxAge = (integer)$testMatch;
$testMatch = NULL;
}
if (isset($_REQUEST["languageCode"]) & $_REQUEST["languageCode"] != "") {
//validate to wms, wfs
$testMatch = $_REQUEST["languageCode"];
if (!($testMatch == 'de' or $testMatch == 'en' or $testMatch == 'fr')){
echo 'languageCode is not valid.
';
die();
}
$languageCode = $testMatch;
$testMatch = NULL;
}
if (isset($_REQUEST["hostName"]) & $_REQUEST["hostName"] != "") {
//validate to some hosts
$testMatch = $_REQUEST["hostName"];
//look for whitelist in mapbender.conf
$HOSTNAME_WHITELIST_array = explode(",",HOSTNAME_WHITELIST);
if (!in_array($testMatch,$HOSTNAME_WHITELIST_array)) {
echo "Requested hostname not whitelist! Please control your mapbender.conf.";
$e = new mb_notice("Whitelist: ".HOSTNAME_WHITELIST);
$e = new mb_notice("hostname not found in whitelist!");
die();
}
$hostName = $testMatch;
$testMatch = NULL;
}
if ($outputFormat == 'json'){
$classJSON = new Mapbender_JSON;
}
if ($languageCode == 'en'){
$pathToLoadScript = '/portal/en/maps.html?WMC=';
}
if ($languageCode == 'fr'){
$pathToLoadScript = '/portal/fr/cartes.html?WMC=';
}
/*
//define sql for selecting informations from database:
$sql = "";
$sql .= "SELECT search_wmc_view.wmc_serial_id,search_wmc_view.wmc_title,search_wmc_view.wmc_abstract, custom_category.custom_category_code_".$languageCode. ", search_wmc_view.load_count ";
$sql .= "FROM search_wmc_view INNER JOIN wmc_custom_category ON ";
$sql .= "(wmc_custom_category.fkey_wmc_serial_id=search_wmc_view.wmc_serial_id) INNER JOIN custom_category ON ";
$sql .= "(custom_category.custom_category_id=wmc_custom_category.fkey_custom_category_id) WHERE ";
$sql .= "custom_category.custom_category_key = 'mbc1' ORDER BY search_wmc_view.load_count DESC LIMIT $1 ";
*/
//define sql for selecting informations from database:
//$sql = "";
//$sql .= "SELECT search_wmc_view.wmc_serial_id,search_wmc_view.wmc_title,search_wmc_view.wmc_abstract, search_wmc_view.load_count ";
//$sql .= "FROM search_wmc_view ORDER BY search_wmc_view.load_count DESC LIMIT $1 ";
$sql = "";
//select wmc_serial_id,wmc_title,wmc_abstract,CASE WHEN (wmc_timestamp > (extract(epoch from now())- ((86400)*5))) THEN wmc_timestamp ELSE 0 END as timestamp, load_count from search_wmc_view order by timestamp desc, load_count desc LIMIT
$sql .= "SELECT search_wmc_view.wmc_serial_id,search_wmc_view.wmc_title,search_wmc_view.wmc_abstract,";
$sql .= " CASE WHEN (wmc_timestamp > (extract(epoch from now())- ((86400) * $2))) THEN wmc_timestamp ELSE 0 END as timestamp,search_wmc_view.load_count ";
$sql .= " from search_wmc_view order by timestamp desc, load_count desc LIMIT $1";
$v = array($maxObjects,$maxAge);
$t = array('i','i');
$res = db_prep_query($sql,$v,$t);
$initialWmc = array();
$i = 0;
while($row = db_fetch_array($res)){
//$mobileUrl = $row['wmc_serial_id'];
//$uuid = new Uuid;
$filename = "qr_wmc_".$row['wmc_serial_id'].".png";
//generate qr on the fly in tmp folder if not already exists
//check if exists
if (file_exists(TMPDIR."/".$filename)) {
$mobileUrl = MAPBENDER_PATH."/extensions/mobilemap/map.php?wmcid=".$row['wmc_serial_id'];
$mobileQrImageUrl = MAPBENDER_PATH."/tmp/".$filename;
} else {
//link to invoke wmc per get api if wrapper path isset
if (defined("MAPBENDER_PATH") && MAPBENDER_PATH != "") {
$mobileUrl = MAPBENDER_PATH."/extensions/mobilemap/map.php?wmcid=".$row['wmc_serial_id'];
//$invokeLink = "http://www.geoportal.rlp.de/mapbender/extensions/mobilemap/map.php";
QRcode::png($mobileUrl,TMPDIR."/".$filename);
$mobileQrImageUrl = MAPBENDER_PATH."/tmp/".$filename;
} else {
$mobileUrl = "";
$mobileQrImageUrl = "";
}
}
$initialWmc[$i] = array('id' =>$row['wmc_serial_id'], 'title' =>$row['wmc_title'], 'abstract' =>$row['wmc_abstract'],'loadUrl'=>'http://'.$hostName.$pathToLoadScript.$row['wmc_serial_id'],'metadataUrl'=>'http://'.$hostName.$pathToMetadata."languageCode=".$languageCode."&resource=wmc&id=".$row['wmc_serial_id'], 'previewUrl'=>'http://'.$hostName.$pathToPreview."resource=wmc&id=".$row['wmc_serial_id'],'timestamp' => $row['timestamp'],'loadCount' => $row['load_count'], 'mobileUrl' => $mobileUrl, 'mobileQrImageUrl' => $mobileQrImageUrl);
//generate qr images
$i++;
}
if ($outputFormat == 'html'){
echo "";
echo "