<?php
require("mysql.php");
require_once 'filter.php';

$titel = 'Profil - Fotos';
$row = mysql_fetch_array(mysql_query("select * from accounts where name='".mysql_real_escape_string(utf8_decode($_GET[id]))."'"));
$rand = mysql_fetch_array(mysql_query("select * from accounts where id='".mysql_real_escape_string(utf8_decode($_GET[id]))."'"));
$low = mysql_fetch_array(mysql_query("select * from accounts where name='".$_SESSION[foto]."'"));
$sun = mysql_fetch_array(mysql_query("select * from accounts where name='".mysql_real_escape_string(utf8_decode($_GET[id]))."'"));

$tage = array("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag");
$datum = date("d.m.Y", time());
$uhrzeit = date("H:i:s", time());
$tag = date("w", time());


if($_GET[delcomment] != '') {
	$pc = mysql_fetch_array(mysql_query("select id from photocomments where bei='".$_SESSION[foto]."' and id='".$_GET[delcomment]."'"));

	if($pc[id] != '') {
		mysql_query("delete from photocomments where id='".(int)$_GET[delcomment]."'");
		header("location:photos-profile.php?id=$_SESSION[foto]");
	}
}

if($_GET[id] != '') {
if($row[name] != $_SESSION[foto] && !$row[photo]) {
$inhalt .= '
        <div class="box blogentry">
<div class="hd">
          <div class="tl"></div>

          <div class="tr"></div>
          <div class="tm"></div>
          <div class="m">
           <div class="mi">
            <div class="h h2">
             <div class="hbegin"></div>
             <h2>Kein Foto</h2>
            </div>

           </div>
          </div>
         </div>
         <div class="bd fade bd-fade">
          <div class="m">
           <div class="mi">Leider hat dieses Mitglied kein Foto in der Fotogalerie. </div></div>';
}else{

$inhalt .= '
<div class="photo">
<div class="noh1"></div>
<div class="yui-g">
<div class="yui-u first">
<div class="box userbox small">

<div class="hd">
<div class="tl"></div>
<div class="tr"></div>
<div class="tm"></div>
<div class="m"><div class="mi">'; 
if($row[name] == $_SESSION[foto]) {
$inhalt .= '<div id="yui_3_0_0-6-131336156953440" class="bbutton editbutton"><a href="photos-settings.php" title="Bild ändern"><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" title="Bild ändern" id="button-628241905-img" class="jsFixHeight" style="" height="22" width=""><div class="btmi"><span class="text">Ändern</span></div></div><div class="btbl corner"></div><div class="btbr corner"></div><div class="btbm"></div></a></div>';
}
$inhalt .= '
<div class="h h2"><div class="hbegin"></div><h2>'.$row[name];
if($row[gender] == 1) {
$geschlecht = ' <img src="pics/male.png" style="display:inline;margin:-100px 0px -4px 0px">';
}else{
$geschlecht = ' <img src="pics/female.png" style="display:inline;margin:-100px 0px -3px 0px">';
}
$inhalt .= $geschlecht;
if($row[age] != '') {
$inhalt .= ' ('.$row[age].')';

}

if(!$row[photo]) {
	$phot = 'pics/nopic.jpg';
}else{
	$phot = 'pics/photos/l/'.$row[photo].'.jpg';
}

if($row[photoTitle] != '') {
	$photoTitle = $row[photoTitle];
}else{
	if($_SESSION[foto] == $row[name]) {
		$photoTitle = '<a href="photos-settings.php">Bildunterschrift setzen</a>';
	}
}

if($row[photoUpload] != '') {
	$photoUpload = ' ('.$row[photoUpload].')';
}

$inhalt .= '
</h2></div>
</div></div>
</div>
<div class="bd fade bd-fade">
<div class="m">
<div class="mi">

<div class="photosingleview">
<div class="imgcontainer">

<div class="rating"><div>Rating</div>
<div class="counter">'.round($row[photoRating]/$row[photoRatingVotes], 1).'</div>
</div>
';
if($row[photoVerify] == 1) {
$inhalt .= '<img src="sf/m/verify/fv_checked_large.png" style="position:absolute;right:-13px; top:-10px; border:none;" />
';
}
$inhalt .='
<img src="'.$phot.'" class="albumimage large">
</div></div>
<br><center><div class="comment modeswitch">




<span id="photoSliderComment">'.$photoTitle.$photoUpload.'</span>




<span class="views"><span id="view_count">'.$row[photoViews].' Views</span> </span>
';

$views = mysql_fetch_array(mysql_query("select name, ip from photoviews where name='".$row[name]."' and ip='".ip($ip)."'"));

if(!$views[ip]) { 
mysql_query("insert into photoviews set ip='".ip($ip)."', name='".$row[name]."'");
mysql_query("update accounts set photoViews=photoViews+'1' where name='".$row[name]."'");
}

$inhalt .= '</div></div>';
if($row[name] == $_SESSION[foto]) {
$inhalt .= '<div style="text-align:center; margin: 10px 0 0 0;">
<a href="photos-verifyphoto" target="_self">Mein Profilfoto verifizieren</a>
</div>';
}


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

</div>
<div class="yui-u">

<div class="box albumsbox small">
<div class="hd">
<div class="tl"></div>
<div class="tr"></div>
<div class="tm"></div>
<div class="m"><div class="mi">



<div class="h h2"><div class="hbegin"></div><h2>Fotoalben (0)</h2></div>
</div></div>
</div>
<div class="bd fade bd-fade">
<div class="m">
<div class="mi">

(noch keine Alben vorhanden)

<div class="clear"></div>
</div>
</div>
<div class="bl"></div>
<div class="br"></div>
<div class="bm"></div>
</div>
</div>';

$fans = mysql_fetch_array(mysql_query("SELECT count(id) as zahl from fans where an='".$row[name]."'"));

if($fans[zahl] > 0) {

$inhalt .= '


<div class="box fansbox 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><a href="photos-fans?id='.$row[name].'">Fans ('.$fans[zahl].')</a></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">
<ul>';


$y = mysql_query("select von from fans where an='".$row[name]."' order by time desc limit 15");
while($z = @mysql_fetch_array($y)) {
$ya = mysql_fetch_array(mysql_query("select photo from accounts where name='".$z[von]."'"));

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

$inhalt .= '
<li>
<a href="photos-profile.php?id='.$z[von].'" class="userpic userimage small_square small_quad_centered_link" style="position: relative;">
<img src="'.$yaphoto.'" class="small_quad_centered" />
</a>
</li>';
}

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

$inhalt .= '</div></div><div id="lightbox"></div>';

if($_GET[msgid] == 'COMMENTSUCCESS') {
	$inhalt .= '<div class="servermessage">Kommentar gespeichert</div>';
}


$inhalt .= '<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="mi"><div class="h h2"><div class="hbegin"></div><a id="reg"></a><h2>Kommentare</h2></div>
</div></div>
</div>
<div class="bd fade bd-fade">
<div class="m">
<div class="mi">';
if($row[commentsEnable] == 0) {
$inhalt .= $row[name].' hat die Kommentare für dieses Foto deaktiviert.';
}else{
if($_SESSION[foto] != '') {
if($_POST[lala] != '') {
if($_POST[comment] != '' && strlen($_POST[comment]) < 300) {
mysql_query("insert into photocomments set uhrzeit='".time()."', von='".$low[name]."', bei='".$row[name]."', text='".mysql_real_escape_string($_POST[comment])."'");
if($low[name] != $row[name]) {
mysql_query("update accounts set priviMessage='4',priviMessage2='".$low[priviMessage2].",".$low[name]."' where name='".$row[name]."'");
}
header("location:photos-profile.php?id=$row[name]&msgid=COMMENTSUCCESS");
}
} 
if($low[photo] != '') {
$sefo = 'pics/photos/m/'.$low[photo].'.jpg';
}else{
$sefo ='pics/nopic.jpg';
}

$inhalt .= '<div class="usercomment firstusercomment">

<form action="photos-profile.php?id='.$row[name].'" method="POST" accept-charset="UTF-8"

name="form-comment">
<meta name="maxCommentLength"content="300">
<div class="newcomment"><img src="'.$sefo.'" class="userpic userimage small_square" /><div class="username">
<div class="commentarrow"></div>
'.$_SESSION[foto].'

</div><div class="comment">

<div name="charcount_max_300" class="charcount_container">
<span id="formline-comment-comment" class="formline formline-plain formline-comment-comment formres-no formres-noresult-comment-comment ">
<textarea class="textarea type-String"
name="comment" id="comment-comment"
cols="20"
rows="2"
></textarea><div class="formerror hidden" id="err-comment-comment">
</div>
</span>
<div name="comment" class="charcounter charcounter_top">
<span name="comment" class="countertext"></span>
</div>
</div>

</div><div class="formnote">
<span id="formline-comment-whatIsCommentedId" class="formline formline-plain formline-comment-whatIsCommentedId formres-no formres-noresult-comment-whatIsCommentedId hidden">
<input type="hidden" class="hidden type-String"
name="whatIsCommentedId" id="comment-whatIsCommentedId" /><div class="formerror hidden" id="err-comment-whatIsCommentedId">
</div>

</span>
<div class="formbutton"><div class="bbutton submit" id="submit-button-1893502309"><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="submit-button-2123555485-img" class="jsFixHeight" style="" height="22" width="" /><input type="submit" name="lala" value="Absenden" class="image-submit" /><div class="btmi"><span class="text">Absenden</span></div></div><div class="btbl corner"></div><div class="btbr corner"></div><div class="btbm"></div></div></div>
</div>
</div>
</form>

</div>
';
}else{
$inhalt .= '<div class="usercomment firstusercomment loggedout">
<div class="label">Kommentar zu diesem Foto abgeben?</div>

<div class="bbutton loginbutton"><a href="photos-login"><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="button-625428813-img" class="jsFixHeight" style="" height="22" width="" /><div class="btmi"><span class="text">Jetzt einloggen</span></div></div><div class="btbl corner"></div><div class="btbr corner"></div><div class="btbm"></div></a></div>
</div>

<div class="clear"></div>';
}
$zahl = 1;
$p = mysql_query("select * from photocomments where bei = '".$row[name]."' order by uhrzeit desc");
while($c = @mysql_fetch_array($p)) {

$rol = mysql_fetch_array(mysql_query("select photo from accounts where name='".$c[von]."'"));
if($c[von] == $low[name]) {
$owned = ' ownercomment viewercomment';
}else{
$owned = '';
}
if($rol[photo] != '') {
$userpic = 'pics/photos/s/'.$rol[photo].'.jpg';
}else{
$userpic = 'pics/nopic.jpg';
}
$datum = date("d.m.Y", $c[uhrzeit]);
$uhrzeit = date("H:i:s", $c[uhrzeit]);
$inhalt .= '<li class="usercomment '.$owned.'">
<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="'.$userpic.'" class="small_quad_centered" /></a>
<div class="username">
<a href="photos-profile.php?id='.$c[von].'">'.$c[von].'</a>

</div>
</div>
<div class="comment">';

if($sun[name] == $low[name]) {
	$inhalt .= '<a href="photos-profile.php?delcomment='.$c[id].'" title="Löschen" class="deleter">&nbsp;</a>';
}

$inhalt .= utf8_decode($c[text]).' <span class="timestamp">('.$datum.' '.$uhrzeit.')</span>
</div></li>';
$zahl++;
}
}
$inhalt .= '</div>
</div>
<div class="bl"></div>
<div class="br"></div>

<div class="bm"></div>

</div>';
}
	}else{
	if(!$_SESSION[foto]) {
		header("location:photos-login");
	}else{
		header("location:photos-profile.php?id=$_SESSION[foto]");
	}
}


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

$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/tables/tables.css" rel="stylesheet" type="text/css"><script src="/sf2/f/photos/photos.js" type="text/javascript" language="Javascript"></script>';

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")));
?>    