Файл: modules/askworld/index.php
Строк: 317
<?php
require_once '../../incfiles/core.php';
require_once '../../incfiles/func.php';
require_once '../../incfiles/auth.php';
require_once '../../incfiles/user.php';
$act = htmlentities(trim($_GET['act']));
switch($act)
{
default:
$title = lang('Вопрос/ответ','Питання/відповідь');
require_once '../../incfiles/head.php';
echo '<div class="block">';
echo'<center><a href="'.URL.'/modules/askworld/?act=ask&" onclick="Window.Open(this.href); return false;"><div class="button2">'.lang('Задать вопрос','Запитати').'</div></a></center>';
$all = mysql_query("SELECT * FROM `groups_category`");
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `groups_category`"),0)!=0)
{
$cp = ceil($all/50);
$p = (isset($_GET['p']) and is_numeric($_GET['p']) and $_GET['p']>1 and $_GET['p']<=$cp) ? $_GET['p'] : 1;
$start = $p*50-50;
$arr_comm = mysql_query("SELECT * FROM `groups_category` ORDER BY `id` DESC LIMIT $start,50");
while ($arr = mysql_fetch_array($arr_comm))
{
$all_on = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `askworld_msg` WHERE `categary_id` = '".$arr['id']."' LIMIT 1"),0);
echo '<div class="block"><a href="'.URL.'/modules/askworld/?act=category&id='.$arr['id'].'" onclick="Page.Go(this.href); return false">'.lang($arr['ru_name'],$arr['ua_name']).'</a> ('.$all_on.')</div>';
}
/* echo '<div class="block"><a href="'.URL.'/modules/askworld/?act=category&id=0" onclick="Page.Go(this.href); return false">'.lang('Другое','Інше').'</a> ('.$all_on.')</div>';*/
navi($p,$cp,''.URL.'/modules/askworld/?&&');
}
echo'</div>';
break;
case 'category':
if (!empty($_GET['id']) && is_numeric($_GET['id']))
{
$id = abs(intval($_GET['id']));
$result = mysql_query("SELECT * FROM `groups_category` WHERE `id` = '".$id."' LIMIT 1");
if (mysql_num_rows($result) == true) $arr_cat = mysql_fetch_array($result);
else go(URL);
}
else go(URL);
$title = lang($arr_cat['ru_name'],$arr_cat['ua_name']);
require_once '../../incfiles/head.php';
echo '<div class="block">';
echo'<center><a href="'.URL.'/modules/askworld/?act=ask&" onclick="Window.Open(this.href); return false;"><div class="button2">'.lang('Задать вопрос','Запитати').'</div></a></center>';
$all = mysql_query("SELECT * FROM `askworld_msg` WHERE `categary_id` = '".$id."' ");
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `askworld_msg` WHERE `categary_id` = '".$id."' "),0)!=0)
{
$cp = ceil($all/30);
$p = (isset($_GET['p']) and is_numeric($_GET['p']) and $_GET['p']>1 and $_GET['p']<=$cp) ? $_GET['p'] : 1;
$start = $p*30-30;
$arr_comm = mysql_query("SELECT * FROM `askworld_msg` WHERE `categary_id` = '".$id."' ORDER BY `time` DESC LIMIT $start,30");
while ($arr = mysql_fetch_array($arr_comm))
{
$t = mysql_query("SELECT * FROM `users` WHERE `id` = '".$arr['user_id']."' LIMIT 1");
if (mysql_num_rows($t) == true) $av_post = mysql_fetch_array($t);
if($av_post['ban']==0)
{
echo '<p><div class="status">'.text_view(convert_clickable_links($arr['text'])).'</p></div>';
echo'<a href="'.URL.'/modules/askworld/view.php?id='.$arr['id'].'" onclick="Page.Go(this.href); return false">'.lang('Обсудить','Обговорити').'</a>';
echo '<div class="right">'.user_name($arr['user_id']).''.vtime($arr['time']).'</div><div class="clear"></div>';
}
}
navi($p,$cp,''.URL.'/modules/askworld/?act=category&id='.$id.'&');
}
echo'</div>';
break;
case 'ask':
if ($window != false)echo '<div class="title">'.lang('Задать вопрос','Запитати').'<div class="for_pc right"><a href="" onclick="Window.Close(); return false"><img src="'.URL.'/design/img/del.png"/></a></div></div>';
$title = lang('Задать вопрос','Запитати');
require_once '../../incfiles/head.php';
if (!empty($user_id))
{
require_once 'handler/new_ask.php';
?>
<script type="text/javascript">
$(function(){
$('#form').on('submit', function(e){
$('#form_content').html('');
Page.Loading('start');
e.preventDefault();
var $that = $(this),
formData = new FormData($that.get(0));
$.ajax({
url: $that.attr('action'),
type: $that.attr('method'),
contentType: false,
processData: false,
data: formData,
success: function(response){
if(response){
$('.content').html(response);
Page.Loading('stop');
}
}
});
});
});
</script>
<?
}
$i=3600;
if($user['level']==1)$i=1;
$fl =(time()-$i);
if (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `askworld_msg` WHERE `user_id` = '".$user_id."' AND `time` > '".$fl."'"),0) == true) $flood = true;
if($flood == false){
echo '<div class="block">';
echo '<div class="block">
<form id="form" action="'.URL.'/modules/askworld/?act=ask&" method="post">
'.lang('Вопрос','Питання').'
<input id="textarea" name="ask" class="input" maxlength="500" value=""/>
'.lang('Опишите детально','Опишіть детально').'
<input id="textarea" name="ask2" class="input" maxlength="500" value=""/>
Тематика:<br/>
<select class="input2" name="category">
<option value="0"'. ($arr_group['category'] == 0?' selected="selected"':NULL) .'>'.lang('Выбрать','Вибрати').'</option>';
$res = mysql_query("SELECT * FROM `groups_category` ORDER by `id`");
while ($array = mysql_fetch_array($res))
{
echo '<option value="'.$array['id'].'"'. ($arr_group['category'] == $array['id']?' selected="selected"':NULL) .'>'.lang($array['ru_name'],$array['ua_name']).'</option>';
}
echo '</select>
<input class="button2" type="submit" value="'.lang('Спросить','Запитати').'" /> ';
echo'<div id="checkbox"><input type="hidden" name="anonim" value="1"/></div>';
echo '</form></div>';
echo'</div>';
}else echo ok(lang('Вопросы возможно задавать только раз в 1 час','Задавати питання можливо тільки 1 раз в годину'));
break;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
case 'question':
if (!empty($_GET['id']) && is_numeric($_GET['id']))
{
$id = abs(intval($_GET['id']));
$result = mysql_query("SELECT * FROM `askworld_msg` WHERE `id` = '".$id."' LIMIT 1");
if (mysql_num_rows($result) == true) $arr_post = mysql_fetch_array($result);
/*$result = mysql_query("SELECT * FROM `askworld_msg` WHERE `id` = '".$id."' LIMIT 1");
if (mysql_num_rows($result) == true) $arr_post = mysql_fetch_array($result);
else go(URL);*/
$arr_user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '".$arr_post['user_id']."' LIMIT 1"));
}
else go(URL);
$title = lang('Обсудить тему :"'.$arr_post['text'].'"','Обговорити тему :"'.$arr_post['text'].'"');
require_once '../../incfiles/head.php';
echo'<div class="main_block">';
echo '<div class="status"><p><H2>'.text_view(convert_clickable_links($arr_post['text'])).'</H2></p></div>';
echo '<div class="status-q">'.text_view(convert_clickable_links($arr_post['text2'])).'</div>';
echo '<div class="right">'.user_name($arr_post['user_id']).''.vtime($arr_post['time']).'</div><div class="clear"></div>';
echo '<div class="title">'.lang('Ответы','Відповіді').' </div>';
/*if (!empty($user_id))
{
?>
<script type="text/javascript">
$(function(){
$('#form_re_comm').on('submit', function(e){
e.preventDefault();
var $that = $(this),
formData = new FormData($that.get(0));
$.ajax({
url: $that.attr('action'),
type: $that.attr('method'),
contentType: false,
processData: false,
data: formData,
success: function(response){
if(response){
Page.Go('<?echo URL.'/modules/askworld/?act=question&id='.$id;?>');
}
}
});
});
});
</script>
<?
}
$all = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `askworld_comm` WHERE `ask_id` = '".$id."' LIMIT 1"),0);
if ($all == true)
{
$cp = ceil($all/10);
$p = (isset($_GET['p']) and is_numeric($_GET['p']) and $_GET['p']>1 and $_GET['p']<=$cp) ? $_GET['p'] : 1;
$start = $p*10-10;
$arr_comm = mysql_query("SELECT * FROM `askworld_comm` WHERE `ask_id` = '".$id."' ORDER by `time` ASC LIMIT $start,10");
while ($arr = mysql_fetch_array($arr_comm))
{
echo '<div class="block">';
//if (!empty($user_id)) if ($user_id == $arr_post['wall_id'] || $user_id == $arr_post['user_id'] || $user_id == $arr['user_id']) echo '<div class="right"><a href="'.URL.'/wall/post.php?id='.$id.'&p='.$p.'&del_comm='.$arr['id'].'" onclick="Form.delPost(this.href); return false"><img src="'.URL.'/design/img/closed.png"/></a></div>';
echo user_name($arr['user_id']).'<br/>'.vtime($arr['time']).'<div class="clear"></div>';
if (!empty($arr['quote_id'])) echo '<ul><div class="quote">'.user_name($arr['quote_id']).'<br/>'.lang('пишет','пише').':<br/>'.smiles(text($arr['quote'])).'</div></ul>';
echo '<p>'.smiles(text($arr['msg'])).'</p>';
if (!empty($user_id))
{
echo '<p><a class="link_re_comm" id="link_re_comm_'.$arr['id'].'" href="" onclick="Form.reComm('.$arr['id'].'); return false">'.lang('Ответить','Відповісти').'</a></p>
<div class="re_comm" id="re_comm_'.$arr['id'].'">
<form id="form_re_comm" method="post" action="'.URL.'/modules/askworld/?act=question&id='.$id.'&p='.$p.'">
<textarea class="input" name="re_comm" rows="4"></textarea>
<input type="hidden" name="re_id" value="'.$arr['id'].'"/>
<input class="button2" type="submit" value="'.lang('Написать','Написати').'"/>
</form>
</div>';
}
echo '</div>';
}
echo '</div></div></div>';
navi($p,$cp,''.URL.'/modules/askworld/?act=question&id='.$id.'&');
}
if (!empty($user_id))
{
require_once 'handler/question.php';
?>
<script type="text/javascript">
$(function(){
$('#form').on('submit', function(e){
$('#form_content').html('');
Page.Loading('start');
e.preventDefault();
var $that = $(this),
formData = new FormData($that.get(0));
$.ajax({
url: $that.attr('action'),
type: $that.attr('method'),
contentType: false,
processData: false,
data: formData,
success: function(response){
if(response){
$('.content').html(response);
Page.Loading('stop');
}
}
});
});
});
</script>
<?
</script>
<?
echo '<div class="block2">
<form id="form" method="post" action="'.URL.'/modules/askworld/?act=question&p='.intval($_GET['p']).'&id='.$id.'&">
<textarea id="textarea" class="input" name="comm" maxlength="500" rows="4"></textarea>
<input class="button2" type="submit" value="'.lang('Ответить','Відповісти').'"/>
<a class="button3" href="'.URL.'/ajax/smiles.php" onclick="FormContent.Smiles(this.href); return false"><img src="'.URL.'/design/img/smile.png"/></a>
</form>
</div>
<div id="form_content"></div>';
}
echo '</div></div>';*/
if (!empty($user_id))
{
if ($site_version == 'default')
{
?>
<script type="text/javascript">
$(function(){
$('#form').on('submit', function(e){
e.preventDefault();
var $that = $(this),
formData = new FormData($that.get(0));
$.ajax({
url: $that.attr('action'),
type: $that.attr('method'),
contentType: false,
processData: false,
data: formData,
success: function(response){
if(response){
$('#content_comm').load($that.attr('action')+ '#content_comm .comm');
$('#textarea').val('');
}
}
});
});
});
$(function(){
$('#form_re_comm').on('submit', function(e){
e.preventDefault();
var $that = $(this),
formData = new FormData($that.get(0));
$.ajax({
url: $that.attr('action'),
type: $that.attr('method'),
contentType: false,
processData: false,
data: formData,
success: function(response){
if(response){
Page.Go($that.attr('action'));
}
}
});
});
});
</script>
<?
}
//require_once 'handler/del_comm.php';
require_once 'handler/comm.php';
echo '<div class="block2">;p
<form id="form" method="post" action="'.URL.'/modules/askworld/?act=question&id='.$id.'">
<textarea id="textarea" class="input" name="comm" rows="4"></textarea>
<input class="button2" type="submit" value="'.lang('Написать','Написати').'"/>
<a class="button3" href="'.URL.'/ajax/smiles.php" onclick="FormContent.Smiles(this.href); return false"><img src="'.URL.'/design/img/smile.png"/></a>
</form>
</div>
<div id="form_content"></div>';
}
echo '<div id="content_comm"><div class="comm">
<div class="title">'.lang('Комментарии','Коментарі').' <div class="right">22</div></div>';
$all = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `video_comm` WHERE `fid` = '".$arr_post['id']."' LIMIT 1"),0);
if ($all == true)
{
$cp = ceil($all/10);
$p = (isset($_GET['p']) and is_numeric($_GET['p']) and $_GET['p']>1 and $_GET['p']<=$cp) ? $_GET['p'] : 1;
$start = $p*10-10;
$arr_comm = mysql_query("SELECT * FROM `video_comm` WHERE `fid` = '".$arr_post['id']."' ORDER by `time` DESC LIMIT $start,10");
while ($arr = mysql_fetch_array($arr_comm))
{
echo '<div class="block">';
if (!empty($user_id) && $user_id == $arr_user['id'] or !empty($user_id) && $user_id == $arr['user_id']) echo '<div class="right"><a href="'.URL.'/video/'.$id.'?p='.$p.'&del_comm='.$arr['id'].'" onclick="Form.delPost(this.href); return false"><img src="'.URL.'/design/img/closed.png"/></a></div>';
echo user_name($arr['user_id']).'<br/>'.vtime($arr['time']).'<ul>';
if (!empty($arr['quote_id'])) echo '<div class="quote">'.user_name($arr['quote_id']).' '.lang('пишет','пише').':<ul>'.smiles(text($arr['quote'])).'</ul></div>';
echo smiles(text($arr['text'])).'</ul>';
if (!empty($user_id) && $user_id != $arr['user_id'])
{
echo '<ul><a class="link_re_comm" id="link_re_comm_'.$arr['id'].'" href="" onclick="Form.reComm('.$arr['id'].'); return false">'.lang('Ответить','Відповісти').'</a></ul>
<div class="re_comm" id="re_comm_'.$arr['id'].'">
<form id="form_re_comm" method="post" action="'.URL.'/video/'.$id.'">
<textarea class="input" name="re_comm" rows="4"></textarea>
<input type="hidden" name="re_id" value="'.$arr['id'].'"/>
<input class="button2" type="submit" value="'.lang('Написать','Написати').'"/>
</form>
</div>';
}
echo '</div>';
}
navi($p,$cp,''.URL.'/video/'.$id.'?');
}
echo '</div></div>';
break;
}
require_once '../../incfiles/foot.php';
?>