6 |
kaklik |
1 |
<?php
|
|
|
2 |
// +-----------------------------------------------------------------------+
|
|
|
3 |
// | PhpWebGallery - a PHP based picture gallery |
|
|
|
4 |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
|
|
5 |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
|
|
6 |
// +-----------------------------------------------------------------------+
|
|
|
7 |
// | branch : BSF (Best So Far)
|
|
|
8 |
// | file : $RCSfile: search.php,v $
|
|
|
9 |
// | last update : $Date: 2005/01/13 10:18:49 $
|
|
|
10 |
// | last modifier : $Author: plg $
|
|
|
11 |
// | revision : $Revision: 1.8 $
|
|
|
12 |
// +-----------------------------------------------------------------------+
|
|
|
13 |
// | This program is free software; you can redistribute it and/or modify |
|
|
|
14 |
// | it under the terms of the GNU General Public License as published by |
|
|
|
15 |
// | the Free Software Foundation |
|
|
|
16 |
// | |
|
|
|
17 |
// | This program is distributed in the hope that it will be useful, but |
|
|
|
18 |
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
19 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
20 |
// | General Public License for more details. |
|
|
|
21 |
// | |
|
|
|
22 |
// | You should have received a copy of the GNU General Public License |
|
|
|
23 |
// | along with this program; if not, write to the Free Software |
|
|
|
24 |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
|
|
25 |
// | USA. |
|
|
|
26 |
// +-----------------------------------------------------------------------+
|
|
|
27 |
|
|
|
28 |
define('PHPWG_ROOT_PATH','../');
|
|
|
29 |
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
|
|
|
30 |
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
|
|
|
31 |
|
|
|
32 |
//----------------------------------------------------- template initialization
|
|
|
33 |
$title = $lang['Find_username'];
|
|
|
34 |
include(PHPWG_ROOT_PATH.'include/page_header.php');
|
|
|
35 |
|
|
|
36 |
$template->set_filenames( array('search'=>'admin/search_username.tpl') );
|
|
|
37 |
$template->assign_vars(array(
|
|
|
38 |
'USERNAME'=>( !empty($search_match) ) ? strip_tags($search_match) : '',
|
|
|
39 |
|
|
|
40 |
'L_SEARCH_USERNAME'=>$lang['Find_username'],
|
|
|
41 |
'L_SEARCH'=>$lang['search'],
|
|
|
42 |
'L_SEARCH_EXPLAIN'=>$lang['search_explain'],
|
|
|
43 |
'L_SELECT'=>$lang['Select'],
|
|
|
44 |
'L_UPDATE_USERNAME'=>$lang['Look_up_user'],
|
|
|
45 |
'L_CLOSE_WINDOW'=>$lang['Close'],
|
|
|
46 |
|
|
|
47 |
'F_SEARCH_ACTION' => add_session_id($_SERVER['PHP_SELF']),
|
|
|
48 |
));
|
|
|
49 |
|
|
|
50 |
//----------------------------------------------------------------- form action
|
|
|
51 |
//
|
|
|
52 |
// Define initial vars
|
|
|
53 |
//
|
|
|
54 |
if ( isset($_POST['mode']) || isset($_GET['mode']) )
|
|
|
55 |
{
|
|
|
56 |
$mode = ( isset($_POST['mode']) ) ? $_POST['mode'] : $_GET['mode'];
|
|
|
57 |
}
|
|
|
58 |
else
|
|
|
59 |
{
|
|
|
60 |
$mode = '';
|
|
|
61 |
}
|
|
|
62 |
$search_match = '';
|
|
|
63 |
if ( isset($_POST['search_username']) )
|
|
|
64 |
{
|
|
|
65 |
$search_match = $_POST['search_username'];
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
$username_list = '';
|
|
|
69 |
if ( !empty($search_match) )
|
|
|
70 |
{
|
|
|
71 |
$username_search = preg_replace('/\*/', '%', trim(strip_tags($search_match)));
|
|
|
72 |
|
|
|
73 |
$sql = "SELECT username
|
|
|
74 |
FROM " . USERS_TABLE . "
|
|
|
75 |
WHERE username LIKE '" . str_replace("\'", "''", $username_search) . "'
|
|
|
76 |
AND id <> ".ANONYMOUS."
|
|
|
77 |
ORDER BY username";
|
|
|
78 |
if ( !($result = pwg_query($sql)) )
|
|
|
79 |
{
|
|
|
80 |
die('Could not obtain search results');
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
if ( $row = mysql_fetch_array($result) )
|
|
|
84 |
{
|
|
|
85 |
do
|
|
|
86 |
{
|
|
|
87 |
$username_list .= '<option value="' . $row['username'] . '">' . $row['username'] . '</option>';
|
|
|
88 |
}
|
|
|
89 |
while ( $row = mysql_fetch_array($result) );
|
|
|
90 |
}
|
|
|
91 |
else
|
|
|
92 |
{
|
|
|
93 |
$username_list .= '<option>' . $lang['No_match']. '</option>';
|
|
|
94 |
}
|
|
|
95 |
mysql_free_result($result);
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
//------------------------------------------------------------------ users list
|
|
|
99 |
if ( !empty($username_list))
|
|
|
100 |
{
|
|
|
101 |
$template->assign_block_vars('switch_select_name', array(
|
|
|
102 |
'F_USERNAME_OPTIONS'=>$username_list
|
|
|
103 |
));
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
$template->parse('search');
|
|
|
107 |
include(PHPWG_ROOT_PATH.'include/page_tail.php');
|
|
|
108 |
?>
|