【发布时间】:2016-06-09 14:24:28
【问题描述】:
由于某种原因,我无法再访问我的 HostPapa cpanel,它说:
The www.hostpapa.ca page isn’t working
www.hostpapa.ca is currently unable to handle this request.
HTTP ERROR 500
我检查了我的错误日志,发现在不同的日期/时间重复出现同样的错误:
[07-Jun-2016 14:30:26 America/Toronto] PHP Notice: Undefined index: HTTP_USER_AGENT in /home/saltn168/public_html/tripepic.com/tripepic-theme/List/tripepic-theme.php on line 1160
[07-Jun-2016 19:26:50 America/Toronto] PHP Notice: Undefined index: HTTP_USER_AGENT in /home/saltn168/public_html/tripepic.com/tripepic-theme/List/tripepic-theme.php on line 1160
[08-Jun-2016 08:45:14 America/Toronto] PHP Notice: Undefined index: HTTP_USER_AGENT in /home/saltn168/public_html/tripepic.com/tripepic-theme/List/tripepic-theme.php on line 1160
[08-Jun-2016 20:35:00 America/Toronto] PHP Notice: Undefined index: HTTP_USER_AGENT in /home/saltn168/public_html/tripepic.com/tripepic-theme/List/tripepic-theme.php on line 1160
[08-Jun-2016 23:14:13 America/Toronto] PHP Notice: Undefined index: HTTP_USER_AGENT in /home/saltn168/public_html/tripepic.com/tripepic-theme/List/tripepic-theme.php on line 1160
我检查了那个文件,第 1160 行是:
if(isset($r[2]) && @$r[2] == 'img' && preg_match('/MSIE [5-7]/',$_SERVER['HTTP_USER_AGENT']) == 0) {
对我来说这看起来像是胡言乱语,所以我不知道该怎么做。昨天我的搭档让我成为该网站的“超级管理员”——不确定它是否与此有关?或者为什么会是平的。
如果有人能指出正确的方向,我将不胜感激。
谢谢
【问题讨论】:
-
你用的是什么浏览器?
-
您可以在
preg_match之前添加条件&& isset($_SERVER['HTTP_USER_AGENT'])。 -
我正在使用 Chrome,但我只是在 Safari 中尝试过,它可以工作。太奇怪了。
-
@AngelaMartinez 就像我上面贴的问题说的那样,User-Agent header 是可选的,所以如果设置了就不会出错,如果没有设置就会出错,因为您将尝试访问不存在的索引。所以最好检查一下是否设置了
isset()。
标签: php regex error-handling phpmyadmin server