source: trunk/search.php @ 2

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

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1<?php
2/***************************************************************************
3 *                  search.php is a part of PhpWebGallery                  *
4 *                            -------------------                          *
5 *   last update          : Wednesday, July 25, 2002                       *
6 *   email                : pierrick@z0rglub.com                           *
7 *                                                                         *
8 ***************************************************************************/
9
10/***************************************************************************
11 *                                                                         *
12 *   This program is free software; you can redistribute it and/or modify  *
13 *   it under the terms of the GNU General Public License as published by  *
14 *   the Free Software Foundation;                                         *
15 *                                                                         *
16 ***************************************************************************/
17
18//----------------------------------------------------------- personnal include
19include_once( './include/init.inc.php' );
20//-------------------------------------------------- access authorization check
21check_login_authorization();
22//----------------------------------------------------------------- redirection
23$error = array();
24if ( isset( $_POST['search'] ) )
25{
26  $i = 0;
27  if ( strlen( $_POST['search'] ) > 2 )
28  {
29    $url = add_session_id( 'category.php?cat=search&search='.
30                           $_POST['search'], true );
31    header( 'Request-URI: '.$url );
32    header( 'Content-Location: '.$url ); 
33    header( 'Location: '.$url );
34    exit();
35  }
36  else
37  {
38    $error[$i++] = $lang['invalid_search'];
39  }
40}
41//----------------------------------------------------- template initialization
42$vtp = new VTemplate;
43$handle = $vtp->Open( './template/default/search.vtp' );
44// language
45$vtp->setGlobalVar( $handle, 'search_page_title',$lang['search_title'] );
46$vtp->setGlobalVar( $handle, 'search_title',     $lang['search_title'] );
47$vtp->setGlobalVar( $handle, 'search_return_main_page',
48                    $lang['search_return_main_page'] );
49$vtp->setGlobalVar( $handle, 'submit',           $lang['submit'] );
50// user
51$vtp->setGlobalVar( $handle, 'page_style',       $user['style'] );
52// structure
53$vtp->setGlobalVar( $handle, 'frame_start',      get_frame_start() );
54$vtp->setGlobalVar( $handle, 'frame_begin',      get_frame_begin() );
55$vtp->setGlobalVar( $handle, 'frame_end',        get_frame_end() );
56//----------------------------------------------------------------- form action
57$vtp->setGlobalVar( $handle, 'form_action', add_session_id( './search.php' ) );
58//-------------------------------------------------------------- errors display
59if ( sizeof( $error ) != 0 )
60{
61  $vtp->addSession( $handle, 'errors' );
62  for ( $i = 0; $i < sizeof( $error ); $i++ )
63  {
64    $vtp->addSession( $handle, 'li' );
65    $vtp->setVar( $handle, 'li.li', $error[$i] );
66    $vtp->closeSession( $handle, 'li' );
67  }
68  $vtp->closeSession( $handle, 'errors' );
69}
70//---------------------------------------------------------------- search field
71$vtp->addSession( $handle, 'line' );
72$vtp->setVar( $handle, 'line.name', $lang['search_field_search'] );
73$vtp->addSession( $handle, 'text' );
74$vtp->setVar( $handle, 'text.size', '40' );
75$vtp->setVar( $handle, 'text.name', 'search' );
76$vtp->setVar( $handle, 'text.value', $_POST['search'] );
77$vtp->closeSession( $handle, 'text' );
78$vtp->closeSession( $handle, 'line' );
79//---------------------------------------------------- return to main page link
80$vtp->setGlobalVar( $handle, 'back_url', add_session_id( './category.php' ) );
81//----------------------------------------------------------- html code display
82$code = $vtp->Display( $handle, 0 );
83echo $code;
84//------------------------------------------------------------ log informations
85$query = 'insert into '.$prefixeTable.'history';
86$query.= '(date,login,IP,page) values';
87$query.= "('".time()."', '".$user['pseudo']."','".$_SERVER['REMOTE_ADDR']."'";
88$query.= ",'search');";
89@mysql_query( $query );
90?>
Note: See TracBrowser for help on using the repository browser.