Файл: support.php
Строк: 263
<?php
require 'sid.php';
require 'config.php';
$link = connect_db();
list($user, $id, $ps) = check_login($link);
include 'head.php';
include 'navigator.php';
whorm(0, 'support');
$do = isset($_GET['do']) ? $_GET['do'] : NULL;
switch($do) {
default:
$news = mysql_result(mysql_query("SELECT COUNT(*) FROM `support` WHERE `type` = 'news'"), 0);
$no = mysql_result(mysql_query("SELECT COUNT(*) FROM `support` WHERE `type` = 'no'"), 0);
$yes = mysql_result(mysql_query("SELECT COUNT(*) FROM `support` WHERE `type` = 'yes'"), 0);
$answer = mysql_result(mysql_query("SELECT COUNT(*) FROM `support` WHERE `type` = 'answer'"), 0);
$now = mysql_result(mysql_query("SELECT COUNT(*) FROM `support` WHERE `type` = 'now'"), 0);
if (isset($_GET['x'])) {
$x = my_int($_GET['x']);
if ($user['level'] < 4) {
header('Location: support.php?' . $ref);
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?' . $ref);
} else {
header('Location: support.php?' . $ref);
die();
}
}
}
echo $div_title . 'Онлайн поддержка' . $div_end . $div_left;
echo '<img src="ico/str.gif" alt=""/> <a href="support.php?do=news">Новые</a> (' . $news . ')
<br/>
Сюда пишем свои вопросы или пожелания.
<br/>
<img src="ico/str.gif" alt=""/> <a href="support.php?do=no">Отклоненные пожелания</a> (' . $no . ')
<br/>
Здесь находятся все отклоненные пожелания
<br/>
<img src="ico/str.gif" alt=""/> <a href="support.php?do=yes">Выполненные пожелания</a> (' . $yes . ')
<br/>
Все что мы сделали по Вашим просьбам.
<br/>
<img src="ico/str.gif" alt=""/> <a href="support.php?do=answer">Ответы на вопросы</a> (' . $answer . ')
<br/>
Полученные ответы на вопросы.
<br/>
<img src="ico/str.gif" alt=""/> <a href="support.php?do=now">Выполняются</a> (' . $now . ')
<br/>
Пожелания, которые уже выполяются и скоро будут сделаны';
echo $div_end;
break;
// Новые
case news:
echo $div_title . 'Новые' . $div_end . $div_left;
echo $div_menu . '<a href="support.php?do=add_p">Оставить предложение</a>' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(*) 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'] == 4 || $user['level'] == 5) {
$d = '<a href="support.php?x='.$a['id'].'"><img src="ico/delete.gif" alt=""/></a>
<a href="support.php?do=edit&e='.$a['id'].'"><img src="ico/edit.gif" 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="support.php?do=view&l='.$a['id'].'">Читать все ></a>';
} else {
$a['name'] = $a['name'];
}
$num_com = mysql_result(mysql_query("SELECT COUNT(*) FROM `support_coms` WHERE `uid` = '$a[id]'"), 0);
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $d . '<img src="ico/t.gif" alt=""/> ' . $a['name'] . '
<br/>
' . us($a['user']) . '
<br/>
<a href="support_coms.php?uid='.$a['id'].'">Комментарии(' . $num_com . ')</a>' . $div_end;
}
echo $n->navi();
} else {
echo 'Новых пожеланий нет!<br/>';
}
echo $div_end;
break;
// Отклоненные
case no:
echo $div_title . 'Отклоненные пожелания' . $div_end . $div_left;
$count = mysql_result(mysql_query("SELECT COUNT(*) 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'] == 4 || $user['level'] == 5) {
$d = '<a href="support.php?x='.$a['id'].'"><img src="ico/delete.gif" alt=""/></a>
<a href="support.php?do=edit&e='.$a['id'].'"><img src="ico/edit.gif" 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="support.php?do=view&l='.$a['id'].'">Читать все ></a>';
} else {
$a['name'] = $a['name'];
}
$num_com = mysql_result(mysql_query("SELECT COUNT(*) FROM `support_coms` WHERE `uid` = '$a[id]'"), 0);
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $d . '<img src="ico/t.gif" alt=""/> ' . $a['name'] . '
<br/>
' . us($a['user']) . '
<br/>
<a href="support_coms.php?uid='.$a['id'].'">Комментарии(' . $num_com . ')</a>' . $div_end;
}
echo $n->navi();
} else {
echo 'Отклоненных пожеланий нет!<br/>';
}
echo $div_end;
break;
// Выполненые
case yes:
echo $div_title . 'Выполненные пожелания' . $div_end . $div_left;
$count = mysql_result(mysql_query("SELECT COUNT(*) 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'] == 4 || $user['level'] == 5) {
$d = '<a href="support.php?x='.$a['id'].'"><img src="ico/delete.gif" alt=""/></a>
<a href="support.php?do=edit&e='.$a['id'].'"><img src="ico/edit.gif" 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="support.php?do=view&l='.$a['id'].'">Читать все ></a>';
} else {
$a['name'] = $a['name'];
}
$num_com = mysql_result(mysql_query("SELECT COUNT(*) FROM `support_coms` WHERE `uid` = '$a[id]'"), 0);
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $d . '<img src="ico/t.gif" alt=""/> ' . $a['name'] . '
<br/>
' . us($a['user']) . '
<br/>
<a href="support_coms.php?uid='.$a['id'].'">Комментарии(' . $num_com . ')</a>' . $div_end;
}
echo $n->navi();
} else {
echo 'Выполненных пожеланий нет!<br/>';
}
echo $div_end;
break;
// Ответы на вопросы
case answer:
echo $div_title . 'Ответы на вопросы' . $div_end . $div_left;
echo $div_menu . '<a href="support.php?do=add_q">Оставить вопрос</a>' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(*) 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'] == 4 || $user['level'] == 5) {
$d = '<a href="support.php?x='.$a['id'].'"><img src="ico/delete.gif" alt=""/></a>
<a href="support.php?do=edit&e='.$a['id'].'"><img src="ico/edit.gif" 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="support.php?do=view&l='.$a['id'].'">Читать все ></a>';
} else {
$a['name'] = $a['name'];
}
$num_com = mysql_result(mysql_query("SELECT COUNT(*) FROM `support_coms` WHERE `uid` = '$a[id]'"), 0);
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $d . '<img src="ico/t.gif" alt=""/> ' . $a['name'] . '
<br/>
' . us($a['user']) . '
<br/>
<a href="support_coms.php?uid='.$a['id'].'">Комментарии(' . $num_com . ')</a>' . $div_end;
}
echo $n->navi();
} else {
echo 'Ответов на вопросы нет!<br/>';
}
echo $div_end;
break;
// Выполняются
case now:
echo $div_title . 'Ответы на вопросы' . $div_end . $div_left;
$count = mysql_result(mysql_query("SELECT COUNT(*) 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'] == 4 || $user['level'] == 5) {
$d = '<a href="support.php?x='.$a['id'].'"><img src="ico/delete.gif" alt=""/></a>
<a href="support.php?do=edit&e='.$a['id'].'"><img src="ico/edit.gif" 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="support.php?do=view&l='.$a['id'].'">Читать все ></a>';
} else {
$a['name'] = $a['name'];
}
$num_com = mysql_result(mysql_query("SELECT COUNT(*) FROM `support_coms` WHERE `uid` = '$a[id]'"), 0);
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $d . '<img src="ico/t.gif" alt=""/> ' . $a['name'] . '
<br/>
' . us($a['user']) . '
<br/>
<a href="support_coms.php?uid='.$a['id'].'">Комментарии(' . $num_com . ')</a>' . $div_end;
}
echo $n->navi();
} else {
echo 'Выполняемых пожеланий нет!<br/>';
}
echo $div_end;
break;
// Оставить предложение
case add_p:
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) {
$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=news');
}
}
echo '<fieldset>
<FORM method="POST" action="support.php?do=add_p">
Ваше предложение:<br/>
<textarea name="quest" cols="50" rows="5" style="width: 99%;"></textarea>
<br/>
<input type="submit" name="ok" value="Отправить"/>
</FORM>
</fieldset>
« <a href="support.php?do=news">Назад</a>';
echo $div_end;
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) {
$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=add_q');
}
}
echo '<fieldset>
<FORM method="POST" action="support.php?do=add_q">
Ваше предложение:<br/>
<textarea name="quest" cols="50" rows="5" style="width: 99%;"></textarea>
<br/>
<input type="submit" name="ok" value="Отправить"/>
</FORM>
</fieldset>
« <a href="support.php?do=add_q">Назад</a>';
echo $div_end;
break;
// Просмотр
case view:
echo $div_title . 'Читать все' . $div_end . $div_left;
$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?'.$ref.'">Назад</a>';
}
echo $div_end;
break;
// Действие
case edit:
echo $div_title . 'Действие' . $div_end . $div_left;
$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/>
<fieldset>
<FORM method="POST" action="support.php?do=edit&e='.$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>
</fieldset>';
}
echo $div_end;
break;
}
include 'foot.php';
?>