Jump to content

cURL to fopen


marklarah

Recommended Posts

I suck at both.

 

Is there anyway of turning this script into using fopen instead of cURL?

//begin verification hack - PROOF OF CONCEPT ONLY
$username = $_POST["user"];
$pusername = str_ireplace("_","+",$username);
$url = "somewebsite=". $pusername ."&ip=".$_SERVER['REMOTE_ADDR'];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);

if ($output!==("1:".str_ireplace("+"," ",$pusername))){ die("retry (some sort of error) " . $pusername); }
//end LL verification hack

 

? Thanks...

 

Link to comment
https://forums.phpfreaks.com/topic/140382-curl-to-fopen/
Share on other sites

this is what i have

 

//begin verification hack - PROOF OF CONCEPT ONLY
$username = $_POST["user"];
$pusername = str_ireplace("_","+",$username);
$url = "site=". $pusername ."&ip=".$_SERVER['REMOTE_ADDR'];
$fhandle = fopen($url,"r");
$tempqb="";
while ( ! feof( $fhandle )){
$tempqb = $tempqb . fgets( $fhandle, 1024 );
}
$output = $tempqb;
if ($output!="1:".str_ireplace("+"," ",$pusername))  { die("Nope, unicorns " . $pusername); }
//end LL verification hack

Link to comment
https://forums.phpfreaks.com/topic/140382-curl-to-fopen/#findComment-734639
Share on other sites

 

Why not try this..

<?php
//begin verification hack - PROOF OF CONCEPT ONLY
$username = $_POST["user"];
$pusername = str_ireplace("_","+",$username);
$url = "site=". $pusername ."&ip=".$_SERVER['REMOTE_ADDR'];
$tempqb="";
$output=file_get_contents($url);
if ($output!="1:".str_ireplace("+"," ",$pusername))  { die("Nope, unicorns " . $pusername); }
//end LL verification hack
?>

Link to comment
https://forums.phpfreaks.com/topic/140382-curl-to-fopen/#findComment-734646
Share on other sites

final bash works theo.

<?php
$username="red_arrow";
$pusername = $_POST["user"];
$pusername = str_ireplace('_','+',$username);
$url = "site=". $pusername ."&ip=".$_SERVER['REMOTE_ADDR'];
$tempqb="";
$output=file_get_contents($url);
if ($output!="1:".str_ireplace("+"," ",$pusername))  { die("Nope, unicorns " . $pusername); }
//end LL verification hack
?>

result

Nope, unicorns red+arrow

Link to comment
https://forums.phpfreaks.com/topic/140382-curl-to-fopen/#findComment-734652
Share on other sites

use preg_replace.

 

<?php
$username="red_arrow";
$pusername = $_POST["user"];
$pusername = preg_replace("/\_/i","+",$username);
$url = "site=". $pusername ."&ip=".$_SERVER['REMOTE_ADDR'];
$tempqb=" ";
$output=file_get_contents($url);
if($output!="1:".preg_replace("/\+/i"," ",$pusername))  { die("Nope, unicorns " . $pusername); }
?>

Link to comment
https://forums.phpfreaks.com/topic/140382-curl-to-fopen/#findComment-734656
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.