[phpbbreloaded-checkins] SF.net SVN: phpbbreloaded: [260] phpBB Reloaded 2
Status: Planning
Brought to you by:
tehphpmaster
From: <teh...@us...> - 2006-10-23 04:34:06
|
Revision: 260 http://svn.sourceforge.net/phpbbreloaded/?rev=260&view=rev Author: tehphpmaster Date: 2006-10-22 21:33:53 -0700 (Sun, 22 Oct 2006) Log Message: ----------- Fixed a language error and also a parse error in search.php Modified Paths: -------------- phpBB Reloaded 2/language/lang_english/lang_main.php phpBB Reloaded 2/search.php Modified: phpBB Reloaded 2/language/lang_english/lang_main.php =================================================================== --- phpBB Reloaded 2/language/lang_english/lang_main.php 2006-10-23 04:11:33 UTC (rev 259) +++ phpBB Reloaded 2/language/lang_english/lang_main.php 2006-10-23 04:33:53 UTC (rev 260) @@ -1041,7 +1041,7 @@ $lang['Admin_reauthenticate'] = 'To administer the board you must re-authenticate yourself.'; $lang['Login_attempts_exceeded'] = 'The maximum number of %s login attempts has been exceeded. You are not allowed to login for the next %s minutes.'; -$lang['Please_remove_install_contrib'] = 'Please ensure both the install/ and contrib/ directories are deleted'; +$lang['Please_remove_install_contrib'] = 'Please ensure that the /install directory has been removed'; //+MOD: Select Expand BBcodes MOD $lang['Select'] = "Select"; Modified: phpBB Reloaded 2/search.php =================================================================== --- phpBB Reloaded 2/search.php 2006-10-23 04:11:33 UTC (rev 259) +++ phpBB Reloaded 2/search.php 2006-10-23 04:33:53 UTC (rev 260) @@ -1,29 +1,38 @@ <?php -/** - * @package core - * @version $ID: Exp$ - * @copyright phpBB Reloaded 2006 - * @license http://opensource.org/licenses/gpl-license.php GNU Public License - */ +//-- mod : categories hierarchy ------------------------------------------------ +/*************************************************************************** + * search.php + * ------------------- + * begin : Saturday, Feb 13, 2001 + * copyright : (C) 2001 The phpBB Group + * email : su...@ph... + * + * $Id: search.php,v 1.72.2.19 2006/02/05 15:59:48 grahamje Exp $ + * + * + ***************************************************************************/ -/** - * phpBB originally created by phpBB http://www.phpbb.com - */ +/*************************************************************************** + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + ***************************************************************************/ -define ('IN_PHPBB', TRUE); +define('IN_PHPBB', true); $phpbb_root_path = './'; -include ($phpbb_root_path . 'extension.inc'); -include ($phpbb_root_path . 'common.' . $phpEx); -include ($phpbb_root_path . 'includes/bbcode.' . $phpEx); -include ($phpbb_root_path . 'includes/functions_search.' . $phpEx); +include($phpbb_root_path . 'extension.inc'); +include($phpbb_root_path . 'common.'.$phpEx); +include($phpbb_root_path . 'includes/bbcode.'.$phpEx); +include($phpbb_root_path . 'includes/functions_search.'.$phpEx); // read forums if not a searchuser - $searchuser = (_read('mode', TYPE_NO_HTML) == 'searchuser'); - if ( !$searchuser ) { - include ($config->url('includes/class_forums')); + include($config->url('includes/class_forums')); $forums = new forums(); $forums->read(); } @@ -31,14 +40,13 @@ // // Start session management // - $userdata = session_pagestart($user_ip, PAGE_SEARCH); init_userprefs($userdata); - // // End session management // + if ( !$searchuser ) { $user->get_cache(POST_FORUM_URL); @@ -48,9 +56,7 @@ } // topics class - -include ($config->url('includes/class_topics')); - +include($config->url('includes/class_topics')); class topics_search extends topics { function topics_search($parms='', $extra_parms='') @@ -69,33 +75,28 @@ $ppage = $this->parms['ppage']; // read topics - $sql = 'SELECT * - FROM ' . TOPICS_TABLE . ' - WHERE topic_id IN(' . $search_results . ') - AND topic_last_post_id > 0 - ORDER BY topic_last_time DESC + FROM ' . TOPICS_TABLE . ' + WHERE topic_id IN(' . $search_results . ') + AND topic_last_post_id > 0 + ORDER BY topic_last_time DESC LIMIT ' . $start . ', ' . $ppage; // read results - - $result = $db->sql_query($sql, FALSE, __LINE__, __FILE__); + $result = $db->sql_query($sql, false, __LINE__, __FILE__); $this->pre_process(); - while ( $row = $db->sql_fetchrow($result) ) { $this->row_process($row); $this->data_ext[ $row['topic_id'] ] = $row; } - $db->sql_freeresult($result); // get complementary data - $this->post_process(); } - function bottom_line($empty = FALSE) + function bottom_line($empty=false) { global $template, $user; @@ -110,7 +111,6 @@ // // Define initial vars // - if ( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) ) { $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; @@ -144,14 +144,13 @@ $show_results = ( isset($HTTP_POST_VARS['show_results']) ) ? $HTTP_POST_VARS['show_results'] : 'posts'; $show_results = ($show_results == 'topics') ? 'topics' : 'posts'; -// start mod save posts as drafts ... if user clicked to see his drafts and posts or topics, set search_id to egosearch and set show_results correctly - -if ( $search_id == 'egosearch_by_topic' || $search_id == 'egosearch_by_post' ) +if( $search_id == 'egosearch_by_topic' || $search_id == 'egosearch_by_post' ) { $show_results = ( $search_id == 'egosearch_by_topic' ) ? 'topics' : 'posts'; $search_id = 'egosearch'; } + if ( isset($HTTP_POST_VARS['search_terms']) ) { $search_terms = ( $HTTP_POST_VARS['search_terms'] == 'all' ) ? 1 : 0; @@ -204,29 +203,27 @@ // // encoding match for workaround // - $multibyte_charset = 'utf-8, big5, shift_jis, euc-kr, gb2312'; // // Begin core code // -if ( $mode == 'searchcolor' ) +if ($mode == 'searchcolor') { // // This handles the simple windowed user color // - color_search(); exit; } -elseif ($mode == 'searchuser') +else if ($mode == 'searchuser') + { // // This handles the simple windowed user search functions called from various other scripts // - if ( isset($HTTP_POST_VARS['search_username']) ) { username_search($HTTP_POST_VARS['search_username']); @@ -238,44 +235,36 @@ exit; } -elseif ( $search_keywords != '' || $search_author != '' || $search_id ) +else if ( $search_keywords != '' || $search_author != '' || $search_id ) { +// start mod save posts as drafts (and end mod too)...added the draft_on variable in the next line so that if the user clicks to after page 1 of list and then goes back to page 1 the draft lists will appear $store_vars = array('search_results', 'total_match_count', 'split_search', 'sort_by', 'sort_dir', 'show_results', 'return_chars', 'draft_on'); $search_results = ''; - // - // note : auth_sql will never be empty, so the forums table will always be joigned to the research - // - $auth_sql = ''; $store_vars[] = 'no_subs'; - // read params - + // read parms $search_forum = _read('search_forum', TYPE_INT); $no_subs = _button('no_subs'); // check forum id - - if ( !isset($forums->data[$search_forum]) || !$user->auth(POST_FORUM_URL, 'auth_read', $search_forum) ) + if (!isset($forums->data[$search_forum]) || !$user->auth(POST_FORUM_URL, 'auth_read', $search_forum) ) { message_die(GENERAL_MESSAGE, $user->lang('No_such_forum')); } // get min and max forum ids for the branch asked - $min_id = intval($search_forum); $max_id = $no_subs ? $search_forum : $forums->data[$search_forum]['last_child_id']; // get excluded forums - $tkeys = array_flip($forums->keys); $min_idx = $tkeys[$min_id]; $max_idx = $tkeys[$max_id]; - unset ($tkeys); + unset($tkeys); $exclude_forums = array(); - $something = FALSE; - + $something = false; for ( $i = $min_idx; $i <= $max_idx; $i++ ) { if ( !$user->auth(POST_FORUM_URL, 'auth_read', $forums->keys[$i]) ) @@ -284,73 +273,64 @@ } else { - $something = TRUE; + $something = true; } } // halt on no forum authed - if ( !$something ) { message_die(GENERAL_MESSAGE, $lang['No_searchable_forums']); } // set branch range - $auth_sql = $no_subs ? 'f.forum_id = ' . $min_id : '(f.forum_order BETWEEN ' . intval($forums->data[$min_id]['forum_order']) . ' AND ' . intval($forums->data[$max_id]['forum_order']) . ')'; // exclude unreadable forums - if ( !empty($exclude_forums) ) { $auth_sql .= count($exclude_forums) > 1 ? ' AND f.forum_id NOT IN(' . implode(', ', $exclude_forums) . ')' : ' AND f.forum_id <> ' . $exclude_forums[0]; - unset ($exclude_forums); + unset($exclude_forums); } // // Search ID Limiter, decrease this value if you experience further timeout problems with searching forums - $limiter = 5000; $current_time = time(); // // Cycle through options ... // - if ( $search_id == 'newposts' || $search_id == 'egosearch' || $search_id == 'unanswered' || $search_keywords != '' || $search_author != '' ) { // // Flood control // - $where_sql = ($userdata['user_id'] == ANONYMOUS) ? "se.session_ip = '$user_ip'" : 'se.session_user_id = ' . $userdata['user_id']; $sql = 'SELECT MAX(sr.search_time) AS last_search_time FROM ' . SEARCH_TABLE . ' sr, ' . SESSIONS_TABLE . " se WHERE sr.session_id = se.session_id AND $where_sql"; - - if ( $result = $db->sql_query($sql) ) + if ($result = $db->sql_query($sql)) { - if ( $row = $db->sql_fetchrow($result) ) + if ($row = $db->sql_fetchrow($result)) { - if ( intval($row['last_search_time']) > 0 && ($current_time - intval($row['last_search_time'])) < intval($board_config['search_flood_interval']) ) + if (intval($row['last_search_time']) > 0 && ($current_time - intval($row['last_search_time'])) < intval($board_config['search_flood_interval'])) { message_die(GENERAL_MESSAGE, $lang['Search_Flood_Error']); } } } - if ( $search_id == 'newposts' || $search_id == 'egosearch' || ( $search_author != '' && $search_keywords == '' ) ) { if ( $search_id == 'newposts' ) { + $user->read_cookies(); - if ( empty($user->cookies['unreads']) ) { message_return('No_search_match'); } - asort($user->cookies['unreads']); $floor = intval($user->cookies['unreads'][ _first_key($user->cookies['unreads']) ]); $sql = 'SELECT post_id, topic_id, post_time @@ -359,10 +339,8 @@ AND post_time > ' . $floor . ' AND post_draft = 0'; // start mod save posts as drafts (and end mod too)...added constraint in the preceding line that post_draft be 0 so that draftws wouldn't get included - - $result = $db->sql_query($sql, FALSE, __LINE__, __FILE__); + $result = $db->sql_query($sql, false, __LINE__, __FILE__); $search_ids = array(); - while ( $row = $db->sql_fetchrow($result) ) { if ( $row['post_time'] >= $user->cookies['unreads'][ $row['topic_id'] ] ) @@ -375,23 +353,25 @@ $sort_by = 0; $sort_dir = 'DESC'; } - elseif ( $search_id == 'egosearch' ) + else if ( $search_id == 'egosearch' ) { - $draft_on = TRUE; + $draft_on = true; - if ( $userdata['session_logged_in'] ) + if ( $userdata['session_logged_in'] ) { $sql = "SELECT post_id FROM " . POSTS_TABLE . " WHERE poster_id = " . $userdata['user_id'] . " AND post_draft = 0"; + } else { - redirect(append_sid("login.$phpEx?redirect=search.$phpEx&search_id=egosearch", TRUE)); + redirect(append_sid("login.$phpEx?redirect=search.$phpEx&search_id=egosearch", true)); } + $sort_by = 0; $sort_dir = 'DESC'; } @@ -399,7 +379,7 @@ { $search_author = str_replace('*', '%', trim($search_author)); - if ( ( strpos($search_author, '%') !== FALSE ) && ( strlen(str_replace('%', '', $search_author)) < $board_config['search_min_chars'] ) ) + if( ( strpos($search_author, '%') !== false ) && ( strlen(str_replace('%', '', $search_author)) < $board_config['search_min_chars'] ) ) { $search_author = ''; } @@ -407,21 +387,19 @@ $sql = "SELECT user_id FROM " . USERS_TABLE . " WHERE username LIKE '" . str_replace("\'", "''", $search_author) . "'"; - if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Couldn't obtain list of matching users (searching for: $search_author)", "", __LINE__, __FILE__, $sql); } $matching_userids = ''; - if ( $row = $db->sql_fetchrow($result) ) { do { $matching_userids .= ( ( $matching_userids != '' ) ? ', ' : '' ) . $row['user_id']; } - while ( $row = $db->sql_fetchrow($result) ); + while( $row = $db->sql_fetchrow($result) ); } else { @@ -432,33 +410,35 @@ FROM " . POSTS_TABLE . " WHERE poster_id IN ($matching_userids)"; - if ( $search_time ) + if ($search_time) { $sql .= " AND post_time >= " . $search_time; } } + if ( $search_id != 'newposts' ) { - if ( !($result = $db->sql_query($sql)) ) - { - message_die(GENERAL_ERROR, 'Could not obtain matched posts list', '', __LINE__, __FILE__, $sql); - } - $search_ids = array(); - - while ( $row = $db->sql_fetchrow($result) ) - { - $search_ids[] = $row['post_id']; - } - - $db->sql_freeresult($result); + if ( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not obtain matched posts list', '', __LINE__, __FILE__, $sql); } + $search_ids = array(); + while( $row = $db->sql_fetchrow($result) ) + { + $search_ids[] = $row['post_id']; + } + $db->sql_freeresult($result); + + } + + $total_match_count = count($search_ids); } - elseif ( $search_keywords != '' ) + else if ( $search_keywords != '' ) { $stopword_array = @file($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/search_stopwords.txt'); $synonym_array = @file($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/search_synonyms.txt'); @@ -466,7 +446,7 @@ $split_search = array(); $stripped_keywords = stripslashes($search_keywords); $split_search = ( !strstr($multibyte_charset, $lang['ENCODING']) ) ? split_words(clean_words('search', $stripped_keywords, $stopword_array, $synonym_array), 'search') : split(' ', $search_keywords); - unset ($stripped_keywords); + unset($stripped_keywords); $search_msg_only = ( !$search_fields ) ? "AND m.title_match = 0" : ( ( strstr($multibyte_charset, $lang['ENCODING']) ) ? '' : '' ); @@ -476,7 +456,7 @@ $word_match = array(); $result_list = array(); - for ( $i = 0; $i < count($split_search); $i++ ) + for($i = 0; $i < count($split_search); $i++) { if ( strlen(str_replace(array('*', '%'), '', trim($split_search[$i]))) < $board_config['search_min_chars'] ) { @@ -523,15 +503,13 @@ WHERE post_text LIKE '$match_word' $search_msg_only"; } - if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not obtain matched posts list', '', __LINE__, __FILE__, $sql); } $row = array(); - - while ( $temp_row = $db->sql_fetchrow($result) ) + while( $temp_row = $db->sql_fetchrow($result) ) { $row[$temp_row['post_id']] = 1; @@ -539,11 +517,11 @@ { $result_list[$temp_row['post_id']] = 1; } - elseif ( $current_match_type == 'or' ) + else if ( $current_match_type == 'or' ) { $result_list[$temp_row['post_id']] = 1; } - elseif ( $current_match_type == 'not' ) + else if ( $current_match_type == 'not' ) { $result_list[$temp_row['post_id']] = 0; } @@ -552,7 +530,7 @@ if ( $current_match_type == 'and' && $word_count ) { @reset($result_list); - while list($post_id, $match_count) = @each($result_list) ) + while( list($post_id, $match_count) = @each($result_list) ) { if ( !$row[$post_id] ) { @@ -570,8 +548,7 @@ @reset($result_list); $search_ids = array(); - - while ( list($post_id, $matches) = each($result_list) ) + while( list($post_id, $matches) = each($result_list) ) { if ( $matches ) { @@ -579,7 +556,7 @@ } } - unset ($result_list); + unset($result_list); $total_match_count = count($search_ids); } @@ -590,15 +567,15 @@ // If not logged in we explicitly prevent searching of private forums // + // // Author name search // - if ( $search_author != '' ) { $search_author = str_replace('*', '%', trim($search_author)); - if ( ( strpos($search_author, '%') !== false ) && ( strlen(str_replace('%', '', $search_author)) < $board_config['search_min_chars'] ) ) + if( ( strpos($search_author, '%') !== false ) && ( strlen(str_replace('%', '', $search_author)) < $board_config['search_min_chars'] ) ) { $search_author = ''; } @@ -611,16 +588,15 @@ // // This one is a beast, try to seperate it a bit (workaround for connection timeouts) // - $search_id_chunks = array(); $count = 0; $chunk = 0; - if ( count($search_ids) > $limiter ) + if (count($search_ids) > $limiter) { - for ( $i = 0; $i < count($search_ids); $i++ ) + for ($i = 0; $i < count($search_ids); $i++) { - if ( $count == $limiter ) + if ($count == $limiter) { $chunk++; $count = 0; @@ -637,7 +613,7 @@ $search_ids = array(); - for ( $i = 0; $i < count($search_id_chunks); $i++ ) + for ($i = 0; $i < count($search_id_chunks); $i++) { $where_sql = ''; @@ -661,8 +637,8 @@ if ( $search_author != '' ) { $from_sql .= ", " . USERS_TABLE . " u"; - - $where_sql .= " AND u.user_id = p.poster_id AND u.username LIKE '$search_author' AND p.post_draft = 0"; + + $where_sql .= " AND u.user_id = p.poster_id AND u.username LIKE '$search_author' AND p.post_draft = 0"; } if ( $auth_sql != '' ) @@ -683,28 +659,27 @@ message_die(GENERAL_ERROR, 'Could not obtain topic ids', '', __LINE__, __FILE__, $sql); } - while ( $row = $db->sql_fetchrow($result) ) + while ($row = $db->sql_fetchrow($result)) { $search_ids[] = $row['topic_id']; } - $db->sql_freeresult($result); } $total_match_count = sizeof($search_ids); } - elseif ( $search_author != '' || $search_time || $auth_sql != '' ) + else if ( $search_author != '' || $search_time || $auth_sql != '' ) { $search_id_chunks = array(); $count = 0; $chunk = 0; - if ( count($search_ids) > $limiter ) + if (count($search_ids) > $limiter) { - for ( $i = 0; $i < count($search_ids); $i++ ) + for ($i = 0; $i < count($search_ids); $i++) { - if ( $count == $limiter ) + if ($count == $limiter) { $chunk++; $count = 0; @@ -721,7 +696,7 @@ $search_ids = array(); - for ( $i = 0; $i < count($search_id_chunks); $i++ ) + for ($i = 0; $i < count($search_id_chunks); $i++) { $where_sql = ( $search_author == '' && $auth_sql == '' ) ? 'post_id IN (' . implode(', ', $search_id_chunks[$i]) . ')' : 'p.post_id IN (' . implode(', ', $search_id_chunks[$i]) . ')'; $select_sql = ( $search_author == '' && $auth_sql == '' ) ? 'post_id' : 'p.post_id'; @@ -748,24 +723,22 @@ $sql = "SELECT " . $select_sql . " FROM $from_sql WHERE $where_sql"; - if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not obtain post ids', '', __LINE__, __FILE__, $sql); } - while ( $row = $db->sql_fetchrow($result) ) + while( $row = $db->sql_fetchrow($result) ) { $search_ids[] = $row['post_id']; } - $db->sql_freeresult($result); } $total_match_count = count($search_ids); } } - elseif ( $search_id == 'unanswered' ) + else if ( $search_id == 'unanswered' ) { if ( $auth_sql != '' ) { @@ -790,12 +763,10 @@ } $search_ids = array(); - - while ( $row = $db->sql_fetchrow($result) ) + while( $row = $db->sql_fetchrow($result) ) { $search_ids[] = $row['topic_id']; } - $db->sql_freeresult($result); $total_match_count = count($search_ids); @@ -803,16 +774,14 @@ // // Basic requirements // - $show_results = 'topics'; $sort_by = 0; $sort_dir = 'DESC'; } else { - // start mod save posts as drafts (and end mod too)...added the check that skips the no match message if there are drafts to be shown - if ( !$draft_on ) + if(!$draft_on) { message_die(GENERAL_MESSAGE, $lang['No_search_match']); } @@ -821,10 +790,8 @@ // // Delete old data from the search result table // - $sql = 'DELETE FROM ' . SEARCH_TABLE . ' WHERE search_time < ' . ($current_time - (int) $board_config['session_length']); - if ( !$result = $db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Could not delete old search id sessions', '', __LINE__, __FILE__, $sql); @@ -833,7 +800,6 @@ // // Store new result data // - $search_results = implode(', ', $search_ids); $per_page = ( $show_results == 'posts' ) ? $board_config['posts_per_page'] : $board_config['topics_per_page']; @@ -841,20 +807,29 @@ // Combine both results and search data (apart from original query) // so we can serialize it and place it in the DB // - $store_search_data = array(); // // Limit the character length (and with this the results displayed at all following pages) to prevent // truncated result arrays. Normally, search results above 12000 are affected. + // - to include or not to include + /* + $max_result_length = 60000; + if (strlen($search_results) > $max_result_length) + { + $search_results = substr($search_results, 0, $max_result_length); + $search_results = substr($search_results, 0, strrpos($search_results, ',')); + $total_match_count = count(explode(', ', $search_results)); + } + */ - for ( $i = 0; $i < count($store_vars); $i++ ) + for($i = 0; $i < count($store_vars); $i++) { $store_search_data[$store_vars[$i]] = $$store_vars[$i]; } $result_array = serialize($store_search_data); - unset ($store_search_data); + unset($store_search_data); mt_srand ((double) microtime() * 1000000); $search_id = mt_rand(); @@ -862,12 +837,10 @@ $sql = "UPDATE " . SEARCH_TABLE . " SET search_id = $search_id, search_time = $current_time, search_array = '" . str_replace("\'", "''", $result_array) . "' WHERE session_id = '" . $userdata['session_id'] . "'"; - if ( !($result = $db->sql_query($sql)) || !$db->sql_affectedrows() ) { $sql = "INSERT INTO " . SEARCH_TABLE . " (search_id, session_id, search_time, search_array) VALUES($search_id, '" . $userdata['session_id'] . "', $current_time, '" . str_replace("\'", "''", $result_array) . "')"; - if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not insert search results', '', __LINE__, __FILE__, $sql); @@ -877,14 +850,12 @@ else { $search_id = intval($search_id); - if ( $search_id ) { $sql = "SELECT search_array FROM " . SEARCH_TABLE . " WHERE search_id = $search_id AND session_id = '". $userdata['session_id'] . "'"; - if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not obtain search results', '', __LINE__, __FILE__, $sql); @@ -893,8 +864,7 @@ if ( $row = $db->sql_fetchrow($result) ) { $search_data = unserialize($row['search_array']); - - for ( $i = 0; $i < count($store_vars); $i++ ) + for($i = 0; $i < count($store_vars); $i++) { $$store_vars[$i] = $search_data[$store_vars[$i]]; } @@ -912,18 +882,15 @@ } // get cookies for unreaded topics - $user->read_cookies(); // display results as topics - if ( $show_results == 'topics' ) { // get highlight parm $highlight_active = ''; $highlight_match = array(); - - for ( $j = 0; $j < count($split_search); $j++ ) + for($j = 0; $j < count($split_search); $j++ ) { $split_word = $split_search[$j]; @@ -944,11 +911,9 @@ } } } - $extra_parms = empty($highlight_active) ? '' : array('highlight' => urlencode(trim($highlight_active))); // filter page and order - $start = max(0, _read('start', TYPE_INT)); $ppage = _read('ppage', TYPE_INT); $ppage = ($ppage > 0) ? $ppage : (intval($user->data['user_topics_ppage']) ? intval($user->data['user_topics_ppage']) : (intval($config->data['topics_per_page']) ? intval($config->data['topics_per_page']) : 50)); @@ -962,26 +927,18 @@ ); $topics = new topics_search($parms, $extra_parms); - - if ( !empty($search_results) ) - { - $topics->read($search_results, $total_match_count); - } + if( !empty($search_results) ) $topics->read($search_results, $total_match_count); // start the page - $page_title = $user->lang('Search'); - include ($config->url('includes/page_header') ); + include($config->url('includes/page_header')); // jumpbox - make_jumpbox('index'); // upper box (so with forum nav sentence for each topic), force display empty, force the title - - $topics->display(TRUE, TRUE); + $topics->display(true, true); - // start mod save posts as drafts...show all drafts at the top of the search results page when a user searches for all of his or her posts (egosearch)... if ( $draft_on && $start == 0 ) { $sql = "SELECT p.post_id, p.post_time, pt.post_subject, t.topic_title, f.forum_name @@ -995,7 +952,7 @@ $result = $db->sql_query($sql); - if ( !$result ) + if( !$result ) { message_die(GENERAL_ERROR, "Couldn't obtain draft posts from database", "", __LINE__, __FILE__, $sql); } @@ -1005,7 +962,6 @@ $total_draft_posts = count($draft_posts); // ok, done collecting all draft posts...now let's find the draft pms - $sql = "SELECT privmsgs_id, privmsgs_subject, privmsgs_date FROM " . PRIVMSGS_TABLE . " WHERE privmsgs_type = " . PRIVMSGS_DRAFT_MAIL . " @@ -1014,7 +970,7 @@ $result = $db->sql_query($sql); - if ( !$result ) + if( !$result ) { message_die(GENERAL_ERROR, "Couldn't obtain draft posts from database", "", __LINE__, __FILE__, $sql); } @@ -1030,25 +986,22 @@ { $drafts = array_merge($draft_posts,$draft_pms); } - $total_drafts = count($drafts); // cut this all off if there are no regular search matches and no drafts - if ( $search_results == '' && $total_drafts == 0 ) + if( $search_results == '' && $total_drafts == 0 ) { message_die(GENERAL_MESSAGE, $lang['No_search_match']); } if ( $total_drafts > 0 ) { - $template->assign_block_vars('switch_show_drafts', array()); - $template->assign_block_vars("draft", array()); - - for ( $i = 0; $i < $total_drafts; $i++ ) + $template->assign_block_vars('switch_show_drafts', array()); + $template->assign_block_vars("draft", array()); + for($i = 0; $i < $total_drafts; $i++) { $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; // now set variables, but variables are different depending on if draft post or draft pm so treat differently... - if ( $i < $total_draft_posts ) { $draft_time = create_date($board_config['default_dateformat'], $drafts[$i]['post_time'], $board_config['board_timezone']); @@ -1077,7 +1030,6 @@ } } } - $total_match_count = $total_match_count + $total_drafts; $l_search_matches = ( $total_match_count == 1 ) ? sprintf($lang['Found_search_match'], $total_match_count) : sprintf($lang['Found_search_matches'], $total_match_count); @@ -1089,12 +1041,11 @@ 'L_DRAFT_POST_SUBJECT' => $lang['Draft_post_subject'], 'L_DRAFT_POST_TOPIC' => $lang['Draft_post_topic'], 'L_DRAFT_POST_FORUM' => $lang['Draft_post_forum'])); - - // display + // display $template->set_filenames(array('body' => 'search_results_topics.tpl')); $template->pparse('body'); - include ($config->url('includes/page_tail')); + include($config->url('includes/page_tail')); exit; } @@ -1111,7 +1062,9 @@ AND p.poster_id = u.user_id"; $sql = str_replace('SELECT ', 'SELECT pt.post_sub_title, ', $sql); + $sql = str_replace('SELECT ', 'SELECT u.user_group_id, u.user_session_time, ', $sql); + } else { @@ -1123,14 +1076,14 @@ AND p.post_id = t.topic_first_post_id AND p2.post_id = t.topic_last_post_id AND u2.user_id = p2.poster_id"; - - $sql = str_replace('SELECT ', 'SELECT u.user_group_id as user_group_id_1, u2.user_group_id as user_group_id_2, u.user_session_time as user_session_time_1, u2.user_session_time as user_session_time_2, ', $sql); + + $sql = str_replace('SELECT ', 'SELECT u.user_group_id as user_group_id_1, u2.user_group_id as user_group_id_2, u.user_session_time as user_session_time_1, u2.user_session_time as user_session_time_2, ', $sql); + } $per_page = ( $show_results == 'posts' ) ? $board_config['posts_per_page'] : $board_config['topics_per_page']; $sql .= " ORDER BY "; - switch ( $sort_by ) { case 1: @@ -1159,19 +1112,17 @@ } $searchset = array(); - - while ( $row = $db->sql_fetchrow($result) ) + while( $row = $db->sql_fetchrow($result) ) { $searchset[] = $row; } $db->sql_freeresult($result); - } + } // // Define censored word matches // - $orig_word = array(); $replacement_word = array(); obtain_word_list($orig_word, $replacement_word); @@ -1179,9 +1130,8 @@ // // Output header // - $page_title = $lang['Search']; - include ($phpbb_root_path . 'includes/page_header.' . $phpEx); + include($phpbb_root_path . 'includes/page_header.'.$phpEx); if ( $show_results == 'posts' ) { @@ -1195,9 +1145,8 @@ 'body' => 'search_results_topics.tpl') ); } - make_jumpbox('viewforum.' . $phpEx); + make_jumpbox('viewforum.'.$phpEx); - // start mod save posts as drafts...show all drafts at the top of the search results page when a user searches for all of his or her posts (egosearch)... if ( $draft_on && $start == 0 ) { $sql = "SELECT p.post_id, p.post_time, pt.post_subject, t.topic_title, f.forum_name @@ -1211,7 +1160,7 @@ $result = $db->sql_query($sql); - if ( !$result ) + if( !$result ) { message_die(GENERAL_ERROR, "Couldn't obtain draft posts from database", "", __LINE__, __FILE__, $sql); } @@ -1221,7 +1170,6 @@ $total_draft_posts = count($draft_posts); // ok, done collecting all draft posts...now let's find the draft pms - $sql = "SELECT privmsgs_id, privmsgs_subject, privmsgs_date FROM " . PRIVMSGS_TABLE . " WHERE privmsgs_type = " . PRIVMSGS_DRAFT_MAIL . " @@ -1230,7 +1178,7 @@ $result = $db->sql_query($sql); - if ( !$result ) + if( !$result ) { message_die(GENERAL_ERROR, "Couldn't obtain draft posts from database", "", __LINE__, __FILE__, $sql); } @@ -1250,22 +1198,19 @@ $total_drafts = count($drafts); // cut this all off if there are no regular search matches and no drafts - - if ( $search_results == '' && $total_drafts == 0 ) + if( $search_results == '' && $total_drafts == 0 ) { message_die(GENERAL_MESSAGE, $lang['No_search_match']); } if ( $total_drafts > 0 ) { - $template->assign_block_vars('switch_show_drafts', array()); - $template->assign_block_vars("draft", array()); - - for ( $i = 0; $i < $total_drafts; $i++) + $template->assign_block_vars('switch_show_drafts', array()); + $template->assign_block_vars("draft", array()); + for($i = 0; $i < $total_drafts; $i++) { $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; // now set variables, but variables are different depending on if draft post or draft pm so treat differently... - if ( $i < $total_draft_posts ) { $draft_time = create_date($board_config['default_dateformat'], $drafts[$i]['post_time'], $board_config['board_timezone']); @@ -1312,8 +1257,7 @@ $highlight_active = ''; $highlight_match = array(); - - for ( $j = 0; $j < count($split_search); $j++ ) + for($j = 0; $j < count($split_search); $j++ ) { $split_word = $split_search[$j]; @@ -1322,7 +1266,7 @@ $highlight_match[] = '#\b(' . str_replace("*", "([\w]+)?", $split_word) . ')\b#is'; $highlight_active .= " " . $split_word; - for ( $k = 0; $k < count($synonym_array); $k++ ) + for ($k = 0; $k < count($synonym_array); $k++) { list($replace_synonym, $match_synonym) = split(' ', trim(strtolower($synonym_array[$k]))); @@ -1337,13 +1281,15 @@ $highlight_active = urlencode(trim($highlight_active)); + // prepare title enhancement - $front_title = new front_title(); - for ( $i = 0; $i < count($searchset); $i++) + for($i = 0; $i < count($searchset); $i++) { - $forum_url = $config->url('index', array(POST_FORUM_URL => $searchset[$i]['forum_id']), TRUE); + + $forum_url = $config->url('index', array(POST_FORUM_URL => $searchset[$i]['forum_id']), true); + $topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $searchset[$i]['topic_id'] . "&highlight=$highlight_active"); $post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $searchset[$i]['post_id'] . "&highlight=$highlight_active") . '#' . $searchset[$i]['post_id']; @@ -1365,7 +1311,6 @@ // If the board has HTML off but the post has HTML // on then we process it, else leave it alone // - if ( $return_chars != -1 ) { $message = strip_tags($message); @@ -1422,7 +1367,7 @@ { $end_counter--; } - elseif ( substr($message, $end_html, 1) == '<' ) + else if ( substr($message, $end_html, 1) == '<' ) { $end_counter++; } @@ -1435,11 +1380,11 @@ $hold_string = str_replace('<!-- #sh -->', '', $hold_string); $hold_string = str_replace('<!-- #eh -->', '', $hold_string); } - elseif ( $hold_string == '<!-- #sh -->' ) + else if ( $hold_string == '<!-- #sh -->' ) { $hold_string = str_replace('<!-- #sh -->', '<span style="color:#' . $theme['fontcolor3'] . '"><b>', $hold_string); } - elseif ( $hold_string == '<!-- #eh -->' ) + else if ( $hold_string == '<!-- #eh -->' ) { $hold_string = str_replace('<!-- #eh -->', '</b></span>', $hold_string); } @@ -1478,7 +1423,7 @@ $post_subject = ( $searchset[$i]['post_subject'] != '' ) ? $searchset[$i]['post_subject'] : $topic_title; } - if ( $board_config['allow_smilies'] && $searchset[$i]['enable_smilies'] ) + if ($board_config['allow_smilies'] && $searchset[$i]['enable_smilies']) { $message = smilies_pass($message); } @@ -1488,11 +1433,12 @@ } $poster = ( $searchset[$i]['user_id'] != ANONYMOUS ) ? '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $searchset[$i]['user_id']) . '">' : ''; + $poster .= ( $searchset[$i]['user_id'] != ANONYMOUS ) ? $colors->get_user_color($searchset[$i]['user_group_id'], $searchset[$i]['user_session_time'], $searchset[$i]['username']) : ((!empty($searchset[$i]['post_username'])) ? $colors->get_user_color($searchset[$i]['user_group_id'], '0', $searchset[$i]['post_username']) : $colors->get_user_color($searchset[$i]['user_group_id'], '0', $lang['Guest'])); + $poster .= ( $searchset[$i]['user_id'] != ANONYMOUS ) ? '</a>' : ''; $topic_last_read = intval($user->cookies['unreads'][ $search_set[$i]['topic_id'] ]); - if ( !empty($topic_last_read) && ($searchset[$i]['post_time'] > $topic_last_read) ) { $mini_post_img = $images['icon_minipost_new']; @@ -1523,26 +1469,25 @@ ); // enhance the topic title - $front_title->set('searchresults', $searchset[$i], $searchset[$i]['topic_first_post_id'] == $searchset[$i]['post_id'], $highlight_active); // navigation - - $forums->display_nav($searchset[$i]['forum_id'], 'searchresults.nav', TRUE); + $forums->display_nav($searchset[$i]['forum_id'], 'searchresults.nav', true); + } - } + } $base_url = "search.$phpEx?search_id=$search_id"; + // pagination - $parms = array('search_id' => $search_id); $requester = 'search'; $pagination = new pagination($requester, $parms, 'start'); $pagination->display('pagination', $total_match_count, $per_page, $start, true, 'Posts_count'); $template->assign_vars(array( - 'I_TOPIC' => $user->img('folder')) - ); + 'I_TOPIC' => $user->img('folder'), + )); $template->assign_vars(array( 'PAGINATION' => generate_pagination($base_url, $total_match_count, $per_page, $start), @@ -1564,7 +1509,7 @@ $template->pparse('body'); - include ($phpbb_root_path . 'includes/page_tail.' . $phpEx); + include($phpbb_root_path . 'includes/page_tail.'.$phpEx); } else { @@ -1578,7 +1523,6 @@ $front_pic = $forums->get_front_pic(); $s_forums = ''; - if ( !empty($front_pic) ) { foreach ( $front_pic as $cur_id => $front ) @@ -1586,17 +1530,14 @@ $selected = ($search_forum == $cur_id) ? ' selected="selected"' : ''; $s_forums .= '<option value="' . (($cur_id >= 0) ? $cur_id : -1) . '"' . $selected . '>'; $count_front = strlen($front); - for ( $i = 0; $i < $count_front; $i++ ) { $s_forums .= $user->lang('tree_pic_' . $front[$i]); } - if ( $cur_id >= 0 ) { $s_forums .= $user->lang($forums->data[$cur_id]['forum_name']); } - $s_forums .= '</option>'; } } @@ -1604,7 +1545,6 @@ { message_die(GENERAL_MESSAGE, $lang['No_searchable_forums']); } - $template->assign_vars(array( 'L_SEARCH_FORUM' => $user->lang('Search_in_forum'), 'L_NO_SUBS' => $user->lang('Search_no_subs'), @@ -1620,7 +1560,7 @@ $s_characters .= '<option value="25">25</option>'; $s_characters .= '<option value="50">50</option>'; -for ( $i = 100; $i < 1100 ; $i += 100 ) +for($i = 100; $i < 1100 ; $i += 100) { $selected = ( $i == 200 ) ? ' selected="selected"' : ''; $s_characters .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>'; @@ -1629,10 +1569,8 @@ // // Sorting // - $s_sort_by = ""; - -for ( $i = 0; $i < count($sort_by_types); $i++ ) +for($i = 0; $i < count($sort_by_types); $i++) { $s_sort_by .= '<option value="' . $i . '">' . $sort_by_types[$i] . '</option>'; } @@ -1640,13 +1578,11 @@ // // Search time // - $previous_days = array(0, 1, 7, 14, 30, 90, 180, 364); $previous_days_text = array($lang['All_Posts'], $lang['1_Day'], $lang['7_Days'], $lang['2_Weeks'], $lang['1_Month'], $lang['3_Months'], $lang['6_Months'], $lang['1_Year']); $s_time = ''; - -for ( $i = 0; $i < count($previous_days); $i++ ) +for($i = 0; $i < count($previous_days); $i++) { $selected = ( $topic_days == $previous_days[$i] ) ? ' selected="selected"' : ''; $s_time .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>'; @@ -1655,9 +1591,8 @@ // // Output the basic page // - $page_title = $lang['Search']; -include ($phpbb_root_path . 'includes/page_header.' . $phpEx); +include($phpbb_root_path . 'includes/page_header.'.$phpEx); $template->set_filenames(array( 'body' => 'search_body.tpl') @@ -1698,6 +1633,6 @@ $template->pparse('body'); -include ($phpbb_root_path . 'includes/page_tail.' . $phpEx); +include($phpbb_root_path . 'includes/page_tail.'.$phpEx); ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |