<?php
// (c) 2010-2013 RapidComp GmbH, Autor: Michael Niendorf
// Das Hosting schliesst automatisch die Akzeptanz eines RapidComp GmbH Lizenzvertrages bzw. der AGBs ein,
// der/die unter anderem als Textdokument bei RapidComp GmbH erhältlich ist/sind.

 $Limit=getDaten("lim");
 if ($Limit===false) $Limit=30;
 $Geschlecht=getDaten("sex");
 if (!in_array($Geschlecht,array('a','m','w','p'))) $Geschlecht='a';
 $PLZ=getDaten("PLZ");

 $Target=getDaten("Target");                            //Ziel zum Klick (click.php)
 $targeturl=getDaten("targeturl");                      //wenn auf 1 dann direkt zur Modelprofilseite
 
 $BGColor=getDaten("BGColor");                          //Hintergrundfarbe Seite
 $TBGColor=getDaten("TBGColor");                        //Hintergrundfarbe Tabelle
 $BorderColor=getDaten("BorderColor");                  //Rahmenfarbe Tabelle
 $TextColor=getDaten("TextColor");                      //Farbe Text
 $HoverColor=getDaten("HoverColor");                    //Farbe Hover Link
 $PicBorderColor=getDaten("PicBorderColor");            //Rahmenfarbe Profilbild
 $PicHoverColor=getDaten("PicHoverColor");              //Rahmenfarbe Hover Profilbild
 
 $Breite=(int)trim(getDaten("breite"));                 //Breite in Pixeln (178-1762)
 $Hoehe=(int)trim(getDaten("hoehe"));                   //Höhe in Pixeln (170-1682)
 $BaseTarget=getDaten("BaseTarget");                    //Zielfenster
 $Skin=getDaten("Skin");
 
 if (!in_array($Skin,array('black','gold','orange','purple','white'))) $Skin='orange';
 
 if (!preg_match("/^#[0-9A-F]{6}$/i",$BorderColor)) $BorderColor="#000000";
 if (!preg_match("/^#[0-9A-F]{6}$/i",$BGColor)) $BGColor="#000000";
 if (!preg_match("/^#[0-9A-F]{6}$/i",$TBGColor)) $TBGColor="#FFF";
 if (!preg_match("/^#[0-9A-F]{6}$/i",$TextColor)) $TextColor="#000000";
 if (!preg_match("/^#[0-9A-F]{6}$/i",$HoverColor)) $HoverColor="#ff0000";
 if (!preg_match("/^#[0-9A-F]{6}$/i",$PicBorderColor)) $PicBorderColor="#000000";
 if (!preg_match("/^#[0-9A-F]{6}$/i",$PicHoverColor)) $PicHoverColor="#ff0000";
 if (!preg_match("/^[_0-9A-Z]+$/i",$BaseTarget)) $BaseTarget="_top";
 
 if ($Breite>1760+2) $Breite=1760+2;    //2Pixel Border
 if ($Hoehe>1680+2) $Hoehe=1680+2;      //2Pixel Border
 
 if ($Breite<170) $Breite=170;      //2Pixel Border
 if ($Hoehe<120) $Hoehe=120;        //2Pixel Border

 $HeaderHoehe=34;
 
 $StdLinkParams=" href=\"".htmlentities($Target)."\" target=\"".htmlentities($BaseTarget)."\"";
 $sLayerCnt=0;
 $PageHeader.="";
 $MaxY=$Hoehe;
 function getsLayerScript($sLayerCnt,$MinY,$MaxY){
  return " onmouseout=\"hidesLayers();\" onmouseover=\"hidesLayers();showsLayer($sLayerCnt,$MinY,$MaxY);\"";
 }
 function getsLayerScript2($sLayerCnt){
  return " onmouseout=\"hidesLayers();\"";
 }

