Initial commit
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* 网页源代码查看
|
||||
*/
|
||||
|
||||
namespace plugin\web\viewhtml;
|
||||
|
||||
use app\Plugin;
|
||||
use Exception;
|
||||
|
||||
class App extends Plugin
|
||||
{
|
||||
|
||||
const ualist = [
|
||||
'pc' => 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',
|
||||
'android' => 'Mozilla/5.0 (Linux; U; Android 10; zh-cn; Mi 10 Build/QKQ1.191117.002) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/10.2 Mobile Safari/537.36',
|
||||
'ios' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1',
|
||||
'harmonyos' => 'Mozilla/5.0 (Linux; Android 10; HarmonyOS; LYA-AL00; HMSCore 6.4.0.312; GMSCore 20.15.16) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.105 HuaweiBrowser/12.0.5.302 Mobile Safari/537.36',
|
||||
'wechat' => 'Mozilla/5.0 (Linux; Android 11; M2011K2C Build/RKQ1.200928.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045713 Mobile Safari/537.36 MMWEBID/2820 MicroMessenger/8.0.11.1980(0x28000B3B) Process/tools WeChat/arm64 Weixin NetType/5G Language/zh_CN ABI/arm64',
|
||||
'qq' => 'Mozilla/5.0 (Linux; Android 12; IN2010 Build/RKQ1.211119.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/97.0.4692.98 Mobile Safari/537.36 V1_AND_SQ_8.8.68_2538_YYB_D A_8086800 QQ/8.8.68.7265 NetType/4G WebP/0.4.1 Pixel/1080 StatusBarHeight/108 SimpleUISwitch/0 QQTheme/3445 InMagicWin/0 StudyMode/0 CurrentMode/0 CurrentFontScale/1.0 GlobalDensityScale/0.90000004 AppId/537112599',
|
||||
'alipay' => 'Mozilla/5.0 (Linux; U; Android 11; zh-CN; MI 10 Build/RKQ1.200928.002) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/69.0.3497.100 UWS/3.22.2.19 Mobile Safari/537.36 UCBS/3.22.2.19_210818212654 NebulaSDK/1.8.100112 Nebula AlipayDefined(nt:3G,ws:411|0|2.625) AliApp(AP/10.2.30.7000) AlipayClient/10.2.30.7000 Language/zh-Hans useStatusBar/true isConcaveScreen/true Region/CN NebulaX/1.0.0 Ariver/1.0.0',
|
||||
'baidu' => 'Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)',
|
||||
'mbaidu' => 'Mozilla/5.0 (Linux;u;Android 4.2.2;zh-cn;) AppleWebKit/534.46 (KHTML,like Gecko) Version/5.1 Mobile Safari/10600.6.3 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)',
|
||||
'google' => 'Googlebot/2.1 (+http://www.googlebot.com/bot.html)',
|
||||
'qqmgr' => 'Mozilla/5.0 (Linux; U; Android 4.4.2; zh-cn; GT-I9500 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko)Version/4.0 MQQBrowser/5.0 QQ-URL-Manager',
|
||||
];
|
||||
|
||||
public function index()
|
||||
{
|
||||
return $this->view();
|
||||
}
|
||||
|
||||
public function getdata(){
|
||||
$url = input('post.url', null, 'trim');
|
||||
$ua = input('post.ua');
|
||||
$useragent = $ua == 'diy' ? input('post.uastr', null, 'trim') : self::ualist[$ua];
|
||||
$referer = input('post.referer', null, 'trim');
|
||||
$post = input('post.post');
|
||||
$cookie = input('post.cookie');
|
||||
|
||||
if(!$url) return msg('error','no url');
|
||||
if(!filter_var($url,FILTER_VALIDATE_URL)){
|
||||
return msg('error','输入的URL不符合规范');
|
||||
}
|
||||
|
||||
$captcha_result = verify_captcha4();
|
||||
if($captcha_result !== true){
|
||||
return msg('error', '验证失败,请重新验证');
|
||||
}
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
$httpheader[] = "Accept: */*";
|
||||
$httpheader[] = "Accept-Language: zh-CN,zh;q=0.8";
|
||||
$httpheader[] = "Connection: close";
|
||||
if(!empty($post) && substr($post, 0, 1) == '{' && substr($post, -1 ,1) == '}'){
|
||||
$httpheader[] = "Content-Type: application/json; charset=utf-8";
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
|
||||
if(input('post.header')=='1'){
|
||||
curl_setopt($ch, CURLOPT_HEADER, true);
|
||||
}
|
||||
if(!empty($referer)){
|
||||
curl_setopt($ch, CURLOPT_REFERER, $referer);
|
||||
}
|
||||
if(!empty($cookie)){
|
||||
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
||||
if(!empty($post)){
|
||||
curl_setopt($ch,CURLOPT_POST, 1);
|
||||
curl_setopt($ch,CURLOPT_POSTFIELDS, $post);
|
||||
}
|
||||
$data = curl_exec($ch);
|
||||
$errno = curl_errno($ch);
|
||||
if ($errno) {
|
||||
$msg = 'Curl error: ' . curl_error($ch);
|
||||
return msg('error',$msg);
|
||||
}
|
||||
curl_close($ch);
|
||||
|
||||
|
||||
$data = (input('post.encoding')=='') ? $data : mb_convert_encoding($data, 'UTF-8', input('post.encoding'));
|
||||
switch(input('post.text')){
|
||||
case 'links':
|
||||
preg_match_all("'<\s*a\s.*?href\s*=\s* # find <a href=
|
||||
([\"\'])? # find single or double quote
|
||||
(?(1) (.*?)\\1 | ([^\s\>]+)) # if quote found, match up to next matching
|
||||
# quote, otherwise match up to next space
|
||||
'isx",$data,$links);
|
||||
$data = '';
|
||||
foreach($links[2] as $val){
|
||||
if(!empty($val)) $data .= $val."\n";
|
||||
}
|
||||
foreach($links[3] as $val){
|
||||
if(!empty($val)) $data .= $val."\n";
|
||||
}
|
||||
break;
|
||||
case 'form':
|
||||
preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi",$data,$elements);
|
||||
$data = implode("\r\n",$elements[0]);
|
||||
break;
|
||||
case 'text':
|
||||
$data = strip_tags($data);
|
||||
break;
|
||||
}
|
||||
|
||||
return msg('ok','success',$data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
{extend name="common/plugin_layout" /}
|
||||
{block name="title"}{$plugin.title} - {:config_get('title')}{/block}
|
||||
{block name="main"}
|
||||
<link href="/assets/viewhtml/prism.css" rel="stylesheet"/>
|
||||
<style>
|
||||
textarea.form-control{min-height: auto;}
|
||||
#viewhtml{
|
||||
word-break: break-all;
|
||||
white-space: break-spaces;
|
||||
}
|
||||
</style>
|
||||
<div class="container-xl" id="app">
|
||||
<div class="col-md-12 col-xl-10 center-block">
|
||||
<div class="card card-preview">
|
||||
<div class="card-inner mt-3">
|
||||
<div class="nya-title nk-ibx-action-item progress-rating">
|
||||
<span class="nk-menu-text font-weight-bold">网页源代码查看</span>
|
||||
</div>
|
||||
<div id="showform">
|
||||
<div class="form-group">
|
||||
<label class="form-label">URL:</label>
|
||||
<div class="form-control-wrap">
|
||||
<textarea class="form-control" v-model="set.url" rows="3" placeholder="输入网址,带http://或https://" ref="input"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">UserAgent:</label>
|
||||
<div class="form-control-wrap">
|
||||
<select class="form-control" v-model="set.ua">
|
||||
<option v-for="item in ualist" :value="item.key">{{item.title}}</option>
|
||||
<option value="diy">自定义</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" v-show="set.ua=='diy'" style="display:none">
|
||||
<div class="form-control-wrap">
|
||||
<input type="text" v-model="set.uastr" placeholder="输入要自定义的UA" class="form-control" ref="input" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">Referer:(选填)</label>
|
||||
<div class="form-control-wrap">
|
||||
<input type="text" v-model="set.referer" placeholder="输入要模拟的来源地址" class="form-control" ref="input" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">POST参数:(选填)</label>
|
||||
<div class="form-control-wrap">
|
||||
<input type="text" v-model="set.post" placeholder="user=admin&pass=123456 或json格式" class="form-control" ref="input" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">COOKIE:(选填)</label>
|
||||
<div class="form-control-wrap">
|
||||
<input type="text" v-model="set.cookie" placeholder="user=admin; pass=123456;" class="form-control" ref="input" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-3">
|
||||
<div class="form-group">
|
||||
<label class="form-label">显示内容:</label>
|
||||
<div class="form-control-wrap">
|
||||
<select v-model="set.text" class="form-control">
|
||||
<option value="all">原始代码</option>
|
||||
<option value="text">提取文字</option>
|
||||
<option value="form">提取表单</option>
|
||||
<option value="links">提取链接</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<div class="form-group">
|
||||
<label class="form-label">头部信息:</label>
|
||||
<div class="form-control-wrap">
|
||||
<select v-model="set.header" class="form-control">
|
||||
<option value="0">不显示</option>
|
||||
<option value="1">显示</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<div class="form-group">
|
||||
<label class="form-label">选择编码:</label>
|
||||
<div class="form-control-wrap">
|
||||
<select v-model="set.encoding" class="form-control">
|
||||
<option>UTF-8</option>
|
||||
<option>GBK</option>
|
||||
<option>BIG5</option>
|
||||
<option>ISO-8859-1</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<div class="form-group">
|
||||
<label class="form-label">代码高亮:</label>
|
||||
<div class="form-control-wrap">
|
||||
<select v-model="set.highlight" class="form-control">
|
||||
<option value="no">不高亮</option>
|
||||
<option value="yes">高亮代码</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-dim btn-outline-primary btn-block card-link mt-4" @click="viewhtml" :disabled="query_disabled">
|
||||
查看源代码
|
||||
</button>
|
||||
</div>
|
||||
<div id="showresult" style="display:none">
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<button class="btn btn-dim btn-outline-info btn-block card-link" @click="backhome" :disabled="query_disabled">
|
||||
<em class="icon ni ni-back-ios"></em>返回
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<button class="btn btn-dim btn-outline-warning btn-block card-link" @click="copyhtml" :disabled="query_disabled">
|
||||
<em class="icon ni ni-copy"></em>复制
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<button class="btn btn-dim btn-outline-success btn-block card-link" @click="downhtml" :disabled="query_disabled">
|
||||
<em class="icon ni ni-download"></em>下载
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3" v-html="output"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
{block name="script"}
|
||||
<script src="{$cdn_cdnjs}vue/2.6.14/vue.min.js"></script>
|
||||
<script src="{$cdn_cdnjs}FileSaver.js/2014-11-29/FileSaver.min.js"></script>
|
||||
<script src="https://static.geetest.com/v4/gt4.js"></script>
|
||||
<script src="/assets/viewhtml/prism.js"></script>
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
query_disabled: true,
|
||||
set: {
|
||||
url: '',
|
||||
ua: 'pc',
|
||||
uastr: '',
|
||||
referer: '',
|
||||
post: '',
|
||||
cookie: '',
|
||||
text: 'all',
|
||||
header: '0',
|
||||
encoding: 'UTF-8',
|
||||
highlight: 'yes',
|
||||
proxy: '0',
|
||||
},
|
||||
ualist: [
|
||||
{key: 'pc', title:'PC-Chrome'},
|
||||
{key: 'android', title:'Android-Chrome'},
|
||||
{key: 'ios', title:'iOS-Safari'},
|
||||
{key: 'harmonyos', title:'HarmonyOS-Browser'},
|
||||
{key: 'wechat', title:'WeChat'},
|
||||
{key: 'qq', title:'QQ'},
|
||||
{key: 'alipay', title:'AlipayClient'},
|
||||
{key: 'baidu', title:'Baiduspider'},
|
||||
{key: 'mbaidu', title:'Baiduspider-Mobile'},
|
||||
{key: 'google', title:'Googlebot'},
|
||||
{key: 'qqmgr', title:'QQ-URL-Manager'},
|
||||
],
|
||||
showresult: false,
|
||||
html: '',
|
||||
output: '',
|
||||
captcha: null
|
||||
},
|
||||
mounted() {
|
||||
//this.$refs.input.focus();
|
||||
var that=this;
|
||||
initGeetest4({
|
||||
captchaId: "99b142aaece96330d0f3ffb565ffb3ef",
|
||||
product: 'bind',
|
||||
protocol: 'https://',
|
||||
riskType: 'ai',
|
||||
},function (captcha) {
|
||||
captcha.onReady(function(){
|
||||
that.query_disabled=false;
|
||||
that.captcha = captcha;
|
||||
}).onSuccess(function(){
|
||||
var result = captcha.getValidate();
|
||||
if (!result) {
|
||||
layer.closeAll();
|
||||
return alert('请先完成验证');
|
||||
}
|
||||
var data = that.set;
|
||||
$.ajax({
|
||||
url: '/api/{$plugin.alias}/getdata',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: Object.assign(data, result),
|
||||
cache: false,
|
||||
success: function (data) {
|
||||
layer.closeAll();
|
||||
if(data.status=='ok'){
|
||||
that.showresult = true;
|
||||
that.html = data.data;
|
||||
that.output = '<pre><code class="language-markup" id="viewhtml">'+that.htmlEncode(data.data)+'</code></pre>';
|
||||
that.$nextTick(() => {
|
||||
Prism.highlightAll()
|
||||
})
|
||||
$("#showform").slideUp();
|
||||
$("#showresult").slideDown();
|
||||
captcha.reset();
|
||||
}else{
|
||||
layer.alert(data.message, {icon: 5});
|
||||
captcha.reset();
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
layer.closeAll();
|
||||
layer.msg('服务器错误', {icon: 5});
|
||||
captcha.reset();
|
||||
}
|
||||
});
|
||||
}).onError(function(){
|
||||
alert('验证码加载失败,请刷新页面重试');
|
||||
})
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
viewhtml() {
|
||||
if(this.set.url.trim() == ''){
|
||||
layer.alert('URL不能为空');return;
|
||||
}
|
||||
layer.load(0, {shade:0.1});
|
||||
this.captcha.showCaptcha();
|
||||
},
|
||||
copyhtml() {
|
||||
if(this.html == '')return;
|
||||
copy(this.html)
|
||||
layer.msg('复制成功', {icon:1, time:600})
|
||||
},
|
||||
downhtml() {
|
||||
if(this.html == '')return;
|
||||
var fileName = (new Date()).toISOString().substr(0, 10) + ".txt";
|
||||
var blob = new Blob([this.html], {type: "text/plain;charset=utf-8"});
|
||||
saveAs(blob, fileName);
|
||||
},
|
||||
backhome() {
|
||||
$("#showresult").slideUp();
|
||||
$("#showform").slideDown();
|
||||
},
|
||||
htmlEncode(html){
|
||||
var tempDiv = document.createElement('div');
|
||||
(tempDiv.textContent != undefined) ? (tempDiv.textContent = html) : (tempDiv.innerText = html);
|
||||
var output = tempDiv.innerHTML;
|
||||
tempDiv = null;
|
||||
return output;
|
||||
}
|
||||
},
|
||||
})
|
||||
</script>
|
||||
{/block}
|
||||
Reference in New Issue
Block a user