|
|
Posted by NC on 08/02/07 01:18
On Aug 1, 1:39 pm, "laredotorn...@zipmail.com"
<laredotorn...@zipmail.com> wrote:
>
> When you say
>
> > 2. Obtain the following cookies from
> > [WordPress_root]/wp-login.php:
>
> what do you mean by "obtain". Am I supposed to be parsing
> this file using "fread"?
No. You're supposed to parse HTTP headers returned by that file.
Something like this:
$host = 'www.yourWordPresshost.com';
$path = 'WordPress_root'; // NO OPENING OR TRAILING SLASHES!!!
$login = 'your_WordPress_login';
$password = 'your_WordPress_password';
$post_query = 'log=' . rawurlencode($login) .
'&pwd=. rawurlencode($password) .
'&submit=Login+%C2%BB&redirect_to=wp-admin%2F';
$fp = fsockopen($host, "80");
if ($fp) {
fputs($fp, "POST /".$path." HTTP/1.0\r\nHost: ".$host."\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ". strlen($post_query) ."\r\n\r\n");
fputs($fp, $post_query);
while (!feof($fp)) {
$line = fgets($fp, 10240);
if (strlen(trim($line)) < 1) {
header('Location: http://' . $host . '/' . $path . '/wp-
admin/');
die();
} else {
list($name, $value) = explode(':' ,$line);
if (strtoupper(trim($name))) == 'SET-COOKIE' {
header($line);
}
}
}
} else {
echo "<p>Sorry, WordPress is not accessible at the moment...</p>";
}
Cheers,
NC
Navigation:
[Reply to this message]
|