ERROR: Please enter a login.'));
}
/* checking the password has been typed twice */
if ($pass1 == '' || $pass2 == '') {
die (__('ERROR: Please enter your password twice.'));
}
/* checking the password has been typed twice the same */
if ($pass1 != $pass2) {
die (__('ERROR: Please type the same password in the two password fields.'));
}
$user_nickname = $user_login;
/* checking the login isn't already used by another user */
$loginthere = $wpdb->get_var("SELECT user_login FROM $wpdb->users WHERE user_login = '$user_login'");
if ($loginthere) {
die (__('ERROR: This login is already registered, please choose another one.'));
}
/* checking e-mail address */
if (empty($_POST["email"])) {
die (__("ERROR: please type an e-mail address"));
return false;
} else if (!is_email($_POST["email"])) {
die (__("ERROR: the email address isn't correct"));
return false;
}
$user_ID = $wpdb->get_var("SELECT ID FROM $wpdb->users ORDER BY ID DESC LIMIT 1") + 1;
$user_nicename = sanitize_title($user_nickname, $user_ID);
$user_uri = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $user_uri) ? $user_uri : 'http://' . $user_uri;
$now = gmdate('Y-m-d H:i:s');
$new_users_can_blog = get_settings('new_users_can_blog');
$result = $wpdb->query("INSERT INTO $wpdb->users
(user_login, user_pass, user_nickname, user_email, user_ip, user_domain, user_browser, dateYMDhour, user_level, user_idmode, user_firstname, user_lastname, user_nicename, user_url)
VALUES
('$user_login', MD5('$pass1'), '$user_nickname', '$user_email', '$user_ip', '$user_domain', '$user_browser', '$now', '$new_users_can_blog', 'nickname', '$user_firstname', '$user_lastname', '$user_nicename', '$user_uri')");
if ($result == false) {
die (__('ERROR: Couldn’t register you!'));
}
$stars = '';
for ($i = 0; $i < strlen($pass1); $i = $i + 1) {
$stars .= '*';
}
$user_login = stripslashes($user_login);
$message = 'New user registration on your blog ' . get_settings('blogname') . ":\r\n\r\n";
$message .= "Login: $user_login\r\n\r\nE-mail: $user_email";
@mail(get_settings('admin_email'), '[' . get_settings('blogname') . '] New User Registration', $message);
header('Location: users.php');
break;
case 'promote':
$standalone = 1;
require_once('admin-header.php');
check_admin_referer();
if (empty($_GET['prom'])) {
header('Location: users.php');
}
$id = $_GET['id'];
$prom = $_GET['prom'];
$user_data = get_userdata($id);
$usertopromote_level = $user_data->user_level;
if ($user_level <= $usertopromote_level) {
die(__('Can’t change the level of a user whose level is higher than yours.'));
}
if ('up' == $prom) {
$new_level = $usertopromote_level + 1;
$sql="UPDATE $wpdb->users SET user_level=$new_level WHERE ID = $id AND $new_level < $user_level";
} elseif ('down' == $prom) {
$new_level = $usertopromote_level - 1;
$sql="UPDATE $wpdb->users SET user_level=$new_level WHERE ID = $id AND $new_level < $user_level";
}
$result = $wpdb->query($sql);
header('Location: users.php');
break;
case 'delete':
$standalone = 1;
require_once('admin-header.php');
check_admin_referer();
$id = intval($_GET['id']);
if (!$id) {
header('Location: users.php');
}
$user_data = get_userdata($id);
$usertodelete_level = $user_data->user_level;
if ($user_level <= $usertodelete_level)
die(__('Can’t delete a user whose level is higher than yours.'));
$post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
if ($post_ids) {
$post_ids = implode(',', $post_ids);
// Delete comments, *backs
$wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID IN ($post_ids)");
// Clean cats
$wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id IN ($post_ids)");
// Clean post_meta
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id IN ($post_ids)");
// Clean links
$wpdb->query("DELETE FROM $wpdb->links WHERE link_owner = $id");
// Delete posts
$wpdb->query("DELETE FROM $wpdb->posts WHERE post_author = $id");
}
// FINALLY, delete user
$wpdb->query("DELETE FROM $wpdb->users WHERE ID = $id");
header('Location: users.php?deleted=true');
break;
default:
$standalone = 0;
include ('admin-header.php');
?>
|
|
|
|
|
|
|
|
get_results("SELECT ID FROM $wpdb->users WHERE user_level > 0 ORDER BY ID");
$style = '';
foreach ($users as $user) {
$user_data = get_userdata($user->ID);
$email = $user_data->user_email;
$url = $user_data->user_url;
$short_url = str_replace('http://', '', $url);
$short_url = str_replace('www.', '', $short_url);
if ('/' == substr($short_url, -1))
$short_url = substr($short_url, 0, -1);
if (strlen($short_url) > 35)
$short_url = substr($short_url, 0, 32).'...';
$style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = $user->ID and post_status = 'publish'");
if (0 < $numposts) $numposts = "$numposts";
echo "
$user_data->ID |
$user_data->user_nickname |
$user_data->user_firstname $user_data->user_lastname |
$email |
$short_url |
";
if (($user_level >= 2) and ($user_level > $user_data->user_level) and ($user_data->user_level > 0))
echo " ID."&prom=down\">- ";
echo $user_data->user_level;
if (($user_level >= 2) and ($user_level > ($user_data->user_level + 1)))
echo " ID."&prom=up\">+ ";
echo " | $numposts | ";
echo '';
if (($user_level >= 2) and ($user_level > $user_data->user_level))
echo "Edit";
echo ' | ';
echo '
';
}
?>
get_results("SELECT * FROM $wpdb->users WHERE user_level = 0 ORDER BY ID");
if ($users) {
?>
|
|
|
|
|
|
|
|
ID);
$email = $user_data->user_email;
$url = $user_data->user_url;
$short_url = str_replace('http://', '', $url);
$short_url = str_replace('www.', '', $short_url);
if ('/' == substr($short_url, -1))
$short_url = substr($short_url, 0, -1);
if (strlen($short_url) > 35)
$short_url = substr($short_url, 0, 32).'...';
$style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
echo "\n
$user_data->ID |
$user_data->user_nickname |
$user_data->user_firstname $user_data->user_lastname |
$email |
$short_url |
";
if ($user_level >= 6)
echo "". __('Promote') . '';
echo " | \n";
echo '';
if (($user_level >= 6) and ($user_level > $user_data->user_level))
echo "Edit";
echo ' | ';
if ($user_level >= 6)
echo "" . __('Delete'). '';
echo ' |
';
}
?>
Users can
register themselves or you can manually create users here.'), get_settings('siteurl')); ?>