[2] ErrorException in common.php line 101

file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known

  1. ////根据ip获得访客所在地地名
  2. function Getaddress($ip = '')
  3. {
  4. if (empty($ip)) {
  5. $ip = request()->ip();
  6. }
  7. $url = 'http://ip.ws.126.net/ipquery?ip=';
  8. $ipadd = file_get_contents($url . $ip); // 根据126.net接口获取
  9. if ($ipadd) {
  10. $charset = iconv("gbk", "utf-8", $ipadd);
  11. preg_match_all("/[\x{4e00}-\x{9fa5}]+/u", $charset, $ipadds);
  12. return $ipadds; // 返回一个二维数组
  13. } else {
  14. return false;
  15. }
  16. }

Call Stack

  1. in common.php line 101
  2. at Error::appError(2, 'file_get_contents():...', '/data/wwwroot/office...', 101, ['ip' => '107.158.144.242'])
  3. at file_get_contents('http://ip.ws.126.net...') in common.php line 101
  4. at Getaddress() in Index.php line 52
  5. at Index->_initialize() in Controller.php line 59
  6. at Controller->__construct(object(Request))
  7. at ReflectionClass->newInstanceArgs([object(Request)]) in App.php line 359
  8. at App::invokeClass('app\index\controller...') in Loader.php line 479
  9. at Loader::controller('index', 'controller', false, 'Error') in App.php line 580
  10. at App::module(['', null, null], ['app_host' => '', 'app_debug' => true, 'app_trace' => false, ...], true) in App.php line 456
  11. at App::exec(['type' => 'module', 'module' => ['', null, null]], ['app_host' => '', 'app_debug' => true, 'app_trace' => false, ...]) in App.php line 139
  12. at App::run() in start.php line 19
  13. at require('/data/wwwroot/office...') in index.php line 26

Environment Variables

GET Data
empty
POST Data
empty
Files
empty

Cookies

PHPSESSID
aqu0ljvdcgrn845q5544msglo8
Session
empty

Server/Request Data

TEMP
/tmp
TMPDIR
/tmp
TMP
/tmp
PATH
/usr/local/bin:/usr/bin:/bin
USER
www
HOME
/home/www
HTTP_COOKIE
PHPSESSID=aqu0ljvdcgrn845q5544msglo8
HTTP_ACCEPT_ENCODING
gzip
HTTP_ACCEPT
*/*
HTTP_HOST
www.huahengxin.com
HTTP_USER_AGENT
Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
PATH_INFO
REDIRECT_STATUS
200
SERVER_NAME
www.huahengxin.com
SERVER_PORT
80
SERVER_ADDR
172.28.128.48
REMOTE_PORT
59688
REMOTE_ADDR
107.158.144.242
SERVER_SOFTWARE
nginx/1.18.0
GATEWAY_INTERFACE
CGI/1.1
REQUEST_SCHEME
http
SERVER_PROTOCOL
HTTP/1.1
DOCUMENT_ROOT
/data/wwwroot/office_v2/public
DOCUMENT_URI
/index.php
REQUEST_URI
/
SCRIPT_NAME
/index.php
CONTENT_LENGTH
CONTENT_TYPE
REQUEST_METHOD
GET
QUERY_STRING
SCRIPT_FILENAME
/data/wwwroot/office_v2/public/index.php
FCGI_ROLE
RESPONDER
PHP_SELF
/index.php
REQUEST_TIME_FLOAT
1655365440.036
REQUEST_TIME
1655365440
Environment Variables
empty

ThinkPHP Constants

APP_PATH
/data/wwwroot/office_v2/public/../application/
THINK_VERSION
5.0.24
THINK_START_TIME
1655365440.0361
THINK_START_MEM
398032
EXT
.php
DS
/
THINK_PATH
/data/wwwroot/office_v2/thinkphp/
LIB_PATH
/data/wwwroot/office_v2/thinkphp/library/
CORE_PATH
/data/wwwroot/office_v2/thinkphp/library/think/
TRAIT_PATH
/data/wwwroot/office_v2/thinkphp/library/traits/
ROOT_PATH
/data/wwwroot/office_v2/
EXTEND_PATH
/data/wwwroot/office_v2/extend/
VENDOR_PATH
/data/wwwroot/office_v2/vendor/
RUNTIME_PATH
/data/wwwroot/office_v2/runtime/
LOG_PATH
/data/wwwroot/office_v2/runtime/log/
CACHE_PATH
/data/wwwroot/office_v2/runtime/cache/
TEMP_PATH
/data/wwwroot/office_v2/runtime/temp/
CONF_PATH
/data/wwwroot/office_v2/public/../application/
CONF_EXT
.php
ENV_PREFIX
PHP_
IS_CLI
false
IS_WIN
false
FILTER_VALIDATE_BOOL
258
ADDON_PATH
/data/wwwroot/office_v2/addons/