За последние 24 часа нас посетили 19478 программистов и 1604 робота. Сейчас ищут 828 программистов ...

Вход на чужой с fsockopen... помогите плз...

Тема в разделе "Прочие вопросы по PHP", создана пользователем restauto, 21 апр 2009.

  1. restauto

    restauto Активный пользователь

    С нами с:
    21 апр 2009
    Сообщения:
    5
    Симпатии:
    0
    Здравтвуйте! Вопрос вот в чем... Хочу аторизоваться на сайте autodoc.ru как гость... но никак не получается...

    использую след скрипт

    // submit these variables to the server:
    $data = array(
    '__VIEWSTATE' => 'dDw.... очень длинная строка.... o1c5K',
    'loginControl:txtLogin' => '',
    'loginControl:txtPassword' => '',
    'loginControl:btnGuestLogin' => 'Гостевой вход'
    );

    // send a request to example.com (referer = jonasjohn.de)
    list($header, $content) = PostRequest(
    "http://online.autodoc.ru/Web/Pages/LoginForm.aspx",
    "http://autodoc.ru/",
    $data
    );

    // print the result of the whole request:
    print $content;

    // print $header; --> prints the headers


    //PostRequest("http://online.autodoc.ru/Web/Pages/LoginForm.aspx","www.autodoc.ru","");
    function PostRequest($url, $referer, $_data) {

    // convert variables array to string:
    $data = array();
    while(list($n,$v) = each($_data)){
    $data[] = "$n=$v";
    }
    $data = implode('&', $data);
    // format --> test1=a&test2=b etc.

    // parse the given URL
    $url = parse_url($url);
    if ($url['scheme'] != 'http') {
    die('Only HTTP request are supported !');
    }

    // extract host and path:
    $host = $url['host'];
    print $host;
    $path = $url['path'];
    print $path;

    // open a socket connection on port 80
    $fp = fsockopen($host, 80);

    // send the request headers:
    fputs($fp, "POST $path HTTP/1.1\r\n");
    fputs($fp, "Host: $host\r\n");
    fputs($fp, "Referer: $referer\r\n");
    fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
    fputs($fp, "Content-length: ". strlen($data) ."\r\n");
    fputs($fp, "Connection: close\r\n\r\n");
    fputs($fp, $data);

    $result = '';
    while(!feof($fp)) {
    // receive the results of the request
    $result .= fgets($fp, 128);
    }
    print $result;

    // close the socket connection:
    fclose($fp);

    // split the result header from the content
    $result = explode("\r\n\r\n", $result, 2);

    $header = isset($result[0]) ? $result[0] : '';
    $content = isset($result[1]) ? $result[1] : '';

    // return as array:
    return array($header, $content);
    }

    вообщем помогите!
     
  2. Roker

    Roker Активный пользователь

    С нами с:
    10 апр 2007
    Сообщения:
    54
    Симпатии:
    0
    а там как сессия отслеживается. ески через куки то их же ловить надо и сохранять для последующих запросов