运行 在本地主机上,但在服务器上不起作用。 (PHP 卷曲)
Running on localhost but does not work on the server. (PHP cURL)
我在我的本地主机上收到了验证码,但同一代码服务器无法正常工作。我尝试运行我自己的服务器在cookie.txt文件中用chmod完全权限也给了完全权限。当我 运行 完美的本地主机。我认为,它不起作用,因为 cookie.txt
<?php
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:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_COOKIE, 1);
if($cookie != ""){
curl_setopt($ch, CURLOPT_COOKIEJAR, realpath(dirname(__FILE__))."\cookie.txt");
}else{
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, "http://www.xxxxxx.com/caller/");
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
open("http://www.xxxxxx.com/caller/", 1);
echo open("http://www.xxxxxx.com/security.php?id=".(floor(rand() * 1000) + 1), 0);
?>
你能帮帮我吗?
这可能是一个安全问题。想象一下,攻击者可以更改您的 php 文件并接管您的应用程序。这就是 Apache 服务器在用户 www-data 下 运行 的原因,除了只读之外,它无法访问您的文件。这同样适用于目录。
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");
}
我在我的本地主机上收到了验证码,但同一代码服务器无法正常工作。我尝试运行我自己的服务器在cookie.txt文件中用chmod完全权限也给了完全权限。当我 运行 完美的本地主机。我认为,它不起作用,因为 cookie.txt
<?php
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:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_COOKIE, 1);
if($cookie != ""){
curl_setopt($ch, CURLOPT_COOKIEJAR, realpath(dirname(__FILE__))."\cookie.txt");
}else{
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, "http://www.xxxxxx.com/caller/");
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
open("http://www.xxxxxx.com/caller/", 1);
echo open("http://www.xxxxxx.com/security.php?id=".(floor(rand() * 1000) + 1), 0);
?>
你能帮帮我吗?
这可能是一个安全问题。想象一下,攻击者可以更改您的 php 文件并接管您的应用程序。这就是 Apache 服务器在用户 www-data 下 运行 的原因,除了只读之外,它无法访问您的文件。这同样适用于目录。
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");
}