PHP Question

Running on localhost but does not work on the server. (PHP cURL)

I received an captcha in my localhost but the same code server does not work. I try to run my own server with chmod full authority also gave full authority in the cookie.txt file. When I run the perfect localhost. I think, it does not work because of cookie.txt

header("Content-type: image/jpeg");
function open($url, $cookie = "")
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20070219 Firefox/');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_COOKIE, 1);
if($cookie != ""){
curl_setopt($ch, CURLOPT_COOKIEJAR, realpath(dirname(__FILE__))."\cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, realpath(dirname(__FILE__))."\cookie.txt");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, "");
$result = curl_exec($ch);
return $result;
open("", 1);
echo open("".(floor(rand() * 1000) + 1), 0);

Can you help me Please?

Answer Source

It's probably a security issue. Imagine that an attacker could change your php files and take over your application. That's why Apache server is running under user www-data, which doesn't have access to your files other than read-only. The same applies for directories.

if($cookie != "") {
                curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/some_better_name_cookie.txt");
} else {
                curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/some_better_name_cookie.txt");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download