summaryrefslogtreecommitdiffstats
path: root/cmd/pxe.c
blob: 46ac08fa3a031b61688dae7a34da41c74333d165 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright 2010-2011 Calxeda, Inc.
 * Copyright (c) 2014, NVIDIA CORPORATION.  All rights reserved.
 */

#include <common.h>
#include <command.h>
#include <fs.h>
#include <net.h>

#include "pxe_utils.h"

#ifdef CONFIG_CMD_NET
const char *pxe_default_paths[] = {
#ifdef CONFIG_SYS_SOC
#ifdef CONFIG_SYS_BOARD
	"default-" CONFIG_SYS_ARCH "-" CONFIG_SYS_SOC "-" CONFIG_SYS_BOARD,
#endif
	"default-" CONFIG_SYS_ARCH "-" CONFIG_SYS_SOC,
#endif
	"default-" CONFIG_SYS_ARCH,
	"default",
	NULL
};

static int do_get_tftp(struct cmd_tbl *cmdtp, const char *file_path,
		       char *file_addr)
{
	char *tftp_argv[] = {"tftp", NULL, NULL, NULL};

	tftp_argv[1] = file_addr;
	tftp_argv[2] = (void *)file_path;

	if (do_tftpb(cmdtp, 0, 3, tftp_argv))
		return -ENOENT;

	return 1;
}

/*
 * Looks for a pxe file with a name based on the pxeuuid environment variable.
 *
 * Returns 1 on success or < 0 on error.
 */
static int pxe_uuid_path(struct cmd_tbl *cmdtp, unsigned long pxefile_addr_r)
{
	char *uuid_str;

	uuid_str = from_env("pxeuuid");

	if (!uuid_str)
		return -ENOENT;

	return get_pxelinux_path(cmdtp, uuid_str, pxefile_addr_r);
}

/*
 * Looks for a pxe file with a name based on the 'ethaddr' environment
 * variable.
 *
 * Returns 1 on success or < 0 on error.
 */
static int pxe_mac_path(struct cmd_tbl *cmdtp, unsigned long pxefile_addr_r)
{
	char mac_str[21];
	int err;

	err = format_mac_pxe(mac_str, sizeof(mac_str));

	if (err < 0)
		return err;

	return get_pxelinux_path(cmdtp, mac_str, pxefile_addr_r);
}

/*
 * Looks for pxe files with names based on our IP address. See pxelinux
 * documentation for details on what these file names look like.  We match
 * that exactly.
 *
 * Returns 1 on success or < 0 on error.
 */
static int pxe_ipaddr_paths(struct cmd_tbl *cmdtp, unsigned long pxefile_addr_r)
{
	char ip_addr[9];
	int mask_pos, err;

	sprintf(ip_addr, "%08X", ntohl(net_ip.s_addr));

	for (mask_pos = 7; mask_pos >= 0;  mask_pos--) {
		err = get_pxelinux_path(cmdtp, ip_addr, pxefile_addr_r);

		if (err > 0)
			return err;

		ip_addr[mask_pos] = '\0';
	}

	return -ENOENT;
}
/*
 * Entry point for the 'pxe get' command.
 * This Follows pxelinux's rules to download a config file from a tftp server.
 * The file is stored at the location given by the pxefile_addr_r environment
 * variable, which must be set.
 *
 * UUID comes from pxeuuid env variable, if defined
 * MAC addr comes from ethaddr env variable, if defined
 * IP
 *
 * see http://syslinux.zytor.com/wiki/index.php/PXELINUX
 *
 * Returns 0 on success or 1 on error.
 */
