首页
关于小站
朋友
壁纸
留言
时光之书
笔顺字帖
LayUI手册
Search
1
【PHP】PHPoffice/PHPSpreadsheet读取和写入Excel
2,202 阅读
2
【Layui】控制页面元素展示隐藏
2,014 阅读
3
【Git】No tracked branch configured for branch master or the branch doesn't exist.
1,943 阅读
4
【PHP】PHP实现JWT生成和验证
1,906 阅读
5
【composer】composer常用命令
1,722 阅读
默认分类
PHP
ThinkPHP
Laravel
面向对象
设计模式
算法
基础
网络安全
webman
Web
HTML
CSS
JavaScript
jQuery
Layui
VUE
uni-app
Database
MySQL
Redis
RabbitMQ
Nginx
Git
Linux
Soft Ware
Windows
网赚
Go
Docker
Elasticsearch
登录
Search
标签搜索
PHP
函数
方法
类
MySQL
ThinkPHP
JavaScript
OOP
Layui
Web
Server
Nginx
Docker
PHPSpreadsheet
PHPoffice
Array
设计模式
Git
排序算法
基础
小破孩
累计撰写
261
篇文章
累计收到
13
条评论
首页
栏目
默认分类
PHP
ThinkPHP
Laravel
面向对象
设计模式
算法
基础
网络安全
webman
Web
HTML
CSS
JavaScript
jQuery
Layui
VUE
uni-app
Database
MySQL
Redis
RabbitMQ
Nginx
Git
Linux
Soft Ware
Windows
网赚
Go
Docker
Elasticsearch
页面
关于小站
朋友
壁纸
留言
时光之书
笔顺字帖
LayUI手册
搜索到
162
篇与
的结果
2022-06-17
【PHP】PHP获取服务器状态
<?php function get_server_status() { $fp = popen('top -b -n 2 | grep -E "^(Cpu|Mem|Tasks)"', "r");//获取某一时刻系统cpu和内存使用情况 $rs = ""; while (!feof($fp)) { $rs .= fread($fp, 1024); } pclose($fp); $sys_info = explode("\n", $rs); $tast_info = explode(",", $sys_info[3]);//进程 数组 $cpu_info = explode(",", $sys_info[4]); //CPU占有量 数组 $mem_info = explode(",", $sys_info[5]); //内存占有量 数组 //正在运行的进程数 $tast_running = trim(trim($tast_info[1], 'running')); //CPU占有量 $cpu_usage = trim(trim($cpu_info[0], 'Cpu(s): '), '%us'); //百分比 //内存占有量 $mem_total = trim(trim($mem_info[0], 'Mem: '), 'k total'); $mem_used = trim($mem_info[1], 'k used'); $mem_usage = round(100 * intval($mem_used) / intval($mem_total), 2); //百分比 /*硬盘使用率 begin*/ $fp = popen('df -lh | grep -E "^(/)"', "r"); $rs = fread($fp, 1024); pclose($fp); $rs = preg_replace("/\s{2,}/", ' ', $rs); //把多个空格换成 “_” $hd = explode(" ", $rs); $hd_avail = trim($hd[3], 'G'); //磁盘可用空间大小 单位G $hd_usage = trim($hd[4], '%'); //挂载点 百分比 /*硬盘使用率 end*/ //检测时间 $fp = popen("date +\"%Y-%m-%d %H:%M\"", "r"); $rs = fread($fp, 1024); pclose($fp); $detection_time = trim($rs); $result = [ 'cpu_usage' => $cpu_usage, 'mem_usage' => $mem_usage, 'hd_avail' => $hd_avail, 'hd_usage' => $hd_usage, 'tast_running' => $tast_running, 'detection_time' => $detection_time ]; return $result; }
2022年06月17日
329 阅读
0 评论
0 点赞
2022-06-17
【PHP】PHP获取网页里的所有图片
<?php $new_url = []; $url="网页地址"; //file_get_contents() 函数把整个文件读入一个字符串中 $string=file_get_contents($url); //preg_match_all函数进行全局正则表达式匹配。 preg_match_all("/<img[^>]*>/i", $string,$matches); //去除数组中重复的值 $new_arr=array_unique($matches[0]); foreach($new_arr as $key){ //查找img标签内的src内容 preg_match_all('/<img.*?src="(.*?)".*?>/is',$key,$match); //根据网页图片后缀可以灵活修改 $one = str_replace('?v1', '', $match[1][0]); //插入数组 array_push($new_url,$url.$one); } //下载并保存图片 function download($downurl, $path = 'images/'){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $downurl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); $file = curl_exec($ch); curl_close($ch); $filename = pathinfo($downurl, PATHINFO_BASENAME); $resource = fopen($path . $filename, 'a'); fwrite($resource, $file); fclose($resource); } //循环下载 foreach ( $new_url as $url ) { download($url); } ?>
2022年06月17日
315 阅读
0 评论
0 点赞
1
...
8
9