marklarah Posted January 11, 2009 Share Posted January 11, 2009 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... Quote Link to comment https://forums.phpfreaks.com/topic/140382-curl-to-fopen/ Share on other sites More sharing options...
Daniel0 Posted January 11, 2009 Share Posted January 11, 2009 Just use file_get_contents to read the data. Quote Link to comment https://forums.phpfreaks.com/topic/140382-curl-to-fopen/#findComment-734632 Share on other sites More sharing options...
marklarah Posted January 11, 2009 Author Share Posted January 11, 2009 its an external site its not what I need too Quote Link to comment https://forums.phpfreaks.com/topic/140382-curl-to-fopen/#findComment-734633 Share on other sites More sharing options...
marklarah Posted January 11, 2009 Author Share Posted January 11, 2009 nope? Quote Link to comment https://forums.phpfreaks.com/topic/140382-curl-to-fopen/#findComment-734638 Share on other sites More sharing options...
marklarah Posted January 11, 2009 Author Share Posted January 11, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/140382-curl-to-fopen/#findComment-734639 Share on other sites More sharing options...
redarrow Posted January 11, 2009 Share Posted January 11, 2009 Example hope it helps. <?php $file = 'http://www.google.com'; $f = fopen($file, r); while ( $line = fgets($f, 1000) ) { print $line; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/140382-curl-to-fopen/#findComment-734640 Share on other sites More sharing options...
redarrow Posted January 11, 2009 Share Posted January 11, 2009 Sorry did it work your code, If not whats wrong. Quote Link to comment https://forums.phpfreaks.com/topic/140382-curl-to-fopen/#findComment-734643 Share on other sites More sharing options...
Daniel0 Posted January 11, 2009 Share Posted January 11, 2009 its an external site its not what I need too Not what you need to? What do you mean? file_get_contents() is just a convenience function doing all the fopen(), fread() and fclose() in one function... Quote Link to comment https://forums.phpfreaks.com/topic/140382-curl-to-fopen/#findComment-734644 Share on other sites More sharing options...
redarrow Posted January 11, 2009 Share Posted January 11, 2009 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 ?> Quote Link to comment https://forums.phpfreaks.com/topic/140382-curl-to-fopen/#findComment-734646 Share on other sites More sharing options...
redarrow Posted January 11, 2009 Share Posted January 11, 2009 tested. <?php $url='http://www.google.co.uk'; $tempqb=""; $output=file_get_contents($url); if ($output!="1:".str_ireplace("+"," ",$pusername)) { die("Nope, unicorns " . $pusername); } //end LL verification hack ?> result Nope, unicorns Quote Link to comment https://forums.phpfreaks.com/topic/140382-curl-to-fopen/#findComment-734648 Share on other sites More sharing options...
redarrow Posted January 11, 2009 Share Posted January 11, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/140382-curl-to-fopen/#findComment-734652 Share on other sites More sharing options...
redarrow Posted January 11, 2009 Share Posted January 11, 2009 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); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/140382-curl-to-fopen/#findComment-734656 Share on other sites More sharing options...
RussellReal Posted January 11, 2009 Share Posted January 11, 2009 wow redarrow lol daz alotta posts and for this guy's question : why would you ever want to use anything other than file_get_contents file or cURL for external data grabbing.. Quote Link to comment https://forums.phpfreaks.com/topic/140382-curl-to-fopen/#findComment-734659 Share on other sites More sharing options...
redarrow Posted January 11, 2009 Share Posted January 11, 2009 if you look at his condition it always true die or not... how the hell does a condition work with a cater nated syntax get me? Quote Link to comment https://forums.phpfreaks.com/topic/140382-curl-to-fopen/#findComment-734666 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.