source: trunk/admin/search.php @ 607

Last change on this file since 607 was 593, checked in by z0rglub, 20 years ago

update headers to comply with GPL

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
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-2004 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2004-11-06 21:12:59 +0000 (Sat, 06 Nov 2004) $
10// | last modifier : $Author: z0rglub $
11// | revision      : $Revision: 593 $
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
28define('PHPWG_ROOT_PATH','../');
29include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
30include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
31
32//----------------------------------------------------- template initialization
33$title = $lang['Find_username'];
34include(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_author_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($PHP_SELF),
48  ));
49
50//----------------------------------------------------------------- form action
51//
52// Define initial vars
53//
54if ( isset($_POST['mode']) || isset($_GET['mode']) )
55{
56  $mode = ( isset($_POST['mode']) ) ? $_POST['mode'] : $_GET['mode'];
57}
58else
59{
60  $mode = '';
61}
62$search_match = ''; 
63if ( isset($_POST['search_username']) )
64{
65  $search_match = $_POST['search_username'];
66}
67 
68$username_list = '';
69if ( !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    ORDER BY username";
77  if ( !($result = pwg_query($sql)) )
78  {
79    die('Could not obtain search results');
80  }
81 
82  if ( $row = mysql_fetch_array($result) )
83  {
84    do
85    {
86    $username_list .= '<option value="' . $row['username'] . '">' . $row['username'] . '</option>';
87    }
88    while ( $row = mysql_fetch_array($result) );
89  }
90  else
91  {
92    $username_list .= '<option>' . $lang['No_match']. '</option>';
93  }
94  mysql_free_result($result);
95}
96 
97//------------------------------------------------------------------ users list
98if ( !empty($username_list))
99{
100  $template->assign_block_vars('switch_select_name', array(
101    'F_USERNAME_OPTIONS'=>$username_list
102    ));
103}
104
105$template->pparse('search');
106include(PHPWG_ROOT_PATH.'include/page_tail.php');
107?>
Note: See TracBrowser for help on using the repository browser.