php快照网页
第二步:创建一个xxxxx.PHP的文件,输入以下代码(本地创建一个img的文件夹)yum install -y https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox-0.12.5-1.centos7.x86_64.rpm
第三步:在宝塔面板PHP里面管理-禁用函数-删除shell_exec 即可<?php
function allow_domain($url){
$is_allow=false;
//获取不带端口号的域名前缀
$servername=trim($_SERVER['SERVER_NAME']);
//授权域名列表
$Array=array("您的域名");
//遍历数组
foreach($Array as $value){
$value=trim($value);
$domain=explode($value,$servername);
if(count($domain)>1){
$is_allow=true;
break;
}
}
if(!$is_allow){
die("域名未授权!"); //授权失败
}else{
//echo "域名已授权!"; //授权成功
Generatepictures($url);
}
}
function Generatepictures($url){
$url= str_replace("http://","",$url);
$url= str_replace("https://","",$url);
$file = getcwd().'/img/'.$url.'.jpg';
if(!is_file($file))
{
set_time_limit(0);
shell_exec('wkhtmltoimage --crop-w 1080 --crop-h 700 --quality 15 '.$url.' '.getcwd().'/img/'.$url.'.jpg');
}
$filename="/img/".$url.".jpg";
// echo $filename;
header('Content-type:image/png');
header("Cache-Control:max-age=600000");
echo file_get_contents(getcwd().'/img/'.$url.'.jpg');
}
if (isset($_GET['url']))
{
allow_domain($_GET['url']);
}
?>
第四步:上传字体
原因:缺少中文字体
解决方法:
网络上下载宋体(simsun.ttc)文件
上传到服务器的 /usr/share/fonts/chinese/TrueType/ 文件夹中(没有这些文件夹新建即可)
第五步:链接代码:http://您的域名/xxxxx.php?url=www.bingdou.net调用快照的网址
字体附件:https://t00y.com/file/1675875-458250141