<?php
// Membermap 0.5.0 by Pascalmh.de
require_once 'phoogle.php';
$map = new PhoogleMap();
//customization options are here
$map->setAPIKey("ABQIAAAAaqkVg4_5S31uqtabXZR9VxSoCF5u_BLdvBUzI69pHxM_gu3ruRTeWU1QjviFszijHOw1bl-NRGBQ3A");
$map->zoomLevel = 13; //0 = Closest
$map->setWidth(430); //pixels
$map->setHeight(340); //pixels
$map->controlType = 'large'; //show large controls on the side
$map->showType = false; //hide the map | sat | hybrid buttons
//CUSTOM INFO WINDOW DATA
$map->centerMap('51.165691','10.451526');
if(isset($_GET['action'])) $action = $_GET['action'];
else $action = '';
if($action=="add") {
eval ("\$membermap_add = \"".gettemplate("membermap_add")."\";");
echo $membermap_add;
}
elseif($action=="change") {
if($loggedin) {
if(getcountryname($userID)!='' AND gettown($userID)!='') {
$flag = ''.getcountry($userID).'';
$country = flags($flag);
$country = str_replace("<img","<img id='county'",$country);
$town = gettown($userID);
$long = getlong($userID);
$lat = getlat($userID);
$countries = str_replace(" selected=\"selected\"", "", $countries);
$countries = str_replace('value="'.getcountry($userID).'"', 'value="'.getcountry($userID).'" selected="selected"', $countries);
}
eval ("\$membermap_change = \"".gettemplate("membermap_change")."\";");
echo $membermap_change;
}
else echo 'You need to be Logedin.';
}
elseif($action=="savechanges" && $loggedin) {
$changed = false;
echo '<div class="block"><h2>Saving your Geolocation.</h2>';
$long = $_POST['long'];
$lat = $_POST['lat'];
$country = $_POST['flag'];
$town = $_POST['town'];
if(isset($long) && isset($lat)) {
if(is_numeric($long) && is_numeric($lat)) {
safe_query("UPDATE ".PREFIX."user SET latitude='$lat',longitude='$long',mapme='1' WHERE userID='".$userID."'");
echo '<p>Your latitude/longitude has been saved to '.$lat.'/'.$long.'</p>';
$changed = true;
}
elseif(!isset($long) && !isset($lat)) echo '';
else echo 'Invalid latitude/longitude.';
}
if(isset($country) && isset($town)) {
safe_query("UPDATE ".PREFIX."user SET town='$town',country='$country',mapme='1' WHERE userID='".$userID."'");
echo '<p>Your Location has been set to '.$town.', '.$country.'</p>';
$changed = true;
}
if($changed == false) echo 'You have to add either <b>latitude AND longitude</b> or <b>Country AND Town</b>';
else echo '<a href="index.php?site=membermap">Back to the Membermap.</a>';
echo '</div>';
}
else {
// Loggedin and entered the Map?
if($loggedin) {
if((getlong($userID)!='' AND getlong($userID)!='undefined') AND (getlat($userID)!='' AND getlat($userID)!='undefined')) {
$yourmapstatus = 'We set your Location to <span id="yourLat">'.getlat($userID).'</span>,<span id="yourLong">'.getlong($userID).'</span> <a href="index.php?site=membermap&action=change">(Change)</a>';
}
elseif(getcountryname($userID)!='' AND gettown($userID)!='') {
$yourmapstatus = 'We set your Location to <span id="yourTown">'.gettown($userID).'</span> in <span id="yourCountry">'.getcountryname($userID).'</span> <a href="index.php?site=membermap&action=change">(Change)</a>';
}
else $yourmapstatus = 'We do not have enough Information to add you to the Membermap. <a href="index.php?site=membermap&action=change">(Change)</a>';
}
else $yourmapstatus = '<a href="index.php?site=login">Login to add yourself to the Membermap.</a>';
eval ("\$membermap_head = \"".gettemplate("membermap_head")."\";");
echo $membermap_head;
$memperpos=safe_query("SELECT * FROM ".PREFIX."user WHERE ((longitude!='' AND longitude!='undefined') OR (town!='' AND country!='')) AND mapme='1' ORDER BY nickname");
while($dl=mysql_fetch_array($memperpos)) {
$town = $dl['town'];
$country = getcountryname($dl['userID']);
$infoHTML = '<a href=\"\/user\/'.$dl['nickname'].'\">'.$dl['nickname'].'<\/a><br \/>'.$country.' '.$town;
$address = $country.','.$town;
$lat = $dl['latitude'];
$long = $dl['longitude'];
if(($lat!="" AND $lat!="undefined") AND ($long!="" AND $long!="undefined")) {
$map->addGeoPoint($lat,$long,$infoHTML);
}
else {
$map->addAddress($address,$infoHTML);
}
}
eval ("\$membermap_content = \"".gettemplate("membermap_content")."\";");
echo $membermap_content;
$map->showMap();
eval ("\$membermap_foot = \"".gettemplate("membermap_foot")."\";");
echo $membermap_foot;
}
$map->printGoogleJS();
?> |