Файл: tankon.mobi/tanks/help.php
Строк: 240
<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
include_once '../sys/inc/thead.php';
err();
aut();
echo '<link rel="stylesheet" type="text/css" href="style.css"/>';
include_once 'function.php';
if($_SESSION['style']!='wap.css'){
function cut_msg($text){mb_internal_encoding("UTF-8");$text = mb_substr($text, 0, 50);return str_replace('','',$text);}
}else{
function cut_msg($text){mb_internal_encoding("UTF-8");$text = mb_substr($text, 0, 20);return str_replace('','',$text);}
}
if(isset($_GET['new_vopros'])){
if(isset($_POST['ok'])){
if (strlen2($_POST['name'])>3){
if (strlen2($_POST['name'])<21){
if (strlen2($_POST['msg'])>3){
if (strlen2($_POST['msg'])<201){
if($tanks_code['help_time']<time()){
mysql_query("INSERT INTO `help` SET `msg` = '".htmlspecialchars($_POST['msg'])."',`name` = '".htmlspecialchars($_POST['name'])."', `id_user` = '$tanks_code[id]', `type` = 'glav', `mother` = '0', `time` = '$time'");
$time_help=time()+3600;
mysql_query("UPDATE `tanks` SET `help_time` = '".$time_help."' WHERE `id` = '$tanks_code[id]' LIMIT 1");
header ("Location: /help");
}else{$help_time=time_left($tanks_code['help_time']-time());err_game('Напишите через '.$help_time.'');}
}else{err_game('Слишком длинный вопрос');}
}else{err_game('Короткий вопрос');}
}else{err_game('Слишком длинное название');}
}else{err_game('Короткое название');}
}
echo'<form method="post" action=""><div class="trnt-block p5" style="margin-bottom:3px"><div class="small cntr white bold">';
echo'Вопрос:<br><input type="text" class="wide w50 greensmall" name="name">';
echo'<br>Подробней(макс:200 сим.):<br><textarea class="w50 greensmall" style="height:100px;" name="msg"></textarea>';
echo'</div></div>';
echo'<div class="bot">
<span class="input-but border"><span>';
echo "<input value="Создать" class='w100' name='ok' type="submit" /></span></span>
</div></form>";
echo'</form><a class="simple-but gray mb10" href="/help"><span><span>Назад</span></span></a></div>';
include_once'foots.php';
exit;
}
elseif(isset($_GET['vopros'])){
$vopros_id = mysql_fetch_array(mysql_query("SELECT * FROM `help` WHERE `id`='".intval($_GET['vopros'])."'"));
if($vopros_id['id_user']==$tanks_code['id'] || $vopros_id['id_vopros']==$tanks_code['id']){
if($vopros_id['id_user']==$tanks_code['id'] && $vopros_id['read_u']!=0){
mysql_query("UPDATE `help` SET `read_u` = '0' WHERE `id` = '$vopros_id[id]'");
}elseif($vopros_id['id_vopros']==$tanks_code['id'] && $vopros_id['read_h']!=0){
mysql_query("UPDATE `help` SET `read_h` = '0' WHERE `id` = '$vopros_id[id]'");
}
if(isset($_GET['locked'])){
echo'<div class="bot"><table><tbody><tr><td class="w50 pr1">
<a class="simple-but border" href="/help?vopros='.$vopros_id['id'].'&locked&ok"><span>
<span>Закрыть</span></span></a></td>
<td class="w50 pl1"><a class="simple-but border" href="/help?vopros='.$vopros_id['id'].'">
<span><span>Отмена</span></span></a></td></tr></tbody></table></div>';
if(isset($_GET['ok'])){
mysql_query("UPDATE `help` SET `locked` = '1' WHERE `id` = '".$vopros_id['id']."'");
header ("Location: /help?vopros=".$vopros_id['id']."");
}
}
if(isset($_POST['ok'])){
if (strlen2($_POST['msg'])>3){
if (strlen2($_POST['msg'])<201){
mysql_query("INSERT INTO `help` SET `msg` = '".htmlspecialchars($_POST['msg'])."',`id_user` = '$tanks_code[id]', `type` = 'komm', `mother` = '".$vopros_id['id']."', `time` = '$time'");
$time_help_vopros_o=time()+1800;
mysql_query("UPDATE `tanks` SET `time_otvet_vopros` = '".$time_help_vopros_o."' WHERE `id` = '$tanks_code[id]'");
if($vopros_id['id_user']==$tanks_code['id']){
mysql_query("UPDATE `help` SET `read_h` = '1' WHERE `id` = '$vopros_id[id]'");
}else{
mysql_query("UPDATE `help` SET `read_u` = '1' WHERE `id` = '$vopros_id[id]'");
}
header ("Location: /help?vopros=".$vopros_id['id']."");
}else{err_game('Слишком длинное сообщение');}
}else{err_game('Короткое сообщение');}
}
$ansc=mysql_fetch_assoc(mysql_query("SELECT * FROM `tanks` WHERE `id` = '".$vopros_id['id_user']."'"));
$rres=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '".$ansc['id']."'"));
echo'<div class="trnt-block p5" style="margin-bottom:3px">';
echo'<center><a class="bold" href="/profile?id='.$vopros_id['id_user'].'"><font color="yellow">'.$rres['nick'].'</font> '.online($rres['id']).'</a><span class="white cntr bold">, вопрос №'.$vopros_id['id'].'</span></center>';
echo'<div class="white medium bold">'.$vopros_id['msg'].'</div>';
echo'</div>';
$vopros_otvet = mysql_query("SELECT * FROM `help` WHERE `mother`='".$vopros_id['id']."' ORDER BY id asc");
while($vopros_otvets = mysql_fetch_array($vopros_otvet)) {
$vopros_id = mysql_fetch_array(mysql_query("SELECT * FROM `help` WHERE `id`='".intval($_GET['vopros'])."'"));
echo'<div class="trnt-block p5" style="margin-bottom:2px">';
if($vopros_otvets['id_user']!=$tanks_code['id']){
echo"<div class='green1 small bold'>";
}else{
echo"<div class='white small bold'>";
}
echo"".$vopros_otvets['msg']."</div>";
echo'</div>';
}
if($vopros_id['locked']!=1){
echo'<form method="post" action=""><table class="chat-msg-panel mt10 mb6"><tbody><tr><td class="msg"><div class="trnt-block mb0"><div class="p5">';
echo'<input w:id="postText" class="chat-msg bold sh_b small lh1 cyan1" value="" type="text" size="20" maxlength="250" name="msg">';
echo'</div>
</div></div></div></div></div><div></div></div></div></div>
</div>
</td>
<td class="btn"><span ><span><input class="simple-but mb0 inbl" style="height:28px;" name="ok" type="submit" value="Ответить"></span></span></td>
</tr>
</tbody></table></form>';
echo'<a class="simple-but blue mb10" href="/help?vopros='.$vopros_id['id'].'&locked"><span><span>Вопрос решен</span></span></a></div>';
}else{err_game('Вопрос решен');}
echo'<a class="simple-but gray mb10" href="/help"><span><span>Назад</span></span></a></div>';
include_once'foots.php';
exit;
}else{header("Location: /help");}
}
echo'<div class="trnt-block p5" style="margin-bottom:3px"><img class="w100" style="border-radius:3px;" src="/images/tehpodd.png"></div>';
if($tanks_code['tehpodd']!=1){
echo '<div class="bot"><table><tbody><tr>';
echo'<td class="w100 pr1"><a class="simple-but border" href="?new_vopros"><span><span>Задать вопрос</span></span></td>';
echo'</tr></tbody></table></div>';
echo'<div class="trnt-block p5" style="margin-bottom:3px">';
echo'<div class="medium cntr white bold">Ваши вопросы</div>';
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `help` WHERE `id_user` = '".$tanks_code['id']."'"), 0)==0){
echo"<div class='white small bold'>Список пуст...</div>";
}
echo'</div>';
$help_vopros = mysql_query("SELECT * FROM `help` WHERE `id_user`='".$tanks_code['id']."' AND `mother`='0' ORDER BY id desc");
while($help_voprosi = mysql_fetch_array($help_vopros)) {
echo'<a href="/help?vopros='.$help_voprosi['id'].'"><div class="trnt-block p5" style="margin-bottom:2px">';
if($help_voprosi['read_u']==0 && $help_voprosi['locked']==0){
echo'<img src="/images/icons/forum.png">';
}elseif($help_voprosi['read_u']==1 && $help_voprosi['locked']==0){
echo'<img src="/images/icons/forum_new.png">';
}elseif($help_voprosi['read_u']==1 && $help_voprosi['locked']==1){
echo'<img src="/images/icons/forum_new.png">';
}else{
echo'<img src="/images/icons/forum_close.png">';
}
echo " <span class='green1 small bold'>".$help_voprosi['name']." (".vremja($my_vopros['time']).")</span>";
echo"<div class='white small bold'>".$help_voprosi['msg']."</div>";
echo'</div></a>';
}
err_game('Внимательно прочтите <a href="/faq"><font color="green">FAQ</font></a>');
}else{
if(isset($_GET['voprosok'])){
$voprosok = mysql_fetch_array(mysql_query("SELECT * FROM `help` WHERE `id`='".intval($_GET['voprosok'])."'"));
if($voprosok['id_vopros']==0){
echo'<div class="bot"><table><tbody><tr><td class="w50 pr1">
<a class="simple-but border" href="/help?voprosok='.$voprosok['id'].'&ok"><span>
<span>Принять</span></span></a></td>
<td class="w50 pl1"><a class="simple-but border" href="/help">
<span><span>Отказать</span></span></a></td></tr></tbody></table></div>';
if(isset($_GET['ok'])){
mysql_query("UPDATE `help` SET `id_vopros` = '".$tanks_code['id']."' WHERE `id` = '".intval($_GET['voprosok'])."'");
header ("Location: /help?vopros=".$voprosok['id']."");
}
}else{err_game('Вы не можете принять этот вопрос');}
}
echo'<div class="trnt-block p5" style="margin-bottom:3px">';
echo'<div class="medium cntr white bold">Принятые вопросы</div>';
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `help` WHERE `id_vopros` = '".$tanks_code['id']."' AND `mother`='0' AND `locked`='0'"), 0)==0){
echo"<div class='white small bold'>Список пуст...</div>";
}echo'</div>';
$my_vopro = mysql_query("SELECT * FROM `help` WHERE `id_vopros`='".$tanks_code['id']."' AND `mother`='0' AND `locked`='0' ORDER BY id desc");
while($my_vopros = mysql_fetch_array($my_vopro)) {
echo'<a href="/help?vopros='.$my_vopros['id'].'"><div class="trnt-block p5" style="margin-bottom:2px">';
if($my_vopros['read_h']==0 && $my_vopros['locked']==0){
echo'<img src="/images/icons/forum.png">';
}elseif($my_vopros['read_h']==1 && $my_vopros['locked']==0){
echo'<img src="/images/icons/forum_new.png">';
}elseif($my_vopros['read_h']==1 && $my_vopros['locked']==1){
echo'<img src="/images/icons/forum_new.png">';
}else{
echo'<img src="/images/icons/forum_close.png">';
}
echo " <span class='green1 small bold'>".$my_vopros['name']." (".vremja($my_vopros['time']).")</span>";
echo"<div class='white small bold'>".cut_msg($my_vopros['msg'])."...</div>";
echo'</div></a>';
}
echo'<div class="trnt-block p5" style="margin-bottom:3px">';
echo'<div class="medium cntr white bold">Новые вопросы</div>';
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `help` WHERE `id_vopros` = '0' AND `mother`='0'"), 0)==0){
echo"<div class='white small bold'>Список пуст...</div>";
}echo'</div>';
$svob_vopros = mysql_query("SELECT * FROM `help` WHERE `id_vopros`='0' AND `mother`='0' ORDER BY id desc");
while($svob_vopross = mysql_fetch_array($svob_vopros)) {
echo'<a href="/help?voprosok='.$svob_vopross['id'].'"><div class="trnt-block p5" style="margin-bottom:2px">';
echo "".$svob_vopross['name']." <span class='green1 small bold'>(".vremja($svob_vopross['time']).")</span>";
echo"<div class='white small bold'>".$svob_vopross['msg']."</div>";
echo'</div></a>';
}
}
echo'<a class="simple-but gray mb10" href="/forum"><span><span>На форум</span></span></a></div>';
include_once 'foots.php';
exit;
?>