Файл: region_clean/obiavkom.php
Строк: 241
<?
#######################################
## Mod By KoT (borispol) [76-75-072] ##
#######################################
require_once "start.php";
require_once "sid.php";
header('Cache-Control: no-store, no-cache, must-revalidate');
if ($ver == "wml") header ("Content-type:text/vnd.wap.wml; charset=utf-8");
else header("Content-Type:text/html; charset=UTF-8");
require_once "inc.php";
$link = connect_db();
list($row, $id, $ps, $fsize1, $fsize2) = check_login($link);
require_once "version.php";
$cm = mysql_query ("select count(id) as num from obiavkom WHERE 1;");
$cmc = mysql_fetch_array($cm);
$news = $cmc['num'];
if ($ver == "wml") {
echo $xml;
echo $dtd;
echo "<wml>n
<head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>n
<card id="change" title="Комментарии объяв">n
<p>n";
} else {
echo "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><link rel="stylesheet" type="text/css" href="css/$css.css"/>
<title>Комментарии объяв</title>n
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head><body>
<div align="left">n";
}
echo $fsize1;
echo '<div class="d1">Комментарии:</div><br/>';
echo $fsize2;
$mid = intval($mid);
$new = mysql_query ("select count(id) as num from obiavkom WHERE mid='$mid';");
$mod = isset($_GET['mod']) ? $_GET['mod'] : NULL;
switch($mod) {
default:
mysql_query("SELECT `id` FROM `obiav` WHERE `id`='".(int)$mid."'");
if (mysql_affected_rows() == '') {
echo 'Такой объявы не существует!<br/>';
break;
}
$news = mysql_fetch_array($new);
$num = $news['num'];
if (!isset($s)) $s = 0;
$mx=round(($num/10)+0.45);
if ($s > $mx) $s = $mx;
if ($s <= 0) $s = 1;
$ot = (($s - 1) * 10) + 1;
$do = $s * 10;
if ($do > $num) $do=$num;
$o = $ot - 1;
$n = $ot;
if ($do == 0) $n = $o;
echo $fsize1;
echo "Показывает $n-$do из $num<br/>n";
echo $fsize2;
$o = intval($o);
$do = intval($do);
$r = mysql_query ("select * from `obiavkom` WHERE mid='$mid' order by id desc limit $o,$do");
for ($i = $ot; $i <= $do; $i++) {
$arr = mysql_fetch_array($r);
echo $fsize1;
if ($row["level"] >= 7) {
echo '[<a href="obiavkom.php?'.$ses.'&mod=del&mid='.$arr['id'].'">X</a>] ';
}
$usnick = $arr['login'];
$whoid = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `user`='".mysql_real_escape_string($usnick)."'"));
echo "<a href="search.php?$ses&go=view$takep2&nick=".$whoid['id'].""><b>".col_n($usnick)."</b></a>(".$arr['date'].")> ".$arr['content']."<br/>";
echo $divide;
echo $fsize2;
}
$next = $s + 1;
$prev = $s - 1;
if ($num > $do) {
$ot = (($next - 1) * 10) + 1;
$do = $next * 10;
if ($do > $num) $do = $num;
echo $fsize1;
echo "<a href="obiavkom.php?$ses&s=$next&mid=$mid">>>$ot-$do>></a>n";
echo $fsize2;
}
if ($s > 1) {
$ot = (($prev - 1) * 10) + 1;
$do = $prev * 10;
echo $fsize1;
echo "<a href="obiavkom.php?$ses&s=$prev&mid=$mid"><<$ot-$do<<</a>n";
echo $fsize2;
}
echo $fsize1;
echo "<br/><a href="obiavkom.php?$ses&mod=add&mid=$mid">Добавить</a><br/>n";
echo $fsize2;
break;
case 'del':
if ($row["level"] < 7) {
echo 'Пшел нах ламко!<br/>';
include_once 'foot.php';
break;
}
$mid = intval($mid);
if (
mysql_query("DELETE FROM `obiavkom` WHERE `id`='$mid'"))
{
echo 'Комментарий удалён!<br/><br/>';
}
break;
case 'add':
$date = date("d/m,H:i");
if (empty($content)) $error=$error."<u>Пустое содержание коммента!</u><br/>";
if (empty($action)) {
echo $fsize1;
echo 'Коммент:<br/>';
echo $fsize2;
if ($ver == "wml") {
echo $fsize1;
echo "<input name="content"/><br/>
<anchor>Добавить<go href="obiavkom.php?$ses&mod=add&mid=$mid" method="post">
<postfield name="action" value="add"/>
<postfield name="content" value="$(content)"/>
<postfield name="date" value="$date"/>
</go></anchor>";
echo $fsize2;
echo '<br/>';
} else {
echo "<form method="POST" action="obiavkom.php?$ses&mod=add&mid=$mid" name="auth">n
<input name="content"/><br/>
<input type="hidden" name="action" value="add"/>
<input type="hidden" name="date" value="$date"/>
<input type="submit" class="ibutton" value="Добавить" name="enter"><br/>n";
}
} else {
if (empty($error)) {
$last_news = mysql_fetch_assoc(mysql_query("SELECT `content` FROM `obiavkom` WHERE `mid`='".intval($mid)."'"));
if ($content != $last_news['content']) {
function ad_cut($str,$to) {
$domains = array('http://','.ru','.su','4at','.mobi','.ws','.tv','.4ats','.tv','.name','.us','.biz','.info','.org','.net','.com','.wen','.in');
$replacer = array_fill(0,count($domains),$to);
$result = array_combine($domains,$replacer);
return strtr($str,$result);
}
$content = ad_cut($content);
$content = mysql_real_escape_string(check(trim($content)));
require_once "smile.php";
$content = smiles($content);
$minpos = 500; $nm = 500;
for ($j=0; $j <= count($smiles)-1;$j++) {
$tmpp = strpos($content,$smiles[$j]);
if (($tmpp < $minpos) and ($tmpp !== false)) {
$minpos = $tmpp; $nm = $j;
}
}
if ($minpos != 500) {
if ($row['translit'] != 1) {
$st1 = substr($content,0,$minpos+strlen($smiles[$nm]));
$st2 = substr($content,$minpos+strlen($smiles[$nm]),strlen($content)-strlen($st1));
$st1_wosm = $st1;
$st1 = str_replace($smiles[$nm],$replaces[$nm],$st1);
if (strpos($replaces[$nm],"smil/") !== false)
$st1_woasm = $st1_wosm;
else
$st1_woasm = $st1;
$content_woasm = $st1.$st2;
$content_wosm = $st1_wosm.$st2;
$content = $st1_woasm.$st2;
}
else
{
$st1 = substr($content,0,$minpos);
$st2 = substr($content,$minpos, strlen($smiles[$nm]));
$st3 = substr($content,$minpos+strlen($smiles[$nm]),strlen($content)-strlen($st1)-strlen($st2));
$st1 = trun_to_rus($st1);
$st2_wosm = $st2;
$st2 = $replaces[$nm];
if (strpos($replaces[$nm],"smil/") !== false)
$st2_woasm = $st2_wosm;
else
$st2_woasm = $st2;
$st3 = trun_to_rus($st3);
$content = $st1.$st2_woasm.$st3;
$content_wosm = $st1.$st2_wosm.$st3;
$content_woasm = $st1.$st2.$st3;
}
}
elseif ($row['translit'] == 1) $content = trun_to_rus($content);
unset($smiles);
unset($replaces);
$mid = intval($mid);
if (mysql_query("insert into obiavkom values(0,'".$mid."','".$row['user']."','".$content."','".$date."');")) {
echo $fsize1;
echo 'Твой коммент успешно добавлен!<br/>';
echo $fsize2;
} else {
echo $fsize1;
echo 'Ошибка записи!<br/>';
echo $fsize2;
}
} else {
echo $fsize1;
echo 'Такой коммент уже добавлен!<br/>';
echo $fsize2;
}
} else {
echo $fsize1;
echo $error;
echo $fsize2;
}
}
echo "<br/><div class='d1'><a href="obiavkom.php?$ses&mid=$mid">Коментарии</a></div>n";
break;
}
echo $fsize1;
echo "<div class='d1'><a href="enter.php?$ses">Прихожая</a></div>";
echo $fsize2;
include_once "foot.php";
mysql_close($link);
?>