1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based picture gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | // +-----------------------------------------------------------------------+ |
---|
24 | // | PhpWebGallery - a PHP based picture gallery | |
---|
25 | // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | |
---|
26 | // +-----------------------------------------------------------------------+ |
---|
27 | // | file : $Id: qsearch.php 2297 2008-04-04 22:57:23Z plg $ |
---|
28 | // | last update : $Date: 2008-04-04 22:57:23 +0000 (Fri, 04 Apr 2008) $ |
---|
29 | // | last modifier : $Author: plg $ |
---|
30 | // | revision : $Revision: 2297 $ |
---|
31 | // +-----------------------------------------------------------------------+ |
---|
32 | // | This program is free software; you can redistribute it and/or modify | |
---|
33 | // | it under the terms of the GNU General Public License as published by | |
---|
34 | // | the Free Software Foundation | |
---|
35 | // | | |
---|
36 | // | This program is distributed in the hope that it will be useful, but | |
---|
37 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
38 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
39 | // | General Public License for more details. | |
---|
40 | // | | |
---|
41 | // | You should have received a copy of the GNU General Public License | |
---|
42 | // | along with this program; if not, write to the Free Software | |
---|
43 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
44 | // | USA. | |
---|
45 | // +-----------------------------------------------------------------------+ |
---|
46 | |
---|
47 | define('PHPWG_ROOT_PATH','./'); |
---|
48 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
49 | |
---|
50 | // +-----------------------------------------------------------------------+ |
---|
51 | // | Check Access and exit when user status is not ok | |
---|
52 | // +-----------------------------------------------------------------------+ |
---|
53 | check_status(ACCESS_GUEST); |
---|
54 | |
---|
55 | if (empty($_GET['q'])) |
---|
56 | { |
---|
57 | redirect( make_index_url() ); |
---|
58 | } |
---|
59 | |
---|
60 | $search = array(); |
---|
61 | $search['q']=$_GET['q']; |
---|
62 | |
---|
63 | $query = ' |
---|
64 | SElECT id FROM '.SEARCH_TABLE.' |
---|
65 | WHERE rules = \''.addslashes(serialize($search)).'\' |
---|
66 | ;'; |
---|
67 | $search_id = array_from_query( $query, 'id'); |
---|
68 | if ( !empty($search_id) ) |
---|
69 | { |
---|
70 | $search_id = $search_id[0]; |
---|
71 | $query = ' |
---|
72 | UPDATE '.SEARCH_TABLE.' |
---|
73 | SET last_seen=NOW() |
---|
74 | WHERE id='.$search_id; |
---|
75 | pwg_query($query); |
---|
76 | } |
---|
77 | else |
---|
78 | { |
---|
79 | $query =' |
---|
80 | INSERT INTO '.SEARCH_TABLE.' |
---|
81 | (rules, last_seen) |
---|
82 | VALUES |
---|
83 | (\''.addslashes(serialize($search)).'\', NOW() ) |
---|
84 | ;'; |
---|
85 | pwg_query($query); |
---|
86 | $search_id = mysql_insert_id(); |
---|
87 | } |
---|
88 | |
---|
89 | redirect( |
---|
90 | make_index_url( |
---|
91 | array( |
---|
92 | 'section' => 'search', |
---|
93 | 'search' => $search_id, |
---|
94 | ) |
---|
95 | ) |
---|
96 | ); |
---|
97 | ?> |
---|