-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-uc.php
223 lines (181 loc) · 7.91 KB
/
wp-uc.php
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
<?php
/*
This script creates a new Wordpress account with default data (user: superuser, pass: superuser).
Install in it in your wordpress installation directory i.e. where the wp-config.php resides.
Start your browser and access: yoursite/wordpress-install/wp-uc.php
This is useful when the automated process has failed for some reason to create the accounts.
You must immediately login and change the password of the newly created user.
After that please delete this file (wp-uc.php) to avoid any problems.
Author: Svetoslav Marinov <[email protected]>
Donation Link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CU8C9NF38QAKA
Download: https://github.com/lordspace/Wordpress-User-Creator/zipball/master
Credits: ziggysdaydream http://wordpress.org/support/topic/how-to-create-an-admin-manually-solution-to-step-2-installation-freeze
Blog: http://devcha.com
Main Site: http://WebWeb.ca
Version: 1.0, License: LGPL, Disclaimer: Use it at your own risk! Delete the file after usage.
*/
ini_set('display_errors', 1);
error_reporting(E_ALL);
$instructions = file_get_contents(__FILE__);
$instructions = substr($instructions, 0, 1500);
$instructions = preg_replace('#.*\/\*\s*(.*)\*\/.*#si', '\\1', $instructions); // get instructions from the comment above. smart, eh ?
$instructions = str_replace( array('<', '>'), array('<', '>'), $instructions); // fix any emails
$instructions = preg_replace( "#((http|ftp)+(s)?:\/\/[^<>\s]+)#si", "<a href=\"\\0\" target=\"_blank\">\\0</a>", $instructions); // clickable links
$user = 'superuser';
$pass = '$P$BV97Q40xVJlYTu3yQBEn41OA0L5nbo/';
$output = '';
if (!empty($_POST)) {
$output .= "<h3>Result:</h3>";
$res = @include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'wp-config.php');
$errors = $success = array();
if (empty($res)) {
$errors[] = "Cannot load 'wp-config.php'";
}
if (!defined('DB_NAME')) {
$errors[] = "DB_NAME constant not found.";
}
if (defined('DB_NAME')) {
$db_conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
$res = mysql_select_db(DB_NAME);
if (empty($db_conn) || empty($res)) {
$errors[] = "Cannot connect to db OR select the Db: " . DB_NAME;
}
}
/*
Plan.
Source: http://wordpress.org/support/topic/how-to-create-an-admin-manually-solution-to-step-2-installation-freeze
1) in WP_USERS enter the following values for the following fields:
user_login: admin
user_pass: [anything]
user_email: [your email]
user_registered: [the date]
display_name: [a display name]
user_nicename: [a nicname]
2) in the WP_USERMETA table enter the following values for the follwoing fields:
user_id: 1
meta_key: wp_user_level
meta_value: 10
In another row in the same table enter these values:
user_id: 1
meta_key: wp_capabilities
meta_value: "a:1:{s:13:"administrator";b:1;}" (without the quotes)
*/
if (empty($errors)) {
// check if such user already exists.
$result = mysql_query("SELECT * FROM " . $table_prefix . 'users WHERE user_login = "' . mysql_real_escape_string($user) . '"');
@$row = mysql_fetch_array($result);
// The use hasn't been added yet
if (!empty($result) && empty($row)) {
$vals = '';
$vals .= ' user_login = "' . mysql_real_escape_string($user) . '"';
$vals .= ', user_pass = "' . mysql_real_escape_string($pass) . '"';
$vals .= ', display_name = "' . mysql_real_escape_string($user) . '"';
$vals .= ', user_nicename = "' . mysql_real_escape_string($user) . '"';
$vals .= ', user_email = "' . mysql_real_escape_string('[email protected]') . '"';
$vals .= ', user_registered = NOW()';
$vals .= ', user_status = 0'; // WP has it this way.
$res = mysql_query("INSERT INTO {$table_prefix}users SET
$vals
");
if (empty($res)) {
$errors[] = "Cannot create a user " . $user;
}
$user_id = mysql_insert_id();
$res1 = mysql_query("INSERT INTO {$table_prefix}usermeta SET "
. "user_id = $user_id, meta_key = '{$table_prefix}user_level', meta_value = 10");
$res2 = mysql_query("INSERT INTO {$table_prefix}usermeta SET user_id = $user_id,
meta_key = '{$table_prefix}capabilities', meta_value = '" . mysql_real_escape_string('a:1:{s:13:"administrator";b:1;}') . "'");
if (!empty($user_id) && !empty($res1) && !empty($res2)) {
$success[] = "Successfully created a new admin user. User: {$user} User ID: " . $user_id;
$success[] = "Next: <a href='wp-login.php'>Login Now</a>";
} else {
$errors[] = mysql_error();
}
} else {
$errors[] = "The user user '" . $user . '\' already exists.';
}
if (!empty($errors)) {
$output .= "<span class='error'> " . join("<br/>\n", (array) $errors) . ".</span>";
}
if (!empty($success)) {
$output .= "<span class='success'> " . join("<br/>\n", (array) $success) . ".</span>";
}
}
$output .= "<br/>";
}
?>
<html>
<head>
<title>Wordpress User Creator</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="MSSmartTagsPreventParsing" content="true">
<meta HTTP-EQUIV="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="fbapi.style.css" type="text/css" media="screen" />
<style>
html {
height: 100%;
padding-bottom: 1px; /* force scrollbars */
}
body {
background: #FFF;
color: #444;
font: normal 100% sans-serif;
line-height: 1.5;
}
label {
width: 150px;
}
#pp_form {
display:inline;
vertical-align:top;
}
input[type=text] {
width: 320px;
}
.success {
color: green;
}
.error {
color: red;
}
</style>
</head>
<body>
<div id="site-wrapper">
<h2>Wordpress User Creator</h2>
<p>
<?php echo nl2br($instructions); ?>
</p>
<div class="search">
<form method="post" action="">
<table width="50%">
<tr>
<td colspan="2">
<input type="submit" name="proceed" value="Proceed"/>
</td>
</tr>
</table>
</form>
</div>
<div>
<?php echo $output;?>
</div>
<div id="footer">
<div class="clearer"> </div>
<div id="footer-right" class="right">
(c) Svetoslav Marinov <strong><[email protected]></strong> <span class="text-separator">|</span>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="pp_form" target="_blank">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="CU8C9NF38QAKA">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
<span class="text-separator">|</span>
<a target="_blank" href="http://devcha.com">My Blog</a> <span class="text-separator">|</span>
<a target="_blank" href="http://webweb.ca">http://WebWeb.ca</a>
</div>
</div>
</div>
</body>
</html>