sg11代码加密

<?php
// 多个PHP版本号,号隔开 支持5.4-7.4 列如 5.4,5.5,5.6
print_r((new Encrypt('Sg11', '7.3', '陌屿PHP代码加密'))->sg11('11.zip', 'encode.zip'));

class Encrypt
{
    private $edition;
    private $version;
    private $comment;
    
    public function __construct($edition, $version, $comment){
        $this->edition = $edition;
        $this->version = $version;
        $this->comment = $comment;
    }
    
    public function sg11($original, $complete) {
        if(!is_file($original)){
            $data = [
                'code' => -1,
                'info' => '$original并不是一个有效文件!'
            ];
            return $this->json_format($data);
        }
        $result = json_decode($this->get_curl('https://encode.phpth.cn/api.php?act=encode',[
            'post'=>[
                'edition'   => $this->edition,
                'version'   => $this->version,
                'comment'   => $this->comment,
                'file'      => new CURLFile($original)
            ]
        ]),true);
        if($result['code'] == 1){
            file_put_contents($complete,$this->get_curl('https://encode.phpth.cn/api.php?act=downfile&file='.$result['down']));
            $data = [
                'code' => 1,
                'info' => $result['info'],
            ];
            return $this->json_format($data);
        }else{
            $data = [
                'code' => -1,
                'info' => $result['info']
            ];
            return $this->json_format($data);
        }
    }
    
    public function json_format($msg) {
        header('Content-Type: application/json; charset=utf-8');
        return json_encode($msg, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
    }
    
    private function get_curl($url, $paras = array()) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        if (@$paras['Header']) {
            $Header = $paras['Header'];
        } else {
            $Header[] = "Accept:*/*";
            $Header[] = "Accept-Encoding:gzip,deflate,sdch";
            $Header[] = "Accept-Language:zh-CN,zh;q=0.8";
            $Header[] = "Connection:close";
        }
        curl_setopt($ch, CURLOPT_HTTPHEADER, $Header);
        if (@$paras['ctime']) { // 连接超时
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $paras['ctime']);
        } else {
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
        }
        if (@$paras['rtime']) { // 读取超时
            curl_setopt($ch, CURLOPT_TIMEOUT, $paras['rtime']);
        }
        if (@$paras['post']) {
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $paras['post']);
        }
        if (@$paras['header']) {
            curl_setopt($ch, CURLOPT_HEADER, true);
        }
        if (@$paras['cookie']) {
            curl_setopt($ch, CURLOPT_COOKIE, $paras['cookie']);
        }
        if (@$paras['refer']) {
            if ($paras['refer'] == 1) {
                curl_setopt($ch, CURLOPT_REFERER, 'http://m.qzone.com/infocenter?g_f=');
            } else {
                curl_setopt($ch, CURLOPT_REFERER, $paras['refer']);
            }
        }
        if (@$paras['ua']) {
            curl_setopt($ch, CURLOPT_USERAGENT, $paras['ua']);
        } else {
            curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36");
        }
        if (@$paras['nobody']) {
            curl_setopt($ch, CURLOPT_NOBODY, 1);
        }
        curl_setopt($ch, CURLOPT_ENCODING, "gzip");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        if (@$paras['GetCookie']) {
            curl_setopt($ch, CURLOPT_HEADER, 1);
            $result = curl_exec($ch);
            preg_match_all("/Set-Cookie: (.*?);/m", $result, $matches);
            $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
            $header = substr($result, 0, $headerSize); //状态码
            $body = substr($result, $headerSize); //响应内容
            $ret = [
                "Cookie" => $matches, "body" => $body, "code" => $header
            ];
            curl_close($ch);
            return $ret;
        }
        $ret = curl_exec($ch);
        if (@$paras['loadurl']) {
            $Headers = curl_getinfo($ch);
            $ret = $Headers['redirect_url'];
        }
        curl_close($ch);
        return $ret;
    }
}
?>

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值