Файл: testimonials.php
Строк: 215
<?
session_set_cookie_params(86400);
session_start();
$full_home_path = dirname(__FILE__);
require_once($full_home_path."/_rootload.php");
mconnect();
validateUser();
if (!EnableLanguages()) { error("Can not load languages."); mclose(); exit; }
if (!GetCurrentCurrency()) { print $_lang[ErrorGetCurrentCurrency]; mclose(); exit; }
head('utf-8',$_lang[TestimonialsTitle]);
print "<H1 class=pagetitle>".$_lang[TestimonialsTitle]."</H1><hr class=hr>";
if (GetSetting("testimonialsEnable")) {
if ($do == "delete" and $id) {
$r=@mysql_query("select * from testimonials where id='$id' and uid<>'0' and uid='".$_SESSION["userId"]."'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if (mysql_num_rows($r) > 0) {
@mysql_query("delete from testimonials where id='$id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
print $_lang[TestimonialsDeleted]."<BR><BR>";
}
}
if ($do == 'send') {
if (!$name) { $error = $_lang[FeedErrorNoName]; $do='';}
else if (!valid_email($email)) {$error=$_lang[FeedErrorBadEmail]; $do='';}
else if (!$message) {$error = $_lang[FeedErrorNoMessage]; $do='';}
else if (GetSetting("captcha_feedback") and $_SESSION['captchakey'] != $captchakeyin) {$error=$_lang[ErrorWrongCaptcha]; $do='';}
else {
@mysql_query("insert into testimonials (uid,dt,ip,name,company,dolzhnost,email,icq,message) VALUES('".$_SESSION['userId']."',NOW(),'$ip','$name','$company','$dolzhnost','$email','$icq','".addslashes($message)."')") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
print $_lang[FeedTestimonialSuccess]."<BR><BR>";
}
}
if ($error) {print "<font color=red>".$_lang[Error].": $error</font><BR><BR>";}
if (GetSetting("testimonialsAdminCheck")) { $where = "WHERE checked='1'"; } else {$where = "";}
$do="testimonials";
$r=@mysql_query("select * from testimonials $where order by dt desc") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$rows = mysql_num_rows($r);
list($start, $perPage, $txt) = MakePages($page, $rows);
$testimonials = @mysql_query("select * from testimonials $where order by dt desc LIMIT $start,$perPage") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());;
if ($testimonials) {
$cnt=0;
while ($r = mysql_fetch_object($testimonials)) {
$cnt++;
$r->message = preg_replace("/rn/ui", "<BR>", $r->message);
print "<B>".mydate($r->dt)."</B>";
if ($_SESSION["userId"] and $r->uid == $_SESSION["userId"] and GetSetting("testimonialsUsersCanDelete")) { print " [ <A class=rootlink href=?do=delete&id=$r->id>".$_lang[CatDelete]."</a> ]";}
print "<BR><B>$r->name";
if ($r->company or $r->dolzhnost) {
if ($r->company) { print ", $r->company"; }
if ($r->dolzhnost) { print ", $r->dolzhnost"; }
}
print "</B><BR><BR>";
print $r->message."<BR>";
# print "<hr class=hr>";
print "<BR><BR>";
}
}
print $_lang[TestimonialsTotalTestimonials].": $rows, ".$_lang[TestimonialsOnPage].": $cnt"."<BR>";
print $txt."<BR><BR>";
?>
<form method=post>
<input type=hidden name=do value=send>
<table class='rpTable' border=0>
<tr><td colspan=2 align=center class=<? print $font_head?>><B><? print $_lang[TestimonialsAddMessage]?></b></td></tr>
<tr><td valign=middle align=right>* <? print $_lang[FeedName]?>:</td><td><input class=input type="text" name="name" size=30 value="<? print $name?>"></td></tr>
<tr><td valign=middle align=right><? print $_lang[FeedCompany]?>:</td><td><input class=input type="text" name="company" size=30 value="<? print $company?>"></td></tr>
<tr><td valign=middle align=right><? print $_lang[FeedDolzhnost]?>:</td><td><input class=input type="text" name="dolzhnost" size=30 value="<? print $dolzhnost?>"></td></tr>
<tr><td valign=middle align=right>* <? print $_lang[FeedEmail]?>:</td><td><input class=input type="text" name="email" size=30 value="<? print $email?>"></td></tr>
<tr><td valign=middle align=right><? print $_lang[FeedICQ]?>:</td><td><input class=input type="text" name="icq" size=30 value="<? print $icq?>"></td></tr>
<tr><Td valign=top align=right>* <? print $_lang[FeedMessage]?>:</td><Td><textarea class=input name=message cols=40 rows=5><? print $message?></textarea></td></tr>
<? if (GetSetting("captcha_feedback")) { ?>
<tr><td></td><td class="styleHelp"><img name="captcha" src="captcha.php" align="left" style="margin-right: 10px;"> <? print $_lang[CaptchaNeVidno]?> <A class=rootlink href="" onclick="document.captcha.src = document.captcha.src + '?' + (new Date()).getTime(); return false;"><? print $_lang[CaptchaObnovit]?></a></td>
<tr><td align=right>* <? print $_lang[Captcha]?>:</td><td><input class=input type="text" name="captchakeyin" size=10 value=""></td></tr>
<? } ?>
<tr><Td colspan=2 align=center><input class=button type=submit value='<? print $_lang[Send]?>'></td></tr>
</table>
</form><BR>
<?
print "<code class=warn>*</code> - ".$_lang[Required];
}
else {
print $_lang[TestimonialsDisabled];
}
foot('utf-8');
mclose();
?>