未定义的偏移:1 php google drive wp media WordPress插件

时间:2016-12-27 03:19:38

标签: php wordpress nginx

我正在为我的WordPress网站使用谷歌驱动器WP媒体WordPress插件 但是这个插件会在我的nginx服务器上保留此错误,有人可以帮我修复此代码

[error] 4437#4437: *175114 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined offset: 1 in /var/www/myhost/htdocs/wp-content/uploads/gdwpm_images/index.php on line 4
PHP message: PHP Notice:  Undefined offset: 1 in /var/www/myhost/htdocs/wp-content/uploads/gdwpm_images/index.php on line 4
PHP message: PHP Notice:  Undefined offset: 1 in /var/www/myhost/htdocs/wp-content/uploads/gdwpm_images/index.php on line 4" while reading response header from upstream, client: 122.167.98.6, server: myhost, request: "GET /wp-content/uploads/gdwpm_images/0B73eY08zeFxawYUhGOTA.jpg HTTP/1.1", upstream: "fastcgi://127.0.0.1:9070", host: "myhost", referrer: "http://...

这里是gdwpm_image / index.php代码

<?php
if (isset($_GET['imgid'])){
    $gdwpm_ekst_gbr = explode('.', $_GET['imgid']);
    if($gdwpm_ekst_gbr[1] == 'png' || $gdwpm_ekst_gbr[1] == 'gif' || $gdwpm_ekst_gbr[1] == 'bmp'){
        header("Content-Type: image/" . $gdwpm_ekst_gbr[1]);
    }else{
        header("Content-Type: image/jpg");
    }
    $gdurl = "https://docs.google.com/uc?id=" . $gdwpm_ekst_gbr[0] . "&export=view";
    @readfile($gdurl);
}
?>

我尝试修复代码,但没有更改。 有人可以帮忙修复它吗? 谢谢!

1 个答案:

答案 0 :(得分:0)

在以下行之后...

$(".@(ViewBag.collapse)").collapse("toggle");

在尝试访问$gdwpm_ekst_gbr = explode('.', $_GET['imgid']); 元素之前,检查$gdwpm_ekst_gbr是否包含任何数组项。

如果您尝试访问的索引处的数组项不存在,则会发生您发布的错误消息。