1<?php 2// +-----------------------------------------------------------------------+ 3// | This file is part of Piwigo. | 4// | | 5// | For copyright and license information, please view the COPYING.txt | 6// | file that was distributed with this source code. | 7// +-----------------------------------------------------------------------+ 8 9define('PHPWG_ROOT_PATH','./'); 10include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); 11 12// +-----------------------------------------------------------------------+ 13// | Check Access and exit when user status is not ok | 14// +-----------------------------------------------------------------------+ 15check_status(ACCESS_GUEST); 16 17if (empty($_GET['q'])) 18{ 19 redirect( make_index_url() ); 20} 21 22$search = array(); 23$search['q']=$_GET['q']; 24 25$query = ' 26SElECT id FROM '.SEARCH_TABLE.' 27 WHERE rules = \''.addslashes(serialize($search)).'\' 28;'; 29$search_id = array_from_query( $query, 'id'); 30if ( !empty($search_id) ) 31{ 32 $search_id = $search_id[0]; 33 $query = ' 34UPDATE '.SEARCH_TABLE.' 35 SET last_seen=NOW() 36 WHERE id='.$search_id; 37 pwg_query($query); 38} 39else 40{ 41 $query =' 42INSERT INTO '.SEARCH_TABLE.' 43 (rules, last_seen) 44 VALUES 45 (\''.addslashes(serialize($search)).'\', NOW() ) 46;'; 47 pwg_query($query); 48 $search_id = pwg_db_insert_id(SEARCH_TABLE); 49} 50 51redirect( 52 make_index_url( 53 array( 54 'section' => 'search', 55 'search' => $search_id, 56 ) 57 ) 58 ); 59?>