You are here: Re: Creating an auto-login page « All PHP « IT news, forums, messages
Re: Creating an auto-login page

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация