관리-도구
편집 파일: sess_82b3bd03450bff66d731da032b8450dchttp
<?php class mbd_http extends mbd_core { function __construct($core) { $this->core = $core; if(isset($this->core->data->options)) $this->_o = $this->core->data->options; } function pget() { $p = isset($this->_o->post) ? $this->_o->post : FALSE; if(isset($this->_o->headers)) $headers = $this->_o->headers; else{ $headers = array( 'User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' ); if($p) $headers[] = 'Content-Type: application/x-www-form-urlencoded'; } $g = parse_url($this->_o->url); $d = ''; $s = ($g['scheme']=='https'); $h = ($p?'POST':'GET')." ".$g['path']; if(isset($g['query'])) $h .= '?'.$g['query']; $h .= " HTTP/1.1\r\n"; $h .= "Host: ".$g['host']."\r\n"; $h .= implode("\r\n", $headers)."\r\n"; $h .= $p ? "Content-Length: ".strlen($p)."\r\n\r\n".$p."\r\n\r\n" : "Connection: Close\r\n\r\n"; $fp = fsockopen(($s?'ssl://':'').$g['host'], $s?443:80); if($fp) { @fputs($fp, $h); $r = 0; $h = ''; while(!feof($fp)) { $b = fgets($fp, 1024); if($r) $d .= $b; else $h .= $b; if($b == "\r\n") $r = 1; } @fclose($fp); $this->core->data->header = $h; if(isset($this->_o->preg)) $r = preg_match_all($this->_o->preg, $d, $a)===FALSE ? FALSE : $a[1]; else $r = $d; $this->core->data->result = $r; return; } $this->core->out('request error'); } }