Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-08-20 00:35:43

davej
Member
From: Ireland
Registered: 2005-11-01
Posts: 27
Website

Use cURL instead of allow_url_fopen

Just a quick one:

Why not use cURL when testing if clean urls are working (diagnostics tab) instead of using the allow_url_fopen function.

allow_url_fopen is not supported by some hosts (i.e.. Dreamhost) for security reasons.

[?php
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, ‘http://example.com/clean_section/clean_article’);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
echo $file_contents;
?]

Offline

#2 2006-08-28 12:25:15

scross
Member
Registered: 2006-01-17
Posts: 13

Re: Use cURL instead of allow_url_fopen

Since you know the code why not implement it yourself

Offline

#3 2006-08-28 13:58:27

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: Use cURL instead of allow_url_fopen

curl is not part of a default php distribution, it’s a special module that has to be installed. So that it isa lot less likely to be available than enabled url-wrappers for fopen.

Offline

#4 2006-08-28 18:53:37

davej
Member
From: Ireland
Registered: 2005-11-01
Posts: 27
Website

Re: Use cURL instead of allow_url_fopen

The cURL library is almost always included with PHP as far as I know.

Offline

#5 2006-08-28 23:05:10

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: Use cURL instead of allow_url_fopen

In my experience it is not.

Also the manual states:

Requirements
In order to use PHP’s CURL functions you need to install the libcurl package.[…]
Installation
To use PHP’s CURL support you must also compile PHP —with-curl[=DIR] where DIR is the location of the directory containing the lib and include directories.[…]

The debian-package does not include it by default either (though seperate packages are available).

If you were lucky enough only to be hosted where it was available, good for you. Yet it doesn’t mean it is the norm.

Last edited by Sencer (2006-08-28 23:06:24)

Offline

#6 2006-08-28 23:11:39

davej
Member
From: Ireland
Registered: 2005-11-01
Posts: 27
Website

Re: Use cURL instead of allow_url_fopen

Ok, fair enough.

Offline

Board footer

Powered by FluxBB