<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://purl.org/rss/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel rdf:about="https://dwt.life/feed/rss/tag/PHP/">
<title>dwt&#039;s life - PHP</title>
<link>https://dwt.life/tag/PHP/</link>
<description></description>
<items>
<rdf:Seq>
<rdf:li resource="https://dwt.life/archives/320/"/>
<rdf:li resource="https://dwt.life/archives/311/"/>
<rdf:li resource="https://dwt.life/archives/203/"/>
<rdf:li resource="https://dwt.life/archives/192/"/>
<rdf:li resource="https://dwt.life/archives/188/"/>
<rdf:li resource="https://dwt.life/archives/164/"/>
<rdf:li resource="https://dwt.life/archives/144/"/>
<rdf:li resource="https://dwt.life/archives/24/"/>
</rdf:Seq>
</items>
</channel>
<item rdf:about="https://dwt.life/archives/320/">
<title>PHP去除LR LF等特殊字符串</title>
<link>https://dwt.life/archives/320/</link>
<dc:date>2023-01-21T20:45:11+08:00</dc:date>
<description>function clean($text)
{
    return trim(preg_replace(&quot;/(\s*[\r\n]+\s*|\s+)/&quot;, &#039; &#039;, $text));
}the first part \s[\r\n]+\s will replace any line breaks, it's leading spaces and it's tailing spaces into just one space.the second part \s+ will shrink spaces into one space.then trim() removes the leading/tailing space.</description>
</item>
<item rdf:about="https://dwt.life/archives/311/">
<title>PHP ssh</title>
<link>https://dwt.life/archives/311/</link>
<dc:date>2022-09-12T17:15:08+08:00</dc:date>
<description>&lt;?php
class NiceSSH {
    // SSH Host
    private $ssh_host = &#039;myserver.example.com&#039;;
    // SSH Port
    private $ssh_port = 22;
    // SSH Server Fingerprint
    private $ssh_server_fp = &#039;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&#039;;
    // SSH Username
    private $ssh_auth_user = &#039;username&#039;;
    // SSH Public Key File
    private $ssh_auth_pub = &#039;/home/username/.ssh/id_rsa.pub&#039;;
    // SSH Private Key File
    private $ssh_auth_priv = &#039;/home/username/.ssh/id_rsa&#039;;
    // SSH Private Key Passphrase (null == no passphrase)
    private $ssh_auth_pass;
    // SSH Connection
    private $connection;
   
    public function connect() {
        if (!($this-&gt;connection = ssh2_connect($this-&gt;ssh_host, $this-&gt;ssh_port))) {
            throw new Exception(&#039;Cannot connect to server&#039;);
        }
        $fingerprint = ssh2_fingerprint($this-&gt;connection, SSH2_FINGERPRINT_MD5 | SSH2_FINGERPRINT_HEX);
        if (strcmp($this-&gt;ssh_server_fp, $fingerprint) !== 0) {
            throw new Exception(&#039;Unable to verify server identity!&#039;);
        }
        if (!ssh2_auth_pubkey_file($this-&gt;connection, $this-&gt;ssh_auth_user, $this-&gt;ssh_auth_pub, $this-&gt;ssh_auth_priv, $this-&gt;ssh_auth_pass)) {
            throw new Exception(&#039;Autentication rejected by server&#039;);
        }
    }
    public function exec($cmd) {
        if (!($stream = ssh2_exec($this-&gt;connection, $cmd))) {
            throw new Exception(&#039;SSH command failed&#039;);
        }
        stream_set_blocking($stream, true);
        $data = &quot;&quot;;
        while ($buf = fread($stream, 4096)) {
            $data .= $buf;
        }
        fclose($stream);
        return $data;
    }
    public function disconnect() {
        $this-&gt;exec(&#039;echo &quot;EXITING&quot; &amp;&amp; exit;&#039;);
        $this-&gt;connection = null;
    }
    public function __destruct() {
        $this-&gt;disconnect();
    }
}
?&gt;</description>
</item>
<item rdf:about="https://dwt.life/archives/203/">
<title>PHP异常处理之获取错误发生的所在行</title>
<link>https://dwt.life/archives/203/</link>
<dc:date>2022-04-24T21:35:08+08:00</dc:date>
<description>在异常被捕获之后，我们可以通过异常处理对象获取其中的异常信息。在实际应用中，我们通常会获取足够多的异常信息，然后写入到错误日志中。通常我们需要将报错的文件名、行号、错误信息、导演追踪信息等记录到日志中，以便调试与修复问题。&lt;?php
 
try {
    throw new Exception(&#039;错误信息&#039;);
} cathc (Exception $e) {
    $msg = &#039;Error: &#039; . $e-&gt;getMessage(); // 获取错误信息
    
    $msg .= $e-&gt;getTraceAsString(); // 获取字符串类型的异常追踪信息
    
    $msg .= &#039;异常行号：&#039; . $e-&gt;getLine(); // 异常发生所在行
    
    $msg .= &#039;所在文件：&#039; . $e-&gt;getFile(); // 异常发生所在文件绝对路径
    
    file_put_contents(&#039;error.log&#039;, $msg);
}</description>
</item>
<item rdf:about="https://dwt.life/archives/192/">
<title>Nmap web在线精确扫描、检测服务器端口开放</title>
<link>https://dwt.life/archives/192/</link>
<dc:date>2022-02-17T00:19:00+08:00</dc:date>
<description>composer安装项目目录执行composer require palepurple/nmap修改代码原来的composer src中的代码并不会进行精确扫描，需要修改文件vendor/palepurple/nmap/src/Nmap/Nmap.php代码实现该功能：    private $enableTcp = false;

    public function buildCommand(array $targets, array $ports = array()): array
    {

        if (true === $this-&gt;enableTcp) {
            $options[] = &#039;-sT&#039;;
        }
    }

    public function enableTcp($enable = true): self
    {
        $this-&gt;enableTcp = $enable;

        return $this;
    }注针对Centos，可以使用yum install nmap进行安装，否则将无法运行扫描。另外需要开放exec函数的执行权限。最后如果要对接web，可以使用workerman websocket连接实现逐行显示。可以见我实现的功能：端口开放在线检测工具https://tool.hi.cn/port/</description>
</item>
<item rdf:about="https://dwt.life/archives/188/">
<title>ThinkPHP5中如何加入插件功能</title>
<link>https://dwt.life/archives/188/</link>
<dc:date>2022-01-31T17:28:00+08:00</dc:date>
<description>加入插件的方法：1、在系统的index.php入口中加入如下配置// 插件目录
define(&#039;ADDON_PATH&#039;, __DIR__ . &#039;/../addons/&#039;);
// 开启系统行为
define(&#039;APP_HOOK&#039;, true);2、在数据库中加入addons插件表和hooks钩子表CREATE TABLE `addons` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT &#039;主键&#039;,
  `name` varchar(40) NOT NULL COMMENT &#039;插件名或标识&#039;,
  `title` varchar(20) NOT NULL DEFAULT &#039;&#039; COMMENT &#039;中文名&#039;,
  `description` text COMMENT &#039;插件描述&#039;,
  `status` tinyint(1) NOT NULL DEFAULT &#039;1&#039; COMMENT &#039;状态&#039;,
  `config` text COMMENT &#039;配置&#039;,
  `author` varchar(40) DEFAULT &#039;&#039; COMMENT &#039;作者&#039;,
  `version` varchar(20) DEFAULT &#039;&#039; COMMENT &#039;版本号&#039;,
  `create_time` int(10) unsigned NOT NULL DEFAULT &#039;0&#039; COMMENT &#039;安装时间&#039;,
  `has_adminlist` tinyint(1) unsigned NOT NULL DEFAULT &#039;0&#039; COMMENT &#039;是否有后台列表&#039;,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT=&#039;插件表&#039;;

CREATE TABLE `hooks` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT &#039;主键&#039;,
  `name` varchar(40) NOT NULL DEFAULT &#039;&#039; COMMENT &#039;钩子名称&#039;,
  `description` text NOT NULL COMMENT &#039;描述&#039;,
  `type` tinyint(1) unsigned NOT NULL DEFAULT &#039;1&#039; COMMENT &#039;类型&#039;,
  `update_time` int(10) unsigned NOT NULL DEFAULT &#039;0&#039; COMMENT &#039;更新时间&#039;,
  `addons` varchar(255) NOT NULL DEFAULT &#039;&#039; COMMENT &#039;钩子挂载的插件 &#039;&#039;，&#039;&#039;分割&#039;,
  `status` tinyint(2) DEFAULT &#039;1&#039;,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;3、在ThinkPHP5的根目录中创建addons目录www  WEB项目目录
├─composer.json         composer定义文件
├─README.md             README文件
├─LICENSE.txt           授权说明文件
├─addons                插件目录（新增）
├─application           应用目录
│  ├─common             公共模块目录（可以更改）
│  ├─runtime            应用的运行时目录（可写，可定制）
│  ├─module             模块目录
│  │  └─ ...            更多类库目录
│  ├─common.php         公共函数文件
│  ├─config.php         公共配置文件
│  ├─route.php          路由配置文件
│  └─database.php       数据库配置文件
│
├─public                WEB目录（对外访问目录）
│  ├─index.php          入口文件
│  ├─.htaccess          用于apache的重写
│  └─router.php         快速测试文件（用于PHP内置webserver）
│
├─thinkphp              框架系统目录4、在application中的common.php公共函数里添加两个公共方法/**
 * 获取插件类的类名
 * @param strng $name 插件名
 * @param string $ext 扩展名
 */
function get_addon_class($name, $ext = EXT)
{
    // 初始化命名空间及类名
    $class = &quot;addons\\{$name}\\&quot; . ucfirst($name);
    return $class;
}

/**
 * 处理插件钩子
 * @param string $hook   钩子名称
 * @param mixed $params 传入参数
 * @return void
 */
function hook($hook, $params = [])
{
    // 钩子调用
    \think\Hook::listen($hook, $params);
}5、在application目录下创建common模块，在common模块中创建behavior行为目录，在公共行为目录中创建Hooks.php钩子行为插件，内容如下：&lt;?php
// +----------------------------------------------------------------------
// | zzstudio [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://www.zzstudio.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Byron Sampson &lt;xiaobo.sun@gzzstudio.net&gt;
// +----------------------------------------------------------------------
namespace app\common\behavior;

use think\Hook;

class Hooks
{
    public function run(&amp;$param = [])
    {
        if(defined(&#039;BIND_MODULE&#039;) &amp;&amp; BIND_MODULE === &#039;Install&#039;) return;
        // 动态加入命名空间
        \think\Loader::addNamespace(&#039;addons&#039;, ADDON_PATH);
        // 获取钩子数据
        $data = S(&#039;hooks&#039;);
        if(!$data){
            $hooks = M(&#039;Hooks&#039;)-&gt;getField(&#039;name,addons&#039;);
            // 获取钩子的实现插件信息
            foreach ($hooks as $key =&gt; $value) {
                if($value){
                    $map[&#039;status&#039;]  =   1;
                    $names          =   explode(&#039;,&#039;,$value);
                    $map[&#039;name&#039;]    =   [&#039;IN&#039;, $names];
                    $data = M(&#039;Addons&#039;)-&gt;where($map)-&gt;getField(&#039;id,name&#039;);
                    if($data){
                        $addons = array_intersect($names, $data);
                        Hook::add($key, array_map(&#039;get_addon_class&#039;, $addons));
                    }
                }
            }
            S(&#039;hooks&#039;, Hook::get());
        }else{
            Hook::import($data, false);
        }
    }
}6、在application目录中创建tags.php行为配置文件，并且加入内容&lt;?php
// 系统行为定义
return [
    &#039;app_init&#039; =&gt; [
        &#039;app\\common\\behavior\\Hooks&#039;
    ],
    &#039;action_begin&#039;=&gt; [
    ],
    &#039;app_end&#039;=&gt; [
    ]
];到此为止，插件功能就集成完毕了。接下来我们做个简单的插件试一下：1、在addons目录中创建一个Base.php 插件的基类&lt;?php
// +----------------------------------------------------------------------
// | addons [ WE CAN DO IT JUST ZZSTUDIO IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015 http://www.zzstudio.net All rights reserved.
// +----------------------------------------------------------------------
// | Author: byron sampson &lt;xiaobo.sun@zzstudio.net&gt;
// +----------------------------------------------------------------------
namespace addons;

/**
 * 插件类
 * @author byron sampson &lt;xiaobo.sun@zzstudio.net&gt;
 */
abstract class Base{
    /**
     * 视图实例对象
     * @var view
     * @access protected
     */
    protected $view = null;

    /**
     * $info = array(
     *  &#039;name&#039;=&gt;&#039;Editor&#039;,
     *  &#039;title&#039;=&gt;&#039;编辑器&#039;,
     *  &#039;description&#039;=&gt;&#039;用于增强整站长文本的输入和显示&#039;,
     *  &#039;status&#039;=&gt;1,
     *  &#039;author&#039;=&gt;&#039;thinkphp&#039;,
     *  &#039;version&#039;=&gt;&#039;0.1&#039;
     *  )
     */
    public $info                =   array();
    public $addon_path          =   &#039;&#039;;
    public $config_file         =   &#039;&#039;;
    public $custom_config       =   &#039;&#039;;
    public $admin_list          =   array();
    public $custom_adminlist    =   &#039;&#039;;
    public $access_url          =   array();

    /**
     * 基类构造函数
     * Base constructor.
     */
    public function __construct()
    {
        $this-&gt;view         =   new \think\View();
        $this-&gt;addon_path   =   ADDON_PATH . $this-&gt;getName() . &#039;/&#039;;
        $TMPL_PARSE_STRING = C(&#039;parse_str&#039;);
        $TMPL_PARSE_STRING[&#039;__ADDONROOT__&#039;] = $TMPL_PARSE_STRING[&#039;__ADDONS__&#039;] . &#039;/&#039; . $this-&gt;getName();
        C(&#039;parse_str&#039;, $TMPL_PARSE_STRING);
        if(is_file($this-&gt;addon_path . &#039;config.php&#039;)){
            $this-&gt;config_file = $this-&gt;addon_path . &#039;config.php&#039;;
        }
    }

    /**
     * 模板主题设置
     * @access protected
     * @param string $theme 模版主题
     * @return Action
     */
    final protected function theme($theme)
    {
        $this-&gt;view-&gt;theme($theme);
        return $this;
    }

    /**
     * 模板变量赋值
     * @access protected
     * @param mixed $name 要显示的模板变量
     * @param mixed $value 变量的值
     * @return Action
     */
    final protected function assign($name, $value=&#039;&#039;)
    {
        $this-&gt;view-&gt;assign($name,$value);
        return $this;
    }


    //用于显示模板的方法
    final protected function fetch($templateFile = CONTROLLER_NAME)
    {
        if(!is_file($templateFile)){
            $templateFile = $this-&gt;addon_path . $templateFile . &quot;.html&quot;;
            if(!is_file($templateFile)){
                E(L(&#039;_TEMPLATE_NOT_EXIST_&#039;) . &quot;:$templateFile&quot;);
            }
        }
        return $this-&gt;view-&gt;fetch($templateFile);
    }

    /**
     * 获取插件名
     * @return string
     */
    final public function getName()
    {
        $class = get_class($this);
        list($space, $name, $class) = explode(&#039;\\&#039;, $class);

        return $name;
    }

    /**
     * 检查配置信息是否完整
     * @return bool
     */
    final public function checkInfo()
    {
        $info_check_keys = array(&#039;name&#039;,&#039;title&#039;,&#039;description&#039;,&#039;status&#039;,&#039;author&#039;,&#039;version&#039;);
        foreach ($info_check_keys as $value) {
            if(!array_key_exists($value, $this-&gt;info))
                return false;
        }
        return true;
    }

    /**
     * 获取插件的配置数组
     */
    final public function getConfig($name = &#039;&#039;)
    {
        static $_config = [];
        if(empty($name)){
            $name = $this-&gt;getName();
        }
        if(isset($_config[$name])){
            return $_config[$name];
        }

        $map[&#039;name&#039;]    =   $name;
        $map[&#039;status&#039;]  =   1;
        $config  =   M(&#039;Addons&#039;)-&gt;where($map)-&gt;getField(&#039;config&#039;);
        if($config){
            $config   =   json_decode($config, true);
        }else{
            $config =   [];
            $temp_arr = include $this-&gt;config_file;
            foreach ($temp_arr as $key =&gt; $value) {
                if($value[&#039;type&#039;] == &#039;group&#039;){
                    foreach ($value[&#039;options&#039;] as $gkey =&gt; $gvalue) {
                        foreach ($gvalue[&#039;options&#039;] as $ikey =&gt; $ivalue) {
                            $config[$ikey] = $ivalue[&#039;value&#039;];
                        }
                    }
                }else{
                    $config[$key] = $temp_arr[$key][&#039;value&#039;];
                }
            }
        }
        $_config[$name]     =   $config;
        return $config;
    }

    /**
     * 必须实现安装
     * @return mixed
     */
    abstract public function install();

    /**
     * 必须卸载插件方法
     * @return mixed
     */
    abstract public function uninstall();
}2、在插件表(addons)，钩子表(hooks)中加入相应的数据INSERT INTO `addons` (`id`, `name`, `title`, `description`, `status`, `config`, `author`, `version`, `create_time`, `has_adminlist`) VALUES (&#039;2&#039;, &#039;test&#039;, &#039;test插件&#039;, &#039;test插件简介&#039;, &#039;1&#039;, NULL, &#039;byron sampson&#039;, &#039;0.1&#039;, &#039;1438154545&#039;, &#039;0&#039;);

INSERT INTO .`hooks` (`id`, `name`, `description`, `type`, `update_time`, `addons`, `status`) VALUES (&#039;21&#039;, &#039;demo&#039;, &#039;demo钩子&#039;, &#039;1&#039;, &#039;1384481614&#039;, &#039;test&#039;, &#039;1&#039;);3、在addons目录中创建一个test目录，且内部创建一个Test.php插件类&lt;?php
// +----------------------------------------------------------------------
// | test [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://www.zzstudio.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Byron Sampson &lt;xiaobo.sun@gzzstudio.net&gt;
// +----------------------------------------------------------------------
namespace addons\test;

class Test extends \addons\Base
{
    /**
     * 实现demo钩子
     * @param array $params
     */
    public function demo($params = [])
    {
        echo &#039;demo hook!page is &#039; . $params[&#039;p&#039;];
    }

    /**
     * 安装方法
     */
    public function install()
    {
        // TODO: Implement install() method.
    }

    /**
     * 卸载方法
     */
    public function uninstall()
    {
        // TODO: Implement uninstall() method.
    }
}4、在控制器中使用hook方法来调用钩子hook(&#039;demo&#039;, [&#039;p&#039;=&gt;&#039;page&#039;]);5、ok，大功告成来源：https://blog.zzstudio.net/bs/article_888.html</description>
</item>
<item rdf:about="https://dwt.life/archives/164/">
<title>ImagickDraw::roundRectangle</title>
<link>https://dwt.life/archives/164/</link>
<dc:date>2022-01-26T22:24:17+08:00</dc:date>
<description>Descriptionpublic ImagickDraw::roundRectangle( float $x1, float $y1, float $x2, float $y2, float $rx, float $ry): boolWarning这个函数目前还没有被记录下来,只有它的参数列表是可用的。给定两个坐标（x和y角半径）并使用当前笔触，笔划宽度和填充设置绘制圆角矩形。Parametersx1左上角的X坐标y1左上角的Y坐标x2右下角的X坐标y2右下角的y坐标rxx四舍五入ry四舍五入返回值没有返回任何值。ExamplesExample #1 ImagickDraw::roundRectangle()例子&lt;?php
function roundRectangle($strokeColor, $fillColor, $backgroundColor, $startX, $startY, $endX, $endY, $roundX, $roundY) {

    $draw = new \ImagickDraw();

    $draw-&gt;setStrokeColor($strokeColor);
    $draw-&gt;setFillColor($fillColor);
    $draw-&gt;setStrokeOpacity(1);
    $draw-&gt;setStrokeWidth(2);

    $draw-&gt;roundRectangle($startX, $startY, $endX, $endY, $roundX, $roundY);

    $imagick = new \Imagick();
    $imagick-&gt;newImage(500, 500, $backgroundColor);
    $imagick-&gt;setImageFormat(&quot;png&quot;);

    $imagick-&gt;drawImage($draw);

    header(&quot;Content-Type: image/png&quot;);
    echo $imagick-&gt;getImageBlob();
}

?&gt;https://www.php.net/manual/en/imagickdraw.roundrectangle.php</description>
</item>
<item rdf:about="https://dwt.life/archives/144/">
<title>PHP生成远程图片缩略图</title>
<link>https://dwt.life/archives/144/</link>
<dc:date>2021-11-12T22:03:00+08:00</dc:date>
<description>&lt;?php  
/** 
*
*函数：调整图片尺寸或生成缩略图 
*返回：True/False 
*参数：
*   $Image   需要调整的图片(含路径) 
*   $Dw=450  调整时最大宽度;缩略图时的绝对宽度 
*   $Dh=450  调整时最大高度;缩略图时的绝对高度 
*   $Type=1  1,调整尺寸; 2,生成缩略图 
*/ 
$phtypes=array(&#039;img/gif&#039;, &#039;img/jpg&#039;, &#039;img/jpeg&#039;, &#039;img/bmp&#039;, &#039;img/pjpeg&#039;, &#039;img/x-png&#039;); 

function compressImg($Image,$Dw,$Dh,$Type){  
 
                $Img =@imagecreatefromstring($Image);  

    // 如果对象没有创建成功,则说明非图片文件  
    IF(Empty($Img)){  
        // 如果是生成缩略图的时候出错,则需要删掉已经复制的文件  
        
        return false;  
    }  
    // 如果是执行调整尺寸操作则  
    IF($Type==1){  
        $w=ImagesX($Img);  
        $h=ImagesY($Img);  
        $width = $w;  
        $height = $h;  
        IF($width&gt;$Dw){  
            $Par=$Dw/$width;  
            $width=$Dw;  
            $height=$height*$Par;  
            IF($height&gt;$Dh){  
                $Par=$Dh/$height;  
                $height=$Dh;  
                $width=$width*$Par;  
            }  
        } ElseIF($height&gt;$Dh) {  
            $Par=$Dh/$height;  
            $height=$Dh;  
            $width=$width*$Par;  
            IF($width&gt;$Dw){  
                $Par=$Dw/$width;  
                $width=$Dw;  
                $height=$height*$Par;  
            }  
        } Else {  
            $width=$width;  
            $height=$height;  
        }  
        $nImg =ImageCreateTrueColor($width,$height);// 新建一个真彩色画布  
        ImageCopyReSampled($nImg,$Img,0,0,0,0,$width,$height,$w,$h);// 重采样拷贝部分图像并调整大小  
        ImageJpeg($nImg);// 以JPEG格式将图像输出到浏览器或文件  
        return true;  
    } Else {// 如果是执行生成缩略图操作则  
        $w=ImagesX($Img);  
        $h=ImagesY($Img);  
        $width = $w;  
        $height = $h;  
        $nImg =ImageCreateTrueColor($Dw,$Dh);  
        IF($h/$w&gt;$Dh/$Dw){// 高比较大  
            $width=$Dw;  
            $height=$h*$Dw/$w;  
            $IntNH=$height-$Dh;  
            ImageCopyReSampled($nImg, $Img, 0, -$IntNH/1.8, 0, 0, $Dw, $height, $w, $h);  
        } Else {// 宽比较大  
            $height=$Dh;  
            $width=$w*$Dh/$h;  
            $IntNW=$width-$Dw;  
            ImageCopyReSampled($nImg, $Img,-$IntNW/1.8,0,0,0, $width, $Dh, $w, $h);  
        }  
        ImageJpeg($nImg);  
        return true;  
    }  
};  
  
$arrContextOptions=array(

    &quot;ssl&quot;=&gt;array(

        &quot;verify_peer&quot;=&gt;false,

        &quot;verify_peer_name&quot;=&gt;false,

    ),

); 

 

$imgPath = &#039;https://old.typecho.bearlab.in/usr/uploads/2021/11/4214120057.png&#039;;//远程URL 地址  
header(&#039;Content-Type: image/png&#039;);  
$bigImg=file_get_contents($imgPath, false , stream_context_create($arrContextOptions));//GrabImage($imgPath, $tempPath); 
//echo $bigImg;exit;
compressImg($bigImg,100,100,1);
</description>
</item>
<item rdf:about="https://dwt.life/archives/24/">
<title>PHP Composer镜像</title>
<link>https://dwt.life/archives/24/</link>
<dc:date>2021-07-04T00:53:07+08:00</dc:date>
<description>composer config -g repo.packagist composer https://packagist.phpcomposer.com</description>
</item>
</rdf:RDF>