FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » php curl only saves a cookie with tempnam()
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: php curl only saves a cookie with tempnam() [message #180770 is a reply to message #180766] Sun, 17 March 2013 14:03 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 3/17/2013 2:46 AM, Doug Cassidy wrote:
> Here's the whole function.
>
> Two things I dont get, why does the curl_setopt use the $tmpfile that I set first and not the overwritten one. And, even if I comment the tempnam() $tmpfile, it wont write a cookie to /tmp/CURL_var_.txt. No cookie gets written at all, or at least not in the tmp dir. Both local Win and live Linux server.
>
> function curl($url, $referer = null, $post = null, $removeWhiteSpaces = true) {
> global $cost, $cost, $last_url;
> if(is_array($referer)){//must be an args array
> extract( wp_parse_args( $referer, array(
> 'referer' => null
> ,'post' => null
> ,'removeWhiteSpaces' => true
> ,'caller' => 'nocaller'
> ) ) );
> }
> if($removeWhiteSpaces)$url = removeWhiteSpaces($url);
>
> static $tmpfile;
>
> if(!isset($tmpfile) || ($tmpfile == ''))
> $tmpfile = tempnam('/tmp', 'CURL_tmpfile');
>
> $tmpfile = '/tmp/CURL_var_.txt';
>
> $ch = curl_init($url);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
>
> curl_setopt($ch, CURLOPT_COOKIEFILE, $tmpfile);
> curl_setopt($ch, CURLOPT_COOKIEJAR, $tmpfile);
>
>
> @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
> curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061024 BonEcho/2.0");
>
> if($referer) curl_setopt($ch, CURLOPT_REFERER, $referer);
>
> if(!is_null($post)){
> curl_setopt($ch, CURLOPT_POST, true);
> curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
> }
>
> $html = curl_exec($ch);
>
> $last_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
>
> curl_close($ch);
> return $html;
> }
>

Did you copy/paste this code? Or did you type it in? Are you sure this
is the code being executed?

Because there is no way the code would generate the results you claim.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: all done
Next Topic: validation of a text box input...
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Nov 25 03:50:18 GMT 2024

Total time taken to generate the page: 0.05131 seconds