Просмотр файла mnlxswgb.php

Размер файла: 11.88Kb
<?
############################################
# Создание скрипта: Manlix SW              #
# Имя скрипта: Manlix SW GuestBook         #
# Версия скрипта: 0.3                      #
# Статус: Бесплатный скрипт                #
# Требования: PHP3 и выше                  #
# Дата создания скрипта: 9 февраля 2002 год#
# Страница:  http://manliks.ru/manlix      #
############################################
#         Читай файл HowToUse.htm          #
############################################
include ("config.inc.php");
if ($add == "$add_b")
{
if (isset($name) and $name != "" or $name == "")
{
setcookie("c_name",$name,time()+33333333);
}
if (isset($city) and $city != "" or $city == "")
{
setcookie("c_city",$city,time()+33333333);
}
if (isset($homepage) and $homepage != "" or $homepage == "")
{
$homepage = str_replace("http://","",$homepage);
setcookie("c_homepage",$homepage,time()+3333333);
}
if (isset($mail) and $mail != "" or $mail == "")
{
setcookie("c_mail",$mail,time()+33333333);
}
}
if ($add != "$add_b")
{
if (isset($name) or $name == "")
{
$name = $c_name;
}
if (isset($city) or $city == "")
{
$city = $c_city;
}
if (isset($mail) or $mail == "")
{
$mail = $c_mail;
}
if (isset($homepage) or $homepage == "")
{
$homepage = $c_homepage;
}
}
include ("$dtemplates/top.htm");
if ($statgb == "closed")
{
include ("$dtemplates/c.htm");
include ("$dtemplates/end.htm");
exit();
}
function p ($string)
{
$string = str_replace('\"','&quot;',$string);
$string = str_replace("\'","&quot;",$string);
$string = str_replace("\&","&",$string);
return $string;
}
function vm($mail)
{
if (eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}", $mail))
{
return true;
}
else
{
return false;
}
}
function error()
{
include ("config.inc.php");
$t_error = file("$dtemplates/error.htm");
$tmp = file("$dlogs/errors.tmp");
for ($tm = 0; $tm < count($tmp); $tm++)
{
list($er1,$er2,$er3,$er4,$er5,$er6,$er7,$er8,$er9)=explode("::", $tmp[$tm]);
}
for($e = 0 ; $e < count($t_error); $e++)
{
if ($er1 == "yes")
{
$t_error[$e] = str_replace("%error1%","<font color=$error_color>$e1</font>",$t_error[$e]);
}
if ($er1 == "")
{
$t_error[$e] = str_replace("%error1%",$e1,$t_error[$e]);
}
if ($er2 == "yes")
{
$t_error[$e] = str_replace("%error2%","<font color=$error_color>$e2</font>",$t_error[$e]);
}
if ($er2 == "")
{
$t_error[$e] = str_replace("%error2%",$e2,$t_error[$e]);
}
if ($er3 == "yes")
{
$t_error[$e] = str_replace("%error3%","<font color=$error_color>$e3</font>",$t_error[$e]);
}
if ($er3 == "")
{
$t_error[$e] = str_replace("%error3%",$e3,$t_error[$e]);
}
if ($er4 == "yes")
{
$t_error[$e] = str_replace("%error4%","<font color=$error_color>$e4</font>",$t_error[$e]);
}
if ($er4 == "")
{
$t_error[$e] = str_replace("%error4%",$e4,$t_error[$e]);
}
if ($er5 == "yes")
{
$t_error[$e] = str_replace("%error5%","<font color=$error_color>$e5</font>",$t_error[$e]);
}
if ($er5 == "")
{
$t_error[$e] = str_replace("%error5%",$e5,$t_error[$e]);
}
if ($er6 == "yes")
{
$t_error[$e] = str_replace("%error6%","<font color=$error_color>$e6</font>",$t_error[$e]);
}
if ($er6 == "")
{
$t_error[$e] = str_replace("%error6%",$e6,$t_error[$e]);
}
if ($er7 == "yes")
{
$t_error[$e] = str_replace("%error7%","<font color=$error_color>$e7</font>",$t_error[$e]);
}
if ($er7 == "")
{
$t_error[$e] = str_replace("%error7%",$e7,$t_error[$e]);
}
if ($er8 == "yes")
{
$t_error[$e] = str_replace("%error8%","<font color=$error_color>$e8</font>",$t_error[$e]);
}
if ($er8 == "")
{
$t_error[$e] = str_replace("%error8%",$e8,$t_error[$e]);
}
if ($er9 == "yes")
{
$t_error[$e] = str_replace("%error9%","<font color=$error_color>$e9</font>",$t_error[$e]);
}
if ($er9 == "")
{
$t_error[$e] = str_replace("%error9%",$e9,$t_error[$e]);
}
$t_error[$e] = str_replace("%script%",$noos,$t_error[$e]);
echo $t_error[$e];
}
}
function okey()
{
include ("config.inc.php");
$t_okey = file("$dtemplates/okey.htm");
for($o = 0 ; $o < count($t_okey); $o++)
{
echo $t_okey[$o];
}
}
if ($QUERY_STRING == "" or $page != "")
{
$general=file($base);
$lines=count($general);
$all_messages = $lines;
$pmessages = file("$base");
if ($page == "")
{
$page = "1";
}
$first = count($pmessages) - ($onlyg * ($page - 1));
$second = count($pmessages) - ($onlyg * $page) + 1;
if ($second < 1)
{
$second = 1;
}
$pages = (int) ((count($pmessages) + $onlyg) / $onlyg);
$line = "|";
for ($onlyg = 1; $onlyg <= $pages; $onlyg++)
{
if ($onlyg != $page)
{
$line .= "<a href=\"mnlxswgb.php?page=$onlyg\" title=\"$perp $onlyg\"> $onlyg </a>|";
}
if ($onlyg == $page)
{
$line .= " $onlyg |";
}
}
if ($QUERY_STRING == "" or $page != "")
{
$t_form = file("$dtemplates/form.htm");
for($f = 0 ; $f < count($t_form); $f++)
{
$t_form[$f] = str_replace("%name%",$c_name,$t_form[$f]);
$t_form[$f] = str_replace("%mail%",$mail,$t_form[$f]);
$t_form[$f] = str_replace("%city%",$city,$t_form[$f]);
$t_form[$f] = str_replace("%homepage%",$homepage,$t_form[$f]);
$t_form[$f] = str_replace("%add_button%",$add_b,$t_form[$f]);
echo $t_form[$f];
}
}
if ($all_messages >= "1")
{
$t_center = file("$dtemplates/center.htm");
for($c = 0 ; $c < count($t_center); $c++)
{
$t_center[$c] = str_replace("%line%",$line,$t_center[$c]);
$t_center[$c] = str_replace("%page%",$page,$t_center[$c]);
echo $t_center[$c];
}
}
for ( $i = $first-1; $i >= $second-1; $i--)
{
list($name,$message,$mail,$city,$homepage,$date,$ip,$answer)=explode("::", $general[$i]);
$id = $i;
$id++;
$date = date("$mdate",$date);
$t_mha = file("$dtemplates/message.htm");
$message = p($message);
for($mha = 0 ; $mha < count($t_mha); $mha++)
{
$t_mha[$mha] = str_replace("%name%",$name,$t_mha[$mha]);
if ($city != "")
{
$t_mha[$mha] = str_replace("%city%","$cp $city",$t_mha[$mha]);
}
if ($city == "")
{
$t_mha[$mha] = str_replace("%city%","",$t_mha[$mha]);
}
if ($mail != "")
{
$t_mha[$mha] = str_replace("%mail%","<a href=\"mailto:$mail\" title=\"$mail\">$mail</a>",$t_mha[$mha]);
}
if ($mail == "")
{
$t_mha[$mha] = str_replace("%mail%","$mabsent",$t_mha[$mha]);
}
if ($homepage != "")
{
$t_mha[$mha] = str_replace("%homepage%","<a href=\"http://$homepage\" target=\"_blank\" title=\"$homepage\">$homepage</a>",$t_mha[$mha]);
}
if ($homepage == "")
{
$t_mha[$mha] = str_replace("%homepage%","$habsent",$t_mha[$mha]);
}
$t_mha[$mha] = str_replace("%message%",$message,$t_mha[$mha]);
$t_mha[$mha] = str_replace("%date%",$date,$t_mha[$mha]);
if (strlen($answer) != "1")
{
$t_mha[$mha] = str_replace("%admin%","$yn:",$t_mha[$mha]);
$t_mha[$mha] = str_replace("%answer%","$answer",$t_mha[$mha]);
}
if (strlen($answer) == "1")
{
$t_mha[$mha] = str_replace("%admin%","",$t_mha[$mha]);
$t_mha[$mha] = str_replace("%answer%","",$t_mha[$mha]);
}
$t_mha[$mha] = str_replace("%id%",$id,$t_mha[$mha]);
echo $t_mha[$mha];
}
echo "$separator";
}
if ($all_messages != "0")
{
$t_bottom = file("$dtemplates/bottom.htm");
for($b = 0 ; $b < count($t_bottom); $b++)
{
$t_bottom[$b] = str_replace("%line%",$line,$t_bottom[$b]);
$t_bottom[$b] = str_replace("%page%",$page,$t_bottom[$b]);
$t_bottom[$b] = str_replace("%all_messages%",$all_messages,$t_bottom[$b]);
echo $t_bottom[$b];
}
}
if ($all_messages == "0")
{
include ("$dtemplates/empty.htm");
include ("$dtemplates/end.htm");
}
}
if ($add == "$add_b")
{
function replace ($string)
{
$string = ereg_replace("<","&lt;",$string);
$string = ereg_replace(">","&gt;",$string);
$string = ereg_replace('"',"&quot;",$string);
$string = ereg_replace(":","&#58;",$string);
$string = ereg_replace("::","&#58;&#58;",$string);
$string = ereg_replace("\r\n","<br>",$string);
return $string;
}
$f = $mlwim;
$e = explode(" ",$message);
for ($a = 0; $a < sizeof($e); $a++)
{
$o = strlen($e[$a]);
$b = 0;
$q = $o;
while($q > 0)
{
$s[$b] = substr ($e[$a], $f*$b, $f);
$q = $q - $f;
$b++;
}
for ($c=0;$c < sizeof($s);$c++)
$h[] = $s[$c];
}
for ($d = 0; $d < sizeof($h); $d++)
$r .= $h[$d]." ";
$message = $r;
if(empty($ip))
{
if (getenv('HTTP_X_FORWARDED_FOR'))
{
$ip=getenv('HTTP_X_FORWARDED_FOR');
}
else
{
$ip=getenv('REMOTE_ADDR');
}
}
$name = replace($name);
$message = replace($message);
$mail = replace($mail);
$city = replace($city);
$homepage = replace($homepage);
$date = time();
include ("config.inc.php");
if (strlen($name) > $mname)
{
$error = "yes";
$er2 = "yes";
}
if (strlen($mail) > $mmail)
{
$error = "yes";
$er3 = "yes";
}
if (strlen($city) > $mcity)
{
$error = "yes";
$er4 = "yes";
}
if (strlen($homepage) > $mhomepage)
{
$error = "yes";
$er5 = "yes";
}
if (strlen($message) > $mmessage) 
{
$error = "yes";
$er6 = "yes";
}
if ($mail != "")
{
if (vm($mail))
{
}
else
{
$error = "yes";
$er7 = "yes";
}
}
$autof = file("$autochange");
for ($au=0; $au < count($autof); $au++)
{
list($autochange3,$autochange2)=explode("::", $autof[$au]);
if ($auchname == "yes")
{
$name = eregi_replace("$autochange3","$autochange2","$name");
$name = eregi_replace("\n","","$name");
}
if ($auchcity == "yes")
{
$city = eregi_replace("$autochange3","$autochange2","$city");
$city = eregi_replace("\n","","$city");
}
if ($auchmail == "yes")
{
$mail = eregi_replace("$autochange3","$autochange2","$mail");
$mail = eregi_replace("\n","","$mail");
}
if ($auchhomepage == "yes")
{
$homepage = eregi_replace("$autochange3","$autochange2","$homepage");
$homepage = eregi_replace("\n","","$homepage");
}
if ($auchmessage == "yes")
{
$message = eregi_replace("$autochange3","$autochange2","$message");
$message = eregi_replace("\n","","$message");
}
}
$general=file($base);
$lines=count($general);
$all_messages = $lines;
$ban = file("$banlist");
for ($fbo = 0; $fbo < count($ban); $fbo++)
{
$ban[$fbo] = ereg_replace("\n","",$ban[$fbo]);
list($banip,$banmessage)= split ("\::",$ban[$fbo]);
if (ereg("^$banip$",$ip))
{
$error = "yes";
$er9 = "yes";
}
}
for ($i=0; $i < $lines; $i++)
{
list($t1,$messageold,$t2,$t3,$t4,$t5,$t6)=explode("::", $general[$i]);
if ($messageold == "$message")
{
$error = "yes";
$er8 = "yes";
}
}
if ($name == "" or $message == "")
{
$er1 = "yes";
}
if ($name == "" or $message == "" or $error == "yes")
{
$tmp_gb = fopen("$dlogs/errors.tmp","w+");
$er1 = replace($er1);
$er2 = replace($er2);
$er3 = replace($er3);
$er4 = replace($er4);
$er5 = replace($er5);
$er6 = replace($er6);
$er7 = replace($er7);
$er8 = replace($er8);
$er9 = replace($er9);
fputs ($tmp_gb,"$er1::$er2::$er3::$er4::$er5::$er6::$er7::$er8::$er9::\n");
fclose ($tmp_gb);
error();
exit;
}
if ($name != "" and $message != "")
{
if ($iwe == "yes")
{
$body = $nmig;
$b_mail = $mail;
$b_city = $city;
$b_homepage = $homepage;
$body = str_replace("%name%",$name,$body);
if ($b_mail != "")
{
$body = str_replace("%mail%","<a href=\"mailto:$b_mail\">$b_mail</a>",$body);
}
if ($b_mail == "")
{
$body = str_replace("%mail%","none",$body);
}
if ($b_city != "")
{
$body = str_replace("%city%",$b_city,$body);
}
if ($b_city == "")
{
$body = str_replace("%city%","none",$body);
}
if ($b_homepage != "")
{
$body = str_replace("%homepage%","<a href=\"http://$b_homepage\" target=\"_blank\">$b_homepage</a>",$body);
}
if ($b_homepage == "")
{
$body = str_replace("%homepage%","none",$body);
}
$body = str_replace ("%date%","".date("d.m.Y (H:i:s)",$date)."","$body");
$body = str_replace ("%message%","$message","$body");
$body = str_replace ("%ip%","$ip","$body");

$from="\"Гостевая книга\" <$noos>";
$headers="Content-Type: text/html; charset=windows-1251\n";
$headers.="From: $from\nX-Mailer: $noos";
$newm = "Новое сообщение в гостевой книге";
mail($moa,$newm,$body,$headers);
}
if ($homepage != "")
{
$homepage = eregi_replace("http:\/\/","",$homepage);
$homepage = eregi_replace("www.","",$homepage);
}
$file = fopen("$base","a");
fputs ($file,"$name::$message::$mail::$city::$homepage::$date::$ip::\n");
fclose ($file);
okey();
}
}
include ("$dtemplates/end.htm");
?>