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