punbb/search.php
author Dan
Sun, 06 Apr 2008 00:28:50 -0400
changeset 7 98bbc533541c
permissions -rw-r--r--
Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
     1
<?php
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
     2
/***********************************************************************
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
     3
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
     4
  Copyright (C) 2002-2008  PunBB.org
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
     5
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
     6
  This file is part of PunBB.
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
     7
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
     8
  PunBB is free software; you can redistribute it and/or modify it
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
     9
  under the terms of the GNU General Public License as published
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    10
  by the Free Software Foundation; either version 2 of the License,
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    11
  or (at your option) any later version.
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    12
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    13
  PunBB is distributed in the hope that it will be useful, but
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    14
  WITHOUT ANY WARRANTY; without even the implied warranty of
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    15
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    16
  GNU General Public License for more details.
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    17
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    18
  You should have received a copy of the GNU General Public License
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    19
  along with this program; if not, write to the Free Software
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    20
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    21
  MA  02111-1307  USA
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    22
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    23
************************************************************************/
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    24
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    25
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    26
// if (!defined('PUN_ROOT'))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    27
// 	define('PUN_ROOT', './');
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    28
// require PUN_ROOT.'include/common.php';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    29
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    30
// import globals (I really hope this isn't dangerous)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    31
foreach ( $GLOBALS as $key => $_ )
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    32
{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    33
  $$key =& $GLOBALS[$key];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    34
}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    35
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    36
($hook = get_hook('se_start')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    37
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    38
// Load the search.php language file
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    39
require PUN_ROOT.'lang/'.$pun_user['language'].'/search.php';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    40
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    41
if ($pun_user['g_read_board'] == '0')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    42
	message($lang_common['No view']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    43
else if ($pun_user['g_search'] == '0')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    44
	message($lang_search['No search permission']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    45
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    46
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    47
// Figure out what to do :-)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    48
if (isset($_GET['action']) || isset($_GET['search_id']))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    49
{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    50
	// Grab and validate all the submitted data
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    51
	$action = (isset($_GET['action'])) ? $_GET['action'] : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    52
	$value = (isset($_GET['value'])) ? intval($_GET['value']) : 86400;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    53
	$forum = (isset($_GET['forum'])) ? intval($_GET['forum']) : -1;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    54
	$sort_dir = (isset($_GET['sort_dir'])) ? (($_GET['sort_dir'] == 'DESC') ? 'DESC' : 'ASC') : 'DESC';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    55
	if (isset($search_id)) unset($search_id);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    56
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    57
	// If a search_id was supplied
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    58
	if (isset($_GET['search_id']))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    59
	{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    60
		$search_id = intval($_GET['search_id']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    61
		if ($db_type == 'mysql' || $db_type == 'mysqli')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    62
			message($lang_common['Bad request']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    63
		if ($search_id < 1)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    64
			message($lang_common['Bad request']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    65
	}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    66
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    67
	// A list of valid actions (extensions can add their own actions to the array)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    68
	$valid_actions = array('search', 'show_new', 'show_recent', 'show_user_posts', 'show_user_topics', 'show_subscriptions', 'show_unanswered');
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    69
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    70
	($hook = get_hook('se_search_selected')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    71
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    72
	// Validate action
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    73
	if ($action && !in_array($action, $valid_actions))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    74
		message($lang_common['Bad request']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    75
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    76
	// If it's a regular search (keywords and/or author)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    77
	if ($action == 'search')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    78
	{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    79
		$keywords = (isset($_GET['keywords'])) ? strtolower(trim($_GET['keywords'])) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    80
		$author = (isset($_GET['author'])) ? strtolower(trim($_GET['author'])) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    81
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    82
		if (preg_match('#^[\*%]+$#', $keywords) || pun_strlen(str_replace(array('*', '%'), '', $keywords)) < 3)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    83
			$keywords = '';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    84
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    85
		if (preg_match('#^[\*%]+$#', $author) || pun_strlen(str_replace(array('*', '%'), '', $author)) < 2)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    86
			$author = '';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    87
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    88
		if (!$keywords && !$author)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    89
			message($lang_search['No terms']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    90
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    91
		if ($author)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    92
			$author = str_replace('*', '%', $author);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    93
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    94
		$show_as = (isset($_GET['show_as'])) ? $_GET['show_as'] : 'posts';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    95
		$sort_by = (isset($_GET['sort_by'])) ? intval($_GET['sort_by']) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    96
		$search_in = (!isset($_GET['search_in']) || $_GET['search_in'] == 'all') ? 0 : (($_GET['search_in'] == 'message') ? 1 : -1);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    97
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    98
	}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
    99
	// If it's a user search (by id), make sure we have a user_id
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   100
	else if ($action == 'show_user_posts' || $action == 'show_user_topics')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   101
	{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   102
		$user_id = isset($_GET['user_id']) ? intval($_GET['user_id']) : 0;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   103
		if ($user_id < 2)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   104
			message($lang_common['Bad request']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   105
	}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   106
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   107
	// First of all lets find out if we need to cache the results, we only need to do this for detailed queries, not quicksearches or for mysql(i)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   108
	if ($db_type != 'mysql' && $db_type != 'mysqli' && (isset($keywords) || isset($author)))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   109
	{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   110
		// We need to grab results, insert them into the cache and reload with a search id before showing them
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   111
		$keyword_results = $author_results = array();
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   112
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   113
		// If it's a search for keywords
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   114
		if ($keywords)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   115
		{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   116
			$stopwords = (array)@file(PUN_ROOT.'lang/'.$pun_user['language'].'/stopwords.txt');
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   117
			$stopwords = array_map('trim', $stopwords);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   118
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   119
			// Filter out non-alphabetical chars
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   120
			$noise_match = array('^', '$', '&', '(', ')', '<', '>', '`', '\'', '"', '|', ',', '@', '_', '?', '%', '~', '[', ']', '{', '}', ':', '\\', '/', '=', '#', '\'', ';', '!', '¤');
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   121
			$noise_replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', '',  '',   ' ', ' ', ' ', ' ', '',  ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '' ,  ' ', ' ', ' ', ' ',  ' ', ' ', ' ');
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   122
			$keywords = str_replace($noise_match, $noise_replace, $keywords);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   123
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   124
			// Strip out excessive whitespace
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   125
			$keywords = trim(preg_replace('#\s+#', ' ', $keywords));
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   126
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   127
			// Fill an array with all the words
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   128
			$keywords_array = explode(' ', $keywords);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   129
			if (empty($keywords_array))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   130
				message($lang_search['No hits']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   131
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   132
			while (list($i, $word) = @each($keywords_array))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   133
			{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   134
				$num_chars = pun_strlen($word);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   135
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   136
				if ($word !== 'or' && ($num_chars < 3 || $num_chars > 20 || in_array($word, $stopwords)))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   137
					unset($keywords_array[$i]);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   138
			}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   139
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   140
			$word_count = 0;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   141
			$match_type = 'and';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   142
			$result_list = array();
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   143
			@reset($keywords_array);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   144
			while (list(, $cur_word) = @each($keywords_array))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   145
			{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   146
				switch ($cur_word)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   147
				{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   148
					case 'and':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   149
					case 'or':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   150
					case 'not':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   151
						$match_type = $cur_word;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   152
						break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   153
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   154
					default:
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   155
					{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   156
						$cur_word = str_replace('*', '%', $cur_word);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   157
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   158
						$query = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   159
							'SELECT'	=> 'm.post_id',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   160
							'FROM'		=> 'search_words AS w',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   161
							'JOINS'		=> array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   162
								array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   163
									'INNER JOIN'	=> 'search_matches AS m',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   164
									'ON'			=> 'm.word_id=w.id'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   165
								)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   166
							),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   167
							'WHERE'		=> 'w.word LIKE \''.$cur_word.'\''
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   168
						);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   169
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   170
						// Search in what?
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   171
						if ($search_in)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   172
							$query['WHERE'] .= ($search_in > 0 ? ' AND m.subject_match=0' : ' AND m.subject_match=1');
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   173
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   174
						($hook = get_hook('se_qr_get_keyword_hits')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   175
						$result = $pun_db->query_build($query, true) or error(__FILE__, __LINE__);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   176
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   177
						$row = array();
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   178
						while ($temp = $pun_db->fetch_row($result))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   179
						{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   180
							$row[$temp[0]] = 1;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   181
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   182
							if (!$word_count)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   183
								$result_list[$temp[0]] = 1;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   184
							else if ($match_type == 'or')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   185
								$result_list[$temp[0]] = 1;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   186
							else if ($match_type == 'not')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   187
								$result_list[$temp[0]] = 0;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   188
						}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   189
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   190
						if ($match_type == 'and' && $word_count)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   191
						{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   192
							@reset($result_list);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   193
							while (list($post_id,) = @each($result_list))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   194
							{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   195
								if (!isset($row[$post_id]))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   196
									$result_list[$post_id] = 0;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   197
							}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   198
						}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   199
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   200
						++$word_count;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   201
						$pun_db->free_result($result);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   202
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   203
						break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   204
					}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   205
				}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   206
			}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   207
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   208
			@reset($result_list);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   209
			while (list($post_id, $matches) = @each($result_list))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   210
			{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   211
				if ($matches)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   212
					$keyword_results[] = $post_id;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   213
			}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   214
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   215
			unset($result_list);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   216
		}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   217
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   218
		// If it's a search for author name (and that author name isn't Guest)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   219
		if ($author && strtolower($author) != 'guest' && strtolower($author) != strtolower($lang_common['Guest']))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   220
		{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   221
			$query = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   222
				'SELECT'	=> 'u.id',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   223
				'FROM'		=> 'users AS u',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   224
				'WHERE'		=> 'u.username '.($db_type == 'pgsql' ? 'ILIKE' : 'LIKE').' \''.$pun_db->escape($author).'\''
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   225
			);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   226
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   227
			($hook = get_hook('se_qr_get_author')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   228
			$result = $pun_db->query_build($query) or error(__FILE__, __LINE__);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   229
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   230
			if ($pun_db->num_rows($result))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   231
			{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   232
				$user_ids = '';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   233
				while ($row = $pun_db->fetch_row($result))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   234
					$user_ids .= (($user_ids != '') ? ',' : '').$row[0];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   235
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   236
				$query = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   237
					'SELECT'	=> 'p.id',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   238
					'FROM'		=> 'posts AS p',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   239
					'WHERE'		=> 'p.poster_id IN('.$user_ids.')'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   240
				);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   241
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   242
				($hook = get_hook('se_qr_get_author_hits')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   243
				$result = $pun_db->query_build($query) or error(__FILE__, __LINE__);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   244
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   245
				$search_ids = array();
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   246
				while ($row = $pun_db->fetch_row($result))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   247
					$author_results[] = $row[0];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   248
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   249
				$pun_db->free_result($result);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   250
			}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   251
		}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   252
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   253
		if ($author && $keywords)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   254
		{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   255
			// If we searched for both keywords and author name we want the intersection between the results
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   256
			$search_ids = array_intersect($keyword_results, $author_results);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   257
			unset($keyword_results, $author_results);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   258
		}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   259
		else if ($keywords)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   260
			$search_ids = $keyword_results;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   261
		else
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   262
			$search_ids = $author_results;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   263
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   264
		if (count($search_ids) == 0)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   265
			message($lang_search['No hits']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   266
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   267
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   268
		// Setup the default show_as topics search
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   269
		$query = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   270
			'SELECT'	=> 't.id',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   271
			'FROM'		=> 'posts AS p',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   272
			'JOINS'		=> array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   273
				array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   274
					'INNER JOIN'	=> 'topics AS t',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   275
					'ON'			=> 't.id=p.topic_id'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   276
				),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   277
				array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   278
					'LEFT JOIN'		=> 'forum_perms AS fp',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   279
					'ON'			=> '(fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].')'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   280
				)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   281
			),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   282
			'WHERE'		=> '(fp.read_forum IS NULL OR fp.read_forum=1) AND p.id IN('.implode(',', $search_ids).')',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   283
			'GROUP BY'	=> 't.id'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   284
		);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   285
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   286
		// Search a specific forum?
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   287
		if ($forum != -1 || ($forum == -1 && $pun_config['o_search_all_forums'] == '0' && !$pun_user['is_admmod']))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   288
			$query['WHERE'] .= ' AND t.forum_id = '.$forum;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   289
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   290
		// Adjust the query if show_as posts
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   291
		if ($show_as == 'posts')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   292
		{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   293
			$query['SELECT'] = 'p.id';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   294
			unset($query['GROUP BY']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   295
		}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   296
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   297
		($hook = get_hook('se_qr_get_hits')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   298
		$result = $pun_db->query_build($query, true) or error(__FILE__, __LINE__);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   299
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   300
		$search_ids = array();
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   301
		while ($row = $pun_db->fetch_row($result))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   302
			$search_ids[] = $row[0];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   303
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   304
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   305
		// Prune "old" search results
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   306
		$query = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   307
			'SELECT'	=> 'o.ident',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   308
			'FROM'		=> 'online AS o'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   309
		);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   310
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   311
		($hook = get_hook('se_qr_get_online_idents')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   312
		$result = $pun_db->query_build($query) or error(__FILE__, __LINE__);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   313
		if ($pun_db->num_rows($result))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   314
		{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   315
			$online_idents = array();
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   316
			while ($row = $pun_db->fetch_row($result))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   317
				$online_idents[] = '\''.$pun_db->escape($row[0]).'\'';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   318
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   319
			$query = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   320
				'DELETE'	=> 'search_cache',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   321
				'WHERE'		=> 'ident NOT IN('.implode(',', $online_idents).')'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   322
			);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   323
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   324
			($hook = get_hook('se_qr_delete_old_cached_searches')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   325
			$pun_db->query_build($query) or error(__FILE__, __LINE__);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   326
		}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   327
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   328
		// Final search results
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   329
		$search_results = implode(',', $search_ids);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   330
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   331
		// Fill an array with our results and search properties
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   332
		$temp['search_results'] = $search_results;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   333
		$temp['sort_by'] = $sort_by;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   334
		$temp['sort_dir'] = $sort_dir;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   335
		$temp['show_as'] = $show_as;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   336
		$temp = serialize($temp);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   337
		$search_id = mt_rand(1, 2147483647);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   338
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   339
		$ident = ($pun_user['is_guest']) ? get_remote_address() : $pun_user['username'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   340
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   341
		$query = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   342
			'INSERT'	=> 'id, ident, search_data',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   343
			'INTO'		=> 'search_cache',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   344
			'VALUES'	=> $search_id.', \''.$pun_db->escape($ident).'\', \''.$pun_db->escape($temp).'\''
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   345
		);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   346
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   347
		($hook = get_hook('se_qr_cache_search')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   348
		$pun_db->query_build($query) or error(__FILE__, __LINE__);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   349
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   350
		$pun_db->end_transaction();
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   351
		$pun_db->close();
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   352
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   353
		// Redirect the user to the cached result page
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   354
		header('Location: '.str_replace('&amp;', '&', pun_link($pun_url['search_results'], $search_id)));
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   355
		exit;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   356
	}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   357
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   358
	// If we're still running we don't need to cache results but we still need to get them, either from the cache or from their respective sources.
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   359
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   360
	// We're doing a fulltext search!
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   361
	else if (($db_type == 'mysql' || $db_type == 'mysqli') && (isset($keywords) || isset($author)))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   362
	{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   363
		// Are we limiting the results to a specific forum?
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   364
		if ($forum != -1 || ($forum == -1 && $pun_config['o_search_all_forums'] == '0' && !$pun_user['is_admmod']))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   365
			$forum_where = ' AND f.id = '.$forum;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   366
		else
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   367
			$forum_where = '';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   368
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   369
		// Sort out how to order the results
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   370
		switch ($sort_by)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   371
		{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   372
			case 1:
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   373
				$sort_by_sql = ($show_as == 'topics') ? 'poster' : 'p.poster';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   374
				break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   375
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   376
			case 2:
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   377
				$sort_by_sql = 'subject';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   378
				break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   379
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   380
			case 3:
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   381
				$sort_by_sql = 'forum_id';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   382
				break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   383
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   384
			case 4:
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   385
				if ($show_as == 'posts')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   386
					$sort_by_sql = 'MATCH(p.message) AGAINST(\''.$pun_db->escape($keywords).'\')';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   387
				else
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   388
					$sort_by_sql = 'total_relevance';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   389
				break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   390
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   391
			default:
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   392
				$sort_by_sql = ($show_as == 'topics') ? 'posted' : 'p.posted';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   393
				break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   394
		}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   395
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   396
		// Generate the query to give us our results
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   397
		if ($show_as == 'posts')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   398
			$query = '
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   399
				SELECT
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   400
					p.id AS pid, p.poster AS pposter, p.posted AS pposted, p.poster_id, SUBSTRING(p.message, 1, 1000) AS message, t.id AS tid, t.poster, t.subject, t.first_post_id, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.forum_id, f.forum_name
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   401
				FROM '.$pun_db->prefix.'posts AS p LEFT JOIN '.$pun_db->prefix.'topics AS t ON t.id=p.topic_id LEFT JOIN '.$pun_db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   402
				WHERE
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   403
					(fp.read_forum IS NULL OR fp.read_forum=1)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   404
					'.($author ? 'AND p.poster LIKE \''.$pun_db->escape($author).'\'' : '').'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   405
					'.($keywords ? 'AND MATCH(p.message) AGAINST(\''.$pun_db->escape($keywords).'\' IN BOOLEAN MODE)' : '').'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   406
					'.$forum_where.'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   407
				ORDER BY '.$sort_by_sql.' '.$sort_dir;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   408
		else
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   409
		{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   410
			$query = '
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   411
				SELECT
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   412
					*, SUM(relevance) AS total_relevance FROM
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   413
				(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   414
					SELECT
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   415
						t.id AS tid, t.poster, t.subject, t.first_post_id, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id, t.posted, f.forum_name, MATCH(t.subject) AGAINST(\''.$pun_db->escape($keywords).'\') AS relevance
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   416
					FROM '.$pun_db->prefix.'topics AS t LEFT JOIN '.$pun_db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   417
					WHERE
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   418
						(fp.read_forum IS NULL OR fp.read_forum=1)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   419
						'.($keywords ? 'AND MATCH(t.subject) AGAINST(\''.$pun_db->escape($keywords).'\' IN BOOLEAN MODE)' : '').'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   420
						'.$forum_where.'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   421
					UNION
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   422
					SELECT
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   423
						t.id AS tid, t.poster, t.subject, t.first_post_id, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id, t.posted, f.forum_name, MATCH(p.message) AGAINST(\''.$pun_db->escape($keywords).'\') AS relevance
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   424
					FROM '.$pun_db->prefix.'posts AS p INNER JOIN '.$pun_db->prefix.'topics AS t ON p.topic_id = t.id LEFT JOIN '.$pun_db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   425
					WHERE
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   426
						(fp.read_forum IS NULL OR fp.read_forum=1)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   427
						'.($author ? 'AND p.poster LIKE \''.$pun_db->escape($author).'\'' : '').'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   428
						'.($keywords ? 'AND MATCH(p.message) AGAINST(\''.$pun_db->escape($keywords).'\' IN BOOLEAN MODE)' : '').'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   429
						'.$forum_where.'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   430
				) AS tmp
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   431
				GROUP BY tid
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   432
				ORDER BY '.$sort_by_sql.' '.$sort_dir;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   433
		}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   434
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   435
		$url_type = $pun_url['search_resultft'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   436
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   437
		$search_id = array($keywords, $forum, $author, ($search_in == 0 ) ? 'all' : (($search_in == 1) ? 'message' : 'subject'), $sort_by, $sort_dir, $show_as);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   438
	}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   439
	// We aren't doing a fulltext but we are getting results, if a valid search_id was supplied we attempt to fetch the search results from the cache
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   440
	else if (isset($search_id))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   441
	{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   442
		$ident = ($pun_user['is_guest']) ? get_remote_address() : $pun_user['username'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   443
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   444
		$query = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   445
			'SELECT'	=> 'sc.search_data',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   446
			'FROM'		=> 'search_cache AS sc',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   447
			'WHERE'		=> 'sc.id='.$search_id.' AND sc.ident=\''.$pun_db->escape($ident).'\''
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   448
		);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   449
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   450
		($hook = get_hook('se_qr_get_cached_search_data')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   451
		$result = $pun_db->query_build($query) or error(__FILE__, __LINE__);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   452
		if ($row = $pun_db->fetch_assoc($result))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   453
		{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   454
			$temp = unserialize($row['search_data']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   455
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   456
			$search_results = $temp['search_results'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   457
			$sort_by = $temp['sort_by'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   458
			$sort_dir = $temp['sort_dir'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   459
			$show_as = $temp['show_as'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   460
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   461
			unset($temp);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   462
		}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   463
		else
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   464
			message($lang_search['No hits']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   465
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   466
		switch ($sort_by)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   467
		{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   468
			case 1:
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   469
				$sort_by_sql = ($show_as == 'topics') ? 't.poster' : 'p.poster';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   470
				break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   471
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   472
			case 2:
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   473
				$sort_by_sql = 't.subject';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   474
				break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   475
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   476
			case 3:
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   477
				$sort_by_sql = 't.forum_id';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   478
				break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   479
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   480
			default:
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   481
				$sort_by_sql = ($show_as == 'topics') ? 't.posted' : 'p.posted';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   482
				break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   483
		}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   484
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   485
		if ($show_as == 'posts')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   486
		{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   487
			$query = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   488
				'SELECT'	=> 'p.id AS pid, p.poster AS pposter, p.posted AS pposted, p.poster_id, '.(($db_type != 'sqlite') ? 'SUBSTRING' : 'SUBSTR').'(p.message, 1, 1000) AS message, t.id AS tid, t.poster, t.subject, t.first_post_id, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.forum_id, f.forum_name',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   489
				'FROM'		=> 'posts AS p',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   490
				'JOINS'		=> array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   491
					array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   492
						'INNER JOIN'	=> 'topics AS t',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   493
						'ON'			=> 't.id=p.topic_id'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   494
					),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   495
					array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   496
						'INNER JOIN'	=> 'forums AS f',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   497
						'ON'			=> 'f.id=t.forum_id'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   498
					)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   499
				),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   500
				'WHERE'		=> 'p.id IN('.$search_results.')',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   501
				'ORDER BY'	=> $sort_by_sql
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   502
			);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   503
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   504
			($hook = get_hook('se_qr_get_cached_hits_as_posts')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   505
		}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   506
		else
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   507
		{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   508
			$query = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   509
				'SELECT'	=> 't.id AS tid, t.poster, t.subject, t.first_post_id, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id, f.forum_name',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   510
				'FROM'		=> 'topics AS t',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   511
				'JOINS'		=> array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   512
					array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   513
						'INNER JOIN'	=> 'forums AS f',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   514
						'ON'			=> 'f.id=t.forum_id'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   515
					)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   516
				),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   517
				'WHERE'		=> 't.id IN('.$search_results.')',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   518
				'ORDER BY'	=> 'p.id, '.$sort_by_sql
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   519
			);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   520
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   521
			($hook = get_hook('se_qr_get_cached_hits_as_topics')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   522
		}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   523
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   524
		$url_type = $pun_url['search_results'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   525
	}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   526
	else if (in_array($action, $valid_actions))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   527
	{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   528
		$search_id = '';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   529
		$show_as = 'topics';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   530
		switch ($action)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   531
		{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   532
			case 'show_new':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   533
				if ($pun_user['is_guest'])
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   534
					message($lang_common['No permission']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   535
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   536
				$query = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   537
					'SELECT'	=> 't.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id, f.forum_name',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   538
					'FROM'		=> 'topics AS t',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   539
					'JOINS'		=> array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   540
						array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   541
							'INNER JOIN'	=> 'forums AS f',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   542
							'ON'			=> 'f.id=t.forum_id'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   543
						),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   544
						array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   545
							'LEFT JOIN'		=> 'forum_perms AS fp',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   546
							'ON'			=> '(fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   547
						)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   548
					),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   549
					'WHERE'		=> '(fp.read_forum IS NULL OR fp.read_forum=1) AND t.last_post>'.$pun_user['last_visit'].' AND t.moved_to IS NULL',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   550
					'ORDER BY'	=> 't.last_post DESC'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   551
				);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   552
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   553
				($hook = get_hook('se_qr_get_new')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   554
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   555
				$url_type = $pun_url['search_new'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   556
				break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   557
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   558
			case 'show_recent':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   559
				$query = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   560
					'SELECT'	=> 't.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id, f.forum_name',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   561
					'FROM'		=> 'topics AS t',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   562
					'JOINS'		=> array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   563
						array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   564
							'INNER JOIN'	=> 'posts AS p',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   565
							'ON'			=> 'p.topic_id=t.id'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   566
						),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   567
						array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   568
							'INNER JOIN'	=> 'forums AS f',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   569
							'ON'			=> 'f.id=t.forum_id'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   570
						),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   571
						array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   572
							'LEFT JOIN'		=> 'forum_perms AS fp',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   573
							'ON'			=> '(fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   574
						)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   575
					),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   576
					'WHERE'		=> '(fp.read_forum IS NULL OR fp.read_forum=1) AND p.posted>'.(time() - $value).' AND t.moved_to IS NULL',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   577
					'GROUP BY'	=> 't.id',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   578
					'ORDER BY'	=> 't.last_post DESC'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   579
				);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   580
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   581
				($hook = get_hook('se_qr_get_recent')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   582
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   583
				$url_type = $pun_url['search_24h'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   584
				break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   585
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   586
			case 'show_user_posts':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   587
				$query = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   588
					'SELECT'	=> 'p.id AS pid, p.poster AS pposter, p.posted AS pposted, p.poster_id, '.(($db_type != 'sqlite') ? 'SUBSTRING' : 'SUBSTR').'(p.message, 1, 1000) AS message, t.id AS tid, t.poster, t.subject, t.first_post_id, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.forum_id, f.forum_name',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   589
					'FROM'		=> 'posts AS p',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   590
					'JOINS'		=> array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   591
						array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   592
							'INNER JOIN'	=> 'topics AS t',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   593
							'ON'			=> 't.id=p.topic_id'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   594
						),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   595
						array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   596
							'INNER JOIN'	=> 'forums AS f',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   597
							'ON'			=> 'f.id=t.forum_id'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   598
						),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   599
						array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   600
							'LEFT JOIN'		=> 'forum_perms AS fp',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   601
							'ON'			=> '(fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   602
						)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   603
					),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   604
					'WHERE'		=> '(fp.read_forum IS NULL OR fp.read_forum=1) AND p.poster_id='.$user_id,
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   605
					'ORDER BY'	=> 'pposted DESC'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   606
				);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   607
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   608
				($hook = get_hook('se_qr_get_user_posts')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   609
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   610
				$url_type = $pun_url['search_user_posts'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   611
				$search_id = $user_id;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   612
				$show_as = 'posts';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   613
				break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   614
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   615
			case 'show_user_topics':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   616
				$query = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   617
					'SELECT'	=> 't.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id, f.forum_name',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   618
					'FROM'		=> 'topics AS t',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   619
					'JOINS'		=> array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   620
						array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   621
							'INNER JOIN'	=> 'posts AS p',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   622
							'ON'			=> 't.first_post_id=p.id'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   623
						),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   624
						array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   625
							'INNER JOIN'	=> 'forums AS f',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   626
							'ON'			=> 'f.id=t.forum_id'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   627
						),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   628
						array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   629
							'LEFT JOIN'		=> 'forum_perms AS fp',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   630
							'ON'			=> '(fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   631
						)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   632
					),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   633
					'WHERE'		=> '(fp.read_forum IS NULL OR fp.read_forum=1) AND p.poster_id='.$user_id,
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   634
					'ORDER BY'	=> 't.last_post DESC'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   635
				);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   636
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   637
				($hook = get_hook('se_qr_get_user_topics')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   638
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   639
				$url_type = $pun_url['search_user_topics'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   640
				$search_id = $user_id;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   641
				break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   642
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   643
			case 'show_subscriptions':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   644
				if ($pun_user['is_guest'])
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   645
					message($lang_common['Bad request']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   646
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   647
				$query = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   648
					'SELECT'	=> 't.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id, f.forum_name',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   649
					'FROM'		=> 'topics AS t',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   650
					'JOINS'		=> array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   651
						array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   652
							'INNER JOIN'	=> 'subscriptions AS s',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   653
							'ON'			=> '(t.id=s.topic_id AND s.user_id='.$pun_user['id'].')'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   654
						),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   655
						array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   656
							'INNER JOIN'	=> 'forums AS f',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   657
							'ON'			=> 'f.id=t.forum_id'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   658
						),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   659
						array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   660
							'LEFT JOIN'		=> 'forum_perms AS fp',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   661
							'ON'			=> '(fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   662
						)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   663
					),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   664
					'WHERE'		=> '(fp.read_forum IS NULL OR fp.read_forum=1)',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   665
					'ORDER BY'	=> 't.last_post DESC'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   666
				);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   667
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   668
				($hook = get_hook('se_qr_get_subscriptions')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   669
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   670
				$url_type = $pun_url['search_subscriptions'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   671
				break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   672
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   673
			case 'show_unanswered':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   674
				$query = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   675
					'SELECT'	=> 't.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id, f.forum_name',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   676
					'FROM'		=> 'topics AS t',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   677
					'JOINS'		=> array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   678
						array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   679
							'INNER JOIN'	=> 'posts AS p',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   680
							'ON'			=> 't.id=p.topic_id'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   681
						),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   682
						array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   683
							'INNER JOIN'	=> 'forums AS f',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   684
							'ON'			=> 'f.id=t.forum_id'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   685
						),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   686
						array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   687
							'LEFT JOIN'		=> 'forum_perms AS fp',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   688
							'ON'			=> '(fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   689
						)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   690
					),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   691
					'WHERE'		=> '(fp.read_forum IS NULL OR fp.read_forum=1) AND t.num_replies=0 AND t.moved_to IS NULL',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   692
					'GROUP BY'	=> 't.id',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   693
					'ORDER BY'	=> 't.last_post DESC'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   694
				);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   695
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   696
				($hook = get_hook('se_qr_get_unanswered')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   697
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   698
				$url_type = $pun_url['search_unanswered'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   699
				break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   700
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   701
			default:
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   702
				// A good place for an extension to add a new search type (action must be added to $valid_actions first)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   703
				($hook = get_hook('se_new_action')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   704
				break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   705
		}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   706
	}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   707
	else
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   708
		message($lang_common['Bad request']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   709
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   710
	// We now have a query that will give us our results in $query, lets get the data!
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   711
	if (is_array($query))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   712
		$result = $pun_db->query_build($query) or error(__FILE__, __LINE__);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   713
	else
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   714
		$result = $pun_db->query($query) or error(__FILE__, __LINE__);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   715
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   716
	// Make sure we actually have some results
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   717
	$num_hits = $pun_db->num_rows($result);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   718
	if ($num_hits == 0)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   719
	{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   720
		$pun_page['search_again'] = '<a href="'.pun_link($pun_url['search']).'">'.$lang_search['Perform new search'].'</a>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   721
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   722
		switch ($action)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   723
		{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   724
			case 'show_new':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   725
				message($lang_search['No new posts'], $pun_page['search_again']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   726
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   727
			case 'show_recent':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   728
				message($lang_search['No recent posts'], $pun_page['search_again']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   729
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   730
			case 'show_user_posts':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   731
				message($lang_search['No user posts'], $pun_page['search_again']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   732
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   733
			case 'show_user_topics':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   734
				message($lang_search['No user topics'], $pun_page['search_again']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   735
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   736
			case 'show_subscriptions':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   737
				message($lang_search['No subscriptions'], $pun_page['search_again']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   738
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   739
			case 'show_unanswered':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   740
				message($lang_search['No unanswered'], $pun_page['search_again']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   741
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   742
			default:
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   743
				($hook = get_hook('se_new_action_no_hits')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   744
				message($lang_search['No hits'], $pun_page['search_again']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   745
		}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   746
	}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   747
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   748
	// Get topic/forum tracking data
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   749
	if (!$pun_user['is_guest'])
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   750
		$tracked_topics = get_tracked_topics();
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   751
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   752
	// Determine the topic or post offset (based on $_GET['p'])
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   753
	$pun_page['per_page'] = ($show_as == 'posts') ? $pun_user['disp_posts'] : $pun_user['disp_topics'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   754
	$pun_page['num_pages'] = ceil($num_hits / $pun_page['per_page']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   755
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   756
	$pun_page['page'] = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $pun_page['num_pages']) ? 1 : $_GET['p'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   757
	$pun_page['start_from'] = $pun_page['per_page'] * ($pun_page['page'] - 1);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   758
	$pun_page['finish_at'] = min(($pun_page['start_from'] + $pun_page['per_page']), $num_hits);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   759
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   760
	// Generate paging links
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   761
	$pun_page['page_post'] = '<p class="paging"><strong>'.$lang_common['Pages'].'</strong> '.pun_paginate($pun_page['num_pages'], $pun_page['page'], $url_type, $search_id).'</p>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   762
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   763
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   764
	// Fill $search_set with out search hits
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   765
	$search_set = array();
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   766
	$row_num = 0;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   767
	while ($row = $pun_db->fetch_assoc($result))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   768
	{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   769
		if ($pun_page['start_from'] <= $row_num && $pun_page['finish_at'] > $row_num)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   770
			$search_set[] = $row;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   771
		++$row_num;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   772
	}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   773
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   774
	$pun_db->free_result($result);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   775
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   776
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   777
	// Navigation links for header and page numbering for title/meta description
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   778
	if ($pun_page['page'] < $pun_page['num_pages'])
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   779
	{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   780
		$pun_page['nav'][] = '<link rel="last" href="'.pun_sublink($url_type, $pun_url['page'], $pun_page['num_pages'], $search_id).'" title="'.$lang_common['Page'].' '.$pun_page['num_pages'].'" />';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   781
		$pun_page['nav'][] = '<link rel="next" href="'.pun_sublink($url_type, $pun_url['page'], ($pun_page['page'] + 1), $search_id).'" title="'.$lang_common['Page'].' '.($pun_page['page'] + 1).'" />';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   782
	}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   783
	if ($pun_page['page'] > 1)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   784
	{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   785
		$pun_page['nav'][] = '<link rel="prev" href="'.pun_sublink($url_type, $pun_url['page'], ($pun_page['page'] - 1), $search_id).'" title="'.$lang_common['Page'].' '.($pun_page['page'] - 1).'" />';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   786
		$pun_page['nav'][] = '<link rel="first" href="'.pun_link($url_type, $search_id).'" title="'.$lang_common['Page'].' 1" />';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   787
	}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   788
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   789
	// Setup breadcrumbs and results header and footer
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   790
	$pun_page['main_foot_options'][] = '<a class="user-option" href="'.pun_link($pun_url['search']).'">'.$lang_search['Perform new search'].'</a>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   791
	$pun_page['crumbs'][] = array($pun_config['o_board_title'], pun_link($pun_url['index']));
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   792
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   793
	switch ($action)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   794
	{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   795
		case 'show_new':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   796
			$pun_page['crumbs'][] = $lang_common['New posts'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   797
			$pun_page['main_info'] = (($pun_page['num_pages'] == 1) ? sprintf($lang_common['Page info'], $lang_search['Topics with new'], $num_hits) : '<span>'.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' </span>'.sprintf($lang_common['Paged info'], $lang_search['Topics with new'], $pun_page['start_from'] + 1, $pun_page['finish_at'], $num_hits));
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   798
			$pun_page['main_foot_options'][] = '<a class="user-option" href="'.pun_link($pun_url['mark_read']).'">'.$lang_common['Mark all as read'].'</a>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   799
			break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   800
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   801
		case 'show_recent':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   802
			$pun_page['crumbs'][] = $lang_common['Recent posts'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   803
			$pun_page['main_info'] = (($pun_page['num_pages'] == 1) ? sprintf($lang_common['Page info'], $lang_search['Topics with recent'], $num_hits) : '<span>'.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' </span>'.sprintf($lang_common['Paged info'], $lang_search['Topics with recent'], $pun_page['start_from'] + 1, $pun_page['finish_at'], $num_hits));
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   804
			break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   805
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   806
		case 'show_unanswered':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   807
			$pun_page['crumbs'][] = $lang_common['Unanswered topics'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   808
			$pun_page['main_info'] = (($pun_page['num_pages'] == 1) ? sprintf($lang_common['Page info'], $lang_common['Unanswered topics'], $num_hits) : '<span>'.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' </span>'.sprintf($lang_common['Paged info'], $lang_common['Unanswered topics'], $pun_page['start_from'] + 1, $pun_page['finish_at'], $num_hits));
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   809
			break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   810
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   811
		case 'show_user_posts':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   812
			$pun_page['crumbs'][] = sprintf($lang_search['Posts by'], $search_set[0]['pposter']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   813
			$pun_page['main_info'] = (($pun_page['num_pages'] == 1) ? sprintf($lang_common['Page info'], sprintf($lang_search['Posts by'], $search_set[0]['pposter']), $num_hits) : '<span>'.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' </span>'.sprintf($lang_common['Paged info'], sprintf($lang_search['Posts by'], $search_set[0]['pposter']), $pun_page['start_from'] + 1, $pun_page['finish_at'], $num_hits));
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   814
			$pun_page['main_foot_options'][] = '<a class="user-option" href="'.pun_link($pun_url['search_user_topics'], $search_id).'">'.sprintf($lang_search['Topics by'], $search_set[0]['pposter']).'</a>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   815
			break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   816
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   817
		case 'show_user_topics':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   818
			$pun_page['crumbs'][] = sprintf($lang_search['Topics by'], $search_set[0]['poster']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   819
			$pun_page['main_info'] = (($pun_page['num_pages'] == 1) ? sprintf($lang_common['Page info'], sprintf($lang_search['Topics by'], $search_set[0]['poster']), $num_hits) : '<span>'.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' </span>'.sprintf($lang_common['Paged info'], sprintf($lang_search['Topics by'], $search_set[0]['poster']), $pun_page['start_from'] + 1, $pun_page['finish_at'], $num_hits));
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   820
			$pun_page['main_foot_options'][] = '<a class="user-option" href="'.pun_link($pun_url['search_user_posts'], $search_id).'">'.sprintf($lang_search['Posts by'], $search_set[0]['poster']).'</a>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   821
			break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   822
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   823
		case 'show_subscriptions':
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   824
			$pun_page['crumbs'][] = $lang_common['Your subscriptions'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   825
			$pun_page['main_info'] = (($pun_page['num_pages'] == 1) ? sprintf($lang_common['Page info'], $lang_common['Your subscriptions'], $num_hits) : '<span>'.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' </span>'.sprintf($lang_common['Paged info'], $lang_common['Your subscriptions'], $pun_page['start_from'] + 1, $pun_page['finish_at'], $num_hits));
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   826
			break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   827
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   828
		default:
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   829
			$pun_page['crumbs'][] = $lang_search['Search results'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   830
			$pun_page['main_info'] = (($pun_page['num_pages'] == 1) ? sprintf($lang_common['Page info'], (($show_as=='topics') ? $lang_common['Topics'] : $lang_common['Posts']), $num_hits) : '<span>'.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' </span>'.sprintf($lang_common['Paged info'], (($show_as=='topics') ? $lang_common['Topics'] : $lang_common['Posts']), $pun_page['start_from'] + 1, $pun_page['finish_at'], $num_hits));
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   831
			break;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   832
	}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   833
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   834
	($hook = get_hook('se_results_pre_header_load')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   835
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   836
	define('PUN_PAGE', $show_as == 'topics' ? 'searchtopics' : 'searchposts');
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   837
	require PUN_ROOT.'header.php';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   838
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   839
	if ($show_as == 'topics')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   840
	{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   841
		// Load the forum.php language file
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   842
		require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   843
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   844
?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   845
<div id="pun-main" class="main paged">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   846
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   847
	<h1><span><?php echo end($pun_page['crumbs']) ?></span></h1>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   848
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   849
	<div class="paged-head">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   850
		<?php echo $pun_page['page_post']."\n" ?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   851
	</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   852
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   853
	<div class="main-head">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   854
		<h2><span><?php echo $pun_page['main_info'] ?></span></h2>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   855
	</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   856
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   857
	<div class="main-content forum">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   858
		<table cellspacing="0" summary="<?php echo $lang_search['Table summary'] ?>">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   859
			<thead>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   860
				<tr>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   861
					<th class="tcl" scope="col"><?php echo $lang_common['Topic']; ?></th>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   862
					<th class="tc2" scope="col"><?php echo $lang_common['Forum'] ?></th>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   863
					<th class="tc3" scope="col"><?php echo $lang_common['Replies'] ?></th>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   864
					<th class="tcr" scope="col"><?php echo $lang_common['Last post'] ?></th>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   865
				</tr>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   866
			</thead>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   867
			<tbody class="statused">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   868
<?php
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   869
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   870
	}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   871
	else
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   872
	{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   873
		// Load the topic.php language file
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   874
		require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   875
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   876
?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   877
<div id="pun-main" class="main paged">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   878
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   879
	<h1><span><?php echo end($pun_page['crumbs']) ?></span></h1>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   880
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   881
	<div class="paged-head">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   882
		<?php echo $pun_page['page_post']."\n" ?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   883
	</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   884
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   885
	<div class="main-head">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   886
		<h2><span><?php echo $pun_page['main_info'] ?></span></h2>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   887
	</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   888
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   889
	<div class="main-content topic">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   890
<?php
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   891
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   892
	}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   893
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   894
	$pun_page['item_count'] = 0;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   895
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   896
	// Finally, lets loop through the results and output them
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   897
	for ($i = 0; $i < count($search_set); ++$i)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   898
	{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   899
		++$pun_page['item_count'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   900
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   901
		if ($pun_config['o_censoring'] == '1')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   902
			$search_set[$i]['subject'] = censor_words($search_set[$i]['subject']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   903
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   904
		if ($show_as == 'posts')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   905
		{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   906
			// Generate the post heading
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   907
			$pun_page['item_head'] = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   908
				'num'	=> '<strong>'.($pun_page['start_from'] + $pun_page['item_count']).'</strong>',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   909
				'user'	=> '<cite>'.(($search_set[$i]['pid'] == $search_set[$i]['first_post_id']) ? sprintf($lang_topic['Topic by'], htmlspecialchars($search_set[$i]['pposter'])) : sprintf($lang_topic['Reply by'], htmlspecialchars($search_set[$i]['pposter']))).'</cite>',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   910
				'date'	=> '<span>'.format_time($search_set[$i]['pposted']).'</span>'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   911
			);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   912
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   913
			$pun_page['item_head'] = '<a class="permalink" rel="bookmark" title="'.$lang_topic['Permalink post'].'" href="'.pun_link($pun_url['post'], $search_set[$i]['pid']).'">'.implode(' ', $pun_page['item_head']).'</a>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   914
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   915
			// Generate author identification
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   916
			$pun_page['user_ident'] = (($search_set[$i]['poster_id'] > 1) ? '<strong class="username"><a title="'.sprintf($lang_search['Go to profile'], htmlspecialchars($search_set[$i]['pposter'])).'" href="'.pun_link($pun_url['user'], $search_set[$i]['poster_id']).'">'.htmlspecialchars($search_set[$i]['pposter']).'</a></strong>' : '<strong class="username">'.htmlspecialchars($search_set[$i]['pposter']).'</strong>');
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   917
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   918
			// Generate the post options links
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   919
			$pun_page['post_options'] = array();
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   920
			$pun_page['post_options'][] = '<a href="'.pun_link($pun_url['forum'], $search_set[$i]['forum_id']).'"><span>'.$lang_search['Go to forum'].'<span>: '.htmlspecialchars($search_set[$i]['forum_name']).'</span></span></a>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   921
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   922
			if ($search_set[$i]['pid'] != $search_set[$i]['first_post_id'])
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   923
				$pun_page['post_options'][] = '<a class="permalink" rel="bookmark" title="'.$lang_topic['Permalink topic'].'" href="'.pun_link($pun_url['topic'], $search_set[$i]['tid']).'"><span>'.$lang_search['Go to topic'].'<span>: '.htmlspecialchars($search_set[$i]['subject']).'</span></span></a>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   924
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   925
			$pun_page['post_options'][] = '<a class="permalink" rel="bookmark" title="'.$lang_topic['Permalink post'].'" href="'.pun_link($pun_url['post'], $search_set[$i]['pid']).'"><span>'.$lang_search['Go to post'].' <span>'.($pun_page['start_from'] + $pun_page['item_count']).'</span></span></a>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   926
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   927
			// Generate the post title
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   928
			$pun_page['item_subject'] = array();
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   929
			if ($search_set[$i]['pid'] == $search_set[$i]['first_post_id'])
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   930
				$pun_page['item_subject'][] = '<strong>'.$lang_common['Topic'].': '.htmlspecialchars($search_set[$i]['subject']).'</strong>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   931
			else
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   932
				$pun_page['item_subject'][] = '<strong>'.$lang_common['Re'].' '.htmlspecialchars($search_set[$i]['subject']).'</strong>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   933
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   934
			$pun_page['item_subject'][] = sprintf($lang_search['Topic info'], htmlspecialchars($search_set[$i]['poster']), htmlspecialchars($search_set[$i]['forum_name']), $search_set[$i]['num_replies']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   935
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   936
			// Generate the post message
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   937
			if ($pun_config['o_censoring'] == '1')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   938
				$search_set[$i]['message'] = censor_words($search_set[$i]['message']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   939
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   940
			$pun_page['message'] = str_replace("\n", '<br />', htmlspecialchars($search_set[$i]['message']));
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   941
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   942
			if (pun_strlen($pun_page['message']) >= 1000)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   943
				$pun_page['message'] .= '&#160;&#8230;';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   944
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   945
			// Give the post some class
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   946
			$pun_page['item_status'] = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   947
				'post',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   948
				(($pun_page['item_count'] % 2 == 0) ? 'odd' : 'even' )
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   949
			);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   950
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   951
			if ($pun_page['item_count'] == 1)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   952
				$pun_page['item_status'][] = 'firstpost';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   953
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   954
			if (($pun_page['start_from'] + $pun_page['item_count']) == $pun_page['finish_at'])
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   955
				$pun_page['item_status'][] = 'lastpost';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   956
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   957
			if ($search_set[$i]['pid'] == $search_set[$i]['first_post_id'])
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   958
				$pun_page['item_status'][] = 'topicpost';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   959
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   960
			($hook = get_hook('se_results_posts_row_pre_display')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   961
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   962
?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   963
		<div class="<?php echo implode(' ', $pun_page['item_status']) ?>">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   964
			<div class="postmain">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   965
				<div class="posthead">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   966
					<h3><?php echo $pun_page['item_head'] ?></h3>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   967
				</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   968
				<div class="postbody">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   969
					<div class="user">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   970
						<h4 class="user-ident"><?php echo $pun_page['user_ident'] ?></h4>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   971
					</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   972
					<div class="post-entry">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   973
						<h4 class="entry-title"><?php echo implode(' ', $pun_page['item_subject']) ?></h4>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   974
						<div class="entry-content">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   975
							<p><?php echo $pun_page['message'] ?></p>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   976
						</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   977
					</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   978
				</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   979
				<div class="postfoot">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   980
					<div class="post-options"><?php echo implode(' ', $pun_page['post_options']) ?></div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   981
				</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   982
			</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   983
		</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   984
<?php
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   985
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   986
		}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   987
		else
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   988
		{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   989
			++$pun_page['item_count'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   990
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   991
			// Start from scratch
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   992
			$pun_page['item_subject'] = $pun_page['item_status'] = $pun_page['item_last_post'] = $pun_page['item_nav'] = array();
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   993
			$pun_page['item_indicator'] = '';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   994
			$pun_page['item_alt_message'] = $lang_common['Topic'].' '.($pun_page['start_from'] + $pun_page['item_count']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   995
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   996
			if ($search_set[$i]['closed'] != '0')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   997
			{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   998
				$pun_page['item_subject'][] = $lang_common['Closed'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
   999
				$pun_page['item_status'][] = 'closed';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1000
			}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1001
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1002
			$pun_page['item_subject'][] = '<a href="'.pun_link($pun_url['topic'], $search_set[$i]['tid']).'">'.htmlspecialchars($search_set[$i]['subject']).'</a>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1003
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1004
			$pun_page['item_pages'] = ceil(($search_set[$i]['num_replies'] + 1) / $pun_user['disp_posts']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1005
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1006
			if ($pun_page['item_pages'] > 1)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1007
				$pun_page['item_nav'][] = pun_paginate($pun_page['item_pages'], -1, $pun_url['topic'], $search_set[$i]['tid']);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1008
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1009
			// Does this topic contains posts we haven't read? If so, tag it accordingly.
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1010
			if (!$pun_user['is_guest'] && $search_set[$i]['last_post'] > $pun_user['last_visit'] && (!isset($tracked_topics['topics'][$search_set[$i]['tid']]) || $tracked_topics['topics'][$search_set[$i]['tid']] < $search_set[$i]['last_post']) && (!isset($tracked_topics['forums'][$search_set[$i]['forum_id']]) || $tracked_topics['forums'][$search_set[$i]['forum_id']] < $search_set[$i]['last_post']))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1011
			{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1012
				$pun_page['item_nav'][] = '<a href="'.pun_link($pun_url['topic_new_posts'], $search_set[$i]['tid']).'" title="'.$lang_forum['New posts info'].'">'.$lang_common['New posts'].'</a>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1013
				$pun_page['item_status'][] = 'new';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1014
			}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1015
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1016
			if (!empty($pun_page['item_nav']))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1017
				$pun_page['item_subject'][] = '<span class="topic-nav">[&#160;'.implode('&#160;&#160;', $pun_page['item_nav']).'&#160;]</span>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1018
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1019
			$pun_page['item_subject'][] = '<span class="byuser">'.sprintf($lang_common['By user'], htmlspecialchars($search_set[$i]['poster'])).'</span>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1020
			$pun_page['item_last_post'][] = '<a href="'.pun_link($pun_url['post'], $search_set[$i]['last_post_id']).'">'.format_time($search_set[$i]['last_post']).'</a>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1021
			$pun_page['item_last_post'][] = '<span class="byuser">'.sprintf($lang_common['By user'], htmlspecialchars($search_set[$i]['last_poster'])).'</span>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1022
			$pun_page['item_indicator'] = '<span class="status '.implode(' ', $pun_page['item_status']).'" title="'.$pun_page['item_alt_message'].'"><img src="'.$base_url.'/style/'.$pun_user['style'].'/status.png" alt="'.$pun_page['item_alt_message'].'" />'.$pun_page['item_indicator'].'</span>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1023
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1024
			($hook = get_hook('se_results_topics_row_pre_display')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1025
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1026
?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1027
				<tr class="<?php echo ($pun_page['item_count'] % 2 != 0) ? 'odd' : 'even' ?>">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1028
					<td class="tcl"><?php echo $pun_page['item_indicator'].' '.implode(' ', $pun_page['item_subject']) ?></td>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1029
					<td class="tc2"><?php echo htmlspecialchars($search_set[$i]['forum_name']) ?></td>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1030
					<td class="tc3"><?php echo $search_set[$i]['num_replies'] ?></td>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1031
					<td class="tcr"><?php echo implode(' ', $pun_page['item_last_post']) ?></td>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1032
				</tr>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1033
<?php
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1034
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1035
		}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1036
	}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1037
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1038
	if ($show_as == 'topics')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1039
	{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1040
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1041
?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1042
			</tbody>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1043
		</table>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1044
<?php
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1045
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1046
	}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1047
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1048
?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1049
	</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1050
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1051
	<div class="main-foot">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1052
		<p class="h2"><strong><?php echo $pun_page['main_info'] ?></strong></p>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1053
<?php if (!empty($pun_page['main_foot_options'])): ?>			<p class="main-options"><?php echo implode(' ', $pun_page['main_foot_options']) ?></p>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1054
<?php endif; ?>	</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1055
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1056
	<div class="paged-foot">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1057
		<?php echo $pun_page['page_post']."\n" ?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1058
	</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1059
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1060
</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1061
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1062
<div id="pun-crumbs-foot">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1063
	<p class="crumbs"><?php echo generate_crumbs(false) ?></p>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1064
</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1065
<?php
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1066
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1067
	require PUN_ROOT.'footer.php';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1068
}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1069
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1070
// Setup form
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1071
$pun_page['set_count'] = $pun_page['fld_count'] = 0;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1072
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1073
// Setup form information
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1074
$pun_page['frm-info'] = array('<li><span>'.$lang_search['Search info'].'</span></li>');
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1075
if ($db_type == 'mysql' || $db_type == 'mysqli')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1076
{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1077
	$pun_page['frm-info'][] = '<li><span>'.$lang_search['Refine info fulltext'].'</span></li>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1078
	$pun_page['frm-info'][] = '<li><span>'.$lang_search['Wildcard info fulltext'].'</span></li>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1079
}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1080
else
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1081
{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1082
	$pun_page['frm-info'][] = '<li><span>'.$lang_search['Refine info'].'</span></li>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1083
	$pun_page['frm-info'][] = '<li><span>'.$lang_search['Wildcard info'].'<span></li>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1084
}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1085
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1086
// Setup predefined search (pds) links
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1087
$pun_page['pd_searches'] = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1088
	'<a href="'.pun_link($pun_url['search_24h']).'">'.$lang_common['Recent posts'].'</a>',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1089
	'<a href="'.pun_link($pun_url['search_unanswered']).'">'.$lang_common['Unanswered topics'].'</a>'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1090
);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1091
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1092
if (!$pun_user['is_guest'])
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1093
{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1094
	array_push(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1095
		$pun_page['pd_searches'],
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1096
		'<a href="'.pun_link($pun_url['search_new']).'" title="'.$lang_common['New posts info'].'">'.$lang_common['New posts'].'</a>',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1097
		'<a href="'.pun_link($pun_url['search_user_posts'], $pun_user['id']).'">'.$lang_common['Your posts'].'</a>',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1098
		'<a href="'.pun_link($pun_url['search_user_topics'], $pun_user['id']).'">'.$lang_common['Your topics'].'</a>'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1099
	);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1100
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1101
	if ($pun_config['o_subscriptions'] == '1')
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1102
		$pun_page['pd_searches'][] = '<a href="'.pun_link($pun_url['search_subscriptions']).'">'.$lang_common['Your subscriptions'].'</a>';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1103
}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1104
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1105
// Setup breadcrumbs
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1106
$pun_page['crumbs'] = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1107
	array($pun_config['o_board_title'], pun_link($pun_url['index'])),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1108
	$lang_common['Search']
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1109
);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1110
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1111
($hook = get_hook('se_pre_header_load')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1112
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1113
define('PUN_PAGE', 'search');
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1114
require PUN_ROOT.'header.php';
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1115
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1116
?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1117
<div id="pun-main" class="main">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1118
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1119
	<h1><span><?php echo $lang_common['Search'] ?></span></h1>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1120
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1121
	<div class="main-head">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1122
		<h2><span><?php echo $lang_search['Search heading'] ?></span></h2>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1123
	</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1124
	<div class="main-content frm">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1125
		<div class="frm-info">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1126
			<h3><?php echo $lang_search['Predefined searches'] ?></h3>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1127
			<p class="actions"><?php echo implode(' ', $pun_page['pd_searches']) ?></p>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1128
			<h3><?php echo $lang_search['Using criteria'] ?></h3>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1129
			<ul>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1130
				<?php echo implode("\n\t\t\t\t", $pun_page['frm-info'])."\n" ?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1131
			</ul>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1132
		</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1133
		<form id="afocus" class="frm-form" method="get" accept-charset="utf-8" action="<?php echo pun_link($pun_url['search']) ?>">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1134
			<div class="hidden">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1135
				<input type="hidden" name="action" value="search" />
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1136
			</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1137
<?php ($hook = get_hook('se_pre_criteria_fieldset')) ? eval($hook) : null; ?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1138
			<fieldset class="frm-set set<?php echo ++$pun_page['set_count'] ?>">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1139
				<legend class="frm-legend"><strong><?php echo $lang_search['Search legend'] ?></strong></legend>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1140
<?php ($hook = get_hook('se_criteria_start')) ? eval($hook) : null; ?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1141
				<div class="frm-fld text">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1142
					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1143
						<span class="fld-label"><?php echo $lang_search['Keyword search'] ?></span><br />
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1144
						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="keywords" size="40" maxlength="100" /></span><br />
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1145
						<span class="fld-help"><?php echo $lang_search['Keyword info'] ?></span>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1146
					</label>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1147
				</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1148
<?php ($hook = get_hook('se_criteria_pre_author_field')) ? eval($hook) : null; ?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1149
				<div class="frm-fld text">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1150
					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1151
						<span class="fld-label"><?php echo $lang_search['Author search'] ?></span><br />
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1152
						<span class="fld-input"><input id="fld<?php echo $pun_page['fld_count'] ?>" type="text" name="author" size="25" maxlength="25" /></span><br />
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1153
						<span class="fld-help"><?php echo $lang_search['Author info'] ?></span>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1154
					</label>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1155
				</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1156
<?php ($hook = get_hook('se_criteria_pre_forum_field')) ? eval($hook) : null; ?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1157
				<div class="frm-fld select">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1158
					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1159
						<span class="fld-label"><?php echo $lang_search['Forum search'] ?></span><br />
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1160
						<span class="fld-input"><select id="fld<?php echo $pun_page['fld_count'] ?>" name="forum">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1161
<?php
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1162
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1163
if ($pun_config['o_search_all_forums'] == '1' || $pun_user['is_admmod'])
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1164
	echo "	\t\t\t\t\t".'<option value="-1">'.$lang_search['All forums'].'</option>'."\n";
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1165
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1166
// Get the list of categories and forums
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1167
$query = array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1168
	'SELECT'	=> 'c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.redirect_url',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1169
	'FROM'		=> 'categories AS c',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1170
	'JOINS'		=> array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1171
		array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1172
			'INNER JOIN'	=> 'forums AS f',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1173
			'ON'			=> 'c.id=f.cat_id'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1174
		),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1175
		array(
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1176
			'LEFT JOIN'		=> 'forum_perms AS fp',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1177
			'ON'			=> '(fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1178
		)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1179
	),
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1180
	'WHERE'		=> '(fp.read_forum IS NULL OR fp.read_forum=1) AND f.redirect_url IS NULL',
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1181
	'ORDER BY'	=> 'c.disp_position, c.id, f.disp_position'
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1182
);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1183
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1184
($hook = get_hook('se_qr_get_cats_and_forums')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1185
$result = $pun_db->query_build($query, true) or error(__FILE__, __LINE__);
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1186
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1187
$cur_category = 0;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1188
while ($cur_forum = $pun_db->fetch_assoc($result))
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1189
{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1190
	if ($cur_forum['cid'] != $cur_category)	// A new category since last iteration?
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1191
	{
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1192
		if ($cur_category)
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1193
			echo "\t\t\t\t\t\t".'</optgroup>'."\n";
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1194
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1195
		echo "\t\t\t\t\t\t".'<optgroup label="'.htmlspecialchars($cur_forum['cat_name']).'">'."\n";
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1196
		$cur_category = $cur_forum['cid'];
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1197
	}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1198
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1199
	echo "\t\t\t\t\t\t".'<option value="'.$cur_forum['fid'].'">'.htmlspecialchars($cur_forum['forum_name']).'</option>'."\n";
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1200
}
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1201
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1202
?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1203
						</optgroup>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1204
						</select></span><br />
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1205
					</label>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1206
				</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1207
<?php ($hook = get_hook('se_criteria_end')) ? eval($hook) : null; ?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1208
			</fieldset>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1209
<?php ($hook = get_hook('se_pre_results_fieldset')) ? eval($hook) : null; ?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1210
			<fieldset class="frm-set set<?php echo ++$pun_page['set_count'] ?>">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1211
				<legend class="frm-legend"><strong><?php echo $lang_search['Results legend'] ?></strong></legend>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1212
<?php ($hook = get_hook('se_results_start')) ? eval($hook) : null; ?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1213
				<div class="frm-fld select">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1214
					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1215
						<span class="fld-label"><?php echo $lang_search['Sort by'] ?></span><br />
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1216
						<span class="fld-input"><select id="fld<?php echo $pun_page['fld_count'] ?>" name="sort_by">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1217
<?php if ($db_type == 'mysql' || $db_type == 'mysqli'):?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1218
						<option value="4"><?php echo $lang_search['Sort by relevance'] ?></option>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1219
<?php endif; ?>						<option value="0"><?php echo $lang_search['Sort by post time'] ?></option>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1220
						<option value="1"><?php echo $lang_search['Sort by author'] ?></option>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1221
						<option value="2"><?php echo $lang_search['Sort by subject'] ?></option>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1222
						<option value="3"><?php echo $lang_search['Sort by forum'] ?></option>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1223
						</select></span><br />
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1224
					</label>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1225
				</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1226
<?php ($hook = get_hook('se_results_pre_sort_choices')) ? eval($hook) : null; ?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1227
				<fieldset class="frm-group">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1228
					<legend><span><?php echo $lang_search['Sort order'] ?></span></legend>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1229
					<div class="radbox frm-yesno"><label for="fld<?php echo ++$pun_page['fld_count'] ?>"><input type="radio" id="fld<?php echo $pun_page['fld_count'] ?>" name="sort_dir" value="ASC" /> <?php echo $lang_search['Ascending'] ?></label> <label for="fld<?php echo ++$pun_page['fld_count'] ?>"><input type="radio" id="fld<?php echo $pun_page['fld_count'] ?>" name="sort_dir" value="DESC" checked="checked" /> <?php echo $lang_search['Descending'] ?></label></div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1230
				</fieldset>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1231
<?php ($hook = get_hook('se_results_pre_display_choices')) ? eval($hook) : null; ?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1232
				<fieldset class="frm-group">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1233
					<legend><span><?php echo $lang_search['Display results'] ?></span></legend>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1234
					<div class="radbox frm-yesno"><label for="fld<?php echo ++$pun_page['fld_count'] ?>"><input type="radio" id="fld<?php echo $pun_page['fld_count'] ?>" name="show_as" value="topics" checked="checked" /> <?php echo $lang_search['Show as topics'] ?></label> <label for="fld<?php echo ++$pun_page['fld_count'] ?>"><input type="radio" id="fld<?php echo $pun_page['fld_count'] ?>" name="show_as" value="posts" /> <?php echo $lang_search['Show as posts'] ?></label></div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1235
				</fieldset>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1236
<?php ($hook = get_hook('se_results_end')) ? eval($hook) : null; ?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1237
			</fieldset>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1238
<?php ($hook = get_hook('se_pre_buttons')) ? eval($hook) : null; ?>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1239
			<div class="frm-buttons">
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1240
				<span class="submit"><input type="submit" name="search" value="<?php echo $lang_search['Submit search'] ?>" accesskey="s" title="<?php echo $lang_common['Submit title'] ?>" /></span>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1241
			</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1242
		</form>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1243
	</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1244
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1245
</div>
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1246
<?php
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1247
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1248
($hook = get_hook('se_end')) ? eval($hook) : null;
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1249
98bbc533541c Finishing re-add, addremove didn't work last time. Integrated with Enano's template engine properly.
Dan
parents:
diff changeset
  1250
require PUN_ROOT.'footer.php';