服务器错误消息:无文件访问

时间:2010-04-08 22:55:13

标签: php

我遇到了问题,但不知道在哪里解决问题。我的模板在xampp中运行良好,但在主机服务器上运行不正常。我收到这条消息:

警告:file_get_contents() [function.file-get-contents]:在主页/....... / twitter.php的服务器配置中禁用URL文件访问。

错误在第64行。

<?php
/*
For use in the "Parse Twitter Feeds" code below
*/
define("SECOND", 1);
define("MINUTE", 60 * SECOND);
define("HOUR", 60 * MINUTE);
define("DAY", 24 * HOUR);
define("MONTH", 30 * DAY);
function relativeTime($time)
{
$delta = time() - $time;
if ($delta < 2 * MINUTE) {
    return "1 min ago";
}
if ($delta < 45 * MINUTE) {
    return floor($delta / MINUTE) . " min ago";
}
if ($delta < 90 * MINUTE) {
    return "1 hour ago";
}
if ($delta < 24 * HOUR) {
    return floor($delta / HOUR) . " hours ago";
}
if ($delta < 48 * HOUR) {
    return "yesterday";
}
if ($delta < 30 * DAY) {
    return floor($delta / DAY) . " days ago";
}
if ($delta < 12 * MONTH) {
    $months = floor($delta / DAY / 30);
    return $months <= 1 ? "1 month ago" : $months . " months ago";
} else {
    $years = floor($delta / DAY / 365);
    return $years <= 1 ? "1 year ago" : $years . " years ago";
}
}


/*
Parse Twitter Feeds

*/
function parse_cache_feed($usernames, $limit, $type) {
$username_for_feed = str_replace(" ", "+OR+from%3A", $usernames);
$feed = "http://twitter.com/statuses/user_timeline.atom?screen_name=" . $username_for_feed . "&count=" . $limit;
$usernames_for_file = str_replace(" ", "-", $usernames);
$cache_file = dirname(__FILE__).'/cache/' . $usernames_for_file . '-twitter-cache-' . $type;

if (file_exists($cache_file)) { 
    $last = filemtime($cache_file);
    }

$now = time();
$interval = 600; // ten minutes
// check the cache file
if ( !$last || (( $now - $last ) > $interval) ) {
    // cache file doesn't exist, or is old, so refresh it
    $cache_rss = file_get_contents($feed); (this is line 64)

有关如何在我的主机服务器上授予此权限的任何帮助?

3 个答案:

答案 0 :(得分:2)

您的服务器管理员已禁止访问php文件功能的网址(allow_url_fopen ini设置)。请他们启用它,或考虑其他方法,如curl

答案 1 :(得分:0)

allow_url_fopen

中的on似乎尚未转为php.ini

答案 2 :(得分:0)

我刚刚创建了一个php.ini文件并添加:"allow_url_fopen=on",保存并将其上传到我的服务器和wolla ......它可以运行。再次感谢上面的人!