I have this URL. When I enter the code and click submit it redirects to this page. From the second page I want to extract the m3u link.
I want the code to send the user's IP address and activation code to this page.
After that want to get the m3u link from another page.
I tried but did not succeed. This is my code.
function getUserIP() {
if( array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ) {
if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',')>0) {
$addr = explode(",",$_SERVER['HTTP_X_FORWARDED_FOR']);
return trim($addr[0]);
} else {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
}
else {
return $_SERVER['REMOTE_ADDR'];
}
}
$ip = getUserIP() ;
$url = 'http://iptv-janberyan.cf:10000/b/active.html';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Forwarded-For: $ip"));
$link = 'http://iptv-janberyan.cf:10000/';
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array("X-Forwarded-For: $ip"));
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array("Cookie: mgs=579060f907283604"));
curl_setopt($curl_handle, CURLOPT_URL,$link);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36');
curl_setopt($curl_handle, CURLOPT_REFERER, 'http://iptv-janberyan.cf:10000/b/active.html');
$query = curl_exec($curl_handle);
curl_close($curl_handle);
//echo $query ;
$lines = explode("
", $query);
$final= $lines[105];
$final = str_replace('<input type="text" class="fo_code" name="code" value="','',$final);
$final = str_replace('&output=mpegts" required/>','',$final);
echo $final ;