美高梅平台下载-美高梅娱乐平台登录

热门关键词: 美高梅平台下载,美高梅娱乐平台登录

复制代码 代码如下,复制代码 代码如下

日期:2020-01-22编辑作者:美高梅平台下载

代码如下所示:复制代码 代码如下:'ERROR', 2=>'WARNING', 4=>'PARSE', 8=>'NOTICE', 16=>'CORE_ERROR', 32=>'CORE_WARNING', 64=>'COMPILE_ERROR', 128=>'COMPILE_WARNING', 256=>'USER_ERROR', 512=>'USER_WARNING', 1024=>'USER_NOTICE', 2047=>'ALL', 2048=>'STRICT'); $msg = sprintf("%s: %s at file %s", $error_no_arr[$error] ,$error_string, $filename, $line); if(in_array{ echo $msg; echo "n";//调试显示 //发送信息 if { sendBankMsg; //发送简讯 if(strpos($error_string, 'xml_parse{ writeFiltefile; } } }}function hex2bin { $bindata = ''; for($i=0; $i < strlen { $bindata .= chr(hexdec(substr; } return $bindata;}function writeFiltefile{ if(strpos($error_string, 'xml_parse===FALSE||strpos===FALSE){ return; } //写入文件 $filename = 'filtetext.php'; include; $error_string = str_replace: Bytes:', '', $error_string); $error_string = str_replace(' 0x','', $error_string); $error_text = hex2bin; $filtetextArr[] = $error_text; $tempArr = array_unique;//去除重复 $result = implode; $result = ""; fileWrite($filename, $result, 'w'); }function sendBankMsg{ $timestamp = time(); $params = "msg=".$msg ."&posttime=".$timestamp; $length = strlen; //创建socket连接 $domain = "www.admin.com"; //socket域名 $actionPath = "/action/bank/bankmsg.php"; //文件路径 $fp = fsockopen; //构造post请求的头 if{ $header = "POST ".$actionPath." HTTP/1.1rn"; $header .= "Host:".$domain."rn"; $header .= "Content-Type: application/x-www-form-urlencodedrn"; $header .= "Content-Length: ".$length."rn"; $header .= "Connection: Closernrn"; //添加post的字符串 $header .= $params."rn"; //发送post的数据 fputs; while { $line = fgets; //去除请求包的头只显示页面的返回数据 if ($inheader && ($line == "n" || $line == "rn")) { echo $line; } } fclose; }}function fileWrite($fFileName, $fContent, $fTag = 'w') { ignore_user_abort ; $fp = fopen; if { fwrite; flock; } fclose; ignore_user_abort ; return;}?>

代码如下所示:
复制代码 代码如下:
/**
* 更新非法字符、發送錯誤信息

* @author
* @copyright 2009-06-10
*/
error_reporting(E_ERROR | E_WARNING | E_PARSE);
set_error_handler('displayErrorHandler');//自定義錯誤
//調試信息
echo "time:".date("Y-m-d H:i:s")."n";
//數據配置
//公共函數
function displayErrorHandler($error, $error_string, $filename, $line, $symbols)
{
    $error_no_arr = array(1=>'ERROR', 2=>'WARNING', 4=>'PARSE', 8=>'NOTICE', 16=>'CORE_ERROR', 32=>'CORE_WARNING', 64=>'COMPILE_ERROR', 128=>'COMPILE_WARNING', 256=>'USER_ERROR', 512=>'USER_WARNING', 1024=>'USER_NOTICE', 2047=>'ALL', 2048=>'STRICT');
    $msg = sprintf("%s: %s at file %s(%s)", $error_no_arr[$error] ,$error_string, $filename, $line);
    if(in_array($error,array(1,2,4))){      
        echo $msg; echo "n";//調試顯示
        //發送信息
        if($error==1||$error==2) {
            sendBankMsg($error_string); //發送簡訊
            if(strpos($error_string, 'xml_parse(): Bytes:')!==FALSE){
                writeFiltefile($error_string);
            }
        }
    }
}
function hex2bin($hexdata) {
    $bindata = '';
    for($i=0; $i < strlen($hexdata); $i += 2) {
        $bindata .= chr(hexdec(substr($hexdata, $i, 2)));
    }
    return $bindata;
}
function writeFiltefile($error_string)
{
    if(strpos($error_string, 'xml_parse(): Bytes:')===FALSE||strpos($error_string, ' 0x')===FALSE){
        return;
    }          
    //寫入文件
    $filename = 'filtetext.php';
    include($filename);
    $error_string = str_replace('xml_parse(): Bytes:', '', $error_string);
    $error_string = str_replace(' 0x','', $error_string);
    $error_text = hex2bin($error_string);
    $filtetextArr[] = $error_text;
    $tempArr = array_unique($filtetextArr);//去除重復
    $result = implode("','",$tempArr);
    $result = "";
    fileWrite($filename, $result, 'w');  
}
function sendBankMsg($msg)
{
    $timestamp = time();
    $params = "msg=".$msg
             ."&posttime=".$timestamp;  
    $length = strlen($params);
    //创建socket连接
    $domain = "www.admin.com"; //socket域名
    $actionPath = "/action/bank/bankmsg.php"; //文件路徑
    $fp = fsockopen($domain,80);
    //构造post请求的头
    if($fp){
        $header = "POST ".$actionPath." HTTP/1.1rn";
        $header .= "Host:".$domain."rn";
        $header .= "Content-Type: application/x-www-form-urlencodedrn";
        $header .= "Content-Length: ".$length."rn";
        $header .= "Connection: Closernrn";
        //添加post的字符串
        $header .= $params."rn";
        //发送post的数据
        fputs($fp,$header);
        while (!feof($fp)) {
            $line = fgets($fp,1024); //去除请求包的头只显示页面的返回数据
            if ($inheader && ($line == "n" || $line == "rn")) {
                echo $line;
            }
        }
        fclose($fp);
    }
}
function fileWrite($fFileName, $fContent, $fTag = 'w') {
    ignore_user_abort (TRUE);
    $fp = fopen($fFileName, $fTag);
    if (flock($fp, LOCK_EX)) {
        fwrite($fp, $fContent);
        flock($fp, LOCK_UN);
    }
    fclose($fp);
    ignore_user_abort (FALSE);
    return;
}
?>

这里给大家分享一段使用PHP Socket 编程模拟Http post和get请求的代码,非常的实用,结尾部分我们再讨论下php模拟http请求的几种方法。

复制代码 代码如下:
 * 使用PHP Socket 编程模拟Http post和get请求
 * @author koma
 */ class Http{
    private $sp = "rn"; //这里必须要写成双引号     private $protocol = 'HTTP/1.1';
    private $requestLine = "";
    private $requestHeader = "";
    private $requestBody = "";
    private $requestInfo = "";
    private $fp = null;
    private $urlinfo = null;
    private $header = array();
    private $body = "";
    private $responseInfo = "";
    private static $http = null; //Http对象单例    
    private function __construct() {}
    public static function create() {
        if ( self::$http === null ) { 
            self::$http = new Http();
        }
        return self::$http;
    }
    public function init($url) {
        $this->parseurl($url);
        $this->header['Host'] = $this->urlinfo['host'];
        return $this;
    }
    public function get($header = array()) {
        $this->header = array_merge($this->header, $header);
        return $this->request('GET');
    }
    public function post($header = array(), $body = array()) {
        $this->header = array_merge($this->header, $header);
        if ( !empty($body) ) {
            $this->body = http_build_query($body);
            $this->header['Content-Type'] = 'application/x-www-form-urlencoded';
            $this->header['Content-Length'] = strlen($this->body);
        }
        return $this->request('POST');
    }
    private function request($method) {
        $header = "";
        $this->requestLine = $method.' '.$this->urlinfo['path'].'?'.$this->urlinfo['query'].' '.$this->protocol;
        foreach ( $this->header as $key => $value ) {
            $header .= $header == "" ? $key.':'.$value : $this->sp.$key.':'.$value;
        }
        $this->requestHeader = $header.$this->sp.$this->sp;
        $this->requestInfo = $this->requestLine.$this->sp.$this->requestHeader;
        if ( $this->body != "" ) {
            $this->requestInfo .= $this->body;
        }
        /*
         * 注意:这里的fsockopen中的url参数形式为"www.xxx.com"
         * 不能够带"
         */
        $port = isset($this->urlinfo['port']) ? isset($this->urlinfo['port']) : '80';
        $this->fp = fsockopen($this->urlinfo['host'], $port, $errno, $errstr);
        if ( !$this->fp ) {
            echo $errstr.'('.$errno.')';
            return false;
        }
        if ( fwrite($this->fp, $this->requestInfo) ) {
            $str = "";
            while ( !feof($this->fp) ) {
                $str .= fread($this->fp, 1024);
            }
            $this->responseInfo = $str;
        }
        fclose($this->fp);
        return $this->responseInfo;
    }
    private function parseurl($url) {
        $this->urlinfo = parse_url($url);
    }
} // $url = "";
$url = ""; $http = Http::create()->init($url); /* 发送get请求 
echo $http->get(array(
    'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36',
));
*/
 /* 发送post请求 */ echo $http->post(array(
        'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36',
), array('username'=>'发一个中文', 'age'=>22));

php 模拟 http请求

方法一:利用php的socket编程来直接给接口发送数据来模拟post的操作。

建立两个文件post.php,getpost.php
post.php内容如下:

复制代码 代码如下:
 $flag = 0;
 $params = '';
 $errno = '';
 $errstr = '';
 //要post的数据
$argv = array(
    'var1'=>'abc',
    'var2'=>'how are you , my friend??');
//构造要post的字符串
foreach ($argv as $key=>$value) {
    if ($flag!=0) {
        $params .= "&";
        $flag = 1;
    }
    $params.= $key."="; $params.= urlencode($value);
    $flag = 1;
    }
    $length = strlen($params);
     //创建socket连接
    $fp = fsockopen("localhost",81,$errno,$errstr,10) or exit($errstr."--->".$errno);
    //构造post请求的头
    $header  = "POST /flandy/getpost.php HTTP/1.1rn";
    $header .= "Host:127.0.0.1rn";
    $header .= "Referer:/flandy/post.phprn";
    $header .= "Content-Type: application/x-www-form-urlencodedrn";
    $header .= "Content-Length: ".$length."rn";
    $header .= "Connection: Closernrn";
    //添加post的字符串
    $header .= $params."rn";    

    //发送post的数据
    fputs($fp,$header);
    $inheader = 1;
    while (!feof($fp)) {
        $line = fgets($fp,1024); //去除请求包的头只显示页面的返回数据
        if ($inheader && ($line == "n" || $line == "rn")) {
             $inheader = 0;
        }
        if ($inheader == 0) {
          echo $line;
        }
    }

fclose($fp);
?>

getpost.php的内容如下

本文由美高梅平台下载发布于美高梅平台下载,转载请注明出处:复制代码 代码如下,复制代码 代码如下

关键词:

PID文件的位置. 默认为空.,并监听不同的端口和

ps aux |grep php-fpm |more 查看php-fpm总数php-fpm.conf 配置pidstringPID文件的位置. 默认为空.error_log string错误日志的位置. 默认:...

详细>>

php不单可以写前台网页

php_cli模式简介 php-cli是php Command LineInterface的简称,如同它名字的意思,就是php在命令行运行的接口,区别于在Web服务...

详细>>

使用同样的构建过程可以创建不同的表示,复制

例一: 复制代码 代码如下:复制代码代码如下:fruit_color = $color; } function getcolor() { return$this-fruit_color; } function setsize ...

详细>>

显示几个分页

复制代码 代码如下:/* * 分页函数 * $num总条数,$perpage 一页多少条, $curpage 当前页, $mpurl url, $page = 10显示几个分页 * */...

详细>>