Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

Seeking php help converting fopen to curl

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
Spacemail by SpaceshipSpacemail by Spaceship
Watch

AshleyQuick

New Member
Impact
0
Here's the part of the code that uses the fopen methodology:

PHP:
$file = SAMPLE_FILE . '.' . $zip . '.xml';
if(!file_exists($file) || filemtime($file) < time() - 3600) {
    $this->data = @file_get_contents('http://xml.mydomain.com/rss?p=' . $zip . '&u=' . $units['zap']);
    $fp = @fopen($file, 'w');
    @fwrite($fp, $this->data);
    @fclose($fd);
}
else $this->data = @file_get_contents($file);
if(strlen($this->data) <= 0) return;
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Use this for your 'if' block:

PHP:
	if(!file_exists($file) || filemtime($file) < time() - 3600) 
	{
		$ch = @curl_init('http://xml.mydomain.com/rss?p=' . urlencode($zip) . '&u=' . urlencode($units['zap']));
		$fp = @fopen($file,'w');
		@curl_setopt($ch, CURLOPT_FILE, $fp);
		@curl_setopt($ch, CURLOPT_HEADER, 0);
		@curl_exec($ch);
		@curl_close($ch);
		@fclose($fp);
	}
 
0
Close
Minor adjustments and corrections. Here's the working fragment:

PHP:
 if(!file_exists($file) || filemtime($file) < time() - 3600) 
    {
        $ch = @curl_init('http://xml.mydomain.com/rss?p=' . urlencode($zip) . '&u=' . urlencode($units['zap']));
        $fp = @fopen($file,'w');
        @curl_setopt($ch, CURLOPT_FILE, $fp);
        @curl_setopt($ch, CURLOPT_HEADER, 0);
        @curl_setopt($ch, CURLOPT_MUTE, 1);
        @curl_exec($ch);
        @curl_close($ch);
        @fclose($fp);
    }  

 $this->data = @file_get_contents($file);
 if(strlen($this->data) <= 0) return;
 
0
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
CryptoExchange.com
Domain Recover

NamePros updates

Quick replies: search, your most used replies, and more on every post
Quick replies are easier to find and use now. The quick reply menu has a search box. Type a few letters to find the reply you want. A...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back