?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<style type="text/css"><!--
.nodeco *{ border:none;}
a.nodeco img,a.nodeco:hover img{border:0px;}
body {margin:0px;padding:0px;background-color:<? Print $BGColor;?>;font-family:tahoma;}
.banner {display:block;width:168px;height:30px;margin-bottom:4px;}
.banner img { border: 0px; }
.prof_body {display:block;width:<? Print number_format($Breite-23,0,"","");?>px;background-color:<? Print $TBGColor;?>;margin:2px 0px;clear:both;border:1px solid <? Print $TBGColor;?>;}
.prof_img {display:block;float:left;width:39px;height:45px;margin-right:5px;}
.prof_img a img.prof_pic { display:block;width:37px;height:43px;border:1px solid <? Print $PicBorderColor;?>;}
.prof_img a:hover img.prof_pic { border-color:<? Print $PicHoverColor;?>;}
.prof_textblock { display:block;float:left;width:<? Print number_format($Breite-67,0,"","");?>px;font-size:11px;}   
.prof_textblock a { color:<? Print $TextColor;?>;}    
.prof_textblock a:hover { color:<? Print $HoverColor;?>;}    
.prof_name { display:inline-block;line-height:15px;float:left;font-size:11px;}    
.prof_geschlecht {display:block;width:25px;height:15px;float:left;text-align:center;}  
.prof_geschlecht img {border:0px;}
.weiterlink {text-align: right;}
.userlist{ text-align: left;
font-family: Arial,Helvetica;font-size: 10px;border:1px solid <? Print $BorderColor?>;background-color:<? Print $TBGColor;?>;
width:<? Print number_format($Breite-2,0,"","");?>px!important; 
width: <? Print number_format($Breite,0,"","");?>px; 
height:<? Print number_format($Hoehe-$HeaderHoehe-2,0,"","");?>px!important;
height:<? Print number_format($Hoehe-$HeaderHoehe,0,"","");?>px;
overflow: auto; margin-top: 0px; 
}
.sLayer2{ position:relative; width:91px; height:94px; top:2px; left:44px; background-image: url('./img/sLayer_back_<? Print $Skin;?>.png'); background-repeat: no-repeat;}
.sLayer2 img{ margin:2px 0px 0px 11px;}                                                                            
.sLayer3{ position:relative; width:91px; height:94px; top:-50px; left:44px; background-image: url('./img/sLayer2_back_<? Print $Skin;?>.png'); background-repeat: no-repeat;}
.sLayer3 img{ margin:2px 0px 0px 11px;}
.sLayer1{ display:none; position:relative; width:0px;height:0px;top:0px;left:0px;}
.sLayer1vis{ display:block;position:relative; width:0px;height:0px;top:0px;left:0px;}
--></style>
<script src="./sLayers.js" type="text/javascript"></script>
</head>
<body>  
<div class="banner"><a<? Print $StdLinkParams;?>><img src="./img/wm1_banner.png" alt=""/></a></div>
<div class="userlist" onscroll="hidesLayers();" id="UserList">
<?
if ($PLZ===false){
 require_once('/usr/local/composer/vendor/autoload.php');
 $reader = new \GeoIp2\Database\Reader('/usr/local/composer/GeoLite2-City.mmdb');

 $GeoLaender=array("DE"=>"Deutschland","AT"=>"Österreich");//,"CH"=>"Schweiz"
 //(mcm)
 $isoBundeslaender = array(
    'DE' => array(
	'BW' => 'DE_01', 'BY' => 'DE_02', 'BE' => 'DE_16', 'BB' => 'DE_11',
	'HB' => 'DE_03', 'HH' => 'DE_04', 'HE' => 'DE_05', 'MV' => 'DE_12', 
	'NI' => 'DE_06', 'NW' => 'DE_07', 'RP' => 'DE_08', 'SL' => 'DE_09',
	'SN' => 'DE_13', 'ST' => 'DE_14', 'SH' => 'DE_10', 'TH' => 'DE_15'),
    'AT' => array(
	'1' => 'AT_01', '2' => 'AT_02', '3' => 'AT_03',
	'4' => 'AT_04', '5' => 'AT_05', '6' => 'AT_06',
	'7' => 'AT_07', '8' => 'AT_08', '9' => 'AT_09'),
    );

 $GeoRegionen=array(
    'DE_01'=>array("Baden-Württemberg",'karte_baden_wuerttemb.gif'),
    'DE_02'=>array("Bayern",'karte_bayern.gif'),
    'DE_03'=>array("Bremen",'karte_bremen.gif'),
    'DE_04'=>array("Hamburg",'karte_hamburg.gif'),
    'DE_05'=>array("Hessen",'karte_hessen.gif'),
    'DE_06'=>array("Niedersachsen",'karte_niedersachsen.gif'),
    'DE_07'=>array("Nordrhein-Westfalen",'karte_nordrhein_westf.gif'),
    'DE_08'=>array("Rheinland-Pfalz",'karte_rheinland_pfalz.gif'),
    'DE_09'=>array("Saarland",'karte_saarland.gif'),
    'DE_10'=>array("Schleswig-Holstein",'karte_schleswig_holstein.gif'),
    'DE_11'=>array("Brandenburg",'karte_brandenburg.gif'),
    'DE_12'=>array("Mecklenburg-Vorpommern",'karte_meck_vorpomm.gif'),
    'DE_13'=>array("Sachsen",'karte_sachsen.gif'),
    'DE_14'=>array("Sachsen-Anhalt",'karte_sachsen_anhalt.gif'),
    'DE_15'=>array("Thüringen",'karte_thueringen.gif'),
    'DE_16'=>array("Berlin",'karte_berlin.gif'),
    
    'AT_01'=>array("Burgenland",'karte_burgenland.gif'),
    'AT_02'=>array("Kärnten",'karte_kaernten.gif'),
    'AT_03'=>array("Niederösterreich",'karte_niederoesterreich.gif'),
    'AT_04'=>array("Oberösterreich",'karte_oberoesterreich.gif'),
    'AT_05'=>array("Salzburg",'karte_salzburg.gif'),
    'AT_06'=>array("Steiermark",'karte_steiermark.gif'),
    'AT_07'=>array("Tirol",'karte_tirol.gif'),
    'AT_08'=>array("Vorarlberg",'karte_voralberg.gif'),
    'AT_09'=>array("Wien",'karte_wien.gif'),
 );                                                                                       
 $Region=0;
 $GeoIP=$_SERVER['REMOTE_ADDR'];

 if ($GeoIP && $geoDaten = $reader->city($GeoIP)) {
    if (!empty($geoDaten->country->isoCode)) {
	$isoCode = $geoDaten->country->isoCode;

	if (!empty($isoBundeslaender[$isoCode][$geoDaten->mostSpecificSubdivision->isoCode]))
	    $Region = $isoBundeslaender[$isoCode][$geoDaten->mostSpecificSubdivision->isoCode];
    }
 }

// if ($GeoDaten=geoip_record_by_name($GeoIP)){
//  $tmpRegion=$GeoDaten['country_code']."_".$GeoDaten['region'];
//  if (array_key_exists($tmpRegion,$GeoRegionen))
//   $Region=$tmpRegion;
// }

      $SourceFile=$Geschlecht.".ab16.$Region";
}elseif (strcasecmp($PLZ,'alle')) $SourceFile=$Geschlecht."_plz".((int)$PLZ).".ab16";
else $SourceFile=$Geschlecht.".ab16.0";

$User=array();
@include("$relPath/WBMExportData/$SourceFile.php");
if (count($User)>0){
 $Keys=array_keys($User);

 $Start=rand(0,count($Keys)-1);
 $Pos=$Start;
 do{
  $Userid=$Keys[$Pos];
  $Userdat=$User[$Userid];  
 
  $UserTarget=$Target;
  if($targeturl==1) $UserTarget.="&turl=".urlencode("http://www.nowyoo.com/tour/profil_".$Userdat['Nick'].".html");  
  
  $LinkParams=" href=\"".htmlentities($UserTarget)."\" target=\"".htmlentities($BaseTarget)."\"";
?>
<div class="prof_body">
    <div class="prof_img">
<? Print "<div id=\"sLayer".(++$sLayerCnt)."\" name=\"sLayers\" class=\"nodeco sLayer1\"><div id=\"sLayerBg$sLayerCnt\" class=\"sLayer3\"".getsLayerScript2($sLayerCnt)."><img border=\"0\" src=\"$absPath/UserPics/".htmlentities($Userid)."_78x90px.jpg\" width=\"78\" height=\"90\" alt=\"\"></div></div>";?>
<? Print "<a$LinkParams ".getsLayerScript($sLayerCnt,20,$MaxY)."><img src=\"$absPath/UserPics/".htmlentities($Userid)."_37x43px.jpg\" width=\"37\" height=\"43\" border=\"0\" class=\"prof_pic\" alt=\"\"></a>";?>
    </div>
    <div class="prof_textblock">
        <div class="prof_name"><a<? Print $LinkParams;?>><? Print htmlentities($Userdat['Nick']);?></a></div>
        <div class="prof_geschlecht"><? 
 //Geschlecht auswerten und anzeigen
 if (array_key_exists('Data',$Userdat) && count($Userdat['Data'])>0){
   $UserCnt=count($Userdat['Data']);
   $Sex="";
   if ($UserCnt==1){
         if (array_key_exists('sex',$Userdat['Data'][0])) $Sex=$Userdat['Data'][0]['sex'];
   }else $Sex="p";
   if (!empty($Sex)){
?><a<? Print $LinkParams;?>><img src="./img/<? Print $Sex;?>_<? Print $Skin;?>.gif" border="0" align="absmiddle"></a><?    
 }}?></div>
        <br clear="all"/>
<? 
  $AlterOrtStr="";$HasAlter=false;$AlterStr="";
  if (array_key_exists('Data',$Userdat)){
   $UserCnt=count($Userdat['Data']);
   for ($i=0;$i<$UserCnt;$i++)
    if (array_key_exists('dateofbirth',$Userdat['Data'][$i])) {
        $HasAlter=true;
        $GebDatum=explode('-',$Userdat['Data'][$i]['dateofbirth']);
        $AlterStr.=($i>0?"/":"").number_format(alter(false,$GebDatum[0],$GebDatum[1],$GebDatum[2]),0,"","");
    }else $AlterStr.=($i>0?"/":"")."-";
  }
           
  $AlterOrtStr=htmlentities(array_key_exists('Region',$Userdat)?($HasAlter?"$AlterStr,":'').$Userdat['Region']:$AlterStr);
  if (!empty($AlterOrtStr)){?><a<? Print $LinkParams;?>><? Print $AlterOrtStr;?></a><? }?>
        <div class="weiterlink"><a<? Print $LinkParams;?>>zum Profil</a></div>
        <div style="clear: both"></div>
    </div>
    <div style="clear: both"></div>
</div>
<? 
  if ($Limit && --$Limit<=0) break;
  $Pos++;
  if ($Pos>=count($Keys)) $Pos=0;
  if ($Pos==$Start) break;
 }while (true);
}?>
</div>
</body>
</html>