Файл: comment/index.php
Строк: 485
<?php
session_start();
?>
<script language=JavaScript type="text/javascript">
<!--
function smile(str){
obj = document.Sad_Raven_Guestbook.mess_;
obj.focus();
obj.value = obj.value + str;
}
function openBrWindow(theURL,winName,features){
window.open(theURL,winName,features);
}
function inserttags(st_t, en_t){
obj = document.Sad_Raven_Guestbook.mess_;
obj2 = document.Sad_Raven_Guestbook;
if ((document.selection)) {
obj.focus();
obj2.document.selection.createRange().text = st_t+obj2.document.selection.createRange().text+en_t;
}
else
{
obj.focus();
obj.value += st_t+en_t;
}
}
//-->
</script>
<?php
include ("foto/comment/config.inc.php");
include ("foto/config.inc.php");
if (!isset($messref)) $messref=0;
function replace ($string,$id)
{
global $exech;
$string = " ".$string;
if ($id=="answ")
{
$string = eregi_replace ("[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*","<a href="mailto:\0" class=answ>\0</a>", $string);
$string = eregi_replace ('([[:space:]]|n|<br>)(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)', '\1<a href="http://\2" target="_blank" class=answ>\2</a>', $string);
$string = eregi_replace ('([[:space:]]|n|<br>)(http://.[-a-zA-Z0-9@:%_+.~#?&//=]+)', '\1<a href="\2" target="_blank" class=answ>\2</a>', $string);
}
else if ($id=="dark")
{
$string = eregi_replace ("[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*","<a href="mailto:\0" class=dark>\0</a>", $string);
$string = eregi_replace ('([[:space:]]|n|<br>)(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)', '\1<a href="http://\2" target="_blank" class=dark>\2</a>', $string);
$string = eregi_replace ('([[:space:]]|n|<br>)(http://.[-a-zA-Z0-9@:%_+.~#?&//=]+)', '\1<a href="\2" target="_blank" class=dark>\2</a>', $string);
}
else
{
$string = eregi_replace ("[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*","<a href="mailto:\0">\0</a>", $string);
$string = eregi_replace ('([[:space:]]|n|<br>)(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)', '\1<a href="http://\2" target="_blank">\2</a>', $string);
$string = eregi_replace ('([[:space:]]|n|<br>)(http://.[-a-zA-Z0-9@:%_+.~#?&//=]+)', '\1<a href="\2" target="_blank">\2</a>', $string);
}
$string = eregi_replace ('([img])(http://.[-a-zA-Z0-9@:%_+.~#?&//=]+)([/img])', '<img src="\2">', $string);
$autochange = file ($exech);
$lines = count ($autochange);
for($i=0;$i<$lines;$i++)
{
list($change1,$change2)=explode("|", $autochange[$i]);
$string = eregi_replace("$change1","$change2",$string);
}
return trim($string);
}
function replace_short ($string)
{
global $exech;
$string = " ".$string;
$autochange = file ($exech);
$lines = count ($autochange);
for($i=0;$i<$lines;$i++)
{
list($change1,$change2)=explode("|", $autochange[$i]);
$string = eregi_replace("$change1","$change2",$string);
}
return trim($string);
}
function getHTMLtags($text)
{
$text = str_replace("[b]","<strong>",$text);
$text = str_replace("[/b]","</strong>",$text);
$text = str_replace("[i]","<i>",$text);
$text = str_replace("[/i]","</i>",$text);
$text = str_replace("[font=red]","<font color=ff0000>",$text);
$text = str_replace("[font=blue]","<font color=003399>",$text);
$text = str_replace("[/font]","</font>",$text);
return $text;
}
function cutHTMLtags($text)
{
$text = str_replace("[b]","",$text);
$text = str_replace("[/b]","",$text);
$text = str_replace("[i]","",$text);
$text = str_replace("[/i]","",$text);
$text = str_replace("[font=red]","",$text);
$text = str_replace("[font=blue]","",$text);
$text = str_replace("[/font]","",$text);
return $text;
}
function mydate($date)
{
include("foto/leng.inc.php");
include ("foto/$yaz");
$min = date ($date);
$date = getdate ($date);
$mymon = array ("","$leng_comment_in[0]","$leng_comment_in[1]","$leng_comment_in[2]","$leng_comment_in[3]","$leng_comment_in[4]","$leng_comment_in[5]","$leng_comment_in[6]","$leng_comment_in[7]","$leng_comment_in[8]","$leng_comment_in[9]","$leng_comment_in[10]","$leng_comment_in[11]");
$m = $date[mon];
$myday = array( "$leng_comment_in[12]","$leng_comment_in[13]","$leng_comment_in[14]","$leng_comment_in[15]","$leng_comment_in[16]","$leng_comment_in[17]","$leng_comment_in[18]");
$d = $date[wday];
$real_month = $mymon[$m];
if ($real_month=="") $real_month="$leng_comment_in[11]";
$date = "$leng_comment_in[19] ".$myday[$d]." $date[mday]".$real_month."$date[year] $leng_comment_in[20] $date[hours]:".date("i",$min);
return $date;
}
function mess($name,$mess,$mail,$url,$city,$date,$answer)
{
global $BORDER, $DARK, $LIGHT, $ANSW, $anti_email, $PICHEIGHT, $PICWIDTH;
include("foto/leng.inc.php");
include ("foto/$yaz");
if (($mail!="")&&($anti_email<>"yes"))
{
$mess_mail = replace($mail,"dark");
}
else if (($mail!="")&&($anti_email=="yes"))
{
list($mm2,$mm1) = explode("@", $mail);
$mess_mail = "<a href="javascript:;" onClick="openBrWindow('foto/comment/send_mail.php?mm1=$mm1&mm2=$mm2','send_mail','scrollbars=yes,resizable=yes,width=420,height=327');return false;"><img src="foto/comment/mail.php?mm1=$mm1&mm2=$mm2" align="absmiddle" border=0 /></a>";
}
echo "n<table border=0 align=center cellpadding=2 cellspacing=1 width=100% bgcolor=$BORDER>n";
echo "<tr><td align=center bgcolor=$DARK class=pdark colspan=2>n";
if($city=="") { echo "<a href="javascript: smile('_reply_ [b]".$name."[/b] \n');" class=dark><b>$name</b></a></td></tr>"; }
else { echo "<a href="javaScript: smile('_reply_ [b]".$name." (".$city.")[/b] \n');" class=dark><b>$name</b> ($city)</a></td></tr>n"; }
if($mail!=""&&$url!="") { echo "</tr><td width=50% align=center bgcolor=$DARK class=pdark>$leng_comment_in[21] $mess_mail</td><td width=50% align=center bgcolor=$DARK class=pdark>$leng_comment_in[22] $url</td></tr>n"; }
if($url!=""&&$mail=="") { echo "</tr><td width=50% align=center bgcolor=$DARK class=pdark>$leng_comment_in[23]</td><td width=50% align=center bgcolor=$DARK class=pdark>$leng_comment_in[22] $url</td></tr>n"; }
if($url==""&&$mail!="") { echo "</tr><td width=50% align=center bgcolor=$DARK class=pdark>$leng_comment_in[21] $mess_mail</td><td width=50% align=center bgcolor=$DARK class=pdark>$leng_comment_in[24]</td></tr>n"; }
echo "</td></tr>n";
echo "<tr><td bgcolor=$LIGHT class=p colspan=2><div id="m$date" align=justify>$mess</div></td></tr>n";
echo "<tr><td align=right bgcolor=$LIGHT class=psmall colspan=2>".mydate($date)."</td></tr>n";
if(!($answer=="")) {
echo "<tr><td align=left bgcolor=$ANSW class=pansw colspan=2>";
echo "<b>$leng_comment_in[25]</b> $answer";
echo "</td></tr>n"; }
echo "</table>n";
echo "<table border=0 cellpadding=0 cellspacing=0 width=100% height=4><tr><td height=4></td></tr></table>n";
}
if (getenv('HTTP_X_FORWARDED_FOR')) { $ip=getenv('HTTP_X_FORWARDED_FOR'); }
else { $ip=getenv('REMOTE_ADDR');}
if (isset($add)):
if ((isset($namee_) && $namee_ == "") || (isset($mess_) && cutHTMLtags($mess_) == "")) { $errors[] = "$leng_comment_in[26]"; }
if (isset($namee_) && strlen($namee_) > $maxword) { $errors[] = $leng_comment_in[27].$maxmail.$leng_comment_in[33]; }
if (isset($mail_) && strlen($mail_) > $maxmail) { $errors[] = $leng_comment_in[28].$maxmail.$leng_comment_in[33]; }
if (isset($mail_) && $mail_ != "" && !eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*$",$mail_)) { $errors[] = "$leng_comment_in[29]"; }
if (isset($url_) && strlen($url_) > $maxurl) { $errors[] = $leng_comment_in[30].$maxurl.$leng_comment_in[33]; }
if (isset($city_) && strlen($city_) > $maxcity) { $errors[] = $leng_comment_in[31].$maxcity.$leng_comment_in[33]; }
if (isset($mess_) && strlen($mess_) > $maxlenght) { $errors[] = $leng_comment_in[32].$maxlenght.$leng_comment_in[33]; }
if (isset($mess_) && eregi("[^ ]{".$maxword.",}",$mess_)) { $errors[] = $leng_comment_in[34].$maxword.$leng_comment_in[33]; }
$data_arrayfff = file("foto/data/$albom[$ftalb]/comment.dat");
$tmpproverkacomment=1;
for($ihgtmp=0;$ihgtmp<=count($data_arrayfff);$ihgtmp++)
{
list($name_foto14,$name14,$city14,$date14,$mail14,$url14,$mess14,$answer14)=explode("::", $data_arrayfff[$ihgtmp]);
if ($name_foto14==$ftnmdoc) {$id=$ihgtmp; $tmpproverkacomment=2; break;}
}
if ($tmpproverkacomment==2)
{
$ch_name = cutty($namee_);
$ch_mess = cutty($mess_);
$name24 = split ("|", $name14);
$mess24 = split ("|", $mess14);
for ($ihgtmp4=0;$ihgtmp4<=count($name24);$ihgtmp4++)
{
if($ch_name == $name24[$ihgtmp4] && $ch_mess == $mess24[$ihgtmp4]) { $errors[] = "$leng_comment_in[35]"; break; }
}
}
$temp_string = $mess_;
while ($temp_string=strstr($temp_string,'[img]'))
{
eregi('([img])(http://.[-a-zA-Z0-9@:%_+.~#?&//=]+)([/img])',$temp_string,$pic_array);
$imgurl = $pic_array[2];
$picfile = @fopen("$imgurl","r");
if (!$picfile) { $error[] = "$leng_comment_in[36]"; }
else
{
$imagesize = GetImageSize("$imgurl");
if (!isset($imagesize[2])) { $errors[] = "$leng_comment_in[37]"; }
else
{
if ($imagesize[0]>$PICWIDTH) { $errors[] = "$leng_comment_in[38] (".$PICWIDTH." $leng_comment_in[40])"; }
if ($imagesize[1]>$PICHEIGHT) { $errors[] = "$leng_comment_in[39] (".$PICHEIGHT." $leng_comment_in[40])"; }
}
}
$cutlength = strlen($pic_array[0]);
$temp_string = substr($temp_string,$cutlength);
}
endif;
if ($namee_ != "" && $mess_ != "" && isset($add) && $errors == "")
{
include("write.php");
exit;
}
echo "<table width=100% border=0 cellspacing=0 cellpadding=0 class=p><tr><td align=center>";
if ($namee_ != "" && $mess_ != "" && isset($add) && $errors == ""):
elseif (isset($errors) && $errors != ""):
echo "<table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="$BORDER">";
echo "<tr><td align="center" class="error" bgcolor="#FF0000"><b>$leng_comment_in[41]</b></td></tr>";
echo "<tr><td align="left" class="p" bgcolor="$LIGHT">";
foreach ($errors as $value)
{
echo "<li>$value<br>";
}
echo "</td></tr>";
echo "</table>";
echo "<table border=0 cellpadding=0 cellspacing=0 width=100% height=4><tr><td height=4></td></tr></table>";
endif;
if (!eregi("%", $TABWIDTH)) $SENDWIDTH = $TABWIDTH-300;
else $SENDWIDTH = 300;
$file_arrayyyy = file("foto/data/$albom[$ftalb]/comment.dat");
for($iiiii=0;$iiiii<=count($file_arrayyyy);$iiiii++)
{
list($name_foto1,$name1,$city1,$date1,$mail1,$url1,$mess1,$answer1)=explode("::", $file_arrayyyy[$iiiii]);;
if ($name_foto1==$ftnmdoc) { $namesss = split ("|", $name1); break;}
}
$lines=0;
if ($namesss[0]!="")
{
$lines=count($namesss);
}
echo "<table bgcolor=$BORDER border=0 cellpadding=2 cellspacing=1 width=100%><tr><td bgcolor="$title_comment_1" class=pmid align=center><b>$leng_comment_in[42]</b></td></tr></table>";
echo "<table border=0 cellpadding=0 cellspacing=0 width=100% height=4><tr><td height=4></td></tr></table>";
if ($name_foto1==$ftnmdoc)
{
$namesss = split ("|", $name1);
$citysss = split ("|", $city1);
$datesss = split ("|", $date1);
$mailsss = split ("|", $mail1);
$urlsss = split ("|", $url1);
$messsss = split ("|", $mess1);
$answersss = split ("|", $answer1);
for ($iii=0;$iii<=count($namesss);$iii++)
{
if(!($namesss[$iii]==""&&$messsss[$iii]=="")):
$names = replace_short($namesss[$iii]);
$messs = replace($messsss[$iii],"light");
$messs = getHTMLtags($messs);
$urls = replace($urlsss[$iii],"dark");
$citys = replace_short($citysss[$iii]);
$answers = replace($answersss[$iii],"answ");
$answers = getHTMLtags($answers);
mess($names,$messs,$mailsss[$iii],$urls,$citys,$datesss[$iii],$answers);
endif;
}
}
echo "<table bgcolor=$BORDER border=0 cellpadding=2 cellspacing=1 width=100%><tr><td bgcolor="$title_comment_2" class=pmid align=center><b>$leng_comment_in[43] $lines</b></td></tr></table>";
echo "</table><tr><td><table border=0 cellpadding=0 cellspacing=0 width=100% height=2><tr><td height=2 align=center>";
include("$send_form");
echo "</td></tr></table>";
?>