2 /***************************************************************************
5 * begin : Tuesday, Oct 05, 2001
6 * copyright : (C) 2001 The phpBB Group
7 * email : support@phpbb.com
9 * $Id: admin_disallow.php,v 1.9.2.2 2002/11/26 11:42:11 psotfx Exp $
12 ***************************************************************************/
14 /***************************************************************************
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 ***************************************************************************/
23 define('IN_PHPBB', 1);
25 if( !empty($setmodules) )
27 $filename = basename(__FILE__);
28 $module['Users']['Disallow'] = append_sid($filename);
34 // Include required files, get $phpEx and check permissions
36 $phpbb_root_path = "./../";
37 require($phpbb_root_path . 'extension.inc');
38 require('./pagestart.' . $phpEx);
40 if( isset($HTTP_POST_VARS['add_name']) )
42 include($phpbb_root_path . 'includes/functions_validate.'.$phpEx);
44 $disallowed_user = ( isset($HTTP_POST_VARS['disallowed_user']) ) ? trim($HTTP_POST_VARS['disallowed_user']) : trim($HTTP_GET_VARS['disallowed_user']);
46 if ($disallowed_user == '')
48 message_die(MESSAGE, $lang['Fields_empty']);
50 if( !validate_username($disallowed_user) )
52 $message = $lang['Disallowed_already'];
56 $sql = "INSERT INTO " . DISALLOW_TABLE . " (disallow_username)
57 VALUES('" . str_replace("\'", "''", $disallowed_user) . "')";
58 $result = $db->sql_query( $sql );
61 message_die(GENERAL_ERROR, "Could not add disallowed user.", "",__LINE__, __FILE__, $sql);
63 $message = $lang['Disallow_successful'];
66 $message .= "<br /><br />" . sprintf($lang['Click_return_disallowadmin'], "<a href=\"" . append_sid("admin_disallow.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");
68 message_die(GENERAL_MESSAGE, $message);
70 else if( isset($HTTP_POST_VARS['delete_name']) )
72 $disallowed_id = ( isset($HTTP_POST_VARS['disallowed_id']) ) ? intval( $HTTP_POST_VARS['disallowed_id'] ) : intval( $HTTP_GET_VARS['disallowed_id'] );
74 $sql = "DELETE FROM " . DISALLOW_TABLE . "
75 WHERE disallow_id = $disallowed_id";
76 $result = $db->sql_query($sql);
79 message_die(GENERAL_ERROR, "Couldn't removed disallowed user.", "",__LINE__, __FILE__, $sql);
82 $message .= $lang['Disallowed_deleted'] . "<br /><br />" . sprintf($lang['Click_return_disallowadmin'], "<a href=\"" . append_sid("admin_disallow.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");
84 message_die(GENERAL_MESSAGE, $message);
89 // Grab the current list of disallowed usernames...
92 FROM " . DISALLOW_TABLE;
93 $result = $db->sql_query($sql);
96 message_die(GENERAL_ERROR, "Couldn't get disallowed users.", "", __LINE__, __FILE__, $sql );
99 $disallowed = $db->sql_fetchrowset($result);
102 // Ok now generate the info for the template, which will be put out no matter
103 // what mode we are in.
105 $disallow_select = '<select name="disallowed_id">';
107 if( trim($disallowed) == "" )
109 $disallow_select .= '<option value="">' . $lang['no_disallowed'] . '</option>';
114 for( $i = 0; $i < count($disallowed); $i++ )
116 $disallow_select .= '<option value="' . $disallowed[$i]['disallow_id'] . '">' . $disallowed[$i]['disallow_username'] . '</option>';
120 $disallow_select .= '</select>';
122 $template->set_filenames(array(
123 "body" => "admin/disallow_body.tpl")
126 $template->assign_vars(array(
127 "S_DISALLOW_SELECT" => $disallow_select,
128 "S_FORM_ACTION" => append_sid("admin_disallow.$phpEx"),
130 "L_INFO" => $output_info,
131 "L_DISALLOW_TITLE" => $lang['Disallow_control'],
132 "L_DISALLOW_EXPLAIN" => $lang['Disallow_explain'],
133 "L_DELETE" => $lang['Delete_disallow'],
134 "L_DELETE_DISALLOW" => $lang['Delete_disallow_title'],
135 "L_DELETE_EXPLAIN" => $lang['Delete_disallow_explain'],
136 "L_ADD" => $lang['Add_disallow'],
137 "L_ADD_DISALLOW" => $lang['Add_disallow_title'],
138 "L_ADD_EXPLAIN" => $lang['Add_disallow_explain'],
139 "L_USERNAME" => $lang['Username'])
142 $template->pparse("body");
144 include('./page_footer_admin.'.$phpEx);