我的代码是
<?php
if ($_POST['hiddensms']) {
ini_set("allow_url_fopen", "ON");
ini_set("allow_url_include", "ON");
$smsno = explode(',', $_POST['hiddensms']);
foreach ($smsno as $mono) {
$baseurl = "http://api.xxxxxxxxxxxx.com";
$sql_q = "select firstname,lastname from tbl_newsletter where phone='" . $mono . "'";
$resultcount = mysql_query($sql_q);
$row_total_count = mysql_fetch_array($resultcount);
$first_name = $row_total_count['firstname'];
$last_name = $row_total_count['lastname'];
if ($_POST['sel_name_sms'] == 'FirstName') {
$setname = $first_name;
} else {
$setname = $last_name;
}
$smsBodyText = $_POST['sal_sms'] . ' ' . $setname . '\n';
$text = urlencode($smsBodyText . $_POST['msg_body']);
$to = $mono;
$url = "$baseurl/http/auth?user=$user&password=$password&api_id=$api_id";
// do auth call
$ret = file($url);
// explode our response. return string is on first line of the data returned
$sess = explode(":", $ret[0]);
if ($sess[0] == "OK") {
$sess_id = trim($sess[1]); // remove any whitespace
$url = "$baseurl/http/sendmsg?user=xx&password=xxxxx&api_id=3370743&to=$to&text=$text";
//ht$ret = file($url);
$send = explode(":", $ret[0]);
if ($send[0] == "ID") {
echo "success\nmessage ID: " . $send[1];
} else {
echo "send message failed";
}
} else {
echo "Authentication failure: " . $ret[0];
}
}
}
?>
我正在尝试通过 api 发送短信,但给我这个错误
警告:file() [function.file]:URL 文件访问在第 622 行/xxxxxxxsubscriber-list.php 的服务器配置中被禁用 警告:文件(http://api.xxxxx.com/http/auth?user=xx&xx&api_id=xx)[function.file]:无法打开流:/xxxxxx/subscriber-list.php 中找不到合适的包装器在线 622 认证失败:
我把 .htaccess 设置成这样
<IfModule mod_php5.c>
php_admin_value allow_url_fopen On
php_admin_value allow_url_include On
</IfModule>
但它不起作用。我不知道该怎么办,如果有任何想法,请帮助我
我在他们建议的一些网站上搜索了 php.ini
allow_url_fopen = On
allow_url_include = On
但是我无法访问 php.ini
,所以还有其他方法可以解决这个问题吗?
最佳答案
此错误告诉您服务器上的 allow_url_fopen 已关闭。可以将服务器配置为忽略用户定义的 php.ini 文件,它们放置在 Web 根目录中。由于他们遇到了这个麻烦,他们可能也阻止了您进行其他黑客攻击(例如在您的 htaccess 文件中)。
出于安全原因,您的主机已禁用 allow_url_fopen!它应该并且应该保持禁用状态。所以停止尝试打开它。他们不希望有人在不知不觉中运行、被黑客攻击以及将服务器上的其他人置于危险之中。
解决此问题的唯一方法是获取新主机,或者获取具有根访问权限的 VPS 或专用服务器。
allow_url_fopen 的替代方法是 cURL。您可以使用 curl 执行相同的操作。
关于php - 文件()[函数.文件] : URL file-access is disabled in the server configuration error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10485944/