source: trunk/search.php @ 393

Last change on this file since 393 was 393, checked in by gweltas, 20 years ago
  • Template migration
  • Admin Control Panel migration
  • Language migration
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// |                              search.php                               |
4// +-----------------------------------------------------------------------+
5// | application   : PhpWebGallery <http://phpwebgallery.net>              |
6// | branch        : BSF (Best So Far)                                     |
7// +-----------------------------------------------------------------------+
8// | file          : $RCSfile$
9// | last update   : $Date: 2004-03-20 00:52:37 +0000 (Sat, 20 Mar 2004) $
10// | last modifier : $Author: gweltas $
11// | revision      : $Revision: 393 $
12// +-----------------------------------------------------------------------+
13// | This program is free software; you can redistribute it and/or modify  |
14// | it under the terms of the GNU General Public License as published by  |
15// | the Free Software Foundation                                          |
16// |                                                                       |
17// | This program is distributed in the hope that it will be useful, but   |
18// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
19// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
20// | General Public License for more details.                              |
21// |                                                                       |
22// | You should have received a copy of the GNU General Public License     |
23// | along with this program; if not, write to the Free Software           |
24// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
25// | USA.                                                                  |
26// +-----------------------------------------------------------------------+
27
28//----------------------------------------------------------- include
29define('PHPWG_ROOT_PATH','./');
30include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
31//-------------------------------------------------- access authorization check
32check_login_authorization();
33//----------------------------------------------------------------- redirection
34$error = array();
35if ( isset( $_POST['search'] ) )
36{
37  $redirect = true;
38  $search = array();
39  $words = preg_split( '/\s+/', $_POST['search'] );
40  foreach ( $words as $i => $word ) {
41    if ( strlen( $word ) > 2 and !preg_match( '/[,;:\']/', $word ) )
42    {
43      array_push( $search, $word );
44    }
45    else
46    {
47      $redirect = false;
48      array_push( $error, $lang['invalid_search'] );
49      break;
50    }
51  }
52  $search = array_unique( $search );
53  $search = implode( ',', $search );
54  if ( $redirect )
55  {
56    $url = 'category.php?cat=search&search='.$search.'&mode='.$_POST['mode'];
57    $url = add_session_id( $url, true );
58    header( 'Request-URI: '.$url );
59    header( 'Content-Location: '.$url ); 
60    header( 'Location: '.$url );
61    exit();
62  }
63}
64//----------------------------------------------------- template initialization
65//
66// Start output of page
67//
68$title= $lang['search_title'];
69include(PHPWG_ROOT_PATH.'include/page_header.php');
70
71$template->set_filenames( array('search'=>'search.tpl') );
72$template->assign_vars(array(
73  'L_TITLE' => $lang['search_title'],
74  'L_COMMENTS' => $lang['search_comments'],
75  'L_RETURN' => $lang['search_return_main_page'],
76  'L_SUBMIT' => $lang['submit'],
77  'L_SEARCH'=>$lang['search_field_search'].' *',
78  'L_SEARCH_OR'=>$lang['search_mode_or'],
79  'L_SEARCH_AND'=>$lang['search_mode_and'],
80 
81  'F_ACTION' => add_session_id( 'search.php' ),
82  'F_TEXT_VALUE' => isset($_POST['search'])?$_POST['search']:'',
83   
84  'U_HOME' => add_session_id( 'category.php' )
85  )
86);
87
88//-------------------------------------------------------------- errors display
89if ( sizeof( $error ) != 0 )
90{
91  $template->assign_block_vars('errors',array());
92  for ( $i = 0; $i < sizeof( $error ); $i++ )
93  {
94    $template->assign_block_vars('errors.error',array('ERROR'=>$error[$i]));
95  }
96}
97//------------------------------------------------------------ log informations
98pwg_log( 'search', $title );
99mysql_close();
100$template->pparse('search');
101include(PHPWG_ROOT_PATH.'include/page_tail.php');
102?>
Note: See TracBrowser for help on using the repository browser.