punbb/search.php
author Dan
Thu, 12 Jul 2007 01:04:01 -0400
changeset 2 a8a21e1c7afa
parent 0 f9ffdbd96607
permissions -rw-r--r--
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     1
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     2
/***********************************************************************
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     3
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     4
  Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     5
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     6
  This file is part of PunBB.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     7
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     8
  PunBB is free software; you can redistribute it and/or modify it
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     9
  under the terms of the GNU General Public License as published
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    10
  by the Free Software Foundation; either version 2 of the License,
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    11
  or (at your option) any later version.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    12
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    13
  PunBB is distributed in the hope that it will be useful, but
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    14
  WITHOUT ANY WARRANTY; without even the implied warranty of
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    15
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    16
  GNU General Public License for more details.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    17
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    18
  You should have received a copy of the GNU General Public License
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    19
  along with this program; if not, write to the Free Software
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    20
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    21
  MA  02111-1307  USA
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    22
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    23
************************************************************************/
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    24
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    25
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    26
// The contents of this file are very much inspired by the file search.php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    27
// from the phpBB Group forum software phpBB2 (http://www.phpbb.com).
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    28
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    29
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    30
//define('PUN_ROOT', './');
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    31
//require PUN_ROOT.'include/common.php';
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    32
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    33
global $pun_db, $pun_user, $pun_config, $lang_common;
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    34
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    35
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    36
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    37
// Load the search.php language file
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    38
require PUN_ROOT.'lang/'.$pun_user['language'].'/search.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    39
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    40
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    41
if ($pun_user['g_read_board'] == '0')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    42
	message($lang_common['No view']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    43
else if ($pun_user['g_search'] == '0')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    44
	message($lang_search['No search permission']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    45
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    46
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    47
// Detect two byte character sets
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    48
$multibyte = (isset($lang_common['lang_multibyte']) && $lang_common['lang_multibyte']) ? true : false;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    49
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    50
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    51
// Figure out what to do :-)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    52
if (isset($_GET['action']) || isset($_GET['search_id']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    53
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    54
	$action = (isset($_GET['action'])) ? $_GET['action'] : null;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    55
	$forum = (isset($_GET['forum'])) ? intval($_GET['forum']) : -1;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    56
	$sort_dir = (isset($_GET['sort_dir'])) ? (($_GET['sort_dir'] == 'DESC') ? 'DESC' : 'ASC') : 'DESC';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    57
	if (isset($search_id)) unset($search_id);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    58
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    59
	// If a search_id was supplied
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    60
	if (isset($_GET['search_id']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    61
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    62
		$search_id = intval($_GET['search_id']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    63
		if ($search_id < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    64
			message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    65
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    66
	// If it's a regular search (keywords and/or author)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    67
	else if ($action == 'search')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    68
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    69
		$keywords = (isset($_GET['keywords'])) ? strtolower(trim($_GET['keywords'])) : null;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    70
		$author = (isset($_GET['author'])) ? strtolower(trim($_GET['author'])) : null;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    71
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    72
		if (preg_match('#^[\*%]+$#', $keywords) || strlen(str_replace(array('*', '%'), '', $keywords)) < 3)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    73
			$keywords = '';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    74
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    75
		if (preg_match('#^[\*%]+$#', $author) || strlen(str_replace(array('*', '%'), '', $author)) < 3)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    76
			$author = '';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    77
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    78
		if (!$keywords && !$author)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    79
			message($lang_search['No terms']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    80
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    81
		if ($author)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    82
			$author = str_replace('*', '%', $author);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    83
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    84
		$show_as = (isset($_GET['show_as'])) ? $_GET['show_as'] : 'posts';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    85
		$sort_by = (isset($_GET['sort_by'])) ? intval($_GET['sort_by']) : null;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    86
		$search_in = (!isset($_GET['search_in']) || $_GET['search_in'] == 'all') ? 0 : (($_GET['search_in'] == 'message') ? 1 : -1);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    87
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    88
	// If it's a user search (by id)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    89
	else if ($action == 'show_user')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    90
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    91
		$user_id = intval($_GET['user_id']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    92
		if ($user_id < 2)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    93
			message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    94
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    95
	else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    96
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    97
		if ($action != 'show_new' && $action != 'show_24h' && $action != 'show_unanswered' && $action != 'show_subscriptions')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    98
			message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    99
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   100
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   101
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   102
	// If a valid search_id was supplied we attempt to fetch the search results from the db
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   103
	if (isset($search_id))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   104
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   105
		$ident = ($pun_user['is_guest']) ? get_remote_address() : $pun_user['username'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   106
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   107
		$result = $pun_db->query('SELECT search_data FROM '.$pun_db->prefix.'search_cache WHERE id='.$search_id.' AND ident=\''.$pun_db->escape($ident).'\'') or error('Unable to fetch search results', __FILE__, __LINE__, $pun_db->error());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   108
		if ($row = $pun_db->fetch_assoc($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   109
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   110
			$temp = unserialize($row['search_data']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   111
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   112
			$search_results = $temp['search_results'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   113
			$num_hits = $temp['num_hits'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   114
			$sort_by = $temp['sort_by'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   115
			$sort_dir = $temp['sort_dir'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   116
			$show_as = $temp['show_as'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   117
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   118
			unset($temp);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   119
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   120
		else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   121
			message($lang_search['No hits']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   122
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   123
	else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   124
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   125
		$keyword_results = $author_results = array();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   126
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   127
		// Search a specific forum?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   128
		$forum_sql = ($forum != -1 || ($forum == -1 && $pun_config['o_search_all_forums'] == '0')) ? ' AND t.forum_id = '.$forum : '';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   129
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   130
		if (!empty($author) || !empty($keywords))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   131
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   132
			// If it's a search for keywords
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   133
			if ($keywords)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   134
			{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   135
				$stopwords = (array)@file(PUN_ROOT.'lang/'.$pun_user['language'].'/stopwords.txt');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   136
				$stopwords = array_map('trim', $stopwords);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   137
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   138
				// Are we searching for multibyte charset text?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   139
				if ($multibyte)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   140
				{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   141
					// Strip out excessive whitespace
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   142
					$keywords = trim(preg_replace('#\s+#', ' ', $keywords));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   143
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   144
					$keywords_array = explode(' ', $keywords);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   145
				}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   146
				else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   147
				{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   148
					// Filter out non-alphabetical chars
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   149
					$noise_match = array('^', '$', '&', '(', ')', '<', '>', '`', '\'', '"', '|', ',', '@', '_', '?', '%', '~', '[', ']', '{', '}', ':', '\\', '/', '=', '#', '\'', ';', '!', '�');
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   150
					$noise_replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', '',  '',   ' ', ' ', ' ', ' ', '',  ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '' ,  ' ', ' ', ' ', ' ',  ' ', ' ', ' ');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   151
					$keywords = str_replace($noise_match, $noise_replace, $keywords);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   152
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   153
					// Strip out excessive whitespace
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   154
					$keywords = trim(preg_replace('#\s+#', ' ', $keywords));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   155
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   156
					// Fill an array with all the words
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   157
					$keywords_array = explode(' ', $keywords);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   158
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   159
					if (empty($keywords_array))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   160
						message($lang_search['No hits']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   161
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   162
					while (list($i, $word) = @each($keywords_array))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   163
					{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   164
						$num_chars = pun_strlen($word);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   165
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   166
						if ($num_chars < 3 || $num_chars > 20 || in_array($word, $stopwords))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   167
							unset($keywords_array[$i]);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   168
					}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   169
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   170
					// Should we search in message body or topic subject specifically?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   171
					$search_in_cond = ($search_in) ? (($search_in > 0) ? ' AND m.subject_match = 0' : ' AND m.subject_match = 1') : '';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   172
				}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   173
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   174
				$word_count = 0;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   175
				$match_type = 'and';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   176
				$result_list = array();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   177
				@reset($keywords_array);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   178
				while (list(, $cur_word) = @each($keywords_array))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   179
				{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   180
					switch ($cur_word)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   181
					{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   182
						case 'and':
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   183
						case 'or':
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   184
						case 'not':
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   185
							$match_type = $cur_word;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   186
							break;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   187
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   188
						default:
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   189
						{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   190
							// Are we searching for multibyte charset text?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   191
							if ($multibyte)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   192
							{
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   193
								$cur_word = $pun_db->escape('%'.str_replace('*', '', $cur_word).'%');
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   194
								$cur_word_like = ($db_type == 'pgsql') ? 'ILIKE \''.$cur_word.'\'' : 'LIKE \''.$cur_word.'\'';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   195
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   196
								if ($search_in > 0)
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   197
									$sql = 'SELECT id FROM '.$pun_db->prefix.'posts WHERE message '.$cur_word_like;
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   198
								else if ($search_in < 0)
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   199
									$sql = 'SELECT p.id FROM '.$pun_db->prefix.'posts AS p INNER JOIN '.$pun_db->prefix.'topics AS t ON t.id=p.topic_id WHERE t.subject '.$cur_word_like.' GROUP BY p.id, t.id';
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   200
								else
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   201
									$sql = 'SELECT p.id FROM '.$pun_db->prefix.'posts AS p INNER JOIN '.$pun_db->prefix.'topics AS t ON t.id=p.topic_id WHERE p.message '.$cur_word_like.' OR t.subject '.$cur_word_like.' GROUP BY p.id, t.id';
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   202
							}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   203
							else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   204
							{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   205
								$cur_word = str_replace('*', '%', $cur_word);
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   206
								$sql = 'SELECT m.post_id FROM '.$pun_db->prefix.'search_words AS w INNER JOIN '.$pun_db->prefix.'search_matches AS m ON m.word_id = w.id WHERE w.word LIKE \''.$cur_word.'\''.$search_in_cond;
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   207
							}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   208
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   209
							$result = $pun_db->query($sql, true) or error('Unable to search for posts', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   210
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   211
							$row = array();
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   212
							while ($temp = $pun_db->fetch_row($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   213
							{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   214
								$row[$temp[0]] = 1;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   215
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   216
								if (!$word_count)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   217
									$result_list[$temp[0]] = 1;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   218
								else if ($match_type == 'or')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   219
									$result_list[$temp[0]] = 1;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   220
								else if ($match_type == 'not')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   221
									$result_list[$temp[0]] = 0;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   222
							}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   223
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   224
							if ($match_type == 'and' && $word_count)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   225
							{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   226
								@reset($result_list);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   227
								while (list($post_id,) = @each($result_list))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   228
								{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   229
									if (!isset($row[$post_id]))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   230
										$result_list[$post_id] = 0;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   231
								}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   232
							}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   233
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   234
							++$word_count;
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   235
							$pun_db->free_result($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   236
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   237
							break;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   238
						}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   239
					}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   240
				}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   241
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   242
				@reset($result_list);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   243
				while (list($post_id, $matches) = @each($result_list))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   244
				{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   245
					if ($matches)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   246
						$keyword_results[] = $post_id;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   247
				}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   248
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   249
				unset($result_list);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   250
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   251
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   252
			// If it's a search for author name (and that author name isn't Guest)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   253
			if ($author && strcasecmp($author, 'Guest') && strcasecmp($author, $lang_common['Guest']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   254
			{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   255
				switch ($db_type)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   256
				{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   257
					case 'pgsql':
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   258
						$result = $pun_db->query('SELECT id FROM '.$pun_db->prefix.'users WHERE username ILIKE \''.$pun_db->escape($author).'\'') or error('Unable to fetch users', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   259
						break;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   260
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   261
					default:
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   262
						$result = $pun_db->query('SELECT id FROM '.$pun_db->prefix.'users WHERE username LIKE \''.$pun_db->escape($author).'\'') or error('Unable to fetch users', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   263
						break;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   264
				}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   265
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   266
				if ($pun_db->num_rows($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   267
				{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   268
					$user_ids = '';
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   269
					while ($row = $pun_db->fetch_row($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   270
						$user_ids .= (($user_ids != '') ? ',' : '').$row[0];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   271
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   272
					$result = $pun_db->query('SELECT id FROM '.$pun_db->prefix.'posts WHERE poster_id IN('.$user_ids.')') or error('Unable to fetch matched posts list', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   273
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   274
					$search_ids = array();
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   275
					while ($row = $pun_db->fetch_row($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   276
						$author_results[] = $row[0];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   277
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   278
					$pun_db->free_result($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   279
				}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   280
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   281
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   282
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   283
			if ($author && $keywords)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   284
			{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   285
				// If we searched for both keywords and author name we want the intersection between the results
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   286
				$search_ids = array_intersect($keyword_results, $author_results);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   287
				unset($keyword_results, $author_results);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   288
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   289
			else if ($keywords)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   290
				$search_ids = $keyword_results;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   291
			else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   292
				$search_ids = $author_results;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   293
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   294
			$num_hits = count($search_ids);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   295
			if (!$num_hits)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   296
				message($lang_search['No hits']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   297
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   298
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   299
			if ($show_as == 'topics')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   300
			{
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   301
				$result = $pun_db->query('SELECT t.id FROM '.$pun_db->prefix.'posts AS p INNER JOIN '.$pun_db->prefix.'topics AS t ON t.id=p.topic_id INNER 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'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id IN('.implode(',', $search_ids).')'.$forum_sql.' GROUP BY t.id', true) or error('Unable to fetch topic list', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   302
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   303
				$search_ids = array();
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   304
				while ($row = $pun_db->fetch_row($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   305
					$search_ids[] = $row[0];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   306
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   307
				$pun_db->free_result($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   308
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   309
				$num_hits = count($search_ids);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   310
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   311
			else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   312
			{
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   313
				$result = $pun_db->query('SELECT p.id FROM '.$pun_db->prefix.'posts AS p INNER JOIN '.$pun_db->prefix.'topics AS t ON t.id=p.topic_id INNER 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'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id IN('.implode(',', $search_ids).')'.$forum_sql, true) or error('Unable to fetch topic list', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   314
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   315
				$search_ids = array();
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   316
				while ($row = $pun_db->fetch_row($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   317
					$search_ids[] = $row[0];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   318
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   319
				$pun_db->free_result($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   320
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   321
				$num_hits = count($search_ids);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   322
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   323
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   324
		else if ($action == 'show_new' || $action == 'show_24h' || $action == 'show_user' || $action == 'show_subscriptions' || $action == 'show_unanswered')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   325
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   326
			// If it's a search for new posts
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   327
			if ($action == 'show_new')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   328
			{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   329
				if ($pun_user['is_guest'])
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   330
					message($lang_common['No permission']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   331
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   332
				$result = $pun_db->query('SELECT t.id FROM '.$pun_db->prefix.'topics AS t INNER 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'].') 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') or error('Unable to fetch topic list', __FILE__, __LINE__, $pun_db->error());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   333
				$num_hits = $pun_db->num_rows($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   334
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   335
				if (!$num_hits)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   336
					message($lang_search['No new posts']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   337
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   338
			// If it's a search for todays posts
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   339
			else if ($action == 'show_24h')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   340
			{
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   341
				$result = $pun_db->query('SELECT t.id FROM '.$pun_db->prefix.'topics AS t INNER 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'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.last_post>'.(time() - 86400).' AND t.moved_to IS NULL') or error('Unable to fetch topic list', __FILE__, __LINE__, $pun_db->error());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   342
				$num_hits = $pun_db->num_rows($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   343
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   344
				if (!$num_hits)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   345
					message($lang_search['No recent posts']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   346
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   347
			// If it's a search for posts by a specific user ID
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   348
			else if ($action == 'show_user')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   349
			{
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   350
				$result = $pun_db->query('SELECT t.id FROM '.$pun_db->prefix.'topics AS t INNER JOIN '.$pun_db->prefix.'posts AS p ON t.id=p.topic_id INNER 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'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.poster_id='.$user_id.' GROUP BY t.id') or error('Unable to fetch topic list', __FILE__, __LINE__, $pun_db->error());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   351
				$num_hits = $pun_db->num_rows($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   352
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   353
				if (!$num_hits)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   354
					message($lang_search['No user posts']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   355
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   356
			// If it's a search for subscribed topics
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   357
			else if ($action == 'show_subscriptions')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   358
			{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   359
				if ($pun_user['is_guest'])
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   360
					message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   361
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   362
				$result = $pun_db->query('SELECT t.id FROM '.$pun_db->prefix.'topics AS t INNER JOIN '.$pun_db->prefix.'subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['id'].') INNER 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'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1)') or error('Unable to fetch topic list', __FILE__, __LINE__, $pun_db->error());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   363
				$num_hits = $pun_db->num_rows($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   364
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   365
				if (!$num_hits)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   366
					message($lang_search['No subscriptions']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   367
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   368
			// If it's a search for unanswered posts
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   369
			else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   370
			{
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   371
				$result = $pun_db->query('SELECT t.id FROM '.$pun_db->prefix.'topics AS t INNER 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'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.num_replies=0 AND t.moved_to IS NULL') or error('Unable to fetch topic list', __FILE__, __LINE__, $pun_db->error());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   372
				$num_hits = $pun_db->num_rows($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   373
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   374
				if (!$num_hits)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   375
					message($lang_search['No unanswered']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   376
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   377
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   378
			// We want to sort things after last post
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   379
			$sort_by = 4;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   380
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   381
			$search_ids = array();
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   382
			while ($row = $pun_db->fetch_row($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   383
				$search_ids[] = $row[0];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   384
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   385
			$pun_db->free_result($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   386
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   387
			$show_as = 'topics';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   388
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   389
		else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   390
			message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   391
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   392
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   393
		// Prune "old" search results
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   394
		$old_searches = array();
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   395
		$result = $pun_db->query('SELECT ident FROM '.$pun_db->prefix.'online') or error('Unable to fetch online list', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   396
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   397
		if ($pun_db->num_rows($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   398
		{
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   399
			while ($row = $pun_db->fetch_row($result))
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   400
				$old_searches[] = '\''.$pun_db->escape($row[0]).'\'';
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   401
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   402
			$pun_db->query('DELETE FROM '.$pun_db->prefix.'search_cache WHERE ident NOT IN('.implode(',', $old_searches).')') or error('Unable to delete search results', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   403
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   404
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   405
		// Final search results
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   406
		$search_results = implode(',', $search_ids);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   407
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   408
		// Fill an array with our results and search properties
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   409
		$temp['search_results'] = $search_results;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   410
		$temp['num_hits'] = $num_hits;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   411
		$temp['sort_by'] = $sort_by;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   412
		$temp['sort_dir'] = $sort_dir;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   413
		$temp['show_as'] = $show_as;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   414
		$temp = serialize($temp);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   415
		$search_id = mt_rand(1, 2147483647);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   416
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   417
		$ident = ($pun_user['is_guest']) ? get_remote_address() : $pun_user['username'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   418
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   419
		$pun_db->query('INSERT INTO '.$pun_db->prefix.'search_cache (id, ident, search_data) VALUES('.$search_id.', \''.$pun_db->escape($ident).'\', \''.$pun_db->escape($temp).'\')') or error('Unable to insert search results', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   420
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   421
		if ($action != 'show_new' && $action != 'show_24h')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   422
		{
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   423
			$pun_db->end_transaction();
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   424
			$pun_db->close();
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   425
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   426
			// Redirect the user to the cached result page
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   427
			header('Location: search.php?search_id='.$search_id);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   428
			exit;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   429
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   430
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   431
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   432
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   433
	// Fetch results to display
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   434
	if ($search_results != '')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   435
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   436
		switch ($sort_by)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   437
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   438
			case 1:
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   439
				$sort_by_sql = ($show_as == 'topics') ? 't.poster' : 'p.poster';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   440
				break;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   441
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   442
			case 2:
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   443
				$sort_by_sql = 't.subject';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   444
				break;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   445
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   446
			case 3:
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   447
				$sort_by_sql = 't.forum_id';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   448
				break;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   449
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   450
			case 4:
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   451
				$sort_by_sql = 't.last_post';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   452
				break;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   453
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   454
			default:
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   455
				$sort_by_sql = ($show_as == 'topics') ? 't.posted' : 'p.posted';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   456
				break;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   457
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   458
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   459
		if ($show_as == 'posts')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   460
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   461
			$substr_sql = ($db_type != 'sqlite') ? 'SUBSTRING' : 'SUBSTR';
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   462
			$sql = 'SELECT p.id AS pid, p.poster AS pposter, p.posted AS pposted, p.poster_id, '.$substr_sql.'(p.message, 1, 1000) AS message, t.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.forum_id FROM '.$pun_db->prefix.'posts AS p INNER JOIN '.$pun_db->prefix.'topics AS t ON t.id=p.topic_id WHERE p.id IN('.$search_results.') ORDER BY '.$sort_by_sql;
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   463
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   464
		else
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   465
			$sql = '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 FROM '.$pun_db->prefix.'topics AS t WHERE t.id IN('.$search_results.') ORDER BY '.$sort_by_sql;
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   466
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   467
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   468
		// Determine the topic or post offset (based on $_GET['p'])
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   469
		$per_page = ($show_as == 'posts') ? $pun_user['disp_posts'] : $pun_user['disp_topics'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   470
		$num_pages = ceil($num_hits / $per_page);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   471
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   472
		$p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   473
		$start_from = $per_page * ($p - 1);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   474
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   475
		// Generate paging links
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   476
		$paging_links = $lang_common['Pages'].': '.pun_paginate($num_pages, $p, 'search.php?search_id='.$search_id);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   477
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   478
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   479
		$sql .= ' '.$sort_dir.' LIMIT '.$start_from.', '.$per_page;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   480
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   481
		$result = $pun_db->query($sql) or error('Unable to fetch search results', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   482
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   483
		$search_set = array();
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   484
		while ($row = $pun_db->fetch_assoc($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   485
			$search_set[] = $row;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   486
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   487
		$pun_db->free_result($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   488
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   489
		$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_search['Search results'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   490
		require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   491
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   492
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   493
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   494
<div class="linkst">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   495
	<div class="inbox">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   496
		<p class="pagelink"><?php echo $paging_links ?></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   497
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   498
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   499
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   500
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   501
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   502
		//Set background switching on for show as posts
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   503
		$bg_switch = true;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   504
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   505
		if ($show_as == 'topics')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   506
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   507
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   508
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   509
<div id="vf" class="blocktable">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   510
	<h2><span><?php echo $lang_search['Search results']; ?></span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   511
	<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   512
		<div class="inbox">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   513
			<table cellspacing="0">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   514
			<thead>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   515
				<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   516
					<th class="tcl" scope="col"><?php echo $lang_common['Topic']; ?></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   517
					<th class="tc2" scope="col"><?php echo $lang_common['Forum'] ?></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   518
					<th class="tc3" scope="col"><?php echo $lang_common['Replies'] ?></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   519
					<th class="tcr" scope="col"><?php echo $lang_common['Last post'] ?></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   520
				</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   521
			</thead>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   522
			<tbody>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   523
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   524
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   525
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   526
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   527
		// Fetch the list of forums
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   528
		$result = $pun_db->query('SELECT id, forum_name FROM '.$pun_db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   529
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   530
		$forum_list = array();
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   531
		while ($forum_list[] = $pun_db->fetch_row($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   532
			;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   533
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   534
		// Finally, lets loop through the results and output them
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   535
		for ($i = 0; $i < count($search_set); ++$i)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   536
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   537
			@reset($forum_list);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   538
			while (list(, $temp) = @each($forum_list))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   539
			{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   540
				if ($temp[0] == $search_set[$i]['forum_id'])
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   541
					$forum = '<a href="viewforum.php?id='.$temp[0].'">'.pun_htmlspecialchars($temp[1]).'</a>';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   542
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   543
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   544
			if ($pun_config['o_censoring'] == '1')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   545
				$search_set[$i]['subject'] = censor_words($search_set[$i]['subject']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   546
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   547
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   548
			if ($show_as == 'posts')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   549
			{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   550
				$icon = '<div class="icon"><div class="nosize">'.$lang_common['Normal icon'].'</div></div>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   551
				$subject = '<a href="viewtopic.php?id='.$search_set[$i]['tid'].'">'.pun_htmlspecialchars($search_set[$i]['subject']).'</a>';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   552
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   553
				if (!$pun_user['is_guest'] && $search_set[$i]['last_post'] > $pun_user['last_visit'])
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   554
					$icon = '<div class="icon inew"><div class="nosize">'.$lang_common['New icon'].'</div></div>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   555
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   556
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   557
				if ($pun_config['o_censoring'] == '1')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   558
					$search_set[$i]['message'] = censor_words($search_set[$i]['message']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   559
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   560
				$message = str_replace("\n", '<br />', pun_htmlspecialchars($search_set[$i]['message']));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   561
				$pposter = pun_htmlspecialchars($search_set[$i]['pposter']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   562
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   563
				if ($search_set[$i]['poster_id'] > 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   564
					$pposter = '<strong><a href="profile.php?id='.$search_set[$i]['poster_id'].'">'.$pposter.'</a></strong>';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   565
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   566
				if (pun_strlen($message) >= 1000)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   567
					$message .= ' &hellip;';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   568
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   569
				$vtpost1 = ($i == 0) ? ' vtp1' : '';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   570
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   571
				// Switch the background color for every message.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   572
				$bg_switch = ($bg_switch) ? $bg_switch = false : $bg_switch = true;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   573
				$vtbg = ($bg_switch) ? ' rowodd' : ' roweven';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   574
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   575
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   576
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   577
<div class="blockpost searchposts<?php echo $vtbg ?>">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   578
	<h2><?php echo $forum ?>&nbsp;&raquo;&nbsp;<?php echo $subject ?>&nbsp;&raquo;&nbsp;<a href="viewtopic.php?pid=<?php echo $search_set[$i]['pid'].'#p'.$search_set[$i]['pid'] ?>"><?php echo format_time($search_set[$i]['pposted']) ?></a></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   579
	<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   580
		<div class="inbox">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   581
			<div class="postleft">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   582
				<dl>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   583
					<dt><?php echo $pposter ?></dt>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   584
					<dd>Replies: <?php echo $search_set[$i]['num_replies'] ?></dd>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   585
					<dd><?php echo $icon; ?></dd>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   586
					<dd><p class="clearb"><a href="viewtopic.php?pid=<?php echo $search_set[$i]['pid'].'#p'.$search_set[$i]['pid'] ?>"><?php echo $lang_search['Go to post'] ?></a></p></dd>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   587
				</dl>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   588
			</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   589
			<div class="postright">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   590
				<div class="postmsg">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   591
					<p><?php echo $message ?></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   592
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   593
			</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   594
			<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   595
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   596
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   597
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   598
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   599
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   600
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   601
			else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   602
			{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   603
				$icon = '<div class="icon"><div class="nosize">'.$lang_common['Normal icon'].'</div></div>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   604
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   605
				$icon_text = $lang_common['Normal icon'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   606
				$item_status = '';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   607
				$icon_type = 'icon';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   608
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   609
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   610
				$subject = '<a href="viewtopic.php?id='.$search_set[$i]['tid'].'">'.pun_htmlspecialchars($search_set[$i]['subject']).'</a> <span class="byuser">'.$lang_common['by'].'&nbsp;'.pun_htmlspecialchars($search_set[$i]['poster']).'</span>';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   611
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   612
				if ($search_set[$i]['closed'] != '0')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   613
				{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   614
					$icon_text = $lang_common['Closed icon'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   615
					$item_status = 'iclosed';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   616
				}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   617
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   618
				if (!$pun_user['is_guest'] && $search_set[$i]['last_post'] > $pun_user['last_visit'])
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   619
				{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   620
					$icon_text .= ' '.$lang_common['New icon'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   621
					$item_status .= ' inew';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   622
					$icon_type = 'icon inew';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   623
					$subject = '<strong>'.$subject.'</strong>';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   624
					$subject_new_posts = '<span class="newtext">[&nbsp;<a href="viewtopic.php?id='.$search_set[$i]['tid'].'&amp;action=new" title="'.$lang_common['New posts info'].'">'.$lang_common['New posts'].'</a>&nbsp;]</span>';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   625
				}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   626
				else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   627
					$subject_new_posts = null;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   628
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   629
				$num_pages_topic = ceil(($search_set[$i]['num_replies'] + 1) / $pun_user['disp_posts']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   630
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   631
				if ($num_pages_topic > 1)
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   632
					$subject_multipage = '[ '.pun_paginate($num_pages_topic, -1, 'viewtopic.php?id='.$search_set[$i]['tid']).' ]';
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   633
				else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   634
					$subject_multipage = null;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   635
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   636
				// Should we show the "New posts" and/or the multipage links?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   637
				if (!empty($subject_new_posts) || !empty($subject_multipage))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   638
				{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   639
					$subject .= '&nbsp; '.(!empty($subject_new_posts) ? $subject_new_posts : '');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   640
					$subject .= !empty($subject_multipage) ? ' '.$subject_multipage : '';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   641
				}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   642
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   643
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   644
				<tr<?php if ($item_status != '') echo ' class="'.trim($item_status).'"'; ?>>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   645
					<td class="tcl">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   646
						<div class="intd">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   647
							<div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo trim($icon_text) ?></div></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   648
							<div class="tclcon">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   649
								<?php echo $subject."\n" ?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   650
							</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   651
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   652
					</td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   653
					<td class="tc2"><?php echo $forum ?></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   654
					<td class="tc3"><?php echo $search_set[$i]['num_replies'] ?></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   655
					<td class="tcr"><?php echo '<a href="viewtopic.php?pid='.$search_set[$i]['last_post_id'].'#p'.$search_set[$i]['last_post_id'].'">'.format_time($search_set[$i]['last_post']).'</a> '.$lang_common['by'].'&nbsp;'.pun_htmlspecialchars($search_set[$i]['last_poster']) ?></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   656
				</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   657
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   658
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   659
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   660
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   661
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   662
		if ($show_as == 'topics')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   663
			echo "\t\t\t".'</tbody>'."\n\t\t\t".'</table>'."\n\t\t".'</div>'."\n\t".'</div>'."\n".'</div>'."\n\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   664
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   665
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   666
<div class="<?php echo ($show_as == 'topics') ? 'linksb' : 'postlinksb'; ?>">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   667
	<div class="inbox">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   668
		<p class="pagelink"><?php echo $paging_links ?></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   669
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   670
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   671
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   672
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   673
		$footer_style = 'search';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   674
		require PUN_ROOT.'footer.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   675
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   676
	else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   677
		message($lang_search['No hits']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   678
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   679
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   680
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   681
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_search['Search'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   682
$focus_element = array('search', 'keywords');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   683
require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   684
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   685
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   686
<div id="searchform" class="blockform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   687
	<h2><span><?php echo $lang_search['Search'] ?></span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   688
	<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   689
		<form id="search" method="get" action="search.php">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   690
			<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   691
				<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   692
					<legend><?php echo $lang_search['Search criteria legend'] ?></legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   693
					<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   694
						<input type="hidden" name="action" value="search" />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   695
						<label class="conl"><?php echo $lang_search['Keyword search'] ?><br /><input type="text" name="keywords" size="40" maxlength="100" /><br /></label>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   696
						<label class="conl"><?php echo $lang_search['Author search'] ?><br /><input id="author" type="text" name="author" size="25" maxlength="25" /><br /></label>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   697
						<p class="clearb"><?php echo $lang_search['Search info'] ?></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   698
					</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   699
				</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   700
			</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   701
			<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   702
				<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   703
					<legend><?php echo $lang_search['Search in legend'] ?></legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   704
					<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   705
						<label class="conl"><?php echo $lang_search['Forum search'] ?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   706
						<br /><select id="forum" name="forum">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   707
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   708
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   709
if ($pun_config['o_search_all_forums'] == '1' || $pun_user['g_id'] >= USER_LEVEL_MEMBER)
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   710
	echo "\t\t\t\t\t\t\t".'<option value="-1">'.$lang_search['All forums'].'</option>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   711
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   712
$result = $pun_db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.redirect_url FROM '.$pun_db->prefix.'categories AS c INNER JOIN '.$pun_db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.redirect_url IS NULL ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   713
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   714
$cur_category = 0;
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   715
while ($cur_forum = $pun_db->fetch_assoc($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   716
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   717
	if ($cur_forum['cid'] != $cur_category)	// A new category since last iteration?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   718
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   719
		if ($cur_category)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   720
			echo "\t\t\t\t\t\t\t".'</optgroup>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   721
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   722
		echo "\t\t\t\t\t\t\t".'<optgroup label="'.pun_htmlspecialchars($cur_forum['cat_name']).'">'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   723
		$cur_category = $cur_forum['cid'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   724
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   725
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   726
	echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_forum['fid'].'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</option>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   727
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   728
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   729
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   730
							</optgroup>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   731
						</select>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   732
						<br /></label>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   733
						<label class="conl"><?php echo $lang_search['Search in'] ?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   734
						<br /><select id="search_in" name="search_in">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   735
							<option value="all"><?php echo $lang_search['Message and subject'] ?></option>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   736
							<option value="message"><?php echo $lang_search['Message only'] ?></option>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   737
							<option value="topic"><?php echo $lang_search['Topic only'] ?></option>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   738
						</select>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   739
						<br /></label>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   740
						<p class="clearb"><?php echo $lang_search['Search in info'] ?></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   741
					</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   742
				</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   743
			</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   744
			<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   745
				<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   746
					<legend><?php echo $lang_search['Search results legend'] ?></legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   747
					<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   748
						<label class="conl"><?php echo $lang_search['Sort by'] ?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   749
						<br /><select name="sort_by">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   750
							<option value="0"><?php echo $lang_search['Sort by post time'] ?></option>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   751
							<option value="1"><?php echo $lang_search['Sort by author'] ?></option>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   752
							<option value="2"><?php echo $lang_search['Sort by subject'] ?></option>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   753
							<option value="3"><?php echo $lang_search['Sort by forum'] ?></option>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   754
						</select>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   755
						<br /></label>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   756
						<label class="conl"><?php echo $lang_search['Sort order'] ?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   757
						<br /><select name="sort_dir">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   758
							<option value="DESC"><?php echo $lang_search['Descending'] ?></option>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   759
							<option value="ASC"><?php echo $lang_search['Ascending'] ?></option>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   760
						</select>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   761
						<br /></label>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   762
						<label class="conl"><?php echo $lang_search['Show as'] ?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   763
						<br /><select name="show_as">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   764
							<option value="topics"><?php echo $lang_search['Show as topics'] ?></option>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   765
							<option value="posts"><?php echo $lang_search['Show as posts'] ?></option>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   766
						</select>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   767
						<br /></label>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   768
						<p class="clearb"><?php echo $lang_search['Search results info'] ?></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   769
					</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   770
				</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   771
			</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   772
			<p><input type="submit" name="search" value="<?php echo $lang_common['Submit'] ?>" accesskey="s" /></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   773
		</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   774
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   775
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   776
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   777
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   778
require PUN_ROOT.'footer.php';