Jump to content
Ruivo

Preg_match com Login

Recommended Posts

HappyHippyHippo

e que tal fazer isto e ver o que dá ?

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://passport.nexoneu.com/Login.aspx?nexoneuTheme=Warrock");
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'txtLogin0=USERNAME&txtpassword0=PASSWORD');
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
curl_setopt($ch, CURLOPT_URL, 'http://en.warrock.nexoneu.com/Ranking/Profile/xhawkeye08');
$content = curl_exec ($ch);
echo file_get_contents('http://en.warrock.nexoneu.com/Ranking/Profile/xhawkeye08');
?>


IRC : sim, é algo que ainda existe >> #p@p

Share this post


Link to post
Share on other sites
laeknishendr

O post de login que eu peguei pelo chrome é:

__VIEWSTATE:/wEPDwUJNjcwNjY0ODEzD2QWAgIBDxYCHgVjbGFzcwURd2Fycm9ja0JhY2tncm91bmQWAgIBD2QWCmYPFgIfAAURd2Fycm9ja0JhY2tncm91bmRkAgEPFgIeBXN0eWxlBQ5kaXNwbGF5OmJsb2NrOxYCAgEPFgIfAQUOZGlzcGxheTpibG9jaztkAgIPFgIfAQUNZGlzcGxheTpub25lO2QCBQ8WAh4Kb25rZXlwcmVzcwVKaWYgKGV2ZW50LmtleUNvZGUgPT0gMTMpIHsgZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoJ2J0bkxvZ2luJykub25jbGljaygpO31kAgYPFgIeB29uY2xpY2sFgwFqYXZhc2NyaXB0OmlmKCBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgnY2hrU2F2ZUlEJykuY2hlY2tlZCA9PSB0cnVlKXsgYWxlcnQoJ1BsZWFzZSB1bmNoZWNrIGlmIHlvdSBhcmUgdXNpbmcgYSBzaGFyZWQgY29tcHV0ZXIuJyk7fWQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgQFCGJ0bkxvZ2luBQljaGtTYXZlSUQFCWJ0bkxvZ2luMQUJYnRuTG9naW4yVlfJY5ULIqaGMfYazHguia153NE=
__EVENTVALIDATION:/wEWCwLBy8uzCALkhOqVCgKC3IeGDAK1qfSoDQLvgdnJBgLlhOqVCgLB6b6zDAK1qeDNBALmhOqVCgK+6b6zDAK1qczyC+bfFH+8buqUYGE6pUB/t0EkzonK
txtLogin0:login
btnLogin.x:0
btnLogin.y:0
txtPassword0:senha
chkSaveID:1
txtLogin1:
txtPassword1:
txtLogin2:
txtPassword2:

Mas quando tento repetir com o php da erro no servidor:

<?php
$ch = curl_init("http://passport.nexoneu.com/Login.aspx?nexoneuTheme=NexonEU");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
preg_match("/d=\"__VIEWSTATE\" value=\"(.*?)\"/", $result, $viewState);
preg_match("/d=\"__EVENTVALIDATION\" value=\"(.*?)\"/", $result, $eventValidation);

curl_setopt_array($ch,
array
(
CURLOPT_URL => "http://passport.nexoneu.com/Login.aspx?nexoneuTheme=NexonEU",
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => "txtLogin0=login&txtPassword0=senha&__VIEWSTATE={$viewState[1]}&__EVENTVALIDATION={$eventValidation[1]}",
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HEADER => true,
CURLOPT_COOKIEFILE => "cookie.txt",
CURLOPT_COOKIEJAR => "cookie.txt",
)
);

curl_exec($ch);

?>

http://www.segbr.net/lucas/nexoneu.php

Edited by laeknishendr

Share this post


Link to post
Share on other sites
Ruivo

e que tal fazer isto e ver o que dá ?

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://passport.nexoneu.com/Login.aspx?nexoneuTheme=Warrock");
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'txtLogin0=USERNAME&txtpassword0=PASSWORD');
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
curl_setopt($ch, CURLOPT_URL, 'http://en.warrock.nexoneu.com/Ranking/Profile/xhawkeye08');
$content = curl_exec ($ch);
echo file_get_contents('http://en.warrock.nexoneu.com/Ranking/Profile/xhawkeye08');
?>

Se no file get contents meto assim como está diz

Object Moved
This document may be found here

se tiro o http://

diz

Warning: file_get_contents(en.warrock.nexoneu.com/Ranking/Profile/xhawkeye08) [function.file-get-contents]: failed to open stream: No such file or directory in /home/a5787440/public_html/stats/warrock.php on line 11

Share this post


Link to post
Share on other sites
HappyHippyHippo

então se a página está noutro lugar, bem que podes fazer pesquisar pela informação que nunca a terás. obvio não ???

corrige o URL e depois diz alguma coisa


IRC : sim, é algo que ainda existe >> #p@p

Share this post


Link to post
Share on other sites
laeknishendr

Gente, só pode acessar a página de usuário se estiver logado, ou seja, temos que primeiro trabalhar no login para depois com os cookies gerados acessarmos a página de um determinado usuário para poder pegar essas informações, com file_get_contents não vai acontecer.

Share this post


Link to post
Share on other sites
Ruivo

Eu já revi e o endereço está correto.

Quanto ao login eu inseri o login da minha conta e mesmo assim nao dá

Share this post


Link to post
Share on other sites
laeknishendr

Supostamente a variável $content já tem o que pretendes. Imprime-a e vê o resultado.

Não tem porque ele não definiu nenhum referrer.

Share this post


Link to post
Share on other sites
laeknishendr

Eu já havia tentado com o user agent, o problema está em pegar o eventvalidation e o viewstate.

http://www.segbr.net/lucas/nexoneu.php

O único cookie que consegui gerar foi:

# Netscape HTTP Cookie File
# http://www.netscape.com/newsref/std/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.
passport.nexoneu.com FALSE / FALSE 0 ASP.NET_SessionId sr2n1d4545hsen45htul5155
passport.nexoneu.com FALSE / FALSE 0 BIGipServerpEU-PORTAL_80_passport 2718566922.20480.0000

Parece que ta difícil de acontecer a autenticação haha.

Edited by laeknishendr

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.