Files
ProxyPanel/resources/views/admin/convert.blade.php
兔姬桑 a0922521cf 初始化
2020-08-05 03:19:28 +08:00

129 lines
5.9 KiB
PHP

@extends('admin.layouts')
@section('content')
<div class="page-content container-fluid">
<div class="panel">
<div class="panel-heading">
<h2 class="panel-title">格式转换
<small>Shadowsocks ShadowsocksR</small>
</h2>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-4 form-group">
<label for="method">加密方式</label>
<select class="form-control" name="method" id="method">
@foreach ($method_list as $method)
<option value="{{$method->name}}" @if($method->is_default) selected @endif>{{$method->name}}</option>
@endforeach
</select>
</div>
<div class="col-md-4 form-group">
<label for="transfer_enable">可用流量</label>
<div class="input-group">
<input type="text" class="form-control" name="transfer_enable" value="1000" id="transfer_enable" placeholder="" required>
<span class="input-group-text">GB</span>
</div>
</div>
<div class="col-md-4 form-group">
<label for="protocol">协议</label>
<select class="form-control" name="protocol" id="protocol">
@foreach ($protocol_list as $protocol)
<option value="{{$protocol->name}}" @if($protocol->is_default) selected @endif>{{$protocol->name}}</option>
@endforeach
</select>
</div>
<div class="col-md-4 form-group">
<label for="protocol_param">协议参数</label>
<input type="text" class="form-control" name="protocol_param" id="protocol_param" placeholder="">
</div>
<div class="col-md-4 form-group">
<label for="obfs">混淆</label>
<select class="form-control" name="obfs" id="obfs">
@foreach ($obfs_list as $obfs)
<option value="{{$obfs->name}}" @if($obfs->is_default) selected @endif>{{$obfs->name}}</option>
@endforeach
</select>
</div>
<div class="col-md-4 form-group">
<label for="obfs_param">混淆参数</label>
<input type="text" class="form-control" name="obfs_param" id="obfs_param" placeholder="">
</div>
<div class="col-md-6">
<textarea class="form-control" rows="22" name="content" id="content" placeholder="请填入要转换的配置信息" autofocus></textarea>
</div>
<div class="col-md-6">
<textarea class="form-control" rows="22" name="result" id="result" onclick="this.focus();this.select()" readonly="readonly"></textarea>
</div>
<div class="col-md-6">
<button class="btn btn-block btn-primary" onclick="doConvert()"> </button>
</div>
<div class="col-md-6">
<button class="btn btn-block btn-danger" onclick="doDownload()"> </button>
</div>
</div>
</div>
</div>
</div>
@endsection
@section('script')
<script type="text/javascript">
// 转换
function doConvert() {
const _token = '{{csrf_token()}}';
const method = $('#method').val();
const transfer_enable = $('#transfer_enable').val();
const protocol = $('#protocol').val();
const protocol_param = $('#protocol_param').val();
const obfs = $('#obfs').val();
const obfs_param = $('#obfs_param').val();
const content = $('#content').val();
if (content.trim() === '') {
swal.fire({title: '请填入要转换的配置信息', type: 'warning', timer: 1000, showConfirmButton: false});
return;
}
swal.fire({
title: '确定继续转换吗?',
type: 'question',
allowEnterKey: false,
showCancelButton: true,
cancelButtonText: '{{trans('home.ticket_close')}}',
confirmButtonText: '{{trans('home.ticket_confirm')}}',
}).then((result) => {
if (result.value) {
$.ajax({
type: "POST",
url: "/admin/convert",
async: false,
data: {
_token: _token,
method: method,
transfer_enable: transfer_enable,
protocol: protocol,
protocol_param: protocol_param,
obfs: obfs,
obfs_param: obfs_param,
content: content
},
dataType: 'json',
success: function (ret) {
if (ret.status === 'success') {
$("#result").val(ret.data);
} else {
$("#result").val(ret.message);
}
}
})
}
});
return false;
}
// 下载
function doDownload() {
window.location.href = '/admin/download?type=1';
}
</script>
@endsection