diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2008-05-29 12:25:56 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2008-05-29 12:25:56 +0000 |
commit | 2f4a618900e2c3b6ea14c68cbeb5897cd2ac1a04 (patch) | |
tree | 3b7ea329bf35eab5ddab9b0b5eb790e45e283a5c /phpBB/search.php | |
parent | 91b4fe1868ca2c4d81111943f781e3cfd0262ef2 (diff) | |
download | forums-2f4a618900e2c3b6ea14c68cbeb5897cd2ac1a04.tar forums-2f4a618900e2c3b6ea14c68cbeb5897cd2ac1a04.tar.gz forums-2f4a618900e2c3b6ea14c68cbeb5897cd2ac1a04.tar.bz2 forums-2f4a618900e2c3b6ea14c68cbeb5897cd2ac1a04.tar.xz forums-2f4a618900e2c3b6ea14c68cbeb5897cd2ac1a04.zip |
ok... i hope i haven't messed too much with the code and everything is still working.
Changes:
- Ascraeus now uses constants for the phpbb root path and the php extension. This ensures more security for external applications and modifications (no more overwriting of root path and extension possible through insecure mods and register globals enabled) as well as no more globalizing needed.
- A second change implemented here is an additional short-hand-notation for append_sid(). It is allowed to omit the root path and extension now (for example calling append_sid('memberlist')) - in this case the root path and extension get added automatically. The hook is called after these are added.
git-svn-id: file:///svn/phpbb/trunk@8572 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/search.php')
-rw-r--r-- | phpBB/search.php | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/phpBB/search.php b/phpBB/search.php index c67581490b..825beac483 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -12,9 +12,9 @@ * @ignore */ define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); +if (!defined('PHPBB_ROOT_PATH')) define('PHPBB_ROOT_PATH', './'); +if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); +include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT); // Start session management $user->session_begin(); @@ -221,12 +221,12 @@ if ($keywords || $author || $author_id || $search_id || $submit) // Select which method we'll use to obtain the post_id or topic_id information $search_type = basename($config['search_type']); - if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx)) + if (!file_exists(PHPBB_ROOT_PATH . 'includes/search/' . $search_type . '.' . PHP_EXT)) { trigger_error('NO_SUCH_SEARCH_MODULE'); } - require("{$phpbb_root_path}includes/search/$search_type.$phpEx"); + require(PHPBB_ROOT_PATH . "includes/search/$search_type." . PHP_EXT); // We do some additional checks in the module to ensure it can actually be utilised $error = false; @@ -440,11 +440,11 @@ if ($keywords || $author || $author_id || $search_id || $submit) if ($show_results == 'posts') { - include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); + include(PHPBB_ROOT_PATH . 'includes/functions_posting.' . PHP_EXT); } else { - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); + include(PHPBB_ROOT_PATH . 'includes/functions_display.' . PHP_EXT); } $user->add_lang('viewtopic'); @@ -470,7 +470,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) $u_show_results = ($show_results != 'posts') ? '&sr=' . $show_results : ''; $u_search_forum = implode('&fid%5B%5D=', $search_forum); - $u_search = append_sid("{$phpbb_root_path}search.$phpEx", $u_sort_param . $u_show_results); + $u_search = append_sid('search', $u_sort_param . $u_show_results); $u_search .= ($search_id) ? '&search_id=' . $search_id : ''; $u_search .= ($u_hilit) ? '&keywords=' . urlencode(htmlspecialchars_decode($search->search_query)) : ''; $u_search .= ($topic_id) ? '&t=' . $topic_id : ''; @@ -681,7 +681,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) // Instantiate BBCode if needed if ($bbcode_bitfield !== '') { - include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); + include_once(PHPBB_ROOT_PATH . 'includes/bbcode.' . PHP_EXT); $bbcode = new bbcode(base64_encode($bbcode_bitfield)); } @@ -763,7 +763,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) $u_forum_id = $forum_id; } - $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$u_forum_id&t=$result_topic_id" . (($u_hilit) ? "&hilit=$u_hilit" : '')); + $view_topic_url = append_sid('viewtopic', "f=$u_forum_id&t=$result_topic_id" . (($u_hilit) ? "&hilit=$u_hilit" : '')); $replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies']; @@ -776,7 +776,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $forum_id)) ? true : false; $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $forum_id)) ? true : false; - $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$result_topic_id", true, $user->session_id) : ''; + $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid('mcp', 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$result_topic_id", true, $user->session_id) : ''; $row['topic_title'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $row['topic_title']); @@ -816,7 +816,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'U_NEWEST_POST' => $view_topic_url . '&view=unread#unread', - 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&t=' . $result_topic_id, true, $user->session_id), + 'U_MCP_REPORT' => append_sid('mcp', 'i=reports&mode=reports&t=' . $result_topic_id, true, $user->session_id), 'U_MCP_QUEUE' => $u_mcp_queue, ); } @@ -892,8 +892,8 @@ if ($keywords || $author || $author_id || $search_id || $submit) 'TOPIC_VIEWS' => $row['topic_views'], 'U_VIEW_TOPIC' => $view_topic_url, - 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id), - 'U_VIEW_POST' => (!empty($row['post_id'])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=" . $row['topic_id'] . '&p=' . $row['post_id'] . (($u_hilit) ? '&hilit=' . $u_hilit : '')) . '#p' . $row['post_id'] : '') + 'U_VIEW_FORUM' => append_sid('viewforum', 'f=' . $forum_id), + 'U_VIEW_POST' => (!empty($row['post_id'])) ? append_sid('viewtopic', "f=$forum_id&t=" . $row['topic_id'] . '&p=' . $row['post_id'] . (($u_hilit) ? '&hilit=' . $u_hilit : '')) . '#p' . $row['post_id'] : '') )); } @@ -912,7 +912,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) $template->set_filenames(array( 'body' => 'search_results.html') ); - make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); + make_jumpbox(append_sid('viewforum')); page_footer(); } @@ -1034,7 +1034,7 @@ if (!empty($_EXTRA_URL)) } $template->assign_vars(array( - 'S_SEARCH_ACTION' => "{$phpbb_root_path}search.$phpEx", + 'S_SEARCH_ACTION' => append_sid('search'), 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), 'S_CHARACTER_OPTIONS' => $s_characters, 'S_FORUM_OPTIONS' => $s_forums, @@ -1061,7 +1061,7 @@ if ($auth->acl_get('a_search')) 'KEYWORDS' => $keywords, 'TIME' => $user->format_date($row['search_time']), - 'U_KEYWORDS' => append_sid("{$phpbb_root_path}search.$phpEx", 'keywords=' . urlencode(htmlspecialchars_decode($keywords))) + 'U_KEYWORDS' => append_sid('search', 'keywords=' . urlencode(htmlspecialchars_decode($keywords))) )); } $db->sql_freeresult($result); @@ -1073,7 +1073,7 @@ page_header($user->lang['SEARCH']); $template->set_filenames(array( 'body' => 'search_body.html') ); -make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); +make_jumpbox(append_sid('viewforum')); page_footer(); |