PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
neoaddict
Forum Commoner
Posts: 44 Joined: Thu Jan 12, 2006 12:28 pm
Post
by neoaddict » Thu Jan 12, 2006 12:33 pm
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>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jan 12, 2006 12:55 pm
o.O
What are we supposed to help with?
neoaddict
Forum Commoner
Posts: 44 Joined: Thu Jan 12, 2006 12:28 pm
Post
by neoaddict » Thu Jan 12, 2006 4:10 pm
Does the cURL stuff look right and how could I allow the script to login without interference from the javascript?
neoaddict
Forum Commoner
Posts: 44 Joined: Thu Jan 12, 2006 12:28 pm
Post
by neoaddict » Fri Jan 13, 2006 8:42 am
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.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Jan 13, 2006 9:02 am
how is it being used?
neoaddict
Forum Commoner
Posts: 44 Joined: Thu Jan 12, 2006 12:28 pm
Post
by neoaddict » Fri Jan 13, 2006 12:33 pm
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.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Jan 13, 2006 3:44 pm
It would be nice to know how the Javascript is being used..
neoaddict
Forum Commoner
Posts: 44 Joined: Thu Jan 12, 2006 12:28 pm
Post
by neoaddict » Fri Jan 13, 2006 4:27 pm
Personally, I'm not too much of a JS coder, but I think it checks whether you pressed submit or not.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Jan 13, 2006 4:37 pm
unless that is used in the submission data, it shouldn't have any baring on curl..
neoaddict
Forum Commoner
Posts: 44 Joined: Thu Jan 12, 2006 12:28 pm
Post
by neoaddict » Fri Jan 13, 2006 7:49 pm
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.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Jan 13, 2006 8:51 pm
the urls appear to be off, at least from what I can tell in the quick look I did..
neoaddict
Forum Commoner
Posts: 44 Joined: Thu Jan 12, 2006 12:28 pm
Post
by neoaddict » Sat Jan 14, 2006 9:40 am
How are they off?
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Mon Jan 16, 2006 10:13 pm
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.