Page 1 of 2
cURL/login help
Posted: Thu Jan 12, 2006 12:33 pm
by neoaddict
Here's my current code:
Code: Select all
<?php
$ch = curl_init("http://neopets.com/login.phtml?username=TEST&password=TEST&destination=/stockmarket.phtml");
$fp = fopen("grabthetext.txt", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, false);
$something = file_get_contents("http://neopets.com/stockmarket.phtml");
$something = preg_match("#<marquee>(.*)<\/marquee>#i", $retrievedhtml, $match);
curl_exec($ch);
//echo $something;
//echo $match[0];
curl_close($ch);
fclose($fp);
file_get_contents("grabthetext.txt", "r");
?>
This code prevents the script from logging in:
Code: Select all
<script name = 'JavaScript'>
<!--
var subcount = 0;
function one_submit()
{
if (subcount == 0)
{
subcount++;
return true;
}
else
return false;
}
//-->
</script>
Posted: Thu Jan 12, 2006 12:55 pm
by feyd
o.O
What are we supposed to help with?
Posted: Thu Jan 12, 2006 4:10 pm
by neoaddict
Does the cURL stuff look right and how could I allow the script to login without interference from the javascript?
Posted: Fri Jan 13, 2006 8:42 am
by neoaddict
Code: Select all
<script name = 'JavaScript'>
<!--
var subcount = 0;
function one_submit()
{
if (subcount == 0)
{
subcount++;
return true;
}
else
return false;
}
//-->
</script>
How can I bypass this Javascript? It's what's blocking my login.
Posted: Fri Jan 13, 2006 9:02 am
by feyd
how is it being used?
Posted: Fri Jan 13, 2006 12:33 pm
by neoaddict
If you're talking about the JS, I don't really know.
If you're talking about my script, it's for a site portal.
Posted: Fri Jan 13, 2006 3:44 pm
by feyd
It would be nice to know how the Javascript is being used..
Posted: Fri Jan 13, 2006 4:27 pm
by neoaddict
Personally, I'm not too much of a JS coder, but I think it checks whether you pressed submit or not.
Posted: Fri Jan 13, 2006 4:37 pm
by feyd
unless that is used in the submission data, it shouldn't have any baring on curl..
Posted: Fri Jan 13, 2006 7:49 pm
by neoaddict
I can't think of anything else that might be causing the problem.
Code: Select all
<?php
header('Content-Type: application/x-www-form-urlencoded');
$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_URL, 'http://neopets.com/login.phtml?');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=TEST&password=TEST&destination=/stockmarket.phtml");
//$something = file_get_contents("http://neopets.com/stockmarket.phtml");
//$something = preg_match("#<marquee>(.*)<\/marquee>#i", $retrievedhtml, $match);
curl_exec($ch);
curl_error($ch);
curl_close($ch);
?>
That's my most current code, but it won't login.
It keeps on returning a bad password page, but I'm sure it's the right password.
Posted: Fri Jan 13, 2006 8:51 pm
by feyd
the urls appear to be off, at least from what I can tell in the quick look I did..
Posted: Sat Jan 14, 2006 9:40 am
by neoaddict
How are they off?
Posted: Sun Jan 15, 2006 9:42 am
by neoaddict
Bump.
Posted: Mon Jan 16, 2006 4:23 pm
by neoaddict
Bump.
Posted: Mon Jan 16, 2006 10:13 pm
by timvw
The problem you have to solve is why the site accepts the value when they are posted by your browser and when they are posted by your script (curl). As you will notice when you search for similar problems is that a browser sends a couple of extra headers (eg: User-Agent). I'm pretty sure that neopets discriminates based on that header (amongst others). Now it's your task to try them all (and combinations of them) out

And see what works and what not.