phillip
Полезный
- Регистрация
- 4 Сен 2007
- Сообщения
- 411
- Реакции
- 15
- Автор темы
- #1
Помогите авторизоваться на SMF!!! все вроде правильно составил- отследил отсылаемые данные, составил запрос, вытащил сессию. не работает! :bc:
PHP:
<?
set_time_limit(0);
ini_set('display_errors',1); error_reporting(E_ALL);
$login='Nulls';
$password='Nulled';
$agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru-RU; rv:1.7.12) Gecko/20050919 Firefox/1.0.7';
$header[] = "Accept: text/html;q=0.9, text/plain;q=0.8, image/png, */*;q=0.5" ;
$header[] = "Accept_charset: windows-1251, utf-8, utf-16;q=0.6, *;q=0.1";
$header[] = "Accept_encoding: identity";
$header[] = "Accept_language: en-us,en;q=0.5";
$header[] = "Connection: close";
$header[] = "Cache-Control: no-store, no-cache, must-revalidate";
$header[] = "Keep_alive: 300";
$header[] = "Expires: Thu, 01 Jan 1970 00:00:01 GMT";
$forum_url='http://forum.mazzako.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$forum_url);
//curl_setopt($ch, CURLOPT_HEADER, 1);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
// curl_setopt($ch, CURLOPT_TIMEOUT, 30);
//curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
// curl_setopt($ch, CURLOPT_POST, 1);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $query_str);
curl_setopt ( $ch , CURLOPT_USERAGENT , $agent);
// curl_setopt ( $ch , CURLOPT_HTTPHEADER , $header);
//curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
//curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
echo $text = curl_exec($ch);
curl_close ($ch);
preg_match("&PHPSESSID=(.+)\&&", $text, $matches); if(isset($matches[1])) $sid=$matches[1];
//Avtorize
$query = array (
'user' => $login,
'passwrd' => $password,
'cookielength'=> '60',
'cookieneverexp'=>'on',
);
$query_str = http_build_query($query);
echo $url = $forum_url.'/index.php?PHPSESSID='.$sid.'&action=login2';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query_str);
curl_setopt ( $ch , CURLOPT_USERAGENT , $agent);
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $header);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
echo $text = curl_exec($ch);
curl_close($ch);
?>