|
<?php
|
|
/**
|
|
* @package Dynamic Script Forum
|
|
* @file search.php
|
|
* @version 1.0.x, 08-02-2008, 17:40
|
|
* @copyright 2008(c) PioDer <[email protected]>
|
|
* @link http://pioder.gim2przemysl.int.pl/dsf.html
|
|
* @license GNU GPL v3
|
|
**/
|
|
define('IN_uF', true);
|
|
//include files
|
|
include('./config.php');
|
|
include('./includes/constants.php');
|
|
include('./includes/class_db.php');
|
|
include('./includes/class_error.php');
|
|
//connect to database
|
|
DataBase::db_connect();
|
|
include('./includes/sessions.php');
|
|
include('./includes/class_user.php');
|
|
include('./common.php');
|
|
include('./includes/class_overall.php');
|
|
include('./includes/class_forum.php');
|
|
include('./includes/class_topic.php');
|
|
include('./includes/classes/secure.php');
|
|
$default_lang = Over::DefaultLang();
|
|
include('./lngs/'.$default_lang.'/main.php');
|
|
$start = Over::TimeGeneration();
|
|
$default_skin = Over::ViewSkinName();
|
|
sess_del_invalid($_SESSION['uid']);
|
|
sess_register($_SESSION['uid']);
|
|
sess_delete_old();
|
|
$sql = "SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id = ".POSTS_TABLE.".u_id ORDER BY `ptime`";
|
|
$query = DataBase::sql_query($sql,'GENERAL', 'Could not obtain amout of posts in forum');
|
|
while($result = @mysql_fetch_array($query))
|
|
{
|
|
$lastpost[$result['t_id']]['tp_id']=$result['tp_id'];
|
|
$lastpost[$result['t_id']]['u_id']=$result['u_id'];
|
|
$lastpost[$result['t_id']]['time']=$result['ptime'];
|
|
$lastpost[$result['t_id']]['user_nick']=$result['nick'];
|
|
$lastpost[$result['t_id']]['user_rank']=$result['rank'];
|
|
}
|
|
$sql = "SELECT COUNT(*) as `p_id`, `t_id` FROM ".POSTS_TABLE." GROUP BY `t_id`";
|
|
$query = DataBase::sql_query($sql,'GENERAL', 'Could not obtain amout of posts in forum');
|
|
while($result = @mysql_fetch_array($query))
|
|
{
|
|
$count_topic[$result['t_id']]=$result['p_id'];
|
|
}
|
|
if (!isset($_GET['content']))
|
|
{
|
|
header('Location: search.php?content=posts');
|
|
}
|
|
//
|
|
//generate output pages
|
|
//
|
|
if ($_SESSION['uid']>0)
|
|
{
|
|
$limiter = $userdata['limit_ftid'];
|
|
}
|
|
else
|
|
{
|
|
$limiter = $forum_config['limit_ftid'];
|
|
}
|
|
if (isset($_GET['page'])&&($_GET['page']!=1))
|
|
{
|
|
if (!is_numeric($_GET['page']))
|
|
{
|
|
die('Hacking attempt');
|
|
}
|
|
$value = ($_GET['page']-1)*$limiter;
|
|
$limit = 'LIMIT '.$value . ', '.$limiter;
|
|
$page = $_GET['page'];
|
|
}
|
|
else
|
|
{
|
|
$limit = 'LIMIT 0, '.$limiter;
|
|
$page=1;
|
|
}
|
|
//
|
|
//end generating pages
|
|
//
|
|
if ((isset($_POST['keywords'])) || ($_GET['content']=='lastposts') || ($_GET['content']=='userposts'))
|
|
{
|
|
$errors = true;
|
|
switch($_GET['content'])
|
|
{
|
|
case 'lastposts':
|
|
{
|
|
if ($_SESSION['uid']>0)
|
|
{
|
|
$time = time()-129600;
|
|
$sql = "SELECT ".TOPICS_TABLE.".*, ".USERS_TABLE.".* FROM ".TOPICS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".TOPICS_TABLE.".author = ".USERS_TABLE.".u_id WHERE lastpost_time>$time ORDER BY `sticky` DESC, `lastpost_time` DESC LIMIT 60;";
|
|
$errors = false;
|
|
$window_title = $lng['showlast30posts'];
|
|
$navigator_title = '</a>> <a href="'.$_SERVER['REQUEST_URI'].'" class="navigator">'.$lng['showlast30posts'];
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
message_forum($lng['youarenotlogd'],'login.php?mode=login');
|
|
break;
|
|
}
|
|
}
|
|
case 'userposts':
|
|
{
|
|
if (isset($_GET['u']))
|
|
{
|
|
$count = @mysql_fetch_array(DataBase::sql_query("SELECT COUNT(`t_id`) as `t_id`
|
|
FROM ".TOPICS_TABLE." WHERE `author`='".intval($_GET['u'])."'",'GENERAL','Could not obtain count amout of topics'));
|
|
$count = $count['t_id'];
|
|
$count = ceil($count / $limiter);
|
|
if ($count==0)
|
|
{
|
|
$count +=1;
|
|
}
|
|
if(isset($_GET['page']) && ($_GET['page']>$count))
|
|
{
|
|
message_forum($lng['invalidpage'],'index.php');
|
|
}
|
|
$sql = "SELECT ".TOPICS_TABLE.".*, ".USERS_TABLE.".* FROM ".TOPICS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".TOPICS_TABLE.".author = ".USERS_TABLE.".u_id WHERE `u_id`='".intval($_GET['u'])."' ORDER BY `sticky` DESC, `lastpost_time` DESC $limit;";
|
|
$errors = false;
|
|
$window_title = $lng['view_user_topics'];
|
|
$navigator_title = '</a>> <a href="'.$_SERVER['REQUEST_URI'].'" class="navigator">'.$lng['view_user_topics'];
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
message_forum($lng['no_user'],'index.php');
|
|
break;
|
|
}
|
|
}
|
|
case 'posts':
|
|
{
|
|
if(strlen(trim($_POST['keywords']))>=3)
|
|
{
|
|
$keyword = explode(' ', strip_tags(addslashes($_POST['keywords'])));
|
|
$like_where = ' `text` LIKE \'%'.$keyword[0].'%\'';
|
|
for($i=1; $i<count($keyword);$i++)
|
|
{
|
|
$like_where .=' OR `text` LIKE \'%'.$keyword[$i].'%\'';
|
|
}
|
|
$sql = "SELECT COUNT(".TOPICS_TABLE.".t_id) as `count`, ".POSTS_TABLE.".* FROM ".TOPICS_TABLE." LEFT JOIN ".POSTS_TABLE." ON ".POSTS_TABLE.".t_id = ".TOPICS_TABLE.".t_id WHERE $like_where GROUP BY `t_id`";
|
|
$count = @mysql_fetch_array(DataBase::sql_query($sql,'GENERAL','Could not obtain count amout of topics'));
|
|
$count = $count['count'];
|
|
$count = ceil($count / $limiter);
|
|
if ($count==0)
|
|
{
|
|
$count +=1;
|
|
}
|
|
if(isset($_GET['page']) && ($_GET['page']>$count))
|
|
{
|
|
message_forum($lng['invalidpage'],'index.php');
|
|
}
|
|
$sql = "SELECT ".TOPICS_TABLE.".*, ".USERS_TABLE.".*, ".POSTS_TABLE.".* FROM ".TOPICS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".TOPICS_TABLE.".author = ".USERS_TABLE.".u_id LEFT JOIN ".POSTS_TABLE." ON ".POSTS_TABLE.".t_id = ".TOPICS_TABLE.".t_id WHERE $like_where ORDER BY `sticky` DESC, `lastpost_time` DESC $limit;";
|
|
$window_title = $lng['search_results'];
|
|
$navigator_title = '</a>> <a href="'.$_SERVER['REQUEST_URI'].'" class="navigator">'.$lng['search_results'];
|
|
$errors = false;
|
|
|
|
}
|
|
else
|
|
{
|
|
message_forum($lng['too_short_keywords'],'search.php?content=posts');
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
if (!$errors)
|
|
{
|
|
//add skin variables
|
|
$skin = array(
|
|
'lposts'=>$lng['posts'],
|
|
'llastposts'=>$lng['lastpost'],
|
|
'lposts'=>$lng['posts'],
|
|
'lauthor'=>$lng['author'],
|
|
'llastpost'=>$lng['lastpost'],
|
|
'ltopicname'=>$lng['ltopicname'],
|
|
'lang'=> $default_lang
|
|
);
|
|
$skin = array_push_associative($skin,Over::generate_header($window_title,$navigator_title));
|
|
include('./skins/'.$default_skin.'/overall_header.tpl');
|
|
include('./skins/'.$default_skin.'/forum_body.tpl');
|
|
$query = DataBase::sql_query($sql,'GENERAL', 'Could not obtain topics information');
|
|
$value = mysql_num_rows($query);
|
|
if ($value>0)
|
|
{
|
|
$isset_topics = array();
|
|
while($record = mysql_fetch_array($query))
|
|
{
|
|
if (!in_array($record['t_id'], $isset_topics))
|
|
{
|
|
$skin = array(
|
|
't_id'=>$record['t_id'],
|
|
'fname'=>($record['sticky']=='1') ? '<b>'.$lng['sticky'].'</b>'.$record['name'] : $record['name'],
|
|
'author'=>Topic::TopicAuthor($record['author']),
|
|
'new_post'=>Topic::LastPostImg(),
|
|
'tposts'=>$count_topic[$record['t_id']],
|
|
'lastpost'=>Topic::LastPostInTopic($record['t_id'])
|
|
);
|
|
include('./skins/'.$default_skin.'/forum_forum_add.tpl');
|
|
array_push($isset_topics, $record['t_id']);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
echo '<tr><td width="'.TABLES_WIDTH.'" colspan="10" height="19" class="fitem"><p class="fstandard" align="center">'.$lng['nopost'].'!</p></td></tr>';
|
|
}
|
|
if ($_GET['content']=='lastposts')
|
|
{
|
|
echo '</table>';
|
|
}
|
|
else
|
|
{
|
|
$skin = array(
|
|
'option_pages' => Over::AddPages(),
|
|
'lwith' => $lng['with'],
|
|
'lpage' => $lng['page'],
|
|
'lpages' => $count,
|
|
);
|
|
include('./skins/'.$default_skin.'/search_end_body.tpl');
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$skin = array(
|
|
'mainpage'=>$lng['lsearch'],
|
|
'lsubmit'=>$lng['search'],
|
|
'lreset'=>$lng['reset'],
|
|
'insert_keywords'=>$lng['insert_keywords']
|
|
);
|
|
$window_title = $lng['lsearch'];
|
|
$navigator_title = '</a>> <a href="'.$_SERVER['REQUEST_URI'].'" class="navigator">'.$lng['lsearch'];
|
|
$skin = array_push_associative($skin,Over::generate_header($window_title,$navigator_title));
|
|
include('./skins/'.$default_skin.'/overall_header.tpl');
|
|
include('./skins/'.$default_skin.'/search_body.tpl');
|
|
}
|
|
if ($_SESSION['uid']>0)
|
|
{
|
|
if(RANK=='2')
|
|
{
|
|
$skin['pa_link']='<a href="admin/index.php" class="fsmall"><b>'.$lng['pa_link'].'</b></a>';
|
|
}
|
|
else
|
|
{
|
|
$skin['pa_link']='';
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$skin['pa_link']='';
|
|
}
|
|
$stop = Over::TimeGeneration();
|
|
$skin['queries'] = Over::ShowQueries($start, $stop);
|
|
include('./skins/'.$default_skin.'/overall_footer.tpl');
|
|
?>
|