add short URL support

pull/471/head
ruopeisun 2021-11-20 11:43:37 +08:00
parent 51d7e13ca5
commit 270c226d2d
3 changed files with 45 additions and 1 deletions

View File

@ -61,6 +61,8 @@ $EnvConfigs = [
'public_path' => 0b111,
'fileConduitSize' => 0b110,
'fileConduitCacheTime' => 0b110,
'reurl_cc_api' => 0b010, //shortUrlSite_apiKey
];
$timezones = array(
@ -2923,6 +2925,8 @@ function render_list($path = '', $files = [])
$tmp = splitfirst($html, '</title>');
$html = $tmp[0] . '</title>' . $authinfo . $tmp[1];
//短链接apikey处理
$html = str_replace('your_api_key_for_reurl_cc', strval(getConfig('reurl_cc_api')), $html);
//if (isset($_SERVER['Set-Cookie'])) return output($html, $statusCode, [ 'Set-Cookie' => $_SERVER['Set-Cookie'], 'Content-Type' => 'text/html' ]);
return output($html, $statusCode);
}

View File

@ -115,6 +115,7 @@ $constStr = [
'domainforproxy' => 'Will replace the https://xxxxx-my.sharepoint.com with this value.Add &Origindomain=xxxxx-my.sharepoint.com at last',
'public_path' => 'Show this Onedrive dir when through the long url of API Gateway.',
'sitename' => 'sitename',
'reurl_cc_api' => 'the api_key of short URL site of reurl.cc',
],
'zh-cn' => [
'admin' => '管理密码,不添加时不显示登录页面且无法登录。',
@ -145,6 +146,7 @@ $constStr = [
'domainforproxy' => '会将https://xxxxx-my.sharepoint.com替换成这个值在目标需要自己设置反代。会加上&Origindomain=原域名',
'public_path' => '使用API长链接访问时显示网盘文件的路径不设置时默认为根目录。',
'sitename' => '网站的名称',
'reurl_cc_api' => 'reurl.cc 短链接网站的api key',
],
'zh-tw' => [
'admin' => '管理密碼,不設定密碼將不顯示登入頁面且無法登入。',
@ -170,6 +172,7 @@ $constStr = [
'domainforproxy' => '會將https://xxxxx-my.sharepoint.com取代成這個值在目標需要自己設定反代。會加上&Origindomain=原域名',
'public_path' => '使用API長連結訪問時顯示網路硬碟檔案的路徑不設定時預設為根目錄。',
'sitename' => '網站的名稱',
'reurl_cc_api' => 'reurl.cc 短連結網站的api key',
],
'ja' => [
'admin' => 'パスワードを管理する、追加しない場合、ログインページは表示されず、ログインできません。',
@ -195,6 +198,7 @@ $constStr = [
'domainforproxy' => '会将https://xxxy-my.sharepoint.comこの値に代えて、目標には自分で反世代を設定する必要があります。に加えて&amp;Originndomain=元のドメイン名',
'public_path' => 'APIのロングリンクアクセスを使用する場合、ネットワークディスクファイルのパスが表示されますが、設定されていない場合はデフォルトでルートディレクトリになり。',
'sitename' => 'ウェブサイト名',
'reurl_cc_api' => 'reurl.cc ショートリンクサイトのapi key',
],
'ko-kr' => [
'admin' => '비밀번호를 관리하고 로그인 페이지를 표시하지 않으며 추가하지 않으면 로그인 할 수 없습니다.',

View File

@ -150,7 +150,7 @@
<div class="list-wrapper" id="list-div">
<div class="list-container">
<div class="list-header-container">
<h3 class="table-header"><a href="<!--base_path-->"><!--constStr@Home--></a><!--DiskPathArrayStart--> / <a href="<!--PathArrayLink-->"><!--PathArrayName--></a><!--DiskPathArrayEnd--></h3>
<h3 class="table-header"><a href="<!--base_path-->"><!--constStr@Home--></a><!--DiskPathArrayStart--> / <a href="<!--PathArrayLink-->"><!--PathArrayName--></a><!--DiskPathArrayEnd-->&nbsp;&nbsp;&nbsp;&nbsp;<button onclick="getShortUrl('Download');">生成短链</button>&nbsp;&nbsp;&nbsp;&nbsp;<button onclick="getShortUrl('Preview');">生成预览短链</button></h3>
</div>
<div class="list-body-container">
<!--EncryptedStart-->
@ -491,6 +491,42 @@
<!--IsFileStart--><!--IspdfFileStart--><script src="//cdn.bootcss.com/pdf.js/2.3.200/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd-->
<!--ListEnd-->
<script type="text/javascript">
function getShortUrl(str)
{
var urlStr = String(document.location);
if (str == 'Preview' && urlStr.indexOf("?preview") == -1)
{
urlStr = urlStr + "?preview";
}
if (str == 'Download' && urlStr.indexOf("?preview") != -1)
{
urlStr = urlStr.replace(/\?preview/g, "");
}
var httpRequest = new XMLHttpRequest();
httpRequest.open('POST', 'https://api.reurl.cc/shorten', true);
httpRequest.setRequestHeader("Content-type","application/json");
httpRequest.setRequestHeader("reurl-api-key","your_api_key_for_reurl_cc");
httpRequest.send('{ "url" : "'+urlStr+'" }');
httpRequest.onreadystatechange = function ()
{
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
var json = httpRequest.responseText;
var json_loads = eval('('+json+')');
var tmptextarea=document.createElement('textarea');
document.body.appendChild(tmptextarea);
tmptextarea.setAttribute('style','position:absolute;left:-100px;width:0px;height:0px;');
tmptextarea.innerHTML = json_loads.short_url;
tmptextarea.select();
tmptextarea.setSelectionRange(0, tmptextarea.value.length);
document.execCommand("copy");
alert(tmptextarea.innerHTML+"\n复制"+"<!--constStr@Success-->");
}
else
{
alert("网络出错, error code "+httpRequest.status);
}
};
}
function changelanguage(str)
{
if (str=='Language') str = '';