Hat Mairu eigentlich gut beschrieben! Aber hier die beiden Dateien, einfach ersetzen!
./include/contents/map.php
<?php
# map mod
# by: Jihi
defined ('main') or die ( 'no direct access' );
require_once("include/contents/map/config.php");
$title = $allgAr['title'].' :: Karte';
$hmenu = 'Karte';
$design = new design ( $title , $hmenu );
$design->header();
$tpl = new tpl ( 'map.htm' );
function deg2posLo($deg){
global $map_west, $pix_per_degree_x, $map_offset_x;
return (int)(($deg-$map_west)*$pix_per_degree_x + $map_offset_x);
}
function deg2posLa($deg){
global $map_north, $pix_per_degree_y, $map_offset_y;
return (int)((-1)*($deg-$map_north)*$pix_per_degree_y + $map_offset_y);
}
function pos2degLo($x){
global $map_west, $pix_per_degree_x;
return (($x / $pix_per_degree_x) + $map_west);
}
function pos2degLa($y){
global $map_north, $pix_per_degree_y;
return ((-1)*($y / $pix_per_degree_y) + $map_north);
}
#### show map ##################
if(empty($_POST['um'])){
######### process selected group
if(!array_key_exists('map_group_selected' , $_SESSION)){
$_SESSION['map_group_selected']=unserialize($map_group_selected_save);
}
if(array_key_exists('changeGroup' , $_POST)){
if(!empty($_POST['groups'])){
$_SESSION['map_group_selected'] = $_POST['groups'];
}
}elseif($menu->get(1)=='showgroup' AND $menu->get(2)!= ''){
$_SESSION['map_group_selected']=array('gr-'.$menu->get(2) => '-'.$menu->get(2));
}elseif($menu->get(1)=='showgroupall'){
$_SESSION['map_group_selected']=array('gr-9'=> '-9','gr-8'=> '-8','gr-7'=> '-7','gr-6'=> '-6','gr-5'=> '-5','gr-4'=> '-4','gr-3'=> '-3','gr-2'=> '-2','gr-1'=> '-1');
}
######### show group selector
if($map_show_group_select){
$str="";
$erg = db_query("SELECT id,name FROM prefix_grundrechte WHERE id < 0 ORDER BY id ASC");
while($row = db_fetch_assoc($erg) ) {
$checked = ((array_key_exists('gr'.$row['id'],$_SESSION['map_group_selected'])) ? ' checked' : '');
$str .= $tpl->list_get('selgroup',array($row['name'], $row['id'], $checked));
}
$tpl->set('selgroup',$str);
$tpl->out(6);
}
$sql_where = 'WHERE ';
foreach($_SESSION['map_group_selected'] as $v){
$sql_where .= 'b.recht = '.$v.' OR ';
}
$sql_where .= '0';
########## show map picture
$tpl->set_ar_out(array('path'=>$map_path,'width'=>$map_width,'height'=>$map_height),0);
########### Daten einlesen
$abf = "SELECT a.uid, a.longitude, a.latitude, a.cname, b.name FROM prefix_map a LEFT JOIN prefix_user b ON a.uid = b.id ".$sql_where;
$erg = db_query($abf);
while($row = db_fetch_assoc($erg) ) {
if(empty($row['name'])){
db_query("DELETE FROM `prefix_map` WHERE `uid` = ".$row['uid']);
}else{
$posx=deg2posLo($row['longitude']);
$posy=deg2posLa($row['latitude']);
if($posx>0 OR $posx<$map_width OR $posy>0 OR $posy<$map_height){
$umi[$row['uid']]['names'][(string)$row['uid']]['name']=$row['name'];
$umi[$row['uid']]['names'][(string)$row['uid']]['cname']=$row['cname'];
$umi[$row['uid']]['posx']=$posx;
$umi[$row['uid']]['posy']=$posy;
}
}
}
########### User gruppieren
if(!empty($umi)){
#$i=$ii=1;
$loop=FALSE;
while(!$loop){
$loop2=FALSE;
$umi2=$umi;
foreach($umi as $mid1 => $a1){
foreach($umi2 as $mid2 => $a2){
if($mid1!=$mid2){
if(($a1['posx']>$a2['posx']-$map_cb AND $a1['posx']<$a2['posx']+$map_cb) AND ($a1['posy']>$a2['posy']-$map_cb AND $a1['posy']<$a2['posy']+$map_cb)){
$umi[$mid1]['names']=$a1['names']+$a2['names'];
$umi[$mid1]['posx']=($a1['posx']+$a2['posx'])/2;
$umi[$mid1]['posy']=($a1['posy']+$a2['posy'])/2;
unset($umi[$mid2]);
$loop2=TRUE;
break;
}
}
#echo $i.' ';$i++;
}
unset($umi2[$mid1]);
#echo '#'.$ii.'<br>';$ii++;$i=1;
if($loop2){break;}
}
if(!$loop2){$loop=TRUE;}
$ii=1;
}
########### Gruppen/User auf der Karte anzeigen
foreach($umi as $mid => $a){
$pt="";
$i=0;
$showmid=false;
foreach($a['names'] as $uid => $b){
if(($menu->get(1)=='uid' AND $menu->get(2)==$uid)){
$showmid=true;
}
$pt .= $tpl->list_get ( 'poplist', array ($uid, $b['name'], $b['cname'], @db_result(db_query('SELECT CONCAT(\'<img src="\',avatar,\'" />\') FROM prefix_user WHERE avatar != "" AND id = '.$uid),0) ));
$i++;
}
$ar=array('posx'=> $a['posx'],
'posy'=> $a['posy'],
'counti'=> $i,
'mid' => $mid,
'poplist' => $pt );
$tpl->set_ar_out($ar,1);
if(($showmid === true)){$tpl->set_ar_out($ar,3);}
}
}
$tpl->out(4);
########### show location change button, or not
if(!empty($_SESSION['authid']) AND $_SESSION['authright']<=$map_authright AND !db_count_query("SELECT COUNT(uid) FROM prefix_mapdeny WHERE uid=".$_SESSION['authid'])){
$tpl->out(2);
}
$tpl->out(5);
}else{
#### Set Location ##################
if($_POST['um']=='setloc'&& !empty($_SESSION['authid']) && $_SESSION['authright']<=$map_authright AND !db_count_query("SELECT COUNT(uid) FROM prefix_mapdeny WHERE uid=".$_SESSION['authid'])){
########### select country #################
if(empty($_POST['country'])&& empty($_POST['fchar']) && empty($_POST['search'])&& empty($_POST['town']) && empty($_POST['man']) && empty($_POST['get_pos'])){
echo '<form action="index.php?map" method="POST"><input type="hidden" name="um" value="setloc"><select name="country">';
$o = opendir ('include/contents/map/country');
while ( $f = readdir($o) ) {
if ( $f != '.' AND $f != '..') {
$fi=explode('.',$f);
echo '<option>'.$fi[0].'</option>';
}
}
echo '</select><input type="submit" value="Auswählen"></form>';
echo '<br /><form action="index.php?map" method="POST"><input type="hidden" name="m" value="map"><input type="hidden" name="um" value="setloc"><input type="hidden" name="man" value="true"><input type="submit" value="Daten manuell eingeben"></form>';
}
########## set manual #######
if(isset($_POST['man']) AND !isset($_POST['save'])){
if(isset($_POST['map_pos_x']) AND isset($_POST['map_pos_y'])){
$lon=pos2deglo($_POST['map_pos_x']);
$lat=pos2degla($_POST['map_pos_y']);
$cname='';
}else{
$lon=(isset($_POST['lon']) ? $_POST['lon'] : '');
$lat=(isset($_POST['lat']) ? $_POST['lat'] : '');
$cname=(isset($_POST['cname']) ? $_POST['cname'] : '');
}
echo 'entweder:<br />';
echo '<form action="index.php?map" method="POST"><input type="hidden" name="um" value="setloc"><input type="hidden" name="get_pos" value="true"><input type="submit" value="Auf der Karte einen Position auswählen"></form><br />';
echo 'oder Daten manuell eingeben:<br />';
echo '<form action="index.php?map" method="POST"><input type="hidden" name="um" value="setloc"><input type="hidden" name="save" value="man"><input type="hidden" name="man" value="true">Name des Ortes:<br /><input type="text" name="cname" value="'.$cname.'"><br />Longitude:<br /><input type="text" name="lon" value="'.$lon.'"><br />Latitude:<br /><input type="text" name="lat" value="'.$lat.'"><br /><input type="submit" value="Eintragen"></form>';
}
######### get pos from map on click #######
if(!empty($_POST['get_pos'])){
echo '<center><form action="index.php?map" method="post"><input type="hidden" name="um" value="setloc"><input type="hidden" name="man" value="true"><input type="image" name="map_pos" src="'.$map_path.'" height="'.$map_height.'" width="'.$map_width.'" /></center>';
}
########## select first char, or search #######
if(!empty($_POST['country'])&& empty($_POST['fchar']) && empty($_POST['search'])&& empty($_POST['town'])){
echo '<br />Einen Anfangsbuchstaben auswählen:<br />';
echo '<form action="index.php?map" method="POST"><input type="hidden" name="um" value="setloc"><input type="hidden" name="country" value="'.$_POST['country'].'"><select name="fchar">';
for ($i=65;$i<91;$i++){
echo '<option value="'.chr($i).'">'.chr($i).'..</option>';
}
echo '</select><input type="submit" value="Auswählen"></form>';
echo '<br /><br />oder suchen Sie nach ihrer Stadt:<br />';
echo '<form action="index.php?map" method="POST"><input type="hidden" name="um" value="setloc"><input type="hidden" name="country" value="'.$_POST['country'].'">';
echo '<input type="text" name="search">';
echo '<input type="submit" value="Suchen"></form>';
}
###########
if(!empty($_POST['country'])&& (!empty($_POST['fchar']) OR !empty($_POST['search']))&& empty($_POST['town'])){
echo '<form action="index.php?map" method="POST"><input type="hidden" name="um" value="setloc"><input type="hidden" name="save" value="chosen"><input type="hidden" name="country" value="'.$_POST['country'].'"><select name="town">';
$f=file('include/contents/map/country/'.$_POST['country'].'.dat');
sort($f);
for ($i=0;$i<count($f)-1;$i++){
if(empty($_POST['search'])){
$comp=(substr($f[$i],1,1)==$_POST['fchar']? TRUE:FALSE);
}else{
$comp=strpos(strtolower($f[$i]),strtolower($_POST['search']));
}
if($comp){
$town=explode(',',str_replace("'","",$f[$i]));
$name=$town[0].' PLZ:'.$town[3];
echo '<option value="'.$i.'">'.$name.'</option>';
}
}
echo '</select><input type="submit" value="Auswählen"></form>';
}
####### save ##########
if(isset($_POST['save'])){
if($_POST['save']=='chosen'){
if(empty($_POST['country']) OR empty($_POST['town'])){
echo '<form action="index.php?map" method="POST"><input type="hidden" name="um" value="setloc">Es ist ein Fehler aufgetreten<br /><input type="submit" value="Zurück"></form>';
}else{
$f=file('include/contents/map/country/'.$_POST['country'].'.dat');
sort($f);
$stown=explode(',',str_replace("'","",$f[$_POST['town']]));
}
}
if($_POST['save']=='man'){
if(empty($_POST['cname']) OR empty($_POST['lon']) OR empty($_POST['lat'])){
echo '<form action="index.php?map" method="POST"><input type="hidden" name="um" value="setloc"><input type="hidden" name="man" value="true"><input type="hidden" name="cname" value="'.@strip_tags($_POST['cname']).'"><input type="hidden" name="lon" value="'.$_POST['lon'].'"><input type="hidden" name="lat" value="'.$_POST['lat'].'">Du müsst alle Felder ausfüllen<br /><input type="submit" value="Zurück"></form>';
}else{
$stown=array(strip_tags($_POST['cname']),str_replace(",",".",$_POST['lat']),str_replace(",",".",$_POST['lon']));
}
}
if(isset($stown)){
$count = @db_result(db_query('SELECT uid FROM `prefix_map` WHERE uid = \''.$_SESSION['authid'].'\''),0);
if (!$count ) {
db_query('INSERT INTO `prefix_map` (`uid`, `longitude`, `latitude`, `cname`) VALUES (\''.$_SESSION['authid'].'\', \''.$stown[2].'\', \''.$stown[1].'\', \''.$stown[0].'\')');
}else{
db_query('UPDATE `prefix_map` SET longitude=\''.$stown[2].'\',latitude=\''.$stown[1].'\',cname=\''.$stown[0].'\'WHERE uid=\''.$_SESSION['authid'].'\'');
}
wd ('?map', 'Dein Wohnort wurde geändert' , 1 );
}
}
}
}
$design->footer();
?>
./include/templates/map.htm
<!--
# map mod
# by: Jihi
-->
<script type="text/javascript">
var tid;
function showi(posx,posy,mid) {
if(tid!=0){
clearTimeout(tid);
tid=0;
}
document.getElementById('map-info-popup').style.left= posx + 4 + "px";
document.getElementById('map-info-popup').style.top= posy + 5 + "px";
document.getElementById('map-info-popup').innerHTML= document.getElementById('tbl-'+mid).innerHTML;
document.getElementById('map-info-popup').style.visibility = 'visible';
}
function hidei() {
tid=setTimeout("document.getElementById('map-info-popup').style.visibility = 'hidden';tid = 0",1000);
}
function overi(){
clearTimeout(tid);
}
</script>
<link rel="stylesheet" type="text/css" href="include/contents/map/map.css">
<center><div style="position:relative;height:{height}px;width:{width}px">
<img src="{path}" height="{height}" width="{width}">
<div id="map-info-popup" class="uinfo" onmouseover="overi()" onmouseout="hidei()"></div>
{EXPLODE}
<div onmouseover="showi({posx},{posy},'{mid}')" onmouseout="hidei()"
class="uinfopt" style="position:absolute; top:{posy}px; left:{posx}px;">
<div class="smalfont" style="border: solid #000000 1px; background-color: #4c5df0;">{counti}</div>
</div>
<div id="tbl-{mid}" style="display:none">
<table class="uinfoTable" cellpadding="0" cellspacing="0">
<tr><td class="uinfoTable1"></td><td class="uinfoTable2"></td><td class="uinfoTable3"></td></tr>
{_list_poplist@
<tr>
<td class="uinfoTable4"></td>
<td class="uinfoTable5">
<div class="uinfoBody">
%4<br><a class="uinfoHeadlink" href="index.php?user-details-%1">%2</a>
<br>%3
</div>
</td>
<td class="uinfoTable6"></td>
</tr>}
<tr><td class="uinfoTable7"></td><td class="uinfoTable8"></td><td class="uinfoTable9"></td></tr>
</table>
</div>
{EXPLODE}
<center><form action="index.php?map" method="POST">
<input type="hidden" name="m" value="map">
<input type="hidden" name="um" value="setloc">
<input type="submit" value="Deinen Wohnort ändern">
</form></center>
{EXPLODE}
<script language=JavaScript>
showi({posx},{posy},'{mid}');
</script>
{EXPLODE}
</div></center>
{EXPLODE}
<center><font class="smalfont" style="color: #000000">[ by jihi ]</font></center>
{EXPLODE}
<script type="text/javascript">
function switch_select_group() {
if (document.getElementById('select-group').style.display == 'inline'){
document.getElementById('select-group').style.display = 'none';
}else{
document.getElementById('select-group').style.display = 'inline';
}
}
</script>
<a href="#" onclick="switch_select_group()">Anzeige Optionen</a><br>
<div id="select-group" class="selectgroup">
<table border="1">
<form action="?map" method="POST">
<input type="hidden" name="changeGroup" value="true">
<tr><td><center><a href="?map-show_group_all">Alle</a></center></td><td></td></tr>
{_list_selgroup@<tr><td><a href="?map-show_group%2">%1</a></td><td><input type="checkbox" name="groups[gr%2]" value="%2"%3></td></tr>}
<tr><td colspan="2"><center><input type="submit" value="Ändern"></center></td></tr>
</form></table>
</div>
<br>
Einfach beide Dateien im richtigen Ordner ersetzen!