00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: index.php 5430 2006-02-17 23:04:40Z toddy $
00006 #
00007 # Copyright 1999-2000 (c) The SourceForge Crew
00008 # Copyright 2000-2003 (c) Free Software Foundation
00009 # Mathieu Roy <yeupou--gnu.org>
00010 #
00011 # Copyright 2004-2006 (c) Mathieu Roy <yeupou--gnu.org>
00012 # Yves Perrin <yves.perrin--cern.ch>
00013 #
00014 # The Savane project is free software; you can redistribute it and/or
00015 # modify it under the terms of the GNU General Public License
00016 # as published by the Free Software Foundation; either version 2
00017 # of the License, or (at your option) any later version.
00018 #
00019 # The Savane project is distributed in the hope that it will be useful,
00020 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00022 # GNU General Public License for more details.
00023 #
00024 # You should have received a copy of the GNU General Public License
00025 # along with the Savane project; if not, write to the Free Software
00026 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00027
00028
00029 require '../include/pre.php';
00030
00031 # FIXME: This should be replaced by a call to register_globals_off()
00032 if ($_POST['group_id'])
00033 {
00034 $group_id = $_POST['group_id'];
00035 }
00036 elseif ($_GET['group_id'])
00037 {
00038 $group_id = $_GET['group_id'];
00039 }
00040 if ($_POST['words'])
00041 {
00042 $words = $_POST['words'];
00043 }
00044 elseif ($_GET['words'])
00045 {
00046 $words = $_GET['words'];
00047 }
00048 if ($_POST['type_of_search'])
00049 {
00050 $type_of_search = $_POST['type_of_search'];
00051 }
00052 elseif ($_GET['type_of_search'])
00053 {
00054 $type_of_search = $_GET['type_of_search'];
00055 }
00056 if ($_POST['func'])
00057 {
00058 $func = $_POST['func'];
00059 }
00060 elseif ($_GET['func'])
00061 {
00062 $func = $_GET['func'];
00063 }
00064
00065 # Prevent xss when displaying the search string
00066 $words = htmlspecialchars($words);
00067
00068 # No words? Ask for them
00069 if (!$words)
00070 {
00071 search_send_header();
00072 print '<p>'._("Enter your search words above.").'</p>';
00073 $HTML->footer(array());
00074 exit;
00075 }
00076
00077 # Do the search
00078 if ($type_of_search == "google")
00079 {
00080 Header("Location: http://www.google.com/search?q=site:".$GLOBALS['sys_default_domain']."+$words");
00081 exit;
00082 }
00083 else
00084 {
00085 $result = search_run($words, $type_of_search);
00086 }
00087
00088 # Print out the results
00089
00090 if ($type_of_search == "soft")
00091 {
00092 $rows = $rows_returned = db_numrows($result);
00093
00094 if (!$result || $rows < 1)
00095 {
00096 # No result? Stop here.
00097 search_failed();
00098 }
00099 elseif (($rows == 1) && ($GLOBALS['offset'] == 0))
00100 {
00101 # Only one result? Redirect, but only if this is the first
00102 # page to be displayed. Otherwise, if the last page contains
00103 # just one row, the user will be redirected.
00104 $res_type = db_query("SELECT base_host FROM group_type WHERE type_id=".db_result($result, 0, 'type'));
00105 $project = db_result($result, 0, 'unix_group_name');
00106 if (db_result($res_type, 0, 'base_host'))
00107 { $host = db_result($res_type, 0, 'base_host'); }
00108 else
00109 { $host = $GLOBALS['HTTP_HOST']; }
00110
00111 Header("Location: http".(session_issecure()?'s':'')."://".$host.$GLOBALS['sys_home']."projects/$project");
00112 }
00113 else
00114 {
00115 # More results? Print them in the respect of max_rows setting.
00116 if ($rows_returned > $GLOBALS['max_rows'])
00117 { $rows = $GLOBALS['max_rows']; }
00118 search_send_header();
00119
00120 $title_arr = array();
00121 $title_arr[] = _("Project");
00122 $title_arr[] = _("Description");
00123 $title_arr[] = _("Type");
00124
00125 print html_build_list_table_top($title_arr);
00126
00127 print "\n";
00128
00129 for ( $i = 0; $i < $rows; $i++ )
00130 {
00131 $res_type = db_query("SELECT base_host,name FROM group_type WHERE type_id=".db_result($result, $i, 'type'));
00132
00133 if (db_result($res_type, 0, 'base_host'))
00134 { $host = db_result($res_type, 0, 'base_host'); }
00135 else
00136 { $host = $GLOBALS['HTTP_HOST']; }
00137
00138 print '<tr class="'. html_get_alt_row_color($i).'"><td><a href="http'.(session_issecure()?'s':'').":
00139 . db_result($result, $i, 'group_name').'</a></td>'
00140 . '<td>'.db_result($result,$i,'short_description').'</td>'
00141 . '<td>'.db_result($res_type, 0, 'name')."</td></tr>\n";
00142 }
00143 print "</table>\n";
00144
00145 print '<p> Note that <strong>private</strong> projects are not shown on this page </p>';
00146 }
00147
00148 }
00149 else if ($type_of_search == "people")
00150 {
00151 $rows = $rows_returned = db_numrows($result);
00152
00153 if (!$result || $rows < 1)
00154 {
00155 search_failed();
00156 }
00157 elseif (($rows == 1) && ($GLOBALS['offset'] == 0))
00158 {
00159 $user = db_result($result, 0, 'user_name');
00160 Header("Location: ".$GLOBALS['sys_home']."users/$user");
00161 }
00162 else
00163 {
00164 if ( $rows_returned > $GLOBALS['max_rows'])
00165 { $rows = $GLOBALS['max_rows']; }
00166
00167 search_send_header();
00168
00169 $title_arr = array();
00170 $title_arr[] = _("Login");
00171 $title_arr[] = _("Name");
00172
00173 print html_build_list_table_top ($title_arr);
00174
00175 print "\n";
00176
00177 for ( $i = 0; $i < $rows; $i++ )
00178 {
00179 $namequery = eregi_replace('[^a-z]+', '+', db_result($result,$i,'realname'));
00180 print "<tr class=\"". html_get_alt_row_color($i) ."\"><td>".
00181 utils_user_link(db_result($result, $i, 'user_name'))
00182
00183 . "<td>".db_result($result,$i,'realname')."</td></tr>\n";
00184 }
00185 print "</table>\n";
00186 }
00187
00188 }
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248 else if ($type_of_search == 'bugs' ||
00249 $type_of_search == 'support' ||
00250 $type_of_search == 'patch' ||
00251 $type_of_search == 'cookbook' ||
00252 $type_of_search == 'task')
00253 {
00254 $rows = $rows_returned = db_numrows($result);
00255
00256 if ( !$result || $rows < 1)
00257 {
00258 search_failed();
00259 }
00260 elseif (($rows == 1) && ($GLOBALS['offset'] == 0 && (db_result($result, $i, 'privacy') != "2")))
00261 {
00262 # no automatic redirection for private item, use the usual listing
00263 $bug = db_result($result, 0, 'bug_id');
00264 Header("Location: ".$GLOBALS['sys_home'].$type_of_search."/?func=detailitem&item_id=$bug");
00265 }
00266 else
00267 {
00268
00269 if ( $rows_returned > $GLOBALS['max_rows'])
00270 { $rows = $GLOBALS['max_rows']; }
00271
00272 search_send_header();
00273
00274 $title_arr = array();
00275 $title_arr[] = _("Item Id");
00276 $title_arr[] = _("Item Summary");
00277 $title_arr[] = _("Group");
00278 $title_arr[] = _("Submitted By");
00279 $title_arr[] = _("Date");
00280
00281 print html_build_list_table_top ($title_arr);
00282
00283 print "\n";
00284
00285 $j;
00286 for ( $i = 0; $i < $rows; $i++ )
00287 {
00288 # Do even show private item
00289 if (db_result($result, $i, 'privacy') == "2" &&
00290 !member_check_private(0, $group_id) &&
00291 db_result($result,$i,'user_name') != user_getname())
00292 {
00293 dbg("Private item.");
00294 }
00295 else
00296 {
00297
00298 $url = $GLOBALS['sys_home'].$type_of_search."/?func=detailitem&item_id=".db_result($result, $i, "bug_id");
00299
00300 print '<tr class="'.html_get_alt_row_color($j).'">'
00301 . '<td><a href="'.$url.'">#'.db_result($result, $i, "bug_id").'</a></td>'
00302 . '<td><a href="'.$url.'">'.db_result($result, $i, "summary").'</a></td>'
00303 . '<td><a href="'.$url.'">'.group_getname(db_result($result, $i, "group_id")).'</a></td>'
00304 . "<td>".utils_user_link(db_result($result, $i, "user_name"))."</td>"
00305 . "<td>".format_date($sys_datefmt,db_result($result,$i,"date"))."</td></tr>";
00306 $j++;
00307 }
00308 }
00309 print "</table>\n";
00310 }
00311 }
00312 else
00313 {
00314 search_send_header();
00315 print '<h2 class="error">'._("Error").' - '._("Invalid Search!!").'</h1>';
00316
00317 }
00318
00319 # Print prev/next links
00320 $nextprev_url = $GLOBALS['sys_home']."search/?type_of_search=$type_of_search&words=".urlencode($words);
00321 if (isset($type))
00322 { $nextprev_url .= "&type=$type"; }
00323 if ($group_id)
00324 { $nextprev_url .= "&only_group_id=$group_id"; }
00325
00326 html_nextprev($nextprev_url,$rows,$rows_returned);
00327
00328 site_footer(Array());
00329
00330 ?>