Файл: adminka/support.php
Строк: 162
<?php
session_start();
define('IN_SCRIPT', true);
require '../includes/ini.php';
include "header.php";
///////////////////
if (isset($_SESSION['auth'])){
$login = $_SESSION['login'];
$login = htmlspecialchars(trim($login));
$login = mysql_real_escape_string($login);
$count = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE login='$login'"));
if($count['tyuioteteeitruytripoetiweero']==1){
If (!isset($_GET['do']) || !ereg("^[a-z0-9_-]{1,15}$",$_GET['do'])) $do=false; else $do=$_GET['do'];
switch ($do){
//////////////////////////////////////Тех.ПОДДЕРЖКА////////////////////////////////////////////////////////
case 'support_del':
echo '<div class="title_page">Удаление тикета</div>';
$id=$_GET['id'];
(int)$id;
If (!isset($_GET['id']) || !is_numeric($_GET['id'])){
echo 'нe зaдaн id!<br>';
break;
}
$row = mysql_fetch_array(mysql_query("SELECT * FROM `support` WHERE `id`='".$id."';"));
$r=@mysql_query("DELETE FROM `tiketsupport` WHERE `support`='".$row['id']."';");
If (!$r){
echo 'Ошибка запроса к бд...<br/>';
break;
}
$result=@mysql_query("DELETE FROM `support` WHERE `id`='".$id."'");
If (!$result){
echo 'Oшибкa зaпpoca к бд...';
break;
}
echo '<div class="box_1">Тикет удален!</div>';
echo '<div class="title_page"><a href="index.php?do=index">Админка</a></div>';
break;
case 'support_noy':
echo '<div class="title_page">Закрыть</div>';
$id=$_GET['id'];
(int)$id;
If (!isset($_GET['id']) || !is_numeric($_GET['id'])){
echo 'нe зaдaн id рекламы!<br>';
break;
}
$result=@mysql_query("UPDATE `support` SET `stus`='2' WHERE `id`='".$id."'");
If (!$result){
echo 'Oшибкa зaпpoca к бд...';
break;
}
echo '<div class="box_1">Тикет закрыт!</div>';
echo '<div class="title_page"><a href="admin.php?do=index">Админка</a></div>';
break;
case 'support_new':
$support_new=@mysql_num_rows(mysql_query("SELECT * FROM `support` WHERE `stus`='0'"));
echo '<div class="title_page">Новые ['.$support_new.']</div>';
$qwq = mysql_query("SELECT * FROM support WHERE stus='0'");
$ss = mysql_fetch_array($qwq);
$page = intval(@$_GET['page']);
$start = intval(@$_GET['start']);
$onpage = 5;
$all = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM support WHERE stus='0'"));
$all = $all[0];
$pages = ceil($all/$onpage);
if(!$pages) $pages = 1;
if($page>$pages or $page<=0) $page=1;
if($start>$all or $start<=0) $start = 0;
if($page) $start = ($page - 1) * $onpage; else $start = 0;
$res = mysql_query("SELECT * FROM support WHERE stus='0' ORDER BY id LIMIT $start,$onpage");
$rows = mysql_fetch_array($res);
if (mysql_affected_rows() != 0)
{
do
{
if ($rows['stus']==0) {
$status='<b style="color:red">не отвечен</b>';
}
if($rows['topic']==1){$topic = '<b>Финансы</b>';}
if($rows['topic']==2){$topic = '<b>Блокировка</b>';}
if($rows['topic']==3){$topic = '<b>Накрутка</b>';}
if($rows['topic']==4){$topic = '<b>Информация</b>';}
if($rows['topic']==5){$topic = '<b>Спам</b>';}
if($rows['topic']==6){$topic = '<b>Другое</b>';}
echo
'<div class="box_1"><b>'.htmlspecialchars(trim($rows['mail'])).'</b><br/>
дата: '.date("<b>d.m.y H:i</b>",$rows['ts']).'<br/>
раздел: '.$topic.'<br/>
статус: '.$status.'</div>
<div class="box_2">[<a href="support.php?do=support_ot&id='.htmlspecialchars(trim($rows['id'])).'">Оветить</a>]</div>';
}
while($rows = mysql_fetch_array($res));
}else{
echo '<div class="box_1">Нет новых тикетов!</div>';
}
if($all > 5){
echo '<div class="box_2">Страницы: ';
}
$asd = $page - 2;
$asd2 = $page + 3; if ($pages>1){
if($asd<$all && $asd>0 && $page>3 ) echo ' <a href="support.php?do=support_new&page=1">1</a> ... ';
for($i=$asd; $i<$asd2;$i++)
{
if($i<$all && $i>0)
{
if ($i > $pages ) break;
if ($page==$i) echo '<span><b>'.$i.'</b></span> ';
else echo '<a href="support.php?do=support_new&page='.$i.'">'.$i.'</a> ';
}
}
if ($i <= $pages)
{
if($asd2<$all) echo ' ... <a href="support.php?do=support_new&page='.$pages.'">'.$pages.'</a>';
}
echo '</div>';
}
echo '<div class="title_page"><a href="index.php?do=index">Админка</a>/<a href="support.php?do=index">Суппорт</a></div>';
break;
case 'support_zak':
$support_ok=@mysql_num_rows(mysql_query("SELECT * FROM `support` WHERE `stus`='2'"));
echo '<div class="title_page">Закрытые ['.$support_ok.']</div>';
$qwq = mysql_query("SELECT * FROM support WHERE stus='1'");
$ss = mysql_fetch_array($qwq);
$page = intval(@$_GET['page']);
$start = intval(@$_GET['start']);
$onpage = 5;
$all = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM support WHERE stus='2'"));
$all = $all[0];
$pages = ceil($all/$onpage);
if(!$pages) $pages = 1;
if($page>$pages or $page<=0) $page=1;
if($start>$all or $start<=0) $start = 0;
if($page) $start = ($page - 1) * $onpage; else $start = 0;
$res = mysql_query("SELECT * FROM support WHERE stus='2' ORDER BY id LIMIT $start,$onpage");
$rows = mysql_fetch_array($res);
if (mysql_affected_rows() != 0)
{
do
{
if ($rows['stus']==1) {
$status='<b style="color:#009900">отвечен</b>';
}
if ($rows['stus']==2) {
$status='<b style="color:red">закрыт</b>';
}
if($rows['topic']==1){$topic = '<b>Финансы</b>';}
if($rows['topic']==2){$topic = '<b>Блокировка</b>';}
if($rows['topic']==3){$topic = '<b>Накрутка</b>';}
if($rows['topic']==4){$topic = '<b>Информация</b>';}
if($rows['topic']==5){$topic = '<b>Спам</b>';}
if($rows['topic']==6){$topic = '<b>Другое</b>';}
echo
'<div class="box_1"><b>'.htmlspecialchars(trim($rows['mail'])).'</b><br/>
дата: '.date("<b>d.m.y H:i</b>",$rows['ts']).'<br/>
раздел: '.$topic.'<br/>
статус: '.$status.'</div>
<div class="box_2">[<a href="support.php?do=support_del&id='.htmlspecialchars(trim($rows['id'])).'">Удалить</a>]</div>';
}
while($rows = mysql_fetch_array($res));
}else{
echo '<div class="box_1">Нет тикетов!</div>';
}
if($all > 5){
echo '<div class="box_2">Страницы: ';
}
$asd = $page - 2;
$asd2 = $page + 3; if ($pages>1){
if($asd<$all && $asd>0 && $page>3 ) echo ' <a href="support.php?do=support_zak&page=1">1</a> ... ';
for($i=$asd; $i<$asd2;$i++)
{
if($i<$all && $i>0)
{
if ($i > $pages ) break;
if ($page==$i) echo '<span><b>'.$i.'</b></span> ';
else echo '<a href="support.php?do=support_zak&page='.$i.'">'.$i.'</a> ';
}
}
if ($i <= $pages)
{
if($asd2<$all) echo ' ... <a href="support.php?do=support_zak&page='.$pages.'">'.$pages.'</a>';
}
echo '</div>';
}
echo '<div class="title_page"><a href="index.php?do=index">Админка</a>/<a href="support.php?do=index">Суппорт</a></div>';
break;
case 'support_ok':
$support_ok=@mysql_num_rows(mysql_query("SELECT * FROM `support` WHERE `stus`='1'"));
echo '<div class="title_page">Отвеченные ['.$support_ok.']</div>';
$qwq = mysql_query("SELECT * FROM support WHERE stus='1'");
$ss = mysql_fetch_array($qwq);
$page = intval(@$_GET['page']);
$start = intval(@$_GET['start']);
$onpage = 5;
$all = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM support WHERE stus='1'"));
$all = $all[0];
$pages = ceil($all/$onpage);
if(!$pages) $pages = 1;
if($page>$pages or $page<=0) $page=1;
if($start>$all or $start<=0) $start = 0;
if($page) $start = ($page - 1) * $onpage; else $start = 0;
$res = mysql_query("SELECT * FROM support WHERE stus='1' ORDER BY id LIMIT $start,$onpage");
$rows = mysql_fetch_array($res);
if (mysql_affected_rows() != 0)
{
do
{
if ($rows['stus']==1) {
$status='<b style="color:#009900">отвечен</b>';
}
if ($rows['stus']==2) {
$status='<b style="color:red">закрыт</b>';
}
if($rows['topic']==1){$topic = '<b>Финансы</b>';}
if($rows['topic']==2){$topic = '<b>Блокировка</b>';}
if($rows['topic']==3){$topic = '<b>Накрутка</b>';}
if($rows['topic']==4){$topic = '<b>Информация</b>';}
if($rows['topic']==5){$topic = '<b>Спам</b>';}
if($rows['topic']==6){$topic = '<b>Другое</b>';}
echo
'<div class="box_1"><b>'.htmlspecialchars(trim($rows['mail'])).'</b><br/>
дата: '.date("<b>d.m.y H:i</b>",$rows['ts']).'<br/>
раздел: '.$topic.'<br/>
статус: '.$status.'</div>
<div class="box_2">[<a href="support.php?do=support_ot&id='.htmlspecialchars(trim($rows['id'])).'">Оветить</a>]</div>';
}
while($rows = mysql_fetch_array($res));
}else{
echo '<div class="box_1">Нет тикетов!</div>';
}
if($all > 5){
echo '<div class="box_2">Страницы: ';
}
$asd = $page - 2;
$asd2 = $page + 3; if ($pages>1){
if($asd<$all && $asd>0 && $page>3 ) echo ' <a href="support.php?do=support_ok&page=1">1</a> ... ';
for($i=$asd; $i<$asd2;$i++)
{
if($i<$all && $i>0)
{
if ($i > $pages ) break;
if ($page==$i) echo '<span><b>'.$i.'</b></span> ';
else echo '<a href="support.php?do=support_ok&page='.$i.'">'.$i.'</a> ';
}
}
if ($i <= $pages)
{
if($asd2<$all) echo ' ... <a href="support.php?do=support_ok&page='.$pages.'">'.$pages.'</a>';
}
echo '</div>';
}
echo '<div class="title_page"><a href="index.php?do=index">Админка</a>/<a href="support.php?do=index">Суппорт</a></div>';
break;
case 'support_ot':
$id=$_GET['id']; (int)$id;
If (!isset($_GET['id']) || !is_numeric($_GET['id'])){
$id=$_POST['id'];
}
$support = mysql_result(mysql_query("SELECT COUNT(*) FROM `support` where `id`='".$id."' "), 0);
if ($support > 0)
{
$r=@mysql_query("SELECT * FROM `support` where `id`='".$id."' ");
$rt=mysql_fetch_array($r);
echo '<div class="title_page">Тикет</div>';
if($rt['topic']==1){$topic = '<b>Финансы</b>';}
if($rt['topic']==2){$topic = '<b>Блокировка</b>';}
if($rt['topic']==3){$topic = '<b>Накрутка</b>';}
if($rt['topic']==4){$topic = '<b>Информация</b>';}
if($rt['topic']==5){$topic = '<b>Спам</b>';}
if($rt['topic']==6){$topic = '<b>Другое</b>';}
if ($rt['stus']==0) {
$status='<b style="color:red">не отвечен</b>';
}
if ($rt['stus']==1) {
$status='<b style="color:#009900">отвечен</b>';
}
if ($rt['stus']==2) {
$status='<b style="color:red">закрыт</b>';
}
if ($rt['stus']<>2) {
$noy='<b style="color:#FFFFFF">«</b> <b>
<a style="color:red" href="support.php?do=support_noy&id='.$id.'">Закрыть</a></b>|<b><a href="support.php?do=support_del&id='.$id.'">Удалить</a></b> <b style="color:#FFFFFF">»</b>';
}
echo '<div class="box_1"><span style="padding: 0 2px 0 2px; background-color: #FFFFFF; color:#45719B; font-size: 11px">'.$rt['mail'].'</span> | '.date("<b>d.m.y H:i</b>",$rt['ts']).'<br/>раздел: '.$topic.' <br/> статус: '.$status.'<br/>'.$noy.'</div>';
$tiketsupport = mysql_result(mysql_query("SELECT COUNT(*) FROM `tiketsupport` WHERE support='".$rt['id']."'"), 0);
echo '<div class="title_page">Вопрос:</div>';
$qwq = mysql_query("SELECT * FROM `tiketsupport` WHERE support='".$id."'");
$ss = mysql_fetch_array($qwq);
$page = intval(@$_GET['page']);
$start = intval(@$_GET['start']);
$onpage = 5;
$all = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM `tiketsupport` WHERE support='".$id."'"));
$all = $all[0];
$pages = ceil($all/$onpage);
if(!$pages) $pages = 1;
if($page>$pages or $page<=0) $page=1;
if($start>$all or $start<=0) $start = 0;
if($page) $start = ($page - 1) * $onpage; else $start = 0;
$sql = mysql_query("SELECT * FROM `tiketsupport` WHERE support='".$id."' ORDER BY `ts` ASC LIMIT ".$start.", ".$onpage);
if ($all > 0)
{
while ($r = mysql_fetch_array($sql))
{
echo '<div class="box_2"><b style="color:#FFFFFF">'.$r['name'].'</b> | '.date("<b>d.m.y H:i</b>",$r['ts']).'<br/>'.$r['text'].'</div>';
}
if($all > 5){
echo "<div class='title_page'>Страницы: ";
}
$asd = $page - 2;
$asd2 = $page + 3; if ($pages>1){
if($asd<$all && $asd>0 && $page>3 ) echo ' <a href="support.php?do=support_ot&id='.$id.'&page=1">1</a> ... ';
for($i=$asd; $i<$asd2;$i++)
{
if($i<$all && $i>0)
{
if ($i > $pages ) break;
if ($page==$i) echo '<span><b>'.$i.'</b></span> ';
else echo '<a href="support.php?do=support_ot&id='.$id.'&page='.$i.'">'.$i.'</a> ';
}
}
if ($i <= $pages)
{
if($asd2<$all) echo ' ... <a href="support.php?do=support_ot&id='.$id.'&page='.$pages.'">'.$pages.'</a>';
}
echo '</div>';
}
}else echo '<div class="box_2">Сообщений нет!</div>';
if($_POST[ok])
{
if(empty($_POST['text'])){
$error .='Не заполненно поле <b>"Сообщение"</b>!<br/>';
}
elseif($rt['stus']==2){
$error .='Тикет <b>"Закрыт"</b>!<br/>';
}
if(!empty($error))
{
echo '<div class="output_err">';
echo $error;
echo '</div>';
if ($rt['stus']<>2) {
echo '<div class="box_1">
<form action="support.php?do=support_ot" method="post">
Сообщение:<br/>
<textarea name="text" type="text" maxlength="1000" cols="13" rows="3"/>'.$_POST['text'].'</textarea><br/>
<input name="id" type="hidden" value="'.$_POST['id'].'"/>
<input type="hidden" name="ok" value="true"/>
<input type="submit" value="Добавить"/></form></div>';
}
}
else
{
echo '<div class="box_2">Ваш ответ добавлен!</div>';
echo '<div class="box_1">
<form action="support.php?do=support_ot" method="post">
<input name="id" type="hidden" value="'.$_POST['id'].'"/>
<input type="submit" value="Обновить"/></form></div>';
$result=@mysql_query("INSERT INTO `tiketsupport`
(`support`,`name`,`text`,`code`,`ts`)
values
('".$id."','Аdmin','".$_POST['text']."','".$rt['code']."','".time()."')");
If (!$result){
echo '<div class="box_2">Ошибка запроса к бд...</div>';
break;
}
$r=@mysql_query("UPDATE `support` SET `stus`='1' WHERE `id`='".$id."';");
If (!$r){
echo '<div class="box_2">Ошибка запроса к бд...</div>';
break;
}
$r = mysql_fetch_array(mysql_query("SELECT * FROM `tiketsupport` where `support`='".$id."'"));
$mail=$rt['mail'];
$name=$r['name'];
$text=$rt['text'];
$sent=$settings['mail'];
$codes=$rt['code'];
$head = "Овет службы поддержки ".$settings['copi']."!";
$msg = "Здравствуйте ".$name." Администратор http://".$settings['copi']." ответил на ваш тикет:
".$text."
///////////////////////////////////////////////////////
Для просмотра ответа на Ваш тикет перейдите по ссылке:
http://".$settings['copi']."/support.php?do=tiket&code=".$codes."
//////////////////////////////////////////////////////
С уважением к Вам, Администрация http://".$settings['copi']."
Данное письмо отправленно автоматически и на него не нужно отвечать!!!";
mail($mail, '=?utf-8?B?' . base64_encode($head) . '?=', $msg, 'From: ' . $sent . "rnContent-type: text/plain; charset=utf-8;rnX-Mailer: " . $sent . "rnX-Priority: 3");
}
}
else
{
if ($rt['stus']<>2) {
echo '<div class="box_1">
<form action="support.php?do=support_ot" method="post">
Сообщение:<br/>
<textarea name="text" type="text" maxlength="1000" cols="13" rows="3"/></textarea><br/>
<input name="id" type="hidden" value="'.$id.'"/>
<input type="hidden" name="ok" value="true"/>
<input type="submit" value="Добавить"/></form></div>
';
}
}
}else echo '<div class="box_1">Тикета несуществует!</div>';
echo '<div class="title_page"><a href="index.php?do=index">Админка</a>/<a href="support.php?do=index">Суппорт</a></div>';
break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
case 'index':
default:
$support_new=@mysql_num_rows(mysql_query("SELECT * FROM `support` WHERE `stus`='0'"));
$support=@mysql_num_rows(mysql_query("SELECT * FROM `support`"));
$support_ok=@mysql_num_rows(mysql_query("SELECT * FROM `support` WHERE `stus`='1'"));
$support_zak=@mysql_num_rows(mysql_query("SELECT * FROM `support` WHERE `stus`='2'"));
echo '<div class="title_page">Суппорт ['.$support.']</div>
<div class="box_1"><b class="b">»</b> <a href="support.php?do=support_new">Новые</a> [<b style="color:red">'.$support_new.'</b>]</div>
<div class="box_2"><b class="b">»</b> <a href="support.php?do=support_ok">Отвеченные</a> ['.$support_ok.']</div>
<div class="box_1"><b class="b">»</b> <a href="support.php?do=support_zak">Закрытые</a> ['.$support_zak.']</div>';
echo '<div class="title_page"><a href="index.php?do=index">Админка</a></div>';
break;
}
}else{
header("Location: ../index.php");
echo '<div id="link" style="display: none;">
<meta http-equiv="refresh" content="0;url=../index.php"></div>';
}
}else{
header("Location: ../index.php");
echo '<div id="link" style="display: none;">
<meta http-equiv="refresh" content="0;url=../index.php"></div>';
}
include "footer.php";
?>