Файл: _rootadmin/_testimonials.inc.php
Строк: 165
<?
if (!$sub) { $sub = "list"; }
if ($sub == 'delete' and $id) {
checkAdminAccess('testimonialsDelete',1);
@mysql_query("delete from testimonials where id='$id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
writeAdminLog("Удален отзыв ID # $id");
print "Отзыв успешно удален.<BR><BR>";
$sub='list';
}
if ($sub == 'edit2') {
checkAdminAccess('testimonialsEdit',1);
$sub2='edit';
if (!$name) {$error = "Не указано ФИО.";}
else if (!$email) {$error = "Не указан e-mail.";}
else if (!$message) {$error = "Не указан отзыв.";}
else {
if ($id) {
@mysql_query("update testimonials set dt='$dt',name='$name',company='$company',dolzhnost='$dolzhnost',email='$email',icq='$icq',message='".addslashes($message)."',checked='$checked' where id=$id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
writeAdminLog("Изменен отзыв ID # $id");
print "Отзыв успешно изменен.<br><br>";
$sub2='list';
}
else {
print "Утерян идентификатор отзыва.<br><br>";
$sub2='list';
}
}
$sub=$sub2;
}
if ($sub == 'edit') {
checkAdminAccess('testimonialsRead',1);
if ($error) { print "<font color=red>Ошибка: $error</font><br><br>"; }
$r=@mysql_query("select * from testimonials where id=$id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$r=mysql_fetch_object($r);
$dt=$r->dt;
$name=$r->name;
$company=$r->company;
$dolzhnost=$r->dolzhnost;
$email=$r->email;
$icq=$r->icq;
$message=$r->message;
$checked=$r->checked;
?>
<form method=post>
<input type=hidden name=do value=<? print $do?>>
<input type=hidden name=sub value=<? print $sub?>2>
<input type=hidden name=id value=<? print $id?>>
<table>
<tr><td colspan=2 align=center bgcolor=#EAEAEA><B>Редактирование отзыва</b></td></tr>
<tr><td>Дата:</td><td><input type=text size=53 name=dt value="<? print $dt?>"></td></tr>
<tr><td>ФИО:</td><td><input type=text size=53 name=name value="<? print $name?>"></td></tr>
<tr><td>Компания:</td><td><input type=text size=53 name=company value="<? print $company?>"></td></tr>
<tr><td>Должность:</td><td><input type=text size=53 name=dolzhnost value="<? print $dolzhnost?>"></td></tr>
<tr><td>E-mail:</td><td><input type=text size=53 name=email value="<? print $email?>"></td></tr>
<tr><td>ICQ:</td><td><input type=text size=53 name=icq value="<? print $icq?>"></td></tr>
<tr><Td valign=top>Отзыв:</td><Td><textarea name=message cols=40 rows=5><? print $message?></textarea></td></tr>
<tr><td>Проверен:</td><td><input type=checkbox name=checked <? if ($checked) {print "checked";}?> value=1> да</td></tr>
<tr><Td colspan=2 align=center><BR><input type=submit value=Изменить></td></tr>
</table>
</form>
<?
}
if ($sub == "list") {
checkAdminAccess('testimonialsRead',1);
$r=@mysql_query("select * from testimonials 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);
$r=@mysql_query("select * from testimonials order by dt desc LIMIT $start,$perPage") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
?>
<table cellpadding=3 width=95%>
<tr><td colspan=6 align=right><? print $txt?></td></tr>
<tr><td colspan=6 align=center bgcolor=<? print $font_head?>><B>Отзывы</b></td></tr>
<tr bgcolor=<? print $font_head?>><td align=center>#</td><td align=center>Дата / IP</td><td align=center>Клиент</td><td align=center>Отзывы</td><td align=center>Проверен</td><td align=center>Операция</td></tr>
<?
$cnt=0;
while ($rr = @mysql_fetch_object($r)) {
getfont(); $i++;
$rr->message = preg_replace("/rn/ui", "<BR>", $rr->message);
print "
<tr bgcolor=$font_row>
<td align=center>$i</td>
<td align=center>$rr->dt<BR>IP: $rr->ip</td>
<td valign=top>";
print "$rr->name";
if ($rr->uid) {
$user = GetUserById($rr->uid);
print " [ <A href=?do=fullinfo&id=$user->id>$user->login</a> ]";
}
if ($rr->company or $rr->dolzhnost) {
print "<BR>";
if ($rr->company) {print "$rr->company";}
if ($rr->dolzhnost) {print " [ $rr->dolzhnost ]";}
}
print "<BR><a href=?do=mailsend&useremail=$rr->email>$rr->email</a>";
if ($rr->icq) {print ", icq: $rr->icq";}
print "</td>
<td valign=top>$rr->message</td>
<td align=center>";
if ($rr->checked) { print $_yes[$rr->checked]; } else { print "<font color=red><B>".$_yes[$rr->checked]."</b></font>"; }
print "</td>
<Td align=center><A href=?do=$do&sub=edit&id=$rr->id><img src=./_rootimages/edit.gif alt=Изменить border=0></a><A href=?do=$do&sub=delete&id=$rr->id onclick="javascript: return confirm('Вы уверены, что хотите удалить отзыв?');"><img src=./_rootimages/del.gif alt=Удалить border=0></a></td>
</tr>
";
$cnt++;
}
?>
<tr bgcolor=<? print $font_head?>><Td colspan=6>Всего отзывов: <? print $rows?>, отзывов на странице: <? print $cnt?></td></tr>
<tr><td colspan=6 align=right><? print $txt?></td></tr>
</table>
<?
}
?>