Initial commit

This commit is contained in:
net909
2023-09-28 16:21:06 +08:00
parent 498772eb04
commit ba7be004c0
640 changed files with 87745 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
<?php
/**
* 短网址生成
*/
namespace plugin\utility\short_url;
use app\Plugin;
use think\facade\Validate;
use Exception;
class App extends Plugin
{
public function index()
{
return $this->view();
}
public function generate(){
$params = request()->param();
$validate = Validate::rule([
'apitype' => 'require',
'url' => 'require|url'
]);
if (!$validate->check($params)) {
return msg('error', $validate->getError());
}
$captcha_result = verify_captcha4_slide();
if($captcha_result !== true){
return msg('error', $captcha_result);
}
$classname = 'plugin\\utility\\short_url\\api\\'.$params['apitype'];
if(class_exists($classname)){
$instance = new $classname();
try{
$shortUrl = $instance->create($params['url']);
return json(['code'=>0, 'msg'=>'success', 'data'=>$shortUrl]);
}catch(Exception $e){
return json(['code'=>-1, 'msg'=>$e->getMessage()]);
}
}else{
return json(['code'=>-1, 'msg'=>'该接口不存在']);
}
}
}
+8
View File
@@ -0,0 +1,8 @@
<?php
namespace plugin\utility\short_url;
interface api
{
public function create($url);
}
@@ -0,0 +1,25 @@
<?php
namespace plugin\utility\short_url\api;
use plugin\utility\short_url\api;
class d_naccl_top implements api
{
public function create($url)
{
$post = ['longURL' => $url];
$data = get_curl('https://d.naccl.top/generate', http_build_query($post));
$json = json_decode($data);
if (!empty($json) && !empty($json->data) && $json->code === 200) {
return $json->data;
}
if (!empty($json->msg)) {
throw new \Exception($json->msg);
}
throw new \Exception('生成失败');
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace plugin\utility\short_url\api;
use plugin\utility\short_url\api;
class dwz_tax implements api
{
public function create($url)
{
$post = [
'token' => 'k9ah7rn36d1dsu51jpjeboopg4',
'longurl' => $url,
'alias' => '',
'expiry' => '',
'password' => '',
];
$data = get_curl('https://dwz.tax/api/shorten', http_build_query($post), 'https://dwz.tax/');
$json = json_decode($data);
if (!empty($json) && !empty($json->short)) {
return $json->short;
}
if (!empty($json->msg)) {
throw new \Exception($json->msg);
}
throw new \Exception('生成失败');
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace plugin\utility\short_url\api;
use plugin\utility\short_url\api;
class gg_gg implements api
{
public function create($url)
{
$post = [
'custom_path' => '',
'use_norefs' => '0',
'long_url' => $url,
'app' => 'site',
'version' => '0.1',
];
$data = get_curl('http://gg.gg/create', http_build_query($post), 'http://gg.gg/');
if (!empty($data)) {
return $data;
}
throw new \Exception('生成失败');
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace plugin\utility\short_url\api;
use plugin\utility\short_url\api;
class is_gd implements api
{
public function create($url): string
{
$data = get_curl("https://is.gd/create.php?format=json&url=".urlencode($url));
$json = json_decode($data);
if (!empty($json) && !empty($json->shorturl)) {
return $json->shorturl;
}
if (!empty($json->errormessage)) {
throw new \Exception($json->errormessage);
}
throw new \Exception('生成失败');
}
}
@@ -0,0 +1,22 @@
<?php
namespace plugin\utility\short_url\api;
use plugin\utility\short_url\api;
class lnks_tools implements api
{
public function create($url): string
{
$data = get_curl('https://lnks.tools', json_encode([
'url' => $url,
]));
$json = json_decode($data);
if (!empty($json) && !empty($json->key)) {
return 'https://lnks.tools' . $json->key;
}
throw new \Exception('生成失败');
}
}
@@ -0,0 +1,26 @@
<?php
namespace plugin\utility\short_url\api;
use plugin\utility\short_url\api;
class moelink_org implements api
{
public function create($url): string
{
$post = [
'url' => $url,
];
$data = get_curl('https://moelink.org/shorten', http_build_query($post));
$json = json_decode($data);
if (!empty($json) && !empty($json->data->shorturl) && $json->error === false) {
return $json->data->shorturl;
}
if (!empty($json->message)) {
throw new \Exception($json->message);
}
throw new \Exception('生成失败');
}
}
@@ -0,0 +1,20 @@
<?php
namespace plugin\utility\short_url\api;
use plugin\utility\short_url\api;
class p_sogou_com implements api
{
public function create($url)
{
if(substr(parse_url($url)['host'], -9) != 'sogou.com')
$url = 'https://m.sogou.com/web/confirm.jsp?url='.urlencode($url);
$data = get_curl('http://sa.sogou.com/gettiny?url='.urlencode($url).'&mid=ff92866333010593695&xid=87b53ac05cc35e678d172752bd690bc3dcb7&imsi=460072887441781&ts=1501395961638&crypto=9agMSumkNV29lKu3jelybeLPZ+c4yDU2Vu7YaMj1OucASKqPnn+Pdo/cQMXTLY3+&ver=5.2.1.0');
if (!empty($data)) {
return $data;
}
throw new \Exception('生成失败');
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace plugin\utility\short_url\api;
use plugin\utility\short_url\api;
class suo_yt implements api
{
public function create($url): string
{
$post = [
'longUrl' => base64_encode($url),
];
$data = get_curl('https://suo.yt/short', http_build_query($post));
$json = json_decode($data);
if (!empty($json) && !empty($json->ShortUrl)) {
return $json->ShortUrl;
}
if (!empty($json->Message)) {
throw new \Exception($json->Message);
}
throw new \Exception('生成失败');
}
}
@@ -0,0 +1,22 @@
<?php
namespace plugin\utility\short_url\api;
use plugin\utility\short_url\api;
class tinyurl_com implements api
{
public function create($url): string
{
$post = [
'url' => $url,
'format' => 'json',
];
$get = get_curl('https://tinyurl.com/api-create.php', http_build_query($post));
if (is_valid_url($get)) {
return $get;
}
throw new \Exception('生成失败');
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace plugin\utility\short_url\api;
use plugin\utility\short_url\api;
class zm_cx implements api
{
public function create($url): string
{
$post = json_encode([
'url' => $url,
]);
$data = get_curl('https://zm.cx/api/set.php', $post);
$json = json_decode($data);
if (!empty($json) && !empty($json->content->url)) {
return $json->content->url;
}
if (!empty($json->content)) {
throw new \Exception($json->content);
}
throw new \Exception('生成失败');
}
}
+168
View File
@@ -0,0 +1,168 @@
{extend name="common/plugin_layout" /}
{block name="title"}{$plugin.title} - {:config_get('title')}{/block}
{block name="main"}
<div class="container-xl" id="app">
<div class="col-sm-12 col-md-10 col-xl-8 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 class="form-group">
<label class="form-label" for="input">选择短网址接口:</label>
<div class="form-control-wrap">
<select class="form-control" v-model="set.api">
<option v-for="api in set.apis" :value="api.value" :disabled="api.disabled">{{api.title}}</option>
</select>
</div>
</div>
<div class="form-group">
<label class="form-label">长网址</label>
<div class="form-control-wrap">
<input type="text" v-model="set.input" placeholder="请输入长网址" class="form-control" autocomplete="off">
</div>
</div>
<button class="btn btn-dim btn-outline-primary btn-block card-link" @click="generate" :disabled="query_disabled">
生成
</button>
<div class="form-group mt-3" v-show="set.output">
<label class="form-label">短网址</label>
<div class="form-control-wrap">
<div class="input-group">
<input type="text" v-model="set.output" id="output" class="form-control" autocomplete="off">
<div class="input-group-append"><button class="btn btn-dim btn-outline-success" @click="copy">复制</button></div>
</div>
</div>
</div>
</div>
</div>
<div class="card card-preview">
<div class="card-inner">
<h6><em class="icon ni ni-info"></em> 工具说明</h6>
<div class="accordion-inner">
<p>部分短网址接口不稳定,请勿频繁生成</p>
<p><a href="/unshorturl">短网址还原</a></p>
</div>
</div>
</div>
</div>
</div>
{/block}
{block name="script"}
<script src="{$cdn_cdnjs}vue/2.6.14/vue.min.js"></script>
<script src="https://static.geetest.com/v4/gt4.js"></script>
<script>
new Vue({
el: '#app',
data: {
query_disabled: true,
set: {
input: '',
output: '',
api: 'zm_cx',
apis: [
{
title: 'zm.cx',
value: 'zm_cx',
disabled: false,
},
{
title: 'gg.gg',
value: 'gg_gg',
disabled: false,
},
{
title: 'lnks.tools',
value: 'lnks_tools',
disabled: false,
},
{
title: 'd.naccl.top',
value: 'd_naccl_top',
disabled: false,
},
{
title: 'moelink.org',
value: 'moelink_org',
disabled: false,
},
{
title: 'suo.yt',
value: 'suo_yt',
disabled: false,
}
]
},
captcha: null
},
mounted() {
var that=this;
initGeetest4({
captchaId: "54088bb07d2df3c46b79f80300b0abbe",
product: 'bind',
protocol: 'https://',
riskType: 'slide',
hideSuccess: true
},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 = {apitype: that.set.api, url: that.set.input};
$.ajax({
url: '/api/{$plugin.alias}/generate',
type: 'post',
dataType: 'json',
data: Object.assign(data, result),
cache: false,
success: function (data) {
layer.closeAll();
if(data.code==0){
layer.msg('生成成功', {icon:1, time:800})
that.set.output = data.data;
captcha.reset();
}else{
layer.alert(data.msg, {icon: 5});
captcha.reset();
}
},
error: function () {
layer.closeAll();
layer.alert('服务器错误', {icon: 5});
captcha.reset();
}
});
}).onError(function(){
alert('验证码加载失败,请刷新页面重试');
})
});
},
methods: {
generate() {
if (this.set.input === '') {
layer.alert('请输入长网址')
return
}
this.set.input = this.set.input.trim();
if (this.set.input.toLowerCase().indexOf("http://")<0 && this.set.input.toLowerCase().indexOf("https://")<0){
layer.alert('长网址格式不正确')
return
}
layer.load(0, {shade:0.1});
this.captcha.showCaptcha();
},
copy(){
if(!this.set.output) return;
$("#output").select();
document.execCommand("Copy");
layer.msg('复制成功', {icon:1, time:600})
},
},
})
</script>
{/block}