function resSteal($dbHandle, $ip, $access, $threadUrl, $prepareSt, $ua, $host) { try { $opc = array("socket" => array("bindto" => "{$ip}:0"), "http" => array("ignore_errors" => true, "method" => "GET", "header" => "Host:{$host}\r\n" . "User-Agent:{$ua}\r\n")); $context = stream_context_create($opc); $resBaseHtml = file_get_contents($threadUrl, false, $context); // var_dump($http_response_header[8].$http_response_header[5]); $encode = mb_detect_encoding($resBaseHtml); if ($encode === "UTF-8") { $encodiedResBaseHtml = $resBaseHtml; } else { $encodiedResBaseHtml = mb_convert_encoding($resBaseHtml, "UTF-8", "SJIS,UTF-8"); } if (!$resBaseHtml) { $em = "Do not steal to Res!"; throw new Exception($em); } } catch (Exception $e) { errorProc($e->getMessage()); echo $e->getMessage(); } ipAccess($dbHandle, $ip, $access, $threadUrl, $prepareSt); return $encodiedResBaseHtml; }
/** * 获取IP是否充许访问 * @param string $ip ip * @return bool */ function ipBanned($ip) { global $_FANWE; if ($_FANWE['setting']['ip_access'] && !ipAccess($ip, $_FANWE['setting']['ip_access'])) { return true; } FanweService::instance()->cache->loadCache('ipbanned'); if (empty($_FANWE['cache']['ipbanned'])) { return false; } else { if ($_FANWE['cache']['ipbanned']['expiration'] < TIME_UTC) { FanweService::instance()->cache->updateCache('ipbanned'); } return preg_match("/^(" . $_FANWE['cache']['ipbanned']['regexp'] . ")\$/", $ip); } }
private function buildMisc() { if (!$this->is_misc) { return false; } $this->var['form_hash'] = formHash(); define('FORM_HASH', $this->var['form_hash']); if ($this->init_user) { if ($this->var['user']['status'] == -1) { systemError('user_banned', null); } } if ($this->var['setting']['ip_access'] && !ipAccess($this->var['client_ip'], $this->var['setting']['ip_access'])) { systemError('user_banned', null); } if ($this->var['setting']['nocacheheaders']) { @header("Expires: -1"); @header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE); @header("Pragma: no-cache"); } }