static int
do_pxe_get(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
	char *pxefile_addr_str;
	unsigned long pxefile_addr_r;
	int err, i = 0;

	do_getfile = do_get_tftp;

	if (argc != 1)
		return CMD_RET_USAGE;

	pxefile_addr_str = from_env("pxefile_addr_r");

	if (!pxefile_addr_str)
		return 1;

	err = strict_strtoul(pxefile_addr_str, 16,
			     (unsigned long *)&pxefile_addr_r);
	if (err < 0)
		return 1;

	/*
	 * Keep trying paths until we successfully get a file we're looking
	 * for.
	 */
	if (pxe_uuid_path(cmdtp, pxefile_addr_r) > 0 ||
	    pxe_mac_path(cmdtp, pxefile_addr_r) > 0 ||
	    pxe_ipaddr_paths(cmdtp, pxefile_addr_r) > 0) {
		printf("Config file found\n");

		return 0;
	}

	while (pxe_default_paths[i]) {
		if (get_pxelinux_path(cmdtp, pxe_default_paths[i],
				      pxefile_addr_r) > 0) {
			printf("Config file found\n");
			return 0;
		}
		i++;
	}

	printf("Config file not found\n");

	return 1;
}

/*
 * Boots a system using a pxe file
 *
 * Returns 0 on success, 1 on error.
 */
static int
do_pxe_boot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
	unsigned long pxefile_addr_r;
	struct pxe_menu *cfg;
	char *pxefile_addr_str;

	do_getfile = do_get_tftp;

	if (argc == 1) {
		pxefile_addr_str = from_env("pxefile_addr_r");
		if (!pxefile_addr_str)
			return 1;

	} else if (argc == 2) {
		pxefile_addr_str = argv[1];
	} else {
		return CMD_RET_USAGE;
	}

	if (strict_strtoul(pxefile_addr_str, 16, &pxefile_addr_r) < 0) {
		printf("Invalid pxefile address: %s\n", pxefile_addr_str);
		return 1;
	}

	cfg = parse_pxefile(cmdtp, pxefile_addr_r);

	if (!cfg) {
		printf("Error parsing config file\n");
		return 1;
	}

	handle_pxe_menu(cmdtp, cfg);

	destroy_pxe_menu(cfg);

	copy_filename(net_boot_file_name, "", sizeof(net_boot_file_name));

	return 0;
}

static struct cmd_tbl cmd_pxe_sub[] = {
	U_BOOT_CMD_MKENT(get, 1, 1, do_pxe_get, "", ""),
	U_BOOT_CMD_MKENT(boot, 2, 1, do_pxe_boot, "", "")
};

static void __maybe_unused pxe_reloc(void)
{
	static int relocated_pxe;

	if (!relocated_pxe) {
		fixup_cmdtable(cmd_pxe_sub, ARRAY_SIZE(cmd_pxe_sub));
		relocated_pxe = 1;
	}
}

static int do_pxe(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
	struct cmd_tbl *cp;

#if defined(CONFIG_NEEDS_MANUAL_RELOC)
	pxe_reloc();
#endif

	if (argc < 2)
		return CMD_RET_USAGE;

	is_pxe = true;

	/* drop initial "pxe" arg */
	argc--;
	argv++;

	cp = find_cmd_tbl(argv[0], cmd_pxe_sub, ARRAY_SIZE(cmd_pxe_sub));

	if (cp)
		return cp->cmd(cmdtp, flag, argc, argv);

	return CMD_RET_USAGE;
}

U_BOOT_CMD(pxe, 3, 1, do_pxe,
	   "commands to get and boot from pxe files",
	   "get - try to retrieve a pxe file using tftp\n"
	   "pxe boot [pxefile_addr_r] - boot from the pxe file at pxefile_addr_r\n"
);
#endif
= '".$wpdb->prefix."capabilities' $search_sql"; if ( !$_GET['update'] && !$this->search_term && !$this->raw_page && $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users, $wpdb->usermeta WHERE $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '".$wpdb->prefix."capabilities'") > $this->users_per_page ) $this->too_many_total_users = sprintf(__('Because this blog has more than %s users, they cannot all be shown on one page. Use the paging or search functionality in order to find the user you want to edit.'), $this->users_per_page); } function query() { global $wpdb; $this->results = $wpdb->get_col('SELECT ID ' . $this->query_from_where . $this->query_limit); if ( $this->results ) $this->total_users_for_query = $wpdb->get_var('SELECT COUNT(ID) ' . $this->query_from_where); // no limit else $this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!')); } function prepare_vars_for_template_usage() { $this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone } function do_paging() { if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results $prev_page = ( $this->page > 1) ? true : false; $next_page = ( ($this->page * $this->users_per_page) < $this->total_users_for_query ) ? true : false; $this->paging_text = ''; if ( $prev_page ) $this->paging_text .= '<p class="alignleft"><a href="' . add_query_arg(array('usersearch' => $this->search_term, 'userspage' => $this->page - 1), 'users.php?') . '">&laquo; Previous Page</a></p>'; if ( $next_page ) $this->paging_text .= '<p class="alignright"><a href="' . add_query_arg(array('usersearch' => $this->search_term, 'userspage' => $this->page + 1), 'users.php?') . '">Next Page &raquo;</a></p>'; if ( $prev_page || $next_page ) $this->paging_text .= '<br style="clear:both" />'; } } function get_results() { return $this->results; } function page_links() { echo $this->paging_text; } function results_are_paged() { if ( $this->paging_text ) return true; return false; } function is_search() { if ( $this->search_term ) return true; return false; } } switch ($action) { case 'promote': check_admin_referer('bulk-users'); if (empty($_POST['users'])) { header('Location: ' . $redirect); } if ( !current_user_can('edit_users') ) die(__('You can&#8217;t edit users.')); $userids = $_POST['users']; $update = 'promote'; foreach($userids as $id) { if ( ! current_user_can('edit_user', $id) ) die(__('You can&#8217;t edit that user.')); // The new role of the current user must also have edit_users caps if($id == $current_user->id && !$wp_roles->role_objects[$_POST['new_role']]->has_cap('edit_users')) { $update = 'err_admin_role'; continue; } $user = new WP_User($id); $user->set_role($_POST['new_role']); } header('Location: ' . add_query_arg('update', $update, $redirect)); break; case 'dodelete': die( "This function is disabled." ); check_admin_referer('delete-users'); if ( empty($_POST['users']) ) { header('Location: ' . $redirect); } if ( !current_user_can('delete_users') ) die(__('You can&#8217;t delete users.')); $userids = $_POST['users']; $update = 'del'; $delete_count = 0; foreach ( (array) $userids as $id) { if ( ! current_user_can('delete_user', $id) ) die(__('You can&#8217;t delete that user.')); if($id == $current_user->id) { $update = 'err_admin_del'; continue; } switch($_POST['delete_option']) { case 'delete': wp_delete_user($id); break; case 'reassign': wp_delete_user($id, $_POST['reassign_user']); break; } ++$delete_count; } $redirect = add_query_arg('delete_count', $delete_count, $redirect); header('Location: ' . add_query_arg('update', $update, $redirect)); break; case 'delete': die( "This function is disabled." ); check_admin_referer('bulk-users'); if ( empty($_POST['users']) ) header('Location: ' . $redirect); if ( !current_user_can('delete_users') ) $errors = new WP_Error('edit_users', __('You can&#8217;t delete users.')); $userids = $_POST['users']; include ('admin-header.php'); ?> <form action="" method="post" name="updateusers" id="updateusers"> <?php wp_nonce_field('delete-users') ?> <?php echo $referer; ?> <div class="wrap"> <h2><?php _e('Delete Users'); ?></h2> <p><?php _e('You have specified these users for deletion:'); ?></p> <ul> <?php $go_delete = false; foreach ( (array) $userids as $id ) { $user = new WP_User($id); if ( $id == $current_user->id ) { echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n"; } else { echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf(__('ID #%1s: %2s'), $id, $user->user_login) . "</li>\n"; $go_delete = true; } } $all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users, $wpdb->usermeta WHERE $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '".$wpdb->prefix."capabilities'"); $user_dropdown = '<select name="reassign_user">'; foreach ( (array) $all_logins as $login ) if ( $login->ID == $current_user->id || !in_array($login->ID, $userids) ) $user_dropdown .= "<option value=\"{$login->ID}\">{$login->user_login}</option>"; $user_dropdown .= '</select>'; ?> </ul> <?php if ( $go_delete ) : ?> <p><?php _e('What should be done with posts and links owned by this user?'); ?></p> <ul style="list-style:none;"> <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" checked="checked" /> <?php _e('Delete all posts and links.'); ?></label></li> <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" /> <?php echo '<label for="delete_option1">'.__('Attribute all posts and links to:')."</label> $user_dropdown"; ?></li> </ul> <input type="hidden" name="action" value="dodelete" /> <p class="submit"><input type="submit" name="submit" value="<?php _e('Confirm Deletion'); ?>" /></p> <?php else : ?> <p><?php _e('There are no valid users selected for deletion.'); ?></p> <?php endif; ?> </div> </form> <?php break; case 'doremove': check_admin_referer('remove-users'); if ( empty($_POST['users']) ) { header('Location: users.php'); } if ( !current_user_can('edit_users') ) die(__('You can&#8217;t remove users.')); $userids = $_POST['users']; $update = 'remove'; foreach ($userids as $id) { if ($id == $current_user->id) { $update = 'err_admin_remove'; continue; } remove_user_from_blog($id); } header('Location: users.php?update=' . $update); break; case 'removeuser': check_admin_referer('bulk-users'); if (empty($_POST['users'])) { header('Location: users.php'); } if ( !current_user_can('edit_users') ) $error = new WP_Error('edit_users', __('You can&#8217;t remove users.')); $userids = $_POST['users']; include ('admin-header.php'); ?> <form action="" method="post" name="updateusers" id="updateusers"> <?php wp_nonce_field('remove-users') ?> <div class="wrap"> <h2><?php _e('Remove Users from Blog'); ?></h2> <p><?php _e('You have specified these users for removal:'); ?></p> <ul> <?php $go_remove = false; foreach ($userids as $id) { $user = new WP_User($id); if ($id == $current_user->id) { echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be removed.</strong>'), $id, $user->user_login) . "</li>\n"; } else { echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf(__('ID #%1s: %2s'), $id, $user->user_login) . "</li>\n"; $go_remove = true; } } ?> <?php if($go_remove) : ?> <input type="hidden" name="action" value="doremove" /> <p class="submit"><input type="submit" name="submit" value="<?php _e('Confirm Removal'); ?>" /></p> <?php else : ?> <p><?php _e('There are no valid users selected for removal.'); ?></p> <?php endif; ?> </div> </form> <?php break; case 'adduser': die( "This function is disabled. Add a user from your community." ); check_admin_referer('add-user'); if ( ! current_user_can('create_users') ) die(__('You can&#8217;t create users.')); $user_id = add_user(); $update = 'add'; if ( is_wp_error( $user_id ) ) $add_user_errors = $user_id; else { $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_POST['user_login']), true)); $redirect = add_query_arg('usersearch', $new_user_login, $redirect); header('Location: ' . add_query_arg('update', $update, $redirect) . '#user-' . $user_id); die(); } case 'addexistinguser': check_admin_referer('add-user'); if ( !current_user_can('edit_users') ) die(__('You can&#8217;t edit users.')); $new_user_email = wp_specialchars(trim($_POST['newuser'])); /* checking that username has been typed */ if ( !empty($new_user_email) ) { if ( $user_id = email_exists( $new_user_email ) ) { if ( array_key_exists($blog_id, get_blogs_of_user($user_id)) ) { $location = 'users.php?update=add_existing'; } else { add_user_to_blog('', $user_id, $_POST[ 'new_role' ]); do_action( "added_existing_user", $user_id ); $location = 'users.php?update=add'; } header("Location: $location"); die(); } } header('Location: users.php'); die(); break; default: wp_enqueue_script('admin-users'); include('admin-header.php'); // Query the users $wp_user_search = new WP_User_Search($_GET['usersearch'], $_GET['userspage']); // Make the user objects foreach ( $wp_user_search->get_results() as $userid ) { $tmp_user = new WP_User($userid); $roles = $tmp_user->roles; $role = array_shift($roles); $roleclasses[$role][$tmp_user->user_login] = $tmp_user; } if ( isset($_GET['update']) ) : switch($_GET['update']) { case 'del': case 'del_many': ?> <?php $delete_count = (int) $_GET['delete_count']; ?> <div id="message" class="updated fade"><p><?php printf(__('%1$s %2$s deleted.'), $delete_count, __ngettext('user', 'users', $delete_count) ); ?></p></div> <?php break; case 'remove': ?> <div id="message" class="updated fade"><p><?php _e('User removed from this blog.'); ?></p></div> <?php break; case 'add': ?> <div id="message" class="updated fade"><p><?php _e('New user created.'); ?></p></div> <?php break; case 'promote': ?> <div id="message" class="updated fade"><p><?php _e('Changed roles.'); ?></p></div> <?php break; case 'err_admin_role': ?> <div id="message" class="error"><p><?php _e("The current user's role must have user editing capabilities."); ?></p></div> <div id="message" class="updated fade"><p><?php _e('Other user roles have been changed.'); ?></p></div> <?php break; case 'err_admin_del': ?> <div id="message" class="error"><p><?php _e("You can't delete the current user."); ?></p></div> <div id="message" class="updated fade"><p><?php _e('Other users have been deleted.'); ?></p></div> <?php break; case 'err_admin_remove': ?> <div id="message" class="error"><p><?php _e("You can't remove the current user."); ?></p></div> <div id="message" class="updated fade"><p><?php _e('Other users have been removed.'); ?></p></div> <?php break; case 'notactive': ?> <div id="message" class="updated fade"><p><?php _e('User not added. User is deleted or not active.'); ?></p></div> <?php break; case 'add_existing': ?> <div id="message" class="updated fade"><p><?php _e('User not added. User is already registered.'); ?></p></div> <?php break; } endif; ?> <?php if ( is_wp_error( $errors ) ) : ?> <div class="error"> <ul> <?php foreach ( $errors->get_error_messages() as $message ) echo "<li>$message</li>"; ?> </ul> </div> <?php endif; ?> <?php if ( $wp_user_search->too_many_total_users ) : ?> <div id="message" class="updated"> <p><?php echo $wp_user_search->too_many_total_users; ?></p> </div> <?php endif; ?> <div class="wrap"> <?php if ( $wp_user_search->is_search() ) : ?> <h2><?php printf(__('Users Matching "%s" by Role'), $wp_user_search->search_term); ?></h2> <?php else : ?> <h2><?php _e('User List by Role'); ?></h2> <?php endif; ?> <form action="" method="get" name="search" id="search"> <p><input type="text" name="usersearch" id="usersearch" value="<?php echo wp_specialchars($wp_user_search->search_term); ?>" /> <input type="submit" value="<?php _e('Search for users &raquo;'); ?>" /></p> </form> <?php if ( is_wp_error( $wp_user_search->search_errors ) ) : ?> <div class="error"> <ul> <?php foreach ( $wp_user_search->search_errors->get_error_messages() as $message ) echo "<li>$message</li>"; ?> </ul> </div> <?php endif; ?> <?php if ( $wp_user_search->get_results() ) : ?> <?php if ( $wp_user_search->is_search() ) : ?> <p><a href="users.php"><?php _e('&laquo; Back to All Users'); ?></a></p> <?php endif; ?> <h3><?php printf(__('Results %1$s - %2$s of %3$s shown below'), $wp_user_search->first_user + 1, min($wp_user_search->first_user + $wp_user_search->users_per_page, $wp_user_search->total_users_for_query), $wp_user_search->total_users_for_query); ?></h3> <?php if ( $wp_user_search->results_are_paged() ) : ?> <div class="user-paging-text"><?php $wp_user_search->page_links(); ?></p></div> <?php endif; ?> <form action="" method="post" name="updateusers" id="updateusers"> <?php wp_nonce_field('bulk-users') ?> <table class="widefat"> <?php foreach($roleclasses as $role => $roleclass) { ksort($roleclass); ?> <tr> <?php if ( !empty($role) ) : ?> <th colspan="7" align="left"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th> <?php else : ?> <th colspan="7" align="left"><h3><em><?php _e('No role for this blog'); ?></h3></th> <?php endif; ?> </tr> <tr class="thead"> <th style="text-align: left"><?php _e('ID') ?></th> <th style="text-align: left"><?php _e('Username') ?></th> <th style="text-align: left"><?php _e('Name') ?></th> <th style="text-align: left"><?php _e('E-mail') ?></th> <th style="text-align: left"><?php _e('Website') ?></th> <th colspan="2"><?php _e('Actions') ?></th> </tr> </thead> <tbody id="role-<?php echo $role; ?>"><?php $style = ''; foreach ( (array) $roleclass as $user_object ) { $style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"'; echo "\n\t" . user_row($user_object, $style); } ?> </tbody> <?php } ?> </table> <?php if ( $wp_user_search->results_are_paged() ) : ?> <div class="user-paging-text"><?php $wp_user_search->page_links(); ?></div> <?php endif; ?> <h2><?php _e('Update Users'); ?></h2> <ul style="list-style:none;"> <li><input type="radio" name="action" id="action0" value="removeuser" /> <label for="action0"><?php _e('Remove checked users.'); ?></label></li> <li> <input type="radio" name="action" id="action1" value="promote" /> <label for="action1"><?php _e('Set the Role of checked users to:'); ?></label> <select name="new_role"><?php wp_dropdown_roles(); ?></select> </li> </ul> <p class="submit"> <?php echo $referer; ?> <input type="submit" value="<?php _e('Update &raquo;'); ?>" /> </p> </form> <?php endif; ?> </div> <?php if ( is_wp_error($add_user_errors) ) { foreach ( array('user_login' => 'user_login', 'first_name' => 'user_firstname', 'last_name' => 'user_lastname', 'email' => 'user_email', 'url' => 'user_uri', 'role' => 'user_role') as $formpost => $var ) { $var = 'new_' . $var; $$var = wp_specialchars(stripslashes($_POST[$formpost])); } unset($name); } ?> <div class="wrap"> <h2><?php _e('Add User From Community') ?></h2> <form action="" method="post" name="adduser" id="adduser"> <?php wp_nonce_field('add-user') ?> <input type='hidden' name='action' value='addexistinguser'> <p>Type the e-mail address of another user to add them to your blog.</p> <table> <tr><th scope="row">User&nbsp;E-Mail: </th><td><input type="text" name="newuser" id="newuser"></td></tr> <tr> <th scope="row"><?php _e('Role:') ?></th> <td><select name="new_role" id="new_role"><?php foreach($wp_roles->role_names as $role => $name) { $selected = ''; if( $role == 'subscriber' ) $selected = 'selected="selected"'; echo "<option {$selected} value=\"{$role}\">{$name}</option>"; } ?></select></td> </tr> </table> <p class="submit"> <?php echo $referer; ?> <input name="adduser" type="submit" id="addusersub" value="<?php _e('Add User &raquo;') ?>" /> </p> </form> <?php if ( is_wp_error( $add_user_errors ) ) : ?> <div class="error"> <ul> <?php foreach ( $add_user_errors->get_error_messages() as $message ) echo "$message<br />"; ?> </ul> </div> <?php endif; ?> <div id="ajax-response"></div> </div> <?php break; } // end of the $action switch include('admin-footer.php'); ?>