Файл: support.php
Строк: 283
<?php
require 'system/sid.php';
require 'system/config.php';
include 'system/user.php';
include 'system/head.php';
include 'system/navigator.php';
whorm(0, 'support');
$do = isset($_GET['do']) ? $_GET['do'] : NULL;
switch($do) {
default:
$news = mysql_result(mysql_query("SELECT COUNT(id) FROM `support` WHERE `type` = 'news'"), 0);
$no = mysql_result(mysql_query("SELECT COUNT(id) FROM `support` WHERE `type` = 'no'"), 0);
$yes = mysql_result(mysql_query("SELECT COUNT(id) FROM `support` WHERE `type` = 'yes'"), 0);
$answer = mysql_result(mysql_query("SELECT COUNT(id) FROM `support` WHERE `type` = 'answer'"), 0);
$now = mysql_result(mysql_query("SELECT COUNT(id) FROM `support` WHERE `type` = 'now'"), 0);
if (isset($_GET['x'])) {
$x = my_int($_GET['x']);
if ($user['level'] < 3) {
header('Location: support.php?');
die();
} else {
$em = mysql_query("SELECT `id` FROM `support` WHERE `id` = '$x' LIMIT 1");
if (mysql_num_rows($em) != FALSE) {
mysql_query("DELETE FROM `support` WHERE `id` = '$x' LIMIT 1");
mysql_query("DELETE FROM `support_coms` WHERE `uid` = '$x'");
header('Location: support.php?');
} else {
header('Location: support.php?');
die();
}
}
}
echo $div_title . 'Онлайн поддержка' . $div_end . $div_menu . '
<a href="support.php?do=add_p">Оставить предложение</a>' . $div_end . $div_menu . '
<a href="support.php?do=add_q">Оставить вопрос</a>' . $div_end;
echo $div_razdel . '<img src="ico/str.png" alt=""/> <a href="support.php?do=news">Новые</a> (' . $news . ')
' . $div_end . $div_tworazdel . '
Сюда пишем свои вопросы или пожелания.
' . $div_end . $div_razdel . '
<img src="ico/str.png" alt=""/> <a href="support.php?do=no">Отклоненные пожелания</a> (' . $no . ')
' . $div_end . $div_tworazdel . '
Здесь находятся все отклоненные пожелания
' . $div_end . $div_razdel . '
<img src="ico/str.png" alt=""/> <a href="support.php?do=yes">Выполненные пожелания</a> (' . $yes . ')
' . $div_end . $div_tworazdel . '
Все что мы сделали по Вашим просьбам.
' . $div_end . $div_razdel . '
<img src="ico/str.png" alt=""/> <a href="support.php?do=answer">Ответы на вопросы</a> (' . $answer . ')
' . $div_end . $div_tworazdel . '
Полученные ответы на вопросы.
' . $div_end . $div_razdel . '
<img src="ico/str.png" alt=""/> <a href="support.php?do=now">Выполняются</a> (' . $now . ')
' . $div_end . $div_tworazdel . '
Пожелания, которые уже выполняются и скоро будут сделаны' . $div_end;
break;
// Новые
case news:
echo $div_title . 'Новые' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM `support` WHERE `type` = 'news'"), 0);
if ($count != FALSE) {
$n = new navigator($count, 10, '?do=news&');
$look = mysql_query("SELECT * FROM `support` WHERE `type` = 'news' ORDER BY `id` DESC {$n->limit}");
$i = 0;
while($a = mysql_fetch_assoc($look)) {
if ($user['level'] >= 3 && $user['level'] <= 5) {
$d = '<a href="support-edit-'.$a['id'].'"><img src="ico/edit.png" alt=""/></a>
<a href="d-support-'.$a['id'].'"><img src="ico/delete.png" alt=""/></a> ';
}
if (mb_strlen($a['name'], 'UTF8') > 200) {
$a['name'] = mb_substr($a['name'], 0, 200, 'UTF8');
$a['name'] = $a['name'] . '...<br/>
<a href="postsup-'.$a['id'].'">Читать все ></a>';
} else {
$a['name'] = $a['name'];
}
$num_com = mysql_result(mysql_query("SELECT COUNT(id) FROM `support_coms` WHERE `uid` = '$a[id]'"), 0);
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $d . '<img src="ico/t.png" alt=""/> ' . $a['name'] . '
<br/>
' . us($a['user']) . '
<br/>
<a href="c-support-'.$a['id'].'">Комментарии(' . $num_com . ')</a>' . $div_end;
}
echo $n->navi();
} else {
echo 'Новых пожеланий нет!<br/>';
}
break;
// Отклоненные
case no:
echo $div_title . 'Отклоненные пожелания' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM `support` WHERE `type` = 'no'"), 0);
if ($count != FALSE) {
$n = new navigator($count, 10, '?do=no&');
$look = mysql_query("SELECT * FROM `support` WHERE `type` = 'no' ORDER BY `id` DESC {$n->limit}");
$i = 0;
while($a = mysql_fetch_assoc($look)) {
if ($user['level'] >= 3 && $user['level'] <= 5) {
$d = '<a href="support-edit-'.$a['id'].'"><img src="ico/edit.png" alt=""/></a>
<a href="d-support-'.$a['id'].'"><img src="ico/delete.png" alt=""/></a> ';
}
if (mb_strlen($a['name'], 'UTF8') > 200) {
$a['name'] = mb_substr($a['name'], 0, 200, 'UTF8');
$a['name'] = $a['name'] . '...<br/>
<a href="postsup-'.$a['id'].'">Читать все ></a>';
} else {
$a['name'] = $a['name'];
}
$num_com = mysql_result(mysql_query("SELECT COUNT(id) FROM `support_coms` WHERE `uid` = '$a[id]'"), 0);
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $d . '<img src="ico/t.png" alt=""/> ' . $a['name'] . '
<br/>
' . us($a['user']) . '
<br/>
<a href="c-support-'.$a['id'].'">Комментарии(' . $num_com . ')</a>' . $div_end;
}
echo $n->navi();
} else {
echo 'Отклоненных пожеланий нет!<br/>';
}
break;
// Выполненые
case yes:
echo $div_title . 'Выполненные пожелания' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM `support` WHERE `type` = 'yes'"), 0);
if ($count != FALSE) {
$n = new navigator($count, 10, '?do=yes&');
$look = mysql_query("SELECT * FROM `support` WHERE `type` = 'yes' ORDER BY `id` DESC {$n->limit}");
$i = 0;
while($a = mysql_fetch_assoc($look)) {
if ($user['level'] >= 3 && $user['level'] <= 5) {
$d = '<a href="support-edit-'.$a['id'].'"><img src="ico/edit.png" alt=""/></a>
<a href="d-support-'.$a['id'].'"><img src="ico/delete.png" alt=""/></a> ';
}
if (mb_strlen($a['name'], 'UTF8') > 200) {
$a['name'] = mb_substr($a['name'], 0, 200, 'UTF8');
$a['name'] = $a['name'] . '...<br/>
<a href="postsup-'.$a['id'].'">Читать все ></a>';
} else {
$a['name'] = $a['name'];
}
$num_com = mysql_result(mysql_query("SELECT COUNT(id) FROM `support_coms` WHERE `uid` = '$a[id]'"), 0);
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $d . '<img src="ico/t.png" alt=""/> ' . $a['name'] . '
<br/>
' . us($a['user']) . '
<br/>
<a href="c-support-'.$a['id'].'">Комментарии(' . $num_com . ')</a>' . $div_end;
}
echo $n->navi();
} else {
echo 'Выполненных пожеланий нет!<br/>';
}
break;
// Ответы на вопросы
case answer:
echo $div_title . 'Ответы на вопросы' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM `support` WHERE `type` = 'answer'"), 0);
if ($count != FALSE) {
$n = new navigator($count, 10, '?do=answer&');
$look = mysql_query("SELECT * FROM `support` WHERE `type` = 'answer' ORDER BY `id` DESC {$n->limit}");
$i = 0;
while($a = mysql_fetch_assoc($look)) {
if ($user['level'] >= 3 && $user['level'] <= 5) {
$d = '<a href="support-edit-'.$a['id'].'"><img src="ico/edit.png" alt=""/></a>
<a href="d-support-'.$a['id'].'"><img src="ico/delete.png" alt=""/></a> ';
}
if (mb_strlen($a['name'], 'UTF8') > 200) {
$a['name'] = mb_substr($a['name'], 0, 200, 'UTF8');
$a['name'] = $a['name'] . '...<br/>
<a href="postsup-'.$a['id'].'">Читать все ></a>';
} else {
$a['name'] = $a['name'];
}
$num_com = mysql_result(mysql_query("SELECT COUNT(id) FROM `support_coms` WHERE `uid` = '$a[id]'"), 0);
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $d . '<img src="ico/t.png" alt=""/> ' . $a['name'] . '
<br/>
' . us($a['user']) . '
<br/>
<a href="c-support-'.$a['id'].'">Комментарии(' . $num_com . ')</a>' . $div_end;
}
echo $n->navi();
} else {
echo 'Ответов на вопросы нет!<br/>';
}
break;
// Выполняются
case now:
echo $div_title . 'Ответы на вопросы' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM `support` WHERE `type` = 'now'"), 0);
if ($count != FALSE) {
$n = new navigator($count, 10, '?do=now&');
$look = mysql_query("SELECT * FROM `support` WHERE `type` = 'now' ORDER BY `id` DESC {$n->limit}");
$i = 0;
while($a = mysql_fetch_assoc($look)) {
if ($user['level'] >= 3 && $user['level'] <= 5) {
$d = '<a href="support-edit-'.$a['id'].'"><img src="ico/edit.png" alt=""/></a>
<a href="d-support-'.$a['id'].'"><img src="ico/delete.png" alt=""/></a> ';
}
if (mb_strlen($a['name'], 'UTF8') > 200) {
$a['name'] = mb_substr($a['name'], 0, 200, 'UTF8');
$a['name'] = $a['name'] . '...<br/>
<a href="postsup-'.$a['id'].'">Читать все ></a>';
} else {
$a['name'] = $a['name'];
}
$num_com = mysql_result(mysql_query("SELECT COUNT(id) FROM `support_coms` WHERE `uid` = '$a[id]'"), 0);
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $d . '<img src="ico/t.png" alt=""/> ' . $a['name'] . '
<br/>
' . us($a['user']) . '
<br/>
<a href="c-support-'.$a['id'].'">Комментарии(' . $num_com . ')</a>' . $div_end;
}
echo $n->navi();
} else {
echo 'Выполняемых пожеланий нет!<br/>';
}
break;
// Оставить предложение
case add_p:
echo $div_title . 'Оставить предложение' . $div_end;
if (isset($_POST['ok'])) {
$quest = trim(mysql_real_escape_string(check($_POST['quest'])));
if (empty($quest)) {
err('Вы не заполнили предложение!');
} else {
// транслит
if ($user['translit'] == 1) {
$quest = trun_to_rus($quest);
}
// антимат
$ant = mysql_fetch_array(mysql_query("SELECT `antimat` FROM `setting` WHERE `ids` = '1'"));
$quest = ($ant[0] == 1) ? mat($quest) : $quest;
// Антиреклама
$_ant = mysql_fetch_assoc(mysql_query("SELECT `on_rekl`, `text_rekl` FROM `setting` WHERE `ids` = '1'"));
if ($_ant['on_rekl'] == 1 && filesize($_SERVER['DOCUMENT_ROOT'] . '/domains.dat') > 0) {
$ex = explode(',', file_get_contents('domains.dat'));
foreach($ex as $value) {
if ($user['level'] != 4 && $user['level'] != 5 && !preg_match('/[url=http://(.*)[/url]/si', $quest)) {
$quest = preg_replace("/(ws|,|.|*|_|-|+)+$value/si", $_ant['text_rekl'], $quest);
}
}
}
mysql_query("INSERT INTO `support` SET `name` = '$quest', `user` = '$user[id]', `type` = 'news'");
header('Location: support.php?do=news');
}
}
echo '<FORM method="POST" action="support.php?do=add_p">
<label>Ваше предложение:</label><br/>
<textarea name="quest" cols="50" rows="5" style="width: 99%;"></textarea>
<br/>
<input type="submit" name="ok" value="Отправить"/>
</FORM>
« <a href="support.php?do=news">Назад</a>';
break;
// Оставить вопрос
case add_q:
echo $div_title . 'Оставить вопрос' . $div_end . $div_left;
if (isset($_POST['ok'])) {
$quest = trim(mysql_real_escape_string(check($_POST['quest'])));
if (empty($quest)) {
err('Вы не заполнили предложение!');
} else {
// транслит
if ($user['translit'] == 1) {
$quest = trun_to_rus($quest);
}
// антимат
$ant = mysql_fetch_array(mysql_query("SELECT `antimat` FROM `setting` WHERE `ids` = '1'"));
$quest = ($ant[0] == 1) ? mat($quest) : $quest;
// Антиреклама
$_ant = mysql_fetch_assoc(mysql_query("SELECT `on_rekl`, `text_rekl` FROM `setting` WHERE `ids` = '1'"));
if ($_ant['on_rekl'] == 1 && filesize($_SERVER['DOCUMENT_ROOT'] . '/domains.dat') > 0) {
$ex = explode(',', file_get_contents('domains.dat'));
foreach($ex as $value) {
if ($user['level'] != 4 && $user['level'] != 5 && !preg_match('/[url=http://(.*)[/url]/si', $quest)) {
$quest = preg_replace("/(.*?)(s|,|.|*|_|+)$value/si", $_ant['text_rekl'], $quest);
}
}
}
mysql_query("INSERT INTO `support` SET `name` = '$quest', `user` = '$user[id]', `type` = 'news'");
header('Location: support.php?do=answer');
}
}
echo '<FORM method="POST" action="support.php?do=add_q">
<label>Ваше предложение:</label><br/>
<textarea name="quest" cols="50" rows="5" style="width: 99%;"></textarea>
<br/>
<input type="submit" name="ok" value="Отправить"/>
</FORM>
« <a href="support.php?do=add_q">Назад</a>';
echo $div_end;
break;
// Просмотр
case view:
echo $div_title . 'Читать все' . $div_end;
$l = my_int($_GET['l']);
$empty = mysql_query("SELECT * FROM `support` WHERE `id` = '$l' LIMIT 1");
if (mysql_num_rows($empty) == FALSE) {
err('Ошибка!');
} else {
$inf = mysql_fetch_assoc($empty);
echo $inf['name'] . '<br/>
<a href="support.php?">Назад</a>';
}
break;
// Действие
case edit:
echo $div_title . 'Действие' . $div_end;
$e = my_int($_GET['e']);
if (isset($_POST['ok'])) {
$action = my_int($_POST['action']);
if ($action == 1) $act = 'no';
if ($action == 2) $act = 'yes';
if ($action == 3) $act = 'now';
if ($action == 4) $act = 'answer';
////////////////////////////////////////
if ($action == 1) $kuda = 'Отклоненные';
if ($action == 2) $kuda = 'Выполненые';
if ($action == 3) $kuda = 'Выполняемые';
if ($action == 4) $kuda = 'Ответы на вопросы';
$sql = mysql_fetch_array(mysql_query("SELECT `user` FROM `support` WHERE `id` = '$e' LIMIT 1"));
$msgg = 'Ваш вопрос или предложение было перенесено в раздел <a href="support.php?do='.$act.'">'.$kuda.'</a>';
mysql_query("INSERT INTO `letters` (`id`,`who`,`idwho`,`message`,`data`,`read`,`mod`)
VALUES (0,'0','$sql[0]','$msgg','" . time() . "','0','i')");
mysql_query("UPDATE `support` SET `type` = '$act' WHERE `id` = '$e' LIMIT 1");
header('Location: support.php?do=' . $act);
}
$empty = mysql_query("SELECT * FROM `support` WHERE `id` = '$e' LIMIT 1");
if (mysql_num_rows($empty) == FALSE) {
err('Ошибка!');
} else {
$inf = mysql_fetch_assoc($empty);
echo $inf['name'] . '<br/>
<FORM method="POST" action="support-edit-'.$e.'">
<select name="action">
<option value="1">Отклонить</option>
<option value="2">Выполнить</option>
<option value="3">В процесс</option>
<option value="4">В ответы</option>
</select>
<br/>
<input type="submit" name="ok" value="OK"/>
</FORM>';
}
break;
}
include 'system/foot.php';
?>