source: trunk/search.php @ 362

Last change on this file since 362 was 362, checked in by z0rglub, 21 years ago

header global refactoring

  • 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-02-11 23:20:38 +0000 (Wed, 11 Feb 2004) $
10// | last modifier : $Author: z0rglub $
11// | revision      : $Revision: 362 $
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
29$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('include/page_header.php');
70
71$template->set_filenames( array('search'=>'search.tpl') );
72initialize_template();
73
74$template->assign_vars(array(
75  'L_TITLE' => $lang['search_title'],
76  'L_COMMENTS' => $lang['search_comments'],
77  'L_RETURN' => $lang['search_return_main_page'],
78  'L_SUBMIT' => $lang['submit'],
79  'L_SEARCH'=>$lang['search_field_search'].' *',
80  'L_SEARCH_OR'=>$lang['search_mode_or'],
81  'L_SEARCH_AND'=>$lang['search_mode_and'],
82 
83  'F_ACTION' => add_session_id( 'search.php' ),
84  'F_TEXT_VALUE' => isset($_POST['search'])?$_POST['search']:'',
85   
86  'U_HOME' => add_session_id( 'category.php' )
87  )
88);
89
90//-------------------------------------------------------------- errors display
91if ( sizeof( $error ) != 0 )
92{
93  $template->assign_block_vars('errors',array());
94  for ( $i = 0; $i < sizeof( $error ); $i++ )
95  {
96    $template->assign_block_vars('errors.error',array('ERROR'=>$error[$i]));
97  }
98}
99//------------------------------------------------------------ log informations
100pwg_log( 'search', $title );
101mysql_close();
102$template->pparse('search');
103include('include/page_tail.php');
104?>
Note: See TracBrowser for help on using the repository browser.