5

I use this script in two different servers:

function curlGetFileInfo($url, $cookies="default"){
global $_config;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, 'serverpath/cookies/'.$cookies.'.txt');
$data = curl_exec($ch);
curl_close($ch); 
if ($data === false) { 
    return 0;
}
//echo $data;   
$info['filename'] = get_between($data, 'filename="', '"');
$info['extension'] = end(explode(".",$info['filename']));
if (preg_match('/Content-Length: (\d+)/', $data, $matches)) {
  $info['filesize'] = (int)$matches[1];
}
return $info;
}

These servers have the same PHP version with the same PHP-Curl version. These are the two different headers of the curl result:

Working one:

HTTP/1.1 302 Found Date: Tue, 12 Jun 2012 07:04:35 GMT Server: Apache/2.2.16 (Debian) X-Powered-By: PHP/5.3.3-7+squeeze13 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache,must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Location: http://stor1076.uploaded.to/dl/b3411ded-0f45-4efc-b705-8c8ac89b5e41 Vary: Accept-Encoding Connection: close Content-Type: text/html HTTP/1.1 200 OK Server: nginx/1.0.5 Date: Tue, 12 Jun 2012 07:04:35 GMT Content-Type: video/x-msvideo Content-Length: 733919232 Last-Modified: Tue, 29 May 2012 15:10:07 GMT Connection: keep-alive Content-Disposition: attachment; filename="Saw.[Spanish.DVDRip].[XviD-Mp3].by.SDG.avi" Accept-Ranges: bytes

Non working one:

HTTP/1.1 302 Found Date: Tue, 12 Jun 2012 07:05:26 GMT Server: Apache/2.2.16 (Debian) X-Powered-By: PHP/5.3.3-7+squeeze13 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Location: http://stor1164.uploaded.to/dl/22c3d242-365d-4e1e-b903-f1e2b81812c2 Vary: Accept-Encoding Connection: close Content-Type: text/html

Cookies are set OK (with login), and other simple Curl functions are working fine.

Also, I did a curl_getinfo($ch, CURLINFO_HTTP_CODE) and give me that result:

Working one: 200

Non working one: 302

Any idea?

1
  • Ok, it was a open_basedir problem. Thanks guys. Commented Jun 12, 2012 at 15:25

2 Answers 2

1

On the working one you seem to be running Apache as well as nginx. You can see there are two HTTP responses:

HTTP/1.1 302 Found Date: Tue, 12 Jun 2012 07:04:35 GMT Server: Apache/2.2.16 (Debian) HTTP/1.1 200 OK Server: nginx/1.0.5

So, your setup differs. I don't know how exactly they are running together, but this gives some insight and may help you solve it: http://kbeezie.com/view/apache-with-nginx/

Sign up to request clarification or add additional context in comments.

3 Comments

They are not "running together", The first request is just redirected.
Ok, it was a open_basedir problem. Thanks anyway mate!
I meant 'running together' in terms of server configuration. But the problem was a different one anyway.
1

Ok, it was a open_basedir problem. Thanks guys.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.