View file modules/forum/index.php

File size: 13.87Kb
<?php
/*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\//
// Sitchi CMS - Mobile Content Management System //
// The author:  Nikoloz Sitchinava [sitchi]      //
// Link:        http://sitchicms.num.ge          //
// Skype:       SitchiCMS                        //
// License:     LICENSE.txt (see attached file)  //
// Version:     VERSION.txt (see attached file)  //
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
define('_SITCHICMS', 1);
$root_path='../../';
require $root_path.'includes/db_connect.php';
require $root_path.'includes/start.php';
require $root_path.'includes/header.php';
require $root_path.'includes/functions.php';
require $root_path.'includes/head.php'; // თავი
$lng_forum = load_lng('forum');
if (!isset($_GET['act']))$_GET['act']='';
$act=htmlspecialchars(trim($_GET['act']));
switch ($act) 
{
/*ფორუმების გამოტანა*/
default:
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_section`"),0);
head(''.$lng_forum['1_1'].''); 
echo'<div class="hdr"><b>'.$lng_forum['1_1'].'</b></div>';
if(isset($user))
{
echo'<a href="my_themes.php">'.$lng_forum['1_2'].'</a> | <a href="my_posts.php">'.$lng_forum['1_3'].'</a>';
}
if ($k_post==0)
{
echo'<div class="errmenu">';
echo''.$lng_forum['1_4'].'';
echo'</div>';
}
$q=mysql_query("SELECT * FROM `forum_section` ORDER BY pos");
while ($post = mysql_fetch_array($q))
{
$count_id_theme=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topic1_view` WHERE `id_forum`='$post[id]'"),0);
$count_id_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topic2_view` WHERE `id_forum`='$post[id]'"),0);
$count_id_post_new=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topic2_view` WHERE `id_forum`='$post[id]' AND `time` > '".($time-86400)."'"),0);
echo'<div class="menu">';
echo'<img src="/themes/'.$set['set_them'].'/forum/forum_section.png" alt="" /><a href="index.php?act=view_section&amp;id_forum='.$post['id'].'"> '.$post['name'].'</a> ['.$count_id_theme.'/'.$count_id_post.']<span style="color:red;">+'.$count_id_post_new.'</span></br>';
if ($post['opis']!=NULL)
echo'<div class="sub">'.post($post['opis']).'</div>';
echo'</div>';
}
echo'<a href="new_posts.php">'.$lng_forum['1_5'].'</a> | <a href="new_themes.php">'.$lng_forum['1_6'].'</a><br/>';
if (isset($user) && $user['level']>=8)
echo'<a href="create.php?act=create_forum">'.$lng_forum['1_7'].'</a>';
require $root_path.'includes/end.php'; // დასასრული
break;
/**ფორუმის განყოფილებების ჩვენება**/
case 'view_section':
if (isset($_GET['id_forum']) && is_numeric($_GET['id_forum']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_section` WHERE `id` = '".intval($_GET['id_forum'])."' LIMIT 1",$dblink), 0)==1)
{
$id_forum=intval(abs($_GET['id_forum']));
$forum = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_section` WHERE `id` = '".$id_forum."' LIMIT 1"));
}else{
header("Location: index.php?".SID);
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_section_view` WHERE `id_forum` = '".$forum['id']."'"),0);
$k_page=k_page($k_post,$set['p_count']);
$page=page($k_page);
$start=$set['p_count']*$page-$set['p_count'];
head(''.$lng_forum['1_1'].' | '.$forum['name']); 
echo'<div class="hdr"><b><a href="index.php">'.$lng_forum['1_1'].'</a> | '.$forum['name'].'</b></div>'; 
if ($k_post==0)
{
echo'<div class="errmenu">';
echo''.$lng_forum['1_8'].'';
echo'</div>';
} 
$q=mysql_query("SELECT * FROM `forum_section_view` WHERE `id_forum` = '".$forum['id']."' ORDER BY `time` DESC LIMIT $start, $set[p_count]");
while ($post = mysql_fetch_assoc($q))
{
$count_id_theme=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topic1_view` WHERE `id_forum`='$forum[id]' AND `id_section`='$post[id]'"),0);
$count_id_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topic2_view` WHERE `id_forum`='$forum[id]' AND `id_section`='$post[id]'"),0);
$count_id_post_new=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topic2_view` WHERE `id_forum`='$forum[id]' AND `id_section`='$post[id]' AND `time` > '".($time-86400)."'"),0); 
echo'<div class="menu">';
echo'<img src="/themes/'.$set['set_them'].'/forum/forum_under_section.png" alt="" /><a href="index.php?act=view_under_section&amp;id_section='.$post['id'].'"> '.$post['name'].'</a> ['.$count_id_theme.'/'.$count_id_post.']<span style="color:red;">+'.$count_id_post_new.'</span>';
echo'</div>';
}
if ($k_page>1)str("?act=view_section&amp;id_forum=".$forum['id'].'&amp;',$k_page,$page); 
if (isset($user) && $user['level']>=4)
echo'<a href="create.php?act=create_section&amp;id_forum='.$forum['id'].'">'.$lng_forum['1_9'].'</a></br>';
if (isset($user) && $user['level']>=8){
echo'<a href="delete.php?act=delete_forum&amp;id_forum='.$forum['id'].'">'.$lng_forum['1_10'].'</a></br>';} 
echo'<a href="/modules/forum/">'.$lng_forum['1_1'].'</a>';
break;
/**ფორუმის ქვედანაყოფების ჩვენება თემიანად**/
case 'view_under_section':
if (isset($_GET['id_section']) && is_numeric($_GET['id_section']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_section_view` WHERE `id` = '".intval($_GET['id_section'])."' LIMIT 1",$dblink), 0)==1)
{
$id_section=intval(abs($_GET['id_section']));
$section = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_section_view` WHERE `id` = '".$id_section."' LIMIT 1"));
$forum = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_section` WHERE `id` = '".$section['id_forum']."' LIMIT 1"));
}else{
header("Location: index.php?".SID);
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topic1_view` WHERE `id_forum` = '".$forum['id']."' AND `id_section`='".$section['id']."'"),0);
$k_page=k_page($k_post,$set['p_count']);
$page=page($k_page);
$start=$set['p_count']*$page-$set['p_count'];
head(''.$lng_forum['1_1'].' | '.$forum['name'].' | '.$section['name']); 
echo'<div class="hdr"><b><a href="index.php">'.$lng_forum['1_1'].'</a> | <a href="/modules/forum/index.php?act=view_section&amp;id_forum='.$forum['id'].'">'.$forum['name'].'</a> | '.$section['name'].'</b></div>';
if ($k_post==0)
{
echo'<div class="errmenu">';
echo''.$lng_forum['1_11'].'';
echo'</div>';
}
$q=mysql_query("SELECT * FROM `forum_topic1_view` WHERE `id_forum` = '".$forum['id']."' AND `id_section`='".$section['id']."' ORDER BY `time` DESC LIMIT $start, $set[p_count]");
while ($post = mysql_fetch_assoc($q))
{
$count_id_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topic2_view` WHERE `id_forum`='$forum[id]' AND `id_section`='$section[id]' AND `id_them`='$post[id]'"),0);
$count_id_post_new=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topic2_view` WHERE `id_forum`='$forum[id]' AND `id_section`='$section[id]' AND `id_them`='$post[id]' AND `time` > '".($time-86400)."'"),0);
$last_user=mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_topic2_view` WHERE `id_them`='".$post['id']."' ORDER BY `id` DESC LIMIT 1"));
echo'<div class="menu">';
echo'<img src="/themes/'.$set['set_them'].'/forum/view_forum_undersection.png" alt="" /><a href="index.php?act=view_topic&amp;id_them='.$post['id'].'"> '.$post['name'].'</a> ['.$count_id_post.'/<span style="color:red;">+'.$count_id_post_new.'</span>] <br/>('.timef($post['time']).') <a href="'.$root_path.'pages/info.php?id='.$last_user['id_user'].'">'.$last_user['login'].'</a> <a href="index.php?act=view_topic&amp;id_them='.$post['id'].'&amp;page=end"><span style="color:red;">&raquo;</span></a>'; 
echo'</div>';
}
if ($k_page>1)str('?act=view_under_section&amp;id_section='.$section['id'].'&amp;',$k_page,$page);
if(isset($user) || $set['guest_forum_create_theme']==1)
echo'<a href="create.php?act=create_theme&amp;id_section='.$section['id'].'">'.$lng_forum['1_12'].'</a><br/>';
if (isset($user) && $user['level']>=6){
echo'<a href="delete.php?act=delete_section&amp;id_section='.$section['id'].'">'.$lng_forum['1_13'].'</a><br/>';}
echo'<a href="/modules/forum/index.php?act=view_section&amp;id_forum='.$forum['id'].'">'.$forum['name'].'</a><br/>
<a href="/modules/forum/">'.$lng_forum['1_1'].'</a>';
break;
/**თემების ჩვენება**/
case 'view_topic':
if (isset($_GET['id_them']) && is_numeric($_GET['id_them']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topic1_view` WHERE `id` = '".intval($_GET['id_them'])."' LIMIT 1",$dblink), 0)==1)
{
$id_them=intval(abs($_GET['id_them']));
$them = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_topic1_view` WHERE `id` = '".$id_them."' LIMIT 1"));
$section = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_section_view` WHERE `id` = '".$them['id_section']."' LIMIT 1"));
$forum = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_section` WHERE `id` = '".$them['id_forum']."' LIMIT 1"));
}else{
header("Location: index.php?".SID);
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topic2_view` WHERE `id_forum` = '".$forum['id']."' AND `id_section`='".$section['id']."' AND `id_them`='".$them['id']."'"),0);
$k_page=k_page($k_post,$set['p_count']);
$page=page($k_page);
$start=$set['p_count']*$page-$set['p_count'];
head(''.$lng_forum['1_1'].' | '.$them['name']); 
echo'<div class="hdr"><b><a href="index.php">'.$lng_forum['1_1'].'</a> | '.$them['name'].'</b></div>'; 
if ($k_post==0)
{
echo'<div class="errmenu">';
echo''.$lng_forum['1_14'].'';
echo'</div>';
}
$q=mysql_query("SELECT * FROM `forum_topic2_view` WHERE `id_forum` = '".$forum['id']."' AND `id_section`='".$section['id']."' AND `id_them`='".$them['id']."' ORDER BY `time` ASC LIMIT $start, $set[p_count]");
while ($post = mysql_fetch_array($q))
{
if (isset($user))
{
$user_count_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topic2_view` WHERE `id_user`='$post[id_user]'"),0);
$count_post="($user_count_post)";
}else{
$count_post='';
}
if ($post['id_user']==0)
{
$ank['sqe']='guest';
$ank['id']='0';
$ank['level']='0';
}else{
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='".$post['id_user']."' LIMIT 1"));
}
echo'<div class="menu">';
echo'<img src="/themes/'.$set['set_them'].'/images/sqe_'.$ank['sqe'].'.png" alt="" /><a href="/pages/info.php?id='.$post['id_user'].'"> '.$post['login'].'</a> '.$count_post.' '.online($ank['id']).' ('.timef($post['time']).')<br/>';
if (isset($user) && $user['level']>=2 && $user['level']>$ank['level'] || isset($user) && $user['id']==$ank['id'] && $post['time']>$time-$set['forum_edit_time'] || isset($user) && $user['id']==$ank['id'] && $user['level']>=2)
{
if(isset($user) && $user['level']<2)
{
$time_edit_post =$post['time']-$time+$set['forum_edit_time'];
$time_edit="($time_edit_post)";
}else{
$time_edit='';
}
echo'<a href="delete.php?act=delete_topic_post&amp;id_post='.$post['id'].'">'.$lng_forum['1_15'].'.</a> | <a href="update.php?act=update_topic_post&amp;id_post='.$post['id'].'">'.$lng_forum['1_16'].'.</a></br>'.$time_edit;
}
echo post($post['msg']);
$freq = mysql_query("SELECT * FROM `forum_files` WHERE `post` = '" .$post['id']. "'");
if (mysql_num_rows($freq) > 0) {
$fres = mysql_fetch_assoc($freq);
$fls = round(@filesize('../../files/forum/' . $fres['filename']) / 1024, 2);
echo'<br/><span class="gray">'.$lng_forum['1_73'].':';
echo'<br/><a href="file.php?id=' . $fres['id'] . '">' . $fres['filename'] . '</a>';
echo'(' . $fls . ' kb.)<br/>';
echo''.$lng_forum['1_71'].': ' . $fres['count'] . ' '.$lng_forum['1_72'].'</span>';}
echo'</div>';
}
if ($k_page>1)str('?act=view_topic&amp;id_them='.$them['id'].'&amp;',$k_page,$page); // გვერდების გამოტანა
if(isset($user) || $set['guest_forum_write']==1)
{
echo'<div class="egmenu"><form method="POST" action="create.php?act=create_post&amp;id_them='.$them['id'].'">';
if (!isset($user))
{
echo''.$lng_forum['1_17'].'(max 32):<br/><input type="text" name="login" maxlength="32" /><br/>';
echo'<img src="/pages/captcha.php" alt=""/><br/>';
echo'<input type="text" name="code" maxlength="4" size="4" /><br/>';
}
echo''.$lng_forum['1_18'].'(max 1280):<br/><textarea name="msg" maxlength="1280" cols="35" rows="3"></textarea><br/>';
if(isset($user)){
echo'<input type="checkbox" name="addfiles" value="1" /> failis damateba<br/>';}
echo'<input type="submit" name="save" value="'.$lng['1_8'].'" />';
echo'</form>';
}
echo'<a href="'.$root_path.'modules/smiles/">'.$lng['1_48'].'</a><br/>';
echo'<a href="'.$root_path.'pages/bb-code.php">'.$lng['1_49'].'</a><br/>';
echo'<a href="index.php?act=view_topic&amp;id_them='.$them['id'].'&amp;tegs">'.$lng_forum['1_19'].'</a>';
echo'</div>';
if (isset($_GET['tegs']))
{
echo''.$lng_forum['1_20'].':<br/>';
echo'<input type="text" value="http://'.$_SERVER['SERVER_NAME'].'/modules/forum/index.php?act=view_topic&id_them='.$them['id'].'"/><br/>';
echo''.$lng_forum['1_21'].':<br/>';
echo'<input type="text" value="[url=http://'.$_SERVER['SERVER_NAME'].'/modules/forum/index.php?act=view_topic&id_them='.$them['id'].']'.$them['name'].'[/url]"/>';
echo'<br/>
<a href="create.php?act=create_txt&amp;id_them='.$them['id'].'">'.$lng_forum['1_22'].'</a><br/>
<a href="index.php?act=view_topic&amp;id_them='.$them['id'].'">'.$lng_forum['1_23'].'</a><br/>';
}
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='".$them['id_user']."' LIMIT 1"));
if (isset($user) && $user['level']>=2 && $user['level']>$ank['level'] || isset($user) && $user['id']==$ank['id'] && $user['level']>=2)
{
echo'<a href="delete.php?act=delete_topic&amp;id_them='.$them['id'].'">'.$lng_forum['1_24'].'</a>';
echo'<br/><a href="update.php?act=update_topic&amp;id_them='.$them['id'].'">'.$lng_forum['1_25'].'</a></br>';
}
echo'<a href="/modules/forum/index.php?act=view_under_section&amp;id_section='.$section['id'].'">'.$section['name'].'</a><br/>
<a href="/modules/forum/index.php?act=view_section&amp;id_forum='.$forum['id'].'">'.$forum['name'].'</a><br/>
<a href="/modules/forum/">'.$lng_forum['1_1'].'</a>';
break;
}
require $root_path.'includes/end.php'; // დასასრული
?>