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 |
---|
19 | include_once( './include/init.inc.php' ); |
---|
20 | //-------------------------------------------------- access authorization check |
---|
21 | check_login_authorization(); |
---|
22 | //----------------------------------------------------------------- redirection |
---|
23 | $error = array(); |
---|
24 | if ( 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 |
---|
59 | if ( 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 ); |
---|
83 | echo $code; |
---|
84 | //------------------------------------------------------------ log informations |
---|
85 | $query = 'insert into '.PREFIX_TABLE.'history'; |
---|
86 | $query.= '(date,login,IP,page) values'; |
---|
87 | $query.= "('".time()."', '".$user['pseudo']."','".$_SERVER['REMOTE_ADDR']."'"; |
---|
88 | $query.= ",'search');"; |
---|
89 | @mysql_query( $query ); |
---|
90 | ?> |
---|