From b653b4dd670af1a07a29861e03f13a4a1960e96e Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Thu, 31 May 2001 11:47:43 +0000 Subject: [PATCH] Various changes and fixes to enable search from username and template updates git-svn-id: file:///svn/phpbb/trunk@382 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/profile.php | 11 ++++-- phpBB/search.php | 38 +++++++++++-------- phpBB/templates/Default/profile_view_body.tpl | 2 +- phpBB/templates/PSO/profile_view_body.tpl | 4 +- 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/phpBB/profile.php b/phpBB/profile.php index a15ad94aa9..e39277aeed 100644 --- a/phpBB/profile.php +++ b/phpBB/profile.php @@ -320,10 +320,11 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode'])) "MSN" => stripslashes($profiledata['user_msnm']), "L_YAHOO" => stripslashes($l_yahoo), "YIM" => stripslashes($profiledata['user_yim']), - "WEBSITE" => "".stripslashes($profiledata['user_website'])."", + "WEBSITE" => stripslashes($profiledata['user_website']), "LOCATION" => stripslashes($profiledata['user_from']), "OCCUPATION" => stripslashes($profiledata['user_occ']), - "INTERESTS" => stripslashes($profiledata['user_interests']), + "INTERESTS" => stripslashes($profiledata['user_interests']), + "AVATAR_IMG" => $board_config['avatar_path'] . "/" . stripslashes($profiledata['user_avatar']), "L_VIEWING_PROFILE" => $l_viewing_profile, "L_USERNAME" => $l_username, @@ -338,7 +339,11 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode'])) "L_MESSENGER" => $l_messenger, "L_LOCATION" => $l_from, "L_OCCUPATION" => $l_occupation, - "L_INTERESTS" => $l_interests, + "L_INTERESTS" => $l_interests, + "L_AVATAR" => $l_avatar, + + "U_SEARCH_USER" => append_sid("search.$phpEx?a=".urlencode($profiledata['username'])."&f=all&b=0&d=DESC&c=100&dosearch=1"), + "U_USER_WEBSITE" => stripslashes($profiledata['user_website']), "S_PROFILE_ACTION" => append_sid("profile.$phpEx")) ); diff --git a/phpBB/search.php b/phpBB/search.php index ff1071cba1..42c00a63e9 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -30,7 +30,6 @@ include('extension.inc'); include('common.'.$phpEx); -include('includes/bbcode.'.$phpEx); $pagetype = "search"; $page_title = "Search Forums"; @@ -260,7 +259,7 @@ function gensearch_sql($searchstring, $override_all = 0) } } - $searchstring = "WHERE ($searchstring) AND (pt.post_id = p.post_id) "; + $searchstring = "($searchstring)"; $searchdata[0] = $searchstring; for($i = 0; $i < count($searchforwords); $i++) @@ -290,11 +289,11 @@ init_userprefs($userdata); $start = (isset($HTTP_GET_VARS['start'])) ? $HTTP_GET_VARS['start'] : 0; -$querystring = (isset($HTTP_POST_VARS['querystring'])) ? $HTTP_POST_VARS['querystring'] : ( (isset($HTTP_GET_VARS['q'])) ? stripslashes($HTTP_GET_VARS['q']) : "" ); -$authorstring = (isset($HTTP_POST_VARS['authorstring'])) ? $HTTP_POST_VARS['authorstring'] : ( (isset($HTTP_GET_VARS['a'])) ? stripslashes($HTTP_GET_VARS['a']) : "" ); +$querystring = (isset($HTTP_POST_VARS['querystring'])) ? $HTTP_POST_VARS['querystring'] : ( (!empty($HTTP_GET_VARS['q'])) ? stripslashes($HTTP_GET_VARS['q']) : "" ); +$authorstring = (isset($HTTP_POST_VARS['authorstring'])) ? $HTTP_POST_VARS['authorstring'] : ( (!empty($HTTP_GET_VARS['a'])) ? stripslashes($HTTP_GET_VARS['a']) : "" ); $return_chars = ($HTTP_POST_VARS['charsreqd'] != "all") ? $HTTP_POST_VARS['charsreqd'] : -1; -$return_chars = (isset($HTTP_GET_VARS['c'])) ? ( ($HTTP_GET_VARS['c']!= "all") ? $HTTP_GET_VARS['c'] : -1 ) : $return_chars; +$return_chars = (isset($HTTP_GET_VARS['c'])) ? ( ($HTTP_GET_VARS['c'] != "all") ? $HTTP_GET_VARS['c'] : -1 ) : $return_chars; $searchall = ($HTTP_POST_VARS['addterms'] == "all") ? 1 : ( ($HTTP_GET_VARS['m'] == "all") ? 1 : 0 ); $searchforum = (isset($HTTP_POST_VARS['searchforum'])) ? $HTTP_POST_VARS['searchforum'] : $HTTP_GET_VARS['f'] ; $sortby = (isset($HTTP_POST_VARS['sortby'])) ? $HTTP_POST_VARS['sortby'] : $HTTP_GET_VARS['b']; @@ -325,27 +324,33 @@ if((isset($HTTP_POST_VARS['dosearch']) || isset($HTTP_GET_VARS['dosearch'])) && // searching of private forums // - if($querystring != "") + if($querystring != "" || $authorstring != "") { $search_sql = ""; - $searchdata = gensearch_sql(stripslashes($querystring), $searchall); - $search_sql = $searchdata[0]; + if($querystring != "") + { + $searchdata = gensearch_sql(stripslashes($querystring), $searchall); + $search_sql = $searchdata[0]; + } + if($authorstring != "") + { + $search_sql = preg_replace("/\(\)/", "", $search_sql); + $authorstring = stripslashes($authorstring); + $search_sql .= ($searchstring == "") ? "u.username LIKE '%$authorstring%'" : " AND (u.username LIKE '%$authorstring%')"; + } if(!ereg("\([ ]*\)",$search_sql)) { - if($authorstring != "") - { - $authorstring = stripslashes($authorstring); - $search_sql .= ($querystring == "") ? "WHERE u.username LIKE '%$authorstring%'" : " AND (u.username LIKE '%$authorstring%')"; - } - $sql .= $search_sql." + $sql .= "WHERE $search_sql AND (pt.post_id = p.post_id) AND (f.forum_id = p.forum_id) AND (p.topic_id = t.topic_id) AND (p.poster_id = u.user_id)"; if($searchforum != "all") + { $sql .= " AND (f.forum_id = '$searchforum')"; + } $sql .= " ORDER BY ".$sortby_sql[$sortby]." $sortby_dir"; @@ -411,7 +416,10 @@ if((isset($HTTP_POST_VARS['dosearch']) || isset($HTTP_GET_VARS['dosearch'])) && $message = preg_replace("/\[.*\]/", "", $message); $message = str_replace("\n", "
", $message); - $message = preg_replace($search_string, $replace_string, $message); + if(count($searchdata) > 1) + { + $message = preg_replace($search_string, $replace_string, $message); + } } else diff --git a/phpBB/templates/Default/profile_view_body.tpl b/phpBB/templates/Default/profile_view_body.tpl index 517709abe2..72fcc63d79 100755 --- a/phpBB/templates/Default/profile_view_body.tpl +++ b/phpBB/templates/Default/profile_view_body.tpl @@ -42,7 +42,7 @@ {L_WEBSITE}: - {WEBSITE} + {WEBSITE} {L_LOCATION}: diff --git a/phpBB/templates/PSO/profile_view_body.tpl b/phpBB/templates/PSO/profile_view_body.tpl index 24edc6ac5b..537bca9dcf 100644 --- a/phpBB/templates/PSO/profile_view_body.tpl +++ b/phpBB/templates/PSO/profile_view_body.tpl @@ -12,7 +12,7 @@ {L_USERNAME}: - {USERNAME} [{L_VIEW_USERS_POSTS}] + {USERNAME} [{L_VIEW_USERS_POSTS}] {L_JOINED}: @@ -44,7 +44,7 @@ {L_WEBSITE}: - {WEBSITE} + {WEBSITE} {L_LOCATION}: