<?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.
 $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
 
 $TextColor=getDaten("TextColor");                      //Farbe Text
 $LinkColor=getDaten("LinkColor");                      //Farbe Link
 $HoverColor=getDaten("HoverColor");                    //Farbe Hover Link
 $BorderColor=getDaten("BorderColor");                  //Rahmenfarbe Tabelle 
 $BGColor=getDaten("BGColor");                          //Hintergrundfarbe Seite
 $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
 $TCol=getDaten("TCol");                                //Farbe Text im Teaser
 $THCol=getDaten("THCol");                              //Hover-Farbe Text im Teaser
 $PicBorderCol=getDaten("PicBorderCol");                //Rahmenfarbe Profilbild
 $PicHoverCol=getDaten("PicHoverCol");                  //Hover-Rahmenfarbe Profilbild
 $SkinType=getDaten("SkinType");                        //Skinnummer
 $Verlauf=getDaten("Verlauf");                          //Verlauftyp im Teaser (black/white)
 $SCol=getDaten("SCol");                                //Farbe Onlinestatus
 $TBGCol=getDaten("TBGCol");                            //Hintergrundfarbe Teaser

 switch ($SkinType){
    case 1:
     $Skin='lila';
     $SColor="#FFF";
     $TColor='#ffffff';
     $THColor='#DFB0DF';
     $PicBorderColor='#5B005B';
     $PicHoverColor='#DFB0DF';
     $TBGColor='#970097';
     $SkinVerlauf='black';
     break;
    case 2: 
     $Skin='weiss';
     $SColor="#FF6600";
     $TColor='#000000';
     $THColor='#FF6600';
     $PicBorderColor='#C8C8C8';
     $PicHoverColor='#FF6600';
     $TBGColor='#C2C2C2';
     $SkinVerlauf='white';
     break;
    case 3: 
     $Skin='weiss';
     $SColor="#7896D8";
     $TColor='#FFFFFF';
     $THColor='#0A286A';
     $PicBorderColor='#FFFFFF';
     $PicHoverColor='#7896D8';
     $TBGColor='#7896D8';
     $SkinVerlauf='white';
     break;
    case 4: 
     $Skin='weiss';
     $SColor="#D0002C";
     $TColor='#FFFFFF';
     $THColor='#FFC0CD';
     $PicBorderColor='#D0002C';
     $PicHoverColor='#D0002C';
     $TBGColor='#D0002C';
     $SkinVerlauf='black';
     break;
    case 5: 
     $Skin='gelb';
     $SColor="#3B54A5";
     $TColor='#000000';
     $THColor='#3B54A5';
     $PicBorderColor='#FFFFFF';
     $PicHoverColor='#FFE400';
     $TBGColor='#FFFFFF';
     $SkinVerlauf='black';
     break;
    case 6: 
     $Skin='schwarz';
     $SColor="#9C9C9C";
     $TColor='#FFFFFF';
     $THColor='#9C9C9C';
     $PicBorderColor='#9C9C9C';
     $PicHoverColor='#FFFFFF';
     $TBGColor='#4B4B4B';
     $SkinVerlauf='white';
     break;
    case 7: 
     $Skin='lila';
     $SColor="#FFE400";
     $TColor='#990099';
     $THColor='#FF00FF';
     $PicBorderColor='#990099';
     $PicHoverColor='#FF00FF';
     $TBGColor='#FFFFFF';
     $SkinVerlauf='black';
     break;
    case 8: 
     $Skin='gelb';
     $SColor="#990099";
     $TColor='#FFE300';
     $THColor='#FFFFFF';
     $PicBorderColor='#FFE300';
     $PicHoverColor='#FFFFFF';
     $TBGColor='#990099';
     $SkinVerlauf='black';
     break;
    default: 
     $Skin='orange';
     $SColor="#FFF";
     $TColor='#000000';
     $THColor='#FF6600';
     $PicBorderColor='#FFFFFF';
     $PicHoverColor='#FF6600';
     $TBGColor='#FFFFFF';
     $SkinVerlauf='black';
     break;
 }
 
 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",$TextColor)) $TextColor="#FFF";
 if (!preg_match("/^#[0-9A-F]{6}$/i",$LinkColor)) $LinkColor="#FFF";
 if (!preg_match("/^#[0-9A-F]{6}$/i",$HoverColor)) $HoverColor="#ff0000";
 if (!preg_match("/^[_0-9A-Z]+$/i",$BaseTarget)) $BaseTarget="_top";

 if (!in_array($Verlauf,array('black','white'))) $Verlauf=$SkinVerlauf;
 if (!preg_match("/^#[0-9A-F]{6}$/i",$TCol)) $TCol=$TColor;
 if (!preg_match("/^#[0-9A-F]{6}$/i",$THCol)) $THCol=$THColor; 
 if (!preg_match("/^#[0-9A-F]{6}$/i",$PicBorderCol)) $PicBorderCol=$PicBorderColor;
 if (!preg_match("/^#[0-9A-F]{6}$/i",$PicHoverCol)) $PicHoverCol=$PicHoverColor;
 if (!preg_match("/^#[0-9A-F]{6}$/i",$SCol)) $SCol=$SColor;
 if (!preg_match("/^#[0-9A-F]{6}$/i",$TBGCol)) $TBGCol=$TBGColor;
 
 if ($Breite>1760+2) $Breite=1760+2;    //2Pixel Border
 if ($Hoehe>1680+2) $Hoehe=1680+2;      //2Pixel Border
 
 if ($Breite<254) $Breite=254;      //2Pixel Border
 if ($Hoehe<168+2) $Hoehe=168+2;        //2Pixel Border

 $ElemsPerRow=floor(($Breite-2)/84);   //2Pixel Border
 $ElemsWidth=$ElemsPerRow*84;
 $HeaderHoehe=34;
 if ($ElemsWidth<179+150) {$HeaderHoehe+=30;}
 if ($ElemsWidth<179+150+250) {$HeaderHoehe+=30;}
 $StdLinkParams=" href=\"".htmlentities($Target)."\" target=\"".htmlentities($BaseTarget)."\"";
 $PageHeader.="";
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<style type="text/css"><!--
body {margin:0px;padding:0px;background-color:<? Print $BGColor;?>;font-family:tahoma;}
.Rahmen { text-align:center;width:<? Print (int)$Breite-2;?>;<? if (!empty($BorderColor)) Print "border: 1px solid $BorderColor;";?>}
.Liste {margin:auto;width:<? Print (int)$ElemsWidth;?>px;} 
.nodeco *{ border:none;}
a.nodeco img,a.nodeco:hover img{border:0px;}
.banner { display:block;height:<? Print (int)$HeaderHoehe;?>px; width:<? Print (int)$ElemsWidth;?>px;overflow:hidden;}
.banner img {width:168px;height:30px;}
.banner .logo {display:block;float:left;width:<? Print $ElemsWidth<179+150?$ElemsWidth-16:168;?>px;margin:0px 8px; text-align:center;}
.banner .text1 {text-align:center;width:<? Print $ElemsWidth<179+150?$ElemsWidth-4:146;?>px;float:left;font-weight:bold;color:<? Print $TextColor;?>;font-size:15px;line-height:30px;margin-right:4px;}
.banner .text2 {text-align:center;width:<? Print $ElemsWidth<179+150+250?$ElemsWidth:250;?>px;float:left;line-height:30px;}
.banner .text2 a{text-decoration:none;text-transform:uppercase;font-weight:bold;color:<? Print $LinkColor;?>;font-size:16px;line-height:30px;}
.banner .text2 a span {text-transform:none;}
.banner .text2 a:hover {color:<? Print $HoverColor;?>;}
.prof1_body {display:block;width:80px;margin:2px;float:left;height:160px;}
.prof1_img {display:block;width:80px;height:92px;}   
.prof1_img a img.prof_pic {display:block;border:1px solid <? Print $PicBorderCol;?>;}
.prof1_img a:hover img.prof_pic {border-color:<? Print $PicHoverCol;?>;}
.prof1_textblock {display:block;width:80px;font-size:11px;}
.prof1_textblock a {color:<? Print $TCol;?>;}
.prof1_textblock a:hover {color:<? Print $THCol;?>;}
.prof1_status {display:block;height:20px;background-image: url("./img/leiste_oben_<?Print $Skin;?>.jpg");}
.prof1_state {display:block;line-height:20px;float:left;margin-left:3px;width:51px;color:<? Print $SCol;?>;font-size:12px;}
.prof1_texte {height:40px;background-color:<? Print $TBGCol;?>;
<? if (!empty($Verlauf)){?>
        background-image:   url("./img/verlauf_<?Print $Verlauf;?>.png");
        background-position: bottom left;
        background-repeat:   repeat-x;
<? }?>}
.prof1_text1, .prof1_text2{width:73px;margin-left:5px;margin-right:2px;overflow:hidden;}
.prof1_geschlecht {display:block;width:25px;height:15px;float:left;text-align:center;}
.prof1_geschlecht img {display:block;margin-top:0px;border:0px;}
--></style>
<script src="./sLayers.js" type="text/javascript"></script>
</head>
<body><div class="Rahmen"><div class="Liste"><?
$GeoDaten=false;
if ($PLZ===false){
 $GeoLaender=array("DE"=>"Deutschland","AT"=>"Österreich");//,"CH"=>"Schweiz"
 require_once('/usr/local/composer/vendor/autoload.php');
 $reader = new \GeoIp2\Database\Reader('/usr/local/composer/GeoLite2-City.mmdb');

 //(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";
?><!-- headline -->
<div class="banner">
<div class="logo"><a<? Print $StdLinkParams;?> class="nodeco"><img src="./img/wm1_banner.png" alt=""/></a></div>
<? 

if (is_array($GeoDaten) && array_key_exists('city',$GeoDaten) && !empty($GeoDaten['city'])){
?>
<div class="text1">Amateure aus</div><div class="text2"><a<? Print $StdLinkParams;?>><? Print htmlentities($GeoDaten['city']);?><span> und Umgebung</span></a></div><? 
}else
if (!empty($Region)){?>
<div class="text1">Amateure aus</div><div class="text2"><a<? Print $StdLinkParams;?>><? Print htmlentities($GeoRegionen[$Region][0]);?></a></div><? 
}else{?>
<div class="text1">Amateure aus</div><div class="text2"><a<? Print $StdLinkParams;?>><span>deiner Umgebung</span></a></div>
<? }?>
    <div style="clear: both"></div>
</div>
<?
$MaxRows=max(1,floor(($Hoehe-2-$HeaderHoehe)/162)); //2Pixel Border
 
$MaxElems=$ElemsPerRow*$MaxRows;

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

 $Start=rand(0,count($Keys)-1);
 $Pos=$Start;$Limit=$MaxElems;
 $Cnt=0;
 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="prof1_body">
<!-- Profilbild -->
<div class="prof1_img"><? Print "<a$LinkParams><img src=\"$absPath/UserPics/".htmlentities($Userid)."_78x90px.jpg\" width=\"78\" height=\"90\" border=\"0\" class=\"prof_pic\" alt=\"\"></a>";?></div>

<!-- Status-->
    <div class="prof1_textblock prof1_status">
        <div class="prof1_state">&nbsp;</div>
        <div class="prof1_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/leiste_oben_<? Print $Skin;?>_<? Print $Sex;?>.jpg" border="0" align="absmiddle"></a><?
 }}?></div>
     <div style="clear: both"></div>
    </div>
    <div class="prof1_textblock prof1_texte">
        <div class="prof1_text1">
            <a onmouseover="StartMover(this);" onmouseout="StopMover(this);"<? Print $LinkParams;?>><nobr><? Print htmlentities($Userdat['Nick']);
  $AlterStr="";$HasAlter=false;
  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?"/":"")."-";
  }
  if ($HasAlter) Print htmlentities(",".$AlterStr);
?></nobr></a>
        </div>
<? if (array_key_exists('Region',$Userdat)){?>        
        <div class="prof1_text2"><a<? Print $LinkParams;?>><? Print htmlentities($Userdat['Region']);?></a></div>
<? }?>
    </div>
</div>
<?
  if ($Limit && --$Limit<=0) break;
  $Pos++;
  if ($Pos>=count($Keys)) $Pos=0;
  if ($Pos==$Start) break;
  if ((++$Cnt%$ElemsPerRow)==0) Print "<br clear=\"all\">";
 }while (true);
}
?><div style="clear: both;"></div></div></div>
</body>
</html>
