2003-12-07 20:28:41 -05:00
|
|
|
<?php
|
2003-12-07 20:55:38 -05:00
|
|
|
$title = 'Users';
|
2003-12-07 20:28:41 -05:00
|
|
|
/* <Team> */
|
|
|
|
|
2003-12-18 04:36:13 -05:00
|
|
|
$wpvarstoreset = array('action','standalone','redirect','profile');
|
|
|
|
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
|
|
|
|
$wpvar = $wpvarstoreset[$i];
|
|
|
|
if (!isset($$wpvar)) {
|
|
|
|
if (empty($HTTP_POST_VARS["$wpvar"])) {
|
|
|
|
if (empty($HTTP_GET_VARS["$wpvar"])) {
|
|
|
|
$$wpvar = '';
|
2003-12-07 20:28:41 -05:00
|
|
|
} else {
|
2003-12-18 04:36:13 -05:00
|
|
|
$$wpvar = $HTTP_GET_VARS["$wpvar"];
|
2003-12-07 20:28:41 -05:00
|
|
|
}
|
|
|
|
} else {
|
2003-12-18 04:36:13 -05:00
|
|
|
$$wpvar = $HTTP_POST_VARS["$wpvar"];
|
2003-12-07 20:28:41 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ($action) {
|
2003-12-23 15:21:29 -05:00
|
|
|
case 'adduser':
|
|
|
|
$standalone = 1;
|
|
|
|
require_once('admin-header.php');
|
|
|
|
function filter($value) {
|
|
|
|
return ereg('^[a-zA-Z0-9\_-\|]+$',$value);
|
|
|
|
}
|
|
|
|
|
|
|
|
$user_login = $HTTP_POST_VARS['user_login'];
|
|
|
|
$pass1 = $HTTP_POST_VARS['pass1'];
|
|
|
|
$pass2 = $HTTP_POST_VARS['pass2'];
|
|
|
|
$user_email = $HTTP_POST_VARS['email'];
|
|
|
|
$user_firstname = $HTTP_POST_VARS['firstname'];
|
|
|
|
$user_lastname = $HTTP_POST_VARS['lastname'];
|
|
|
|
|
|
|
|
/* checking login has been typed */
|
|
|
|
if ($user_login == '') {
|
|
|
|
die ('<strong>ERROR</strong>: Please enter a login.');
|
|
|
|
}
|
|
|
|
|
|
|
|
/* checking the password has been typed twice */
|
|
|
|
if ($pass1 == '' || $pass2 == '') {
|
|
|
|
die ('<strong>ERROR</strong>: Please enter your password twice.');
|
|
|
|
}
|
|
|
|
|
|
|
|
/* checking the password has been typed twice the same */
|
|
|
|
if ($pass1 != $pass2) {
|
|
|
|
die ('<strong>ERROR</strong>: Please type the same password in the two password fields.');
|
|
|
|
}
|
|
|
|
$user_nickname = $user_login;
|
|
|
|
|
|
|
|
/* checking e-mail address */
|
|
|
|
if ($user_email == '') {
|
|
|
|
die ('<strong>ERROR</strong>: Please type your e-mail address.');
|
|
|
|
} else if (!is_email($user_email)) {
|
|
|
|
die ('<strong>ERROR</strong>: The email address isn’t correct.');
|
|
|
|
}
|
|
|
|
|
|
|
|
/* checking the login isn't already used by another user */
|
|
|
|
$loginthere = $wpdb->get_var("SELECT user_login FROM $tableusers WHERE user_login = '$user_login'");
|
|
|
|
if ($loginthere) {
|
|
|
|
die ('<strong>ERROR</strong>: This login is already registered, please choose another one.');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$user_login = addslashes(stripslashes($user_login));
|
|
|
|
$pass1 = addslashes(stripslashes($pass1));
|
|
|
|
$user_nickname = addslashes(stripslashes($user_nickname));
|
2004-02-10 23:51:19 -05:00
|
|
|
$user_nicename = sanitize_title($user_nickname);
|
2003-12-23 15:21:29 -05:00
|
|
|
$user_firstname = addslashes(stripslashes($user_firstname));
|
|
|
|
$user_lastname = addslashes(stripslashes($user_lastname));
|
2004-02-23 09:29:55 -05:00
|
|
|
$now = gmdate('Y-m-d H:i:s');
|
2004-02-29 03:43:36 -05:00
|
|
|
$new_users_can_blog = get_settings('new_users_can_blog');
|
2003-12-23 15:21:29 -05:00
|
|
|
|
|
|
|
$result = $wpdb->query("INSERT INTO $tableusers
|
2004-02-10 23:51:19 -05:00
|
|
|
(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)
|
2003-12-23 15:21:29 -05:00
|
|
|
VALUES
|
2004-02-10 23:51:19 -05:00
|
|
|
('$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')");
|
2003-12-07 20:28:41 -05:00
|
|
|
|
2003-12-23 15:21:29 -05:00
|
|
|
if ($result == false) {
|
|
|
|
die ('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:'.$admin_email.'">webmaster</a> !');
|
|
|
|
}
|
|
|
|
|
|
|
|
$stars = '';
|
|
|
|
for ($i = 0; $i < strlen($pass1); $i = $i + 1) {
|
|
|
|
$stars .= '*';
|
|
|
|
}
|
|
|
|
|
|
|
|
$message = "New user registration on your blog $blogname:\r\n\r\n";
|
|
|
|
$message .= "Login: $user_login\r\n\r\nE-mail: $user_email";
|
|
|
|
|
|
|
|
@mail($admin_email, "[$blogname] New User Registration", $message);
|
|
|
|
header('Location: users.php');
|
|
|
|
break;
|
|
|
|
|
2003-12-07 20:28:41 -05:00
|
|
|
case 'promote':
|
|
|
|
|
|
|
|
$standalone = 1;
|
2003-12-10 19:22:36 -05:00
|
|
|
require_once('admin-header.php');
|
2003-12-07 20:28:41 -05:00
|
|
|
|
|
|
|
if (empty($HTTP_GET_VARS['prom'])) {
|
|
|
|
header('Location: users.php');
|
|
|
|
}
|
|
|
|
|
|
|
|
$id = $HTTP_GET_VARS['id'];
|
|
|
|
$prom = $HTTP_GET_VARS['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) {
|
2003-12-30 11:02:27 -05:00
|
|
|
$new_level = $usertopromote_level + 1;
|
|
|
|
$sql="UPDATE $tableusers SET user_level=$new_level WHERE ID = $id AND $new_level < $user_level";
|
2003-12-07 20:28:41 -05:00
|
|
|
} elseif ('down' == $prom) {
|
2003-12-30 11:02:27 -05:00
|
|
|
$new_level = $usertopromote_level - 1;
|
|
|
|
$sql="UPDATE $tableusers SET user_level=$new_level WHERE ID = $id AND $new_level < $user_level";
|
2003-12-07 20:28:41 -05:00
|
|
|
}
|
|
|
|
$result = $wpdb->query($sql);
|
|
|
|
|
|
|
|
header('Location: users.php');
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'delete':
|
|
|
|
|
|
|
|
$standalone = 1;
|
2003-12-10 19:22:36 -05:00
|
|
|
require_once('admin-header.php');
|
2003-12-07 20:28:41 -05:00
|
|
|
|
|
|
|
$id = $HTTP_GET_VARS['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.');
|
|
|
|
|
|
|
|
$sql = "DELETE FROM $tableusers WHERE ID = $id";
|
|
|
|
$result = $wpdb->query($sql) or die("Couldn’t delete user #$id.");
|
|
|
|
|
|
|
|
$sql = "DELETE FROM $tableposts WHERE post_author = $id";
|
|
|
|
$result = $wpdb->query($sql) or die("Couldn’t delete user #$id’s posts.");
|
|
|
|
|
|
|
|
header('Location: users.php');
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
$standalone = 0;
|
2003-12-10 19:22:36 -05:00
|
|
|
include ('admin-header.php');
|
2003-12-07 20:28:41 -05:00
|
|
|
?>
|
|
|
|
<div class="wrap">
|
|
|
|
<h2>Authors</h2>
|
2003-12-08 03:12:09 -05:00
|
|
|
<table cellpadding="3" cellspacing="3" width="100%">
|
2003-12-07 20:28:41 -05:00
|
|
|
<tr>
|
|
|
|
<th>ID</th>
|
|
|
|
<th>Nickname</th>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>E-mail</th>
|
2003-12-23 15:21:29 -05:00
|
|
|
<th>URI</th>
|
2003-12-07 20:28:41 -05:00
|
|
|
<th>Level</th>
|
|
|
|
<th>Posts</th>
|
|
|
|
</tr>
|
|
|
|
<?php
|
|
|
|
$users = $wpdb->get_results("SELECT ID FROM $tableusers WHERE user_level > 0 ORDER BY ID");
|
|
|
|
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://', '', stripslashes($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).'...';
|
2003-12-08 03:12:09 -05:00
|
|
|
$style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
|
2003-12-07 20:28:41 -05:00
|
|
|
$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $tableposts WHERE post_author = $user->ID and post_status = 'publish'");
|
|
|
|
if (0 < $numposts) $numposts = "<a href='edit.php?author=$user_data->ID' title='View posts'>$numposts</a>";
|
|
|
|
echo "
|
2003-12-08 03:12:09 -05:00
|
|
|
<tr $style>
|
|
|
|
<td align='center'>$user_data->ID</td>
|
2003-12-07 20:28:41 -05:00
|
|
|
<td><strong>$user_data->user_nickname</strong></td>
|
|
|
|
<td>$user_data->user_firstname $user_data->user_lastname</td>
|
|
|
|
<td><a href='mailto:$email' title='e-mail: $email'>$email</a></td>
|
|
|
|
<td><a href='$url' title='website: $url'>$short_url</a></td>
|
|
|
|
<td align='center'>";
|
|
|
|
if (($user_level >= 2) and ($user_level > $user_data->user_level) and ($user_data->user_level > 0))
|
|
|
|
echo " <a href=\"users.php?action=promote&id=".$user_data->ID."&prom=down\">-</a> ";
|
|
|
|
echo $user_data->user_level;
|
|
|
|
if (($user_level >= 2) and ($user_level > ($user_data->user_level + 1)))
|
|
|
|
echo " <a href=\"users.php?action=promote&id=".$user_data->ID."&prom=up\">+</a> ";
|
|
|
|
echo "<td align='right'>$numposts</td>";
|
|
|
|
echo '</tr>';
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<?php
|
2003-12-08 03:12:09 -05:00
|
|
|
$users = $wpdb->get_results("SELECT * FROM $tableusers WHERE user_level = 0 ORDER BY ID");
|
2003-12-07 20:28:41 -05:00
|
|
|
if ($users) {
|
|
|
|
?>
|
|
|
|
<div class="wrap">
|
|
|
|
<h2>Users</h2>
|
2003-12-08 03:12:09 -05:00
|
|
|
<table cellpadding="3" cellspacing="3" width="100%">
|
2003-12-07 20:28:41 -05:00
|
|
|
<tr>
|
2003-12-08 03:12:09 -05:00
|
|
|
<th>ID</th>
|
|
|
|
<th>Nickname</th>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>E-mail</th>
|
2003-12-23 15:21:29 -05:00
|
|
|
<th>URI</th>
|
2003-12-08 03:12:09 -05:00
|
|
|
<th>Level</th>
|
2003-12-07 20:28:41 -05:00
|
|
|
</tr>
|
|
|
|
<?php
|
|
|
|
foreach ($users as $user) {
|
|
|
|
$user_data = get_userdata($user->ID);
|
|
|
|
$email = $user_data->user_email;
|
|
|
|
$url = $user_data->user_url;
|
2003-12-08 03:12:09 -05:00
|
|
|
$short_url = str_replace('http://', '', stripslashes($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<tr $style>
|
|
|
|
<td align='center'>$user_data->ID</td>
|
|
|
|
<td><strong>$user_data->user_nickname</td>
|
|
|
|
<td>$user_data->user_firstname $user_data->user_lastname</td>
|
|
|
|
<td><a href='mailto:$email' title='e-mail: $email'>$email</a></td>
|
|
|
|
<td><a href='$url' title='website: $url'>$short_url</a></td>
|
|
|
|
<td align='center'>";
|
2003-12-07 20:28:41 -05:00
|
|
|
if ($user_level >= 3)
|
|
|
|
echo " <a href=\"users.php?action=delete&id=".$user_data->ID."\" style=\"color:red;font-weight:bold;\">X</a> ";
|
2003-12-08 03:12:09 -05:00
|
|
|
echo $user_data->user_level;
|
|
|
|
if ($user_level >= 2)
|
|
|
|
echo " <a href=\"users.php?action=promote&id=".$user_data->ID."&prom=up\">+</a> ";
|
|
|
|
echo "</td>\n</tr>\n";
|
2003-12-07 20:28:41 -05:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
</table>
|
|
|
|
<p>To delete a user, bring his level to zero, then click on the red X.<br />
|
|
|
|
<strong>Warning:</strong> deleting a user also deletes all posts made by this user.
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
} ?>
|
|
|
|
<div class="wrap">
|
|
|
|
<h2>Add User</h2>
|
2004-02-26 11:15:48 -05:00
|
|
|
<p>Users can <a href="<?php echo get_settings('siteurl'); ?>/wp-register.php">register themselves</a> or you can manually create users here.</p>
|
2003-12-23 15:21:29 -05:00
|
|
|
<form action="" method="post" name="adduser" id="adduser">
|
|
|
|
<table border="0" cellspacing="5" cellpadding="3">
|
|
|
|
<tr>
|
|
|
|
<th scope="row">Nickname
|
|
|
|
<input name="action" type="hidden" id="action" value="adduser" /></th>
|
|
|
|
<td><input name="user_login" type="text" id="user_login" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th scope="row">First Name </th>
|
|
|
|
<td><input name="firstname" type="text" id="firstname" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th scope="row">Last Name </th>
|
|
|
|
<td><input name="lastname" type="text" id="lastname" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th scope="row">Email</th>
|
|
|
|
<td><input name="email" type="text" id="email" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th scope="row">URI</th>
|
|
|
|
<td><input name="uri" type="text" id="uri" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th scope="row">Password (twice) </th>
|
2004-01-21 17:44:28 -05:00
|
|
|
<td><input name="pass1" type="password" id="pass1" />
|
2003-12-23 15:21:29 -05:00
|
|
|
<br />
|
2004-01-21 17:44:28 -05:00
|
|
|
<input name="pass2" type="password" id="pass2" /></td>
|
2003-12-23 15:21:29 -05:00
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<p>
|
|
|
|
<input name="adduser" type="submit" id="adduser" value="Add User">
|
|
|
|
</p>
|
|
|
|
</form>
|
2003-12-07 20:28:41 -05:00
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* </Team> */
|
2003-12-10 19:22:36 -05:00
|
|
|
include('admin-footer.php');
|
2003-12-07 20:28:41 -05:00
|
|
|
?>
|