2003-05-09 14:42:42 +02:00
|
|
|
<?php
|
2004-02-07 20:36:44 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
2004-11-06 22:12:59 +01:00
|
|
|
// | PhpWebGallery - a PHP based picture gallery |
|
|
|
|
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
2005-01-08 00:10:51 +01:00
|
|
|
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
2004-02-07 20:36:44 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
2004-11-06 22:12:59 +01:00
|
|
|
// | branch : BSF (Best So Far)
|
2004-02-07 20:36:44 +01:00
|
|
|
// | file : $RCSfile$
|
|
|
|
// | last update : $Date$
|
|
|
|
// | last modifier : $Author$
|
|
|
|
// | revision : $Revision$
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | This program is free software; you can redistribute it and/or modify |
|
|
|
|
// | it under the terms of the GNU General Public License as published by |
|
|
|
|
// | the Free Software Foundation |
|
|
|
|
// | |
|
|
|
|
// | This program is distributed in the hope that it will be useful, but |
|
|
|
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
|
// | General Public License for more details. |
|
|
|
|
// | |
|
|
|
|
// | You should have received a copy of the GNU General Public License |
|
|
|
|
// | along with this program; if not, write to the Free Software |
|
|
|
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
|
|
|
// | USA. |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2003-05-09 14:42:42 +02:00
|
|
|
|
2004-07-26 22:43:46 +02:00
|
|
|
//--------------------------------------------------------------------- include
|
2004-02-19 01:31:09 +01:00
|
|
|
define('PHPWG_ROOT_PATH','./');
|
|
|
|
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
|
2006-03-09 23:46:28 +01:00
|
|
|
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | Check Access and exit when user status is not ok |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
check_status(ACCESS_GUEST);
|
|
|
|
|
2004-07-26 22:43:46 +02:00
|
|
|
//------------------------------------------------------------------ form check
|
|
|
|
$errors = array();
|
|
|
|
$search = array();
|
|
|
|
if (isset($_POST['submit']))
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-12-05 12:47:40 +01:00
|
|
|
if (isset($_POST['search_allwords'])
|
|
|
|
and !preg_match('/^\s*$/', $_POST['search_allwords']))
|
2006-02-28 05:28:06 +01:00
|
|
|
{
|
2004-12-05 12:47:40 +01:00
|
|
|
$drop_char_match = array(
|
|
|
|
'-','^','$',';','#','&','(',')','<','>','`','\'','"','|',',','@','_',
|
|
|
|
'?','%','~','.','[',']','{','}',':','\\','/','=','\'','!','*');
|
|
|
|
$drop_char_replace = array(
|
|
|
|
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','','',' ',' ',' ',' ','',' ',
|
|
|
|
' ',' ',' ',' ',' ',' ',' ',' ','' ,' ',' ',' ',' ',' ');
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-12-05 12:47:40 +01:00
|
|
|
// Split words
|
2006-01-20 15:34:37 +01:00
|
|
|
$search['fields']['allwords'] = array(
|
|
|
|
'words' => array_unique(
|
|
|
|
preg_split(
|
|
|
|
'/\s+/',
|
|
|
|
str_replace(
|
|
|
|
$drop_char_match,
|
|
|
|
$drop_char_replace,
|
|
|
|
$_POST['search_allwords']
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'mode' => $_POST['mode'],
|
|
|
|
);
|
2004-07-26 22:43:46 +02:00
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2006-04-03 00:26:19 +02:00
|
|
|
if (isset($_POST['tags']))
|
|
|
|
{
|
|
|
|
$search['fields']['tags'] = array(
|
|
|
|
'words' => $_POST['tags'],
|
|
|
|
'mode' => $_POST['tag_mode'],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2004-11-25 15:12:33 +01:00
|
|
|
if ($_POST['search_author'])
|
2004-07-26 22:43:46 +02:00
|
|
|
{
|
2006-01-20 15:34:37 +01:00
|
|
|
$search['fields']['author'] = array(
|
2006-01-27 23:40:51 +01:00
|
|
|
'words' => preg_split(
|
|
|
|
'/\s+/',
|
|
|
|
$_POST['search_author']
|
|
|
|
),
|
|
|
|
'mode' => 'OR',
|
2006-01-20 15:34:37 +01:00
|
|
|
);
|
2003-05-25 10:31:39 +02:00
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-11-25 15:12:33 +01:00
|
|
|
if (isset($_POST['cat']))
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2006-01-20 15:34:37 +01:00
|
|
|
$search['fields']['cat'] = array(
|
|
|
|
'words' => $_POST['cat'],
|
|
|
|
'sub_inc' => ($_POST['subcats-included'] == 1) ? true : false,
|
|
|
|
);
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2004-12-05 12:47:40 +01:00
|
|
|
|
|
|
|
// dates
|
|
|
|
$type_date = $_POST['date_type'];
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-11-25 15:12:33 +01:00
|
|
|
if (!empty($_POST['start_year']))
|
2004-12-05 12:47:40 +01:00
|
|
|
{
|
2006-01-20 15:34:37 +01:00
|
|
|
$search['fields'][$type_date.'-after'] = array(
|
|
|
|
'date' => join(
|
|
|
|
'-',
|
|
|
|
array(
|
|
|
|
$_POST['start_year'],
|
|
|
|
$_POST['start_month'] != 0 ? $_POST['start_month'] : '01',
|
|
|
|
$_POST['start_day'] != 0 ? $_POST['start_day'] : '01',
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'inc' => true,
|
|
|
|
);
|
2004-12-05 12:47:40 +01:00
|
|
|
}
|
2004-11-25 15:12:33 +01:00
|
|
|
|
2004-12-05 12:47:40 +01:00
|
|
|
if (!empty($_POST['end_year']))
|
2004-11-25 15:12:33 +01:00
|
|
|
{
|
2006-01-20 15:34:37 +01:00
|
|
|
$search['fields'][$type_date.'-before'] = array(
|
|
|
|
'date' => join(
|
|
|
|
'-',
|
|
|
|
array(
|
|
|
|
$_POST['end_year'],
|
|
|
|
$_POST['end_month'] != 0 ? $_POST['end_month'] : '12',
|
|
|
|
$_POST['end_day'] != 0 ? $_POST['end_day'] : '31',
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'inc' => true,
|
|
|
|
);
|
2004-11-25 15:12:33 +01:00
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-11-25 15:12:33 +01:00
|
|
|
if (!empty($search))
|
|
|
|
{
|
2006-01-20 15:34:37 +01:00
|
|
|
// default search mode : each clause must be respected
|
|
|
|
$search['mode'] = 'AND';
|
|
|
|
|
|
|
|
// register search rules in database, then they will be available on
|
|
|
|
// thumbnails page and picture page.
|
|
|
|
$query ='
|
|
|
|
INSERT INTO '.SEARCH_TABLE.'
|
|
|
|
(rules)
|
|
|
|
VALUES
|
|
|
|
(\''.serialize($search).'\')
|
|
|
|
;';
|
|
|
|
pwg_query($query);
|
|
|
|
|
|
|
|
$search_id = mysql_insert_id();
|
2004-11-25 15:12:33 +01:00
|
|
|
}
|
|
|
|
else
|
2004-07-26 22:43:46 +02:00
|
|
|
{
|
|
|
|
array_push($errors, $lang['search_one_clause_at_least']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//----------------------------------------------------------------- redirection
|
|
|
|
if (isset($_POST['submit']) and count($errors) == 0)
|
|
|
|
{
|
2006-03-15 23:44:35 +01:00
|
|
|
redirect(
|
|
|
|
make_index_url(
|
|
|
|
array(
|
|
|
|
'section' => 'search',
|
|
|
|
'search' => $search_id,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
//----------------------------------------------------- template initialization
|
2004-11-25 15:12:33 +01:00
|
|
|
|
2004-12-05 12:47:40 +01:00
|
|
|
// start date
|
|
|
|
get_day_list('start_day', @$_POST['start_day']);
|
|
|
|
get_month_list('start_month', @$_POST['start_month']);
|
|
|
|
// end date
|
|
|
|
get_day_list('end_day', @$_POST['end_day']);
|
|
|
|
get_month_list('end_month', @$_POST['end_month']);
|
2004-11-25 15:12:33 +01:00
|
|
|
|
2004-02-02 01:55:18 +01:00
|
|
|
//
|
|
|
|
// Start output of page
|
|
|
|
//
|
|
|
|
$title= $lang['search_title'];
|
- new : HTML BODY identifier to let CSS stylesheets manage specific
behaviour.
- deletion : admin/search useless
- improvement : in admin/user_list, special behaviour for true/false fields
(expand, show_comments)
- new : gallery_title and gallery_description are displayed at the top of
each page.
- improvement : simplification in HTML for categories menu.
- improvement : standardization of presentation in all public pages
(identification, registration, search, profile, notification, comments,
etc.)
(not in ChangeLog, below this line)
- add forgotten notification.php (should have been added in a previous
commit)
- [template cclear] deletion of useless class .bouton
- [template cclear] for test purpose, new presentation of register page
(using FORM.filter)
- [template cclear] adaptation of admin/group_list from template default
- [template cclear] deletion of obsolete admin/infos_images
- [template cclear] deletion of obsolete admin/search_username
- [template cclear] new icon register.png
git-svn-id: http://piwigo.org/svn/trunk@850 68402e56-0260-453c-a942-63ccdbb3a9ee
2005-08-26 00:43:47 +02:00
|
|
|
$page['body_id'] = 'theSearchPage';
|
2004-02-22 03:43:13 +01:00
|
|
|
include(PHPWG_ROOT_PATH.'include/page_header.php');
|
2004-02-02 01:55:18 +01:00
|
|
|
|
2004-02-08 02:28:18 +01:00
|
|
|
$template->set_filenames( array('search'=>'search.tpl') );
|
|
|
|
$template->assign_vars(array(
|
2004-11-25 15:12:33 +01:00
|
|
|
'L_SEARCH_TITLE' => $lang['search_title'],
|
|
|
|
'L_SEARCH_OPTIONS' => $lang['search_options'],
|
2004-11-18 15:57:00 +01:00
|
|
|
'L_RETURN' => $lang['home'],
|
2004-02-08 02:28:18 +01:00
|
|
|
'L_SUBMIT' => $lang['submit'],
|
2004-11-25 15:12:33 +01:00
|
|
|
'L_RESET' => $lang['reset'],
|
|
|
|
'L_SEARCH_KEYWORDS'=>$lang['search_keywords'],
|
|
|
|
'L_SEARCH_ANY_TERMS'=>$lang['search_mode_or'],
|
|
|
|
'L_SEARCH_ALL_TERMS'=>$lang['search_mode_and'],
|
|
|
|
'L_SEARCH_AUTHOR'=>$lang['search_author'],
|
|
|
|
'L_SEARCH_AUTHOR_HINT'=>$lang['search_explain'],
|
|
|
|
'L_SEARCH_CATEGORIES'=>$lang['search_categories'],
|
|
|
|
'L_SEARCH_SUBFORUMS'=>$lang['search_subcats_included'],
|
|
|
|
'L_YES' => $lang['yes'],
|
|
|
|
'L_NO' => $lang['no'],
|
|
|
|
'L_SEARCH_DATE' => $lang['search_date'],
|
|
|
|
'L_TODAY' => $lang['today'],
|
|
|
|
'L_SEARCH_DATE_FROM'=>$lang['search_date_from'],
|
2004-12-02 13:45:57 +01:00
|
|
|
'L_SEARCH_DATE_TO'=>$lang['search_date_to'],
|
2004-11-25 15:12:33 +01:00
|
|
|
'L_DAYS'=>$lang['days'],
|
|
|
|
'L_MONTH'=>$lang['w_month'],
|
|
|
|
'L_SEARCH_DATE_TYPE'=>$lang['search_date_type'],
|
|
|
|
'L_RESULT_SORT'=>$lang['search_sort'],
|
|
|
|
'L_SORT_ASCENDING'=>$lang['search_ascending'],
|
|
|
|
'L_SORT_DESCENDING'=>$lang['search_descending'],
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-11-25 15:12:33 +01:00
|
|
|
'TODAY_DAY' => date('d', time()),
|
|
|
|
'TODAY_MONTH' => date('m', time()),
|
|
|
|
'TODAY_YEAR' => date('Y', time()),
|
2006-01-15 14:45:42 +01:00
|
|
|
'S_SEARCH_ACTION' => 'search.php',
|
- improvement: long localized messages are in HTML files instead of $lang
array. This is the case of admin/help and about pages.
- deletion: of unused functions (ts_to_mysqldt, is_image, TN_exists,
check_date_format, date_convert, get_category_directories,
get_used_metadata_list, array_remove, pwg_write_debug,
get_group_restrictions, get_all_group_restrictions, is_group_allowed,
style_select, deprecated_getAttribute).
- new: many new contextual help pages to replace descriptions previously
included in pages.
- modification: reorganisation of language files. Deletion of unused
language keys, alphabetical sort. No faq.lang.php anymore (replaced by
help.html). Only done for en_UK.iso-8859-1.
git-svn-id: http://piwigo.org/svn/trunk@862 68402e56-0260-453c-a942-63ccdbb3a9ee
2005-09-14 23:57:05 +02:00
|
|
|
'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=search',
|
2006-03-15 23:44:35 +01:00
|
|
|
'U_HOME' => make_index_url(),
|
2006-04-03 00:26:19 +02:00
|
|
|
|
|
|
|
'TAG_SELECTION' => get_html_tag_selection(
|
|
|
|
get_available_tags(
|
|
|
|
isset($user['forbidden_categories'])
|
|
|
|
? explode(',', $user['forbidden_categories'])
|
|
|
|
: null
|
|
|
|
),
|
|
|
|
'tags',
|
|
|
|
isset($_POST['tags']) ? $_POST['tags'] : array()
|
|
|
|
),
|
2004-02-08 02:28:18 +01:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2004-07-26 22:43:46 +02:00
|
|
|
//------------------------------------------------------------- categories form
|
2004-11-23 23:31:24 +01:00
|
|
|
$query = '
|
|
|
|
SELECT name,id,date_last,nb_images,global_rank,uppercats
|
|
|
|
FROM '.CATEGORIES_TABLE;
|
2004-12-05 12:47:40 +01:00
|
|
|
if ($user['forbidden_categories'] != '')
|
|
|
|
{
|
|
|
|
$query.= '
|
2004-11-23 23:31:24 +01:00
|
|
|
WHERE id NOT IN ('.$user['forbidden_categories'].')';
|
2004-12-05 12:47:40 +01:00
|
|
|
}
|
2004-11-23 23:31:24 +01:00
|
|
|
$query.= '
|
|
|
|
;';
|
2004-11-25 15:12:33 +01:00
|
|
|
|
2004-07-26 22:43:46 +02:00
|
|
|
$selecteds = array();
|
2004-11-23 23:31:24 +01:00
|
|
|
display_select_cat_wrapper($query, $selecteds, 'category_option', false);
|
2004-07-26 22:43:46 +02:00
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
//-------------------------------------------------------------- errors display
|
2004-07-26 22:43:46 +02:00
|
|
|
if (sizeof($errors) != 0)
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-02-08 02:28:18 +01:00
|
|
|
$template->assign_block_vars('errors',array());
|
2004-07-26 22:43:46 +02:00
|
|
|
foreach ($errors as $error)
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-07-26 22:43:46 +02:00
|
|
|
$template->assign_block_vars('errors.error',array('ERROR'=>$error));
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2003-05-25 10:31:39 +02:00
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
//------------------------------------------------------------ log informations
|
2004-02-02 01:55:18 +01:00
|
|
|
pwg_log( 'search', $title );
|
2005-01-13 11:18:49 +01:00
|
|
|
$template->parse('search');
|
2004-02-22 03:43:13 +01:00
|
|
|
include(PHPWG_ROOT_PATH.'include/page_tail.php');
|
2004-02-12 00:20:38 +01:00
|
|
|
?>
|