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

$titel = 'Fans - Fotos';
$styles = '<link href="/sf/f/registration/registration.css" rel="stylesheet" type="text/css">
<link href="/sf/m/buttons/buttons.css" rel="stylesheet" type="text/css"><link href="/sf/f/index/index.css" rel="stylesheet" type="text/css"><link href="/sf/m/boxes/boxes.css" rel="stylesheet" type="text/css"><link href="/sf/m/forms/forms.css" rel="stylesheet" type="text/css"><link href="/sf/f/photos/photos.css" rel="stylesheet" type="text/css"><link href="/sf/m/uploader/uploader.css" rel="stylesheet" type="text/css">';

$id = mysql_real_escape_string($_GET[id]);

$row = mysql_fetch_array(mysql_query("SELECT `name`, `photo` FROM `accounts` WHERE `name` = '".$id."'"));
$fans = mysql_fetch_assoc(mysql_query("SELECT COUNT(id) as `zahl` FROM `fans` WHERE `an` = '".$row[name]."'"));

if(!$row[name]) {
	header("location:photos-error");
}

if(!$row[photo]) {
	$photo = 'sf/f/photos/nopic_pro_sq.jpg';
} else {
	$photo = 'pics/photos/s/'.$row[photo].'.jpg';
}

$result_total = mysql_query("SELECT COUNT(*) as `total` FROM `fans` WHERE `an` = '".$row[name]."'");
$row_total = mysql_fetch_assoc($result_total);
$gesamte_anzahl = $row_total['total']; 
$ergebnisse_pro_seite = 10;
$gesamt_seiten = ceil($gesamte_anzahl/$ergebnisse_pro_seite); 

if (empty($_GET['fanInPage'])) {
    $seite = 1;
} else {
    $seite = $_GET['fanInPage'];
    if ($seite > $gesamt_seiten) {
        $seite = 1;
    }
} 
$limit = ($seite*$ergebnisse_pro_seite)-$ergebnisse_pro_seite;


$inhalt .= '<div id="kmain" role="main">
<div class="photo">
<div class="noh1"></div>
<div class="usernavigation">
<div class="fanbutton_right">

</div>
<table><tr><td><a href="photos-profile.php?id='.$row[name].'" class="userpic userimage small_square small_quad_centered_link" style="position: relative;"><img src="'.$photo.'" class="small_quad_centered" /></a>
</td><td>&nbsp;<a href="photos-profile.php?id='.$row[name].'">'.$row[name].'s Profil</a>

|
<a href="photos-albums?id='.$row[name].'">Alle Alben</a>
</td></tr></table></div>
<div class="box comments small">
<div class="hd">
<div class="tl"></div>
<div class="tr"></div>

<div class="tm"></div>
<div class="m">
<div class="ml">
<div class="mr">
<div class="mi">
<div class="h h2"><div class="hbegin"></div><h2>

Fans von '.$row[name];

if($fans[zahl] > 0) {
	$inhalt .= '<span class="fanCount">'.$fans[zahl].' Fans</span>';
}

$inhalt .= '

</h2></div>
</div>
</div>
</div>
</div>

</div>
<div class="bd fade bd-fade">
<div class="m">
<div class="ml">
<div class="mr">
<div class="mi">


<div class="pagination toppagination">
';

for ($i=1; $i<=$gesamt_seiten; ++$i) {
    if ($seite == $i) {
        $inhalt .= '<strong class="page"><span class="ptl"></span><span class="pbl"></span>'.$i.'</strong>';
    } else {
        $inhalt .= '<a href="photos-fans.php?id='.$row[name].'&fanInPage='.$i.'" class="page">'.$i.'</a>';
    }
} 
$inhalt .= '
<a href="photos-fans.php?id='.$row[name].'&fanInPage='.$gesamt_seiten.'" class="page">
&gt;
<span class="ptr"></span><span class="pbr"></span>
</a>
</div>
<div class="clear">&nbsp;</div>

<meta name="deleteCommentQuestion"content="Möchtest du diese Fan-Verbindung wirklich löschen?">

<ul>';
$a = 1;

$p = mysql_query("select von, text,time from fans where an='".$row[name]."' limit $limit,$ergebnisse_pro_seite");
while($c = @mysql_fetch_assoc($p)) {
$lala = mysql_fetch_array(mysql_query("select photo from accounts where name='".$c[von]."'"));
$datum = date("d.m.Y", $c[time]);
$uhrzeit = date("H:i:s", $c[time]);

$inhalt .= '<li class="usercomment ';

if($a == 1) {
	$inhalt .= 'firstusercomment';
}

if($lala[photo] == '') {
$cphoto = 'sf/f/photos/nopic_pro_sq.jpg';
} else {
$cphoto = 'pics/photos/s/'.$lala[photo].'.jpg';
}

$inhalt .= '"><div class="metainfo">
<a href="photos-profile.php?id='.$c[von].'" class="userpic userimage small_square small_quad_centered_link" style="position: relative;"><img src="'.$cphoto.'" class="small_quad_centered" /></a>
<div class="username">
<a href="photos-profile.php?id='.$c[von].'">'.$c[von].'</a>
</div>
</div>
<div class="comment">
'.$c[text].' <span class="timestamp">('.$datum.' '.$uhrzeit.')</span>

</div></li>';

$a++;
}

$inhalt .= '</ul><div class="clear"></div></div></div></div></div><div class="bl"></div><div class="br"></div><div class="bm"></div></div></div></div></div></div>';

echo str_replace(array('<?url?>','<?inhalt?>', '<?titel?>', '<?fotonavi?>', '<?registrieren?>', '<?styles?>', '<?fotos?>'),array($_SERVER[SERVER_NAME], $inhalt, $titel, $fotonavi, $registrieren, $styles, $fotos),implode("",file("sf/b/style.tpl")));
?>