<?php
require("connect.php");

function ip() {
    $ip2 = "UNBEKANNT";
    if ($_SERVER["HTTP_CLIENT_IP"]) 
        $ip2 = $_SERVER["HTTP_CLIENT_IP"];
    else if($_SERVER["HTTP_X_FORWARDED_FOR"]) 
        $ip2 = $_SERVER["HTTP_X_FORWARDED_FOR"];
    else if($_SERVER["REMOTE_ADDR"]) 
        $ip2 = $_SERVER["REMOTE_ADDR"];
    return $ip2;
}

mysql_query("update accounts set agent='".$_SERVER[HTTP_USER_AGENT]."' where ipAddress='".ip($ip2)."'");

$a = mysql_fetch_array(mysql_query("select name, photo from accounts where ratingZahl>='5.0' and photo != '' and name != 'James' order by rand()"));
$b = mysql_fetch_array(mysql_query("select name, photo from accounts where ratingZahl>='5.0' and photo != '' and name != 'James' and name != '".$a[name]."' order by rand()"));
$c = mysql_fetch_array(mysql_query("select name, photo from accounts where ratingZahl>='5.0' and photo != '' and name != 'James' and name != '".$a[name]."' and name != '".$b[name]."' order by rand()"));

if(strlen($a[name]) > 9) {
	$aname = substr($a[name], 0, 9).'...';
}else{
	$aname = $a[name];
}

if(strlen($b[name]) > 9) {
	$bname = substr($b[name], 0, 9).'...';
}else{
	$bname = $b[name];
}

if(strlen($c[name]) > 9) {
	$cname = substr($c[name], 0, 9).'...';
}else{
	$cname = $c[name];
}

$fotos = '<div id="online_user">
<div class="user0">
<div class="user">
<a href="photos-profile.php?id='.$a[name].'"class="userpic userimage medium66 medium66_centered_link" target="_blank">
<span class="medium66_centered">
<img src="pics/photos/m/'.$a[photo].'.jpg" />
</span>
</a>
<br class="">
<a href="photos-profile.php?id='.$a[name].'" class="username" target="_blank">'.$aname.'</a>
</div>
</div>
<div class="user1">
<div class="user">
<a href="photos-profile?id='.$b[name].'" class="userpic userimage medium66 medium66_centered_link" target="_blank">
<span class="medium66_centered">
<img src="pics/photos/m/'.$b[photo].'.jpg" />
</span>
</a>
<br class="">
<a href="photos-profile.php?id='.$b[name].'" class="username" target="_blank">'.$bname.'</a>
</div>
</div>
<div class="user2">
<div class="user">
<a href="photos-profile.php?id='.$c[name].'" class="userpic userimage medium66 medium66_centered_link"  target="_blank">
<span class="medium66_centered">
<img src="pics/photos/m/'.$c[photo].'.jpg" />
</span>
</a>
<br class="">
<a href="photos-profile.php?id='.$c[name].'" class="username" target="_blank">'.$cname.'</a>
</div>
</div></div>';

$registrieren = '<div class="bbutton jsregtrigger" id="hdbtregister"><a href="registrieren.php" id="hdbtregister-a"><div class="bttl corner"></div><div class="bttr corner"></div><div class="bttm"></div><div class="btm"><img src="/sf/m/buttons/bt-nm.png" id="hdbtregister-img" class="jsFixHeight" style="" height="22" width="" /><div class="btmi"><span class="text">Neu Registrieren</span></div></div><div class="btbl corner"></div><div class="btbr corner"></div><div class="btbm"></div></a></div>';

if(substr($_SERVER['PHP_SELF'],0,7) == '/photos') {
	if(!$_SESSION[foto]) {
		$registrieren = '<div class="bbutton jsregtrigger" id="hdbtregister"><a href="registrieren.php" id="hdbtregister-a"><div class="bttl corner"></div><div class="bttr corner"></div><div 		class="bttm"></div><div class="btm"><img src="/sf/m/buttons/bt-nm.png" id="hdbtregister-img" 		class="jsFixHeight" style="" height="22" width="" /><div class="btmi"><span class="text">Neu 		Registrieren</span></div></div><div class="btbl corner"></div><div class="btbr corner"></div><div 		class="btbm"></div></a></div>';
	}else{
		$registrieren = '
		<div class="photo_logout" style="z-index:20;"><a href="photos-profile.php?id='.$_SESSION[foto].'">'.$_SESSION[foto].'</a>&nbsp;<a href="photos-logout.php"><img src="sf/f/photos/logout.gif" /></a></div>';
	}

	$fotonavi = ' <ul class="first">
<li class="last backhome"><a href="index.php" class="menua">&laquo; Startseite<div class="arrow"></div><div class="border"></div><div class="fade"></div></a></li>
</ul>
<ul class="componentnavi">
<li class="first "><a id="photo_myprofile" class="menua" href="photos-profile.php">Mein Profilfoto<div class="arrow"></div><div class="border"></div><div class="fade"></div></a></li>
<li class=""><a class="menua" href="photos-upload.php">Profilfoto hochladen<div class="arrow"></div><div class="border"></div><div class="fade"></div></a></li>
<li class=""><a class="menua" href="photos-verifyphoto.php">Profilfoto verifizieren<div class="arrow"></div><div class="border"></div><div class="fade"></div></a></li>
<li class="last"><a class="menua" href="photos-createalbum.php">Album anlegen<div class="arrow"></div><div class="border"></div><div class="fade"></div></a></li>
</ul>
<ul class="componentnavi">
<li class="first "><a class="menua" href="photos-new.php">Neueste Fotos<div class="arrow"></div><div class="border"></div><div class="fade"></div></a></li>
<li class=""><a id="photo_rating" class="menua" href="photos-rate.php">Fotorating<div class="arrow"></div><div class="border"></div><div class="fade"></div></a></li>
<li class=""><a id="photo_toplists" class="menua" href="photos-index.php">Toplisten<div class="arrow"></div><div class="border"></div><div class="fade"></div></a></li>
<li class=""><a id="photo_random" class="menua" href="photos-random.php">Zufällige Fotos<div class="arrow"></div><div class="border"></div><div class="fade"></div></a></li>
<li class="last "><a class="menua" href="photos-faq.php">FAQ<div class="arrow"></div><div class="border"></div><div class="fade"></div></a></li>
</ul>
<ul>
        <li class="first "><a href="registrieren.php" class="menua">Registrieren<div class="arrow"></div><div class="/div><div class="fade"></div></a></li>
        <li class=""><a href="index.php" class="menua">Chat<div class="arrow"></div><div class="border"></div><div class="fade"></div></a></li>
        <li class="last"><a href="/forum/" target="_blank" class="menua">Forum<div class="arrow"></div><div class="border"></div><div class="fade"></div></a></li>
       </ul>';
}else{
$fotonavi = ' <ul class="first jsregtrigger">
        <li class="first"><a href="registrieren.php" class="menua">Registrieren<div class="arrow"></div><div class="border"></div><div class="fade"></div></a></li>
        <li class=""><a href="index.php" class="menua">Chat<div class="arrow"></div><div class="border"></div><div class="fade"></div></a></li>
        <li class="last"><a href="/forum/" target="_blank" class="menua">Forum<div class="arrow"></div><div class="border"></div><div class="fade"></div></a></li>

       </ul>';
}

?>