update
parent
849a990545
commit
361aa4bf9b
|
@ -0,0 +1,4 @@
|
|||
<?php $configs = '
|
||||
{
|
||||
}
|
||||
';
|
|
@ -0,0 +1,26 @@
|
|||
# # Apache
|
||||
# # LoadModule rewrite_module modules/mod_rewrite.so
|
||||
# # AllowOverride All
|
||||
RewriteEngine On
|
||||
# RewriteCond $1 !^(.well-known)
|
||||
RewriteRule ^(.*) index.php?/$1 [L]
|
||||
|
||||
###-----------------------------------
|
||||
### nginx
|
||||
# rewrite ^/(?!.well-known)(.*)$ /index.php?/$1 last;
|
||||
#
|
||||
### caddy
|
||||
# rewrite {
|
||||
# to index.php?/$1
|
||||
# }
|
||||
#
|
||||
### caddy2 Caddyfile
|
||||
# @try_files {
|
||||
# not path /.well-known/*
|
||||
# file {
|
||||
# try_files index.php
|
||||
# }
|
||||
# }
|
||||
# rewrite @try_files {http.matchers.file.relative}
|
||||
#
|
||||
###-----------------------------------
|
|
@ -0,0 +1,90 @@
|
|||
|
||||
// odd, 单日
|
||||
const SingleDay = 'https://aaa1.herokuapp.com'
|
||||
// even, 双日
|
||||
const DoubleDay = 'https://bbb2.herokuapp.com'
|
||||
|
||||
//const SingleDay = 'https://153xxxxx0.cn-hongkong.fc.aliyuncs.com/2016-08-15/proxy/onedrive/xxx/'
|
||||
//const DoubleDay = 'https://153xxxxx0.cn-hongkong.fc.aliyuncs.com/2016-08-15/proxy/onedrive/xxx/'
|
||||
|
||||
// CF proxy all, 一切给CF代理,true/false
|
||||
const CFproxy = true
|
||||
|
||||
// Used in cloudflare workers, odd or even days point to 2 heroku account.
|
||||
|
||||
// 由于heroku不绑卡不能自定义域名,就算绑卡后https也不方便
|
||||
// 另外免费套餐每月550小时,有些人不够用
|
||||
// 于是在CF Workers使用此代码,分单双日拉取不同heroku帐号下的相同网页
|
||||
// 只改上面,下面不用动
|
||||
|
||||
addEventListener('fetch', event => {
|
||||
let url=new URL(event.request.url);
|
||||
if (url.protocol == 'http:') {
|
||||
url.protocol = 'https:'
|
||||
event.respondWith( Response.redirect(url.href) )
|
||||
} else {
|
||||
let response = null;
|
||||
let nd = new Date();
|
||||
if (nd.getDate()%2) {
|
||||
host = SingleDay
|
||||
} else {
|
||||
host = DoubleDay
|
||||
}
|
||||
if (host.substr(0, 7)!='http://'&&host.substr(0, 8)!='https://') host = 'http://' + host;
|
||||
|
||||
response = fetchAndApply(host, event.request);
|
||||
|
||||
event.respondWith( response );
|
||||
}
|
||||
})
|
||||
|
||||
async function fetchAndApply(host, request) {
|
||||
let f_url = new URL(request.url);
|
||||
let a_url = new URL(host);
|
||||
let replace_path = a_url.pathname;
|
||||
if (replace_path.substr(replace_path.length-1)!='/') replace_path += '/';
|
||||
let replaced_path = '/';
|
||||
let query = f_url.search;
|
||||
let path = f_url.pathname;
|
||||
if (host.substr(host.length-1)=='/') path = path.substr(1);
|
||||
f_url.href = host + path + query;
|
||||
|
||||
let response = null;
|
||||
if (!CFproxy) {
|
||||
response = await fetch(f_url, request);
|
||||
} else {
|
||||
let method = request.method;
|
||||
let body = request.body;
|
||||
let request_headers = request.headers;
|
||||
let new_request_headers = new Headers(request_headers);
|
||||
new_request_headers.set('Host', f_url.host);
|
||||
new_request_headers.set('Referer', request.url);
|
||||
|
||||
response = await fetch(f_url.href, {
|
||||
method: method,
|
||||
body: body,
|
||||
headers: new_request_headers
|
||||
});
|
||||
}
|
||||
|
||||
let out_headers = new Headers(response.headers);
|
||||
if (out_headers.get('Content-Disposition')=='attachment') out_headers.delete('Content-Disposition');
|
||||
let out_body = null;
|
||||
let contentType = out_headers.get('Content-Type');
|
||||
if (contentType.includes("application/text")) {
|
||||
out_body = await response.text();
|
||||
while (out_body.includes(replace_path)) out_body = out_body.replace(replace_path, replaced_path);
|
||||
} else if (contentType.includes("text/html")) {
|
||||
out_body = await response.text();
|
||||
while (replace_path!='/'&&out_body.includes(replace_path)) out_body = out_body.replace(replace_path, replaced_path);
|
||||
} else {
|
||||
out_body = await response.body;
|
||||
}
|
||||
|
||||
let out_response = new Response(out_body, {
|
||||
status: response.status,
|
||||
headers: out_headers
|
||||
})
|
||||
|
||||
return out_response;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"name": "Tfo",
|
||||
"description": "Deploy Tfo to heroku",
|
||||
"website": "https://github.com/BingoKingo/Tfo",
|
||||
"repository": "https://github.com/BingoKingo/Tfo",
|
||||
"success_url": "/"
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,957 @@
|
|||
<?php
|
||||
|
||||
global $exts;
|
||||
global $constStr;
|
||||
|
||||
$exts['img'] = ['ico', 'bmp', 'gif', 'jpg', 'jpeg', 'jpe', 'jfif', 'tif', 'tiff', 'png', 'heic', 'webp'];
|
||||
$exts['music'] = ['mp3', 'wma', 'flac', 'ape', 'wav', 'ogg', 'm4a'];
|
||||
$exts['office'] = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'];
|
||||
$exts['txt'] = ['txt', 'bat', 'sh', 'php', 'asp', 'js', 'css', 'json', 'html', 'c', 'cpp', 'md', 'py', 'omf'];
|
||||
$exts['video'] = ['mp4', 'webm', 'mkv', 'mov', 'flv', 'blv', 'avi', 'wmv', 'm3u8', 'rm', 'rmvb'];
|
||||
$exts['zip'] = ['zip', 'rar', '7z', 'gz', 'tar'];
|
||||
|
||||
$constStr = [
|
||||
'languages' => [
|
||||
'en-us' => 'English',
|
||||
'zh-cn' => '简体中文',
|
||||
'zh-tw' => '繁體中文',
|
||||
'ja' => '日本語',
|
||||
'ko-kr' => '한국어',
|
||||
'fa' => 'فارسی',
|
||||
],
|
||||
'Week' => [
|
||||
'en-us' => [
|
||||
0 => 'Sunday',
|
||||
1 => 'Monday',
|
||||
2 => 'Tuesday',
|
||||
3 => 'Wednesday',
|
||||
4 => 'Thursday',
|
||||
5 => 'Friday',
|
||||
6 => 'Saturday',
|
||||
],
|
||||
'zh-cn' => [
|
||||
0 => '星期日',
|
||||
1 => '星期一',
|
||||
2 => '星期二',
|
||||
3 => '星期三',
|
||||
4 => '星期四',
|
||||
5 => '星期五',
|
||||
6 => '星期六',
|
||||
],
|
||||
'zh-tw' => [
|
||||
0 => '星期日',
|
||||
1 => '星期一',
|
||||
2 => '星期二',
|
||||
3 => '星期三',
|
||||
4 => '星期四',
|
||||
5 => '星期五',
|
||||
6 => '星期六',
|
||||
],
|
||||
'ja' => [
|
||||
0 => '日曜日',
|
||||
1 => '月曜日',
|
||||
2 => '火曜日',
|
||||
3 => '水曜日',
|
||||
4 => '木曜日',
|
||||
5 => '金曜日',
|
||||
6 => '土曜日',
|
||||
],
|
||||
'ko-kr' => [
|
||||
0 => '일요일',
|
||||
1 => '월요일',
|
||||
2 => '화요일',
|
||||
3 => '수요일',
|
||||
4 => '목요일',
|
||||
5 => '금요일',
|
||||
6 => '토요일',
|
||||
],
|
||||
'fa' => [
|
||||
0 => 'یکشنبه',
|
||||
1 => 'دوشنبه',
|
||||
2 => 'سه شنبه',
|
||||
3 => 'چهارشنبه',
|
||||
4 => 'پنج شنبه',
|
||||
5 => 'جمعه',
|
||||
6 => 'شنبه',
|
||||
],
|
||||
],
|
||||
'EnvironmentsDescription' => [
|
||||
'en-us' => [
|
||||
'admin' => 'The admin password, Login button will not show when empty',
|
||||
'adminloginpage' => 'if set, the Login button will not display, and the login page no longer \'?admin\', it is \'?{this value}\'.',
|
||||
'autoJumpFirstDisk' => 'used in multy disks, if 1, auto jump to first disk',
|
||||
'customScript' => '<script> in all pages, e.g. http turn to https',
|
||||
'customCss' => '<style> in <head>',
|
||||
'customTheme' => 'an url of html',
|
||||
'domain_path' => 'more custom domain, format is a1.com:/dirto/path1|b2.com:/path2',
|
||||
'diskname' => 'The disk name you want show.',
|
||||
'disktag' => 'A tag used in store config and url.',
|
||||
'disableShowThumb' => 'if 1, the ShowThumbnail button will not display',
|
||||
'disableChangeTheme' => 'if 1, the Theme selection button will not display',
|
||||
'downloadencrypt' => '0 or 1. if 1, the files in encrypt folder can be downloaded without password',
|
||||
'background' => 'Set an url as background photo.',
|
||||
'backgroundm' => 'Set an url as background in mobile phone.',
|
||||
'theme' => 'Select theme.',
|
||||
'timezone' => 'Set default timezone.',
|
||||
'guestup_path' => 'Set guest upload dir, before set this, the files in this dir will show as normal.',
|
||||
'hideFunctionalityFile' => '0 or 1. if 1, some file will not show in list to guest, like readme.md',
|
||||
'passfile' => 'The password of folder(& its childrens) will save in this file.',
|
||||
'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; public show files less than private.',
|
||||
'sitename' => 'sitename',
|
||||
'Onedrive_ver' => 'Onedrive version',
|
||||
],
|
||||
'zh-cn' => [
|
||||
'admin' => '管理密码,不添加时不显示登录页面且无法登录。',
|
||||
'adminloginpage' => '如果设置,登录按钮及页面隐藏。管理登录的页面不再是\'?admin\',而是\'?此设置的值\'。',
|
||||
'autoJumpFirstDisk' => '用于多盘,如果设1,将会自动跳到第一个盘。',
|
||||
'customScript' => '<script>,在所有页都会存在,例如放一个http跳转https',
|
||||
'customCss' => '<style>,在<head>最后面',
|
||||
'customTheme' => 'html格式的主题的url',
|
||||
'domain_path' => '使用多个自定义域名时,指定每个域名看到的目录。格式为a1.com:/dirto/path1|b1.com:/path2,比private_path优先。',
|
||||
'diskname' => '这个盘你想显示什么名称。',
|
||||
'disktag' => '一个标签,用于保存配置,多盘时会显示在url中。',
|
||||
'disableShowThumb' => '如果填 1, ‘显示缩略’按钮将被隐藏。',
|
||||
'disableChangeTheme' => '如果填 1, 主题选择切换将被隐藏',
|
||||
'downloadencrypt' => '0 或 1。如果 1, 那加密目录内的文件可以不需要密码就能下载。',
|
||||
'background' => '设置一个url作为背景。',
|
||||
'backgroundm' => '设置一个url作为手机用的背景。',
|
||||
'theme' => '选择一个主题。',
|
||||
'timezone' => '设置默认时区。',
|
||||
'guestup_path' => '设置游客上传路径(图床路径),不设置这个值时该目录内容会正常列文件出来,设置后只有上传界面,不显示其中文件(登录后显示)。',
|
||||
'hideFunctionalityFile' => '0 或 1。如果 1, 某些文件不列表给游客看,但它的功能正常,比如readme.md',
|
||||
'passfile' => '自定义密码文件的名字,可以是\'pppppp\',也可以是\'aaaa.txt\'等等;列目录时不会显示,只有知道密码才能查看或下载此文件。密码是这个文件的内容,可以空格、可以中文;',
|
||||
'domainforproxy' => '会将https://xxxxx-my.sharepoint.com替换成这个值,在目标需要自己设置反代。会加上&Origindomain=原域名',
|
||||
'public_path' => '使用API长链接访问时,显示网盘文件的路径,不设置时默认为根目录;不能是private_path的上级(public看到的不能比private多,要么看到的就不一样)。',
|
||||
'sitename' => '网站的名称',
|
||||
'Onedrive_ver' => 'Onedrive版本',
|
||||
],
|
||||
'zh-tw' => [
|
||||
'admin' => '管理密碼,不設定密碼將不顯示登入頁面且無法登入。',
|
||||
'adminloginpage' => '如果設定,登入按鈕及頁面隱藏。管理登入的頁面不再是\'?admin\',而是\'?此設置的值\'。',
|
||||
'autoJumpFirstDisk' => '用於多盤,如果設1,將會自動跳到第一個盤。',
|
||||
'customScript' => '<script>,在所有頁都會存在,例如放一個http跳轉https',
|
||||
'customCss' => '<style>,在<head>最後面',
|
||||
'customTheme' => 'html格式的主題的url',
|
||||
'domain_path' => '使用多個自訂域名時,指定每個域名看到的目錄。格式為a1.com:/dirto/path1|b1.com:/path2,比private_path優先。',
|
||||
'diskname' => '這個盤你想顯示什麼名稱。',
|
||||
'disktag' => '一個標籤,用於儲存配置,多盤時會顯示在url中。',
|
||||
'disableShowThumb' => '如果填 1, ‘顯示縮略’按鈕將被隱藏。',
|
||||
'disableChangeTheme' => '如果填 1, 主題選擇切換將被隱藏',
|
||||
'downloadencrypt' => '0 或 1。如果 1, 那加密目錄內的文件可以不需要密碼就能下載。',
|
||||
'background' => '設定一個url作為背景。',
|
||||
'backgroundm' => '設定一個url作為手機用的背景。',
|
||||
'theme' => '選擇一個主題。',
|
||||
'timezone' => '設定預設時區。',
|
||||
'guestup_path' => '設定遊客上傳路徑(圖床路徑),不設定這個值時該目錄內容會正常列文件出來,設定後只有上傳介面,不顯示其中文件(登入後顯示)。',
|
||||
'hideFunctionalityFile' => '0 或 1。如果 1, 某些文件不列表給遊客看,但它的功能正常,比如readme.md',
|
||||
'passfile' => '自訂密碼文件的名字,可以是\'pppppp\',也可以是\'aaaa.txt\'等等;列目錄時不會顯示,只有知道密碼才能查看或下載此文件。密碼是這個文件的內容,可以空格、可以中文;',
|
||||
'domainforproxy' => '會將https://xxxxx-my.sharepoint.com取代成這個值,在目標需要自己設定反代。會加上&Origindomain=原域名',
|
||||
'public_path' => '使用API長連結訪問時,顯示網路硬碟檔案的路徑,不設定時預設為根目錄;不能是private_path的上級(public看到的不能比private多,要麼看到的就不一樣)。',
|
||||
'sitename' => '網站的名稱',
|
||||
'Onedrive_ver' => 'Onedrive版本',
|
||||
],
|
||||
'ja' => [
|
||||
'admin' => 'パスワードを管理する、追加しない場合、ログインページは表示されず、ログインできません。',
|
||||
'adminloginpage' => '設定すると、ログインボタンとページが非表示になります。ログインを管理するためのページは\'?admin \'ではなく、\'?この設定の値\'。',
|
||||
'domain_path' => '複数のカスタムドメイン名を使用する場合、各ドメイン名に表示されるディレクトリを指定します。形式はa1.com:/dirto/path1|b1.com:/path2で、private_pathよりも優先されます。',
|
||||
'diskname' => '',
|
||||
'disktag' => '',
|
||||
'downloadencrypt' => '',
|
||||
'background' => '',
|
||||
'guestup_path' => 'マップベッドのパスを設定します。この値が設定されていない場合、ディレクトリの内容は通常ファイルにリストされ、設定後はアップロードインターフェイスのみが表示されます。',
|
||||
'passfile' => 'カスタムパスワードファイルの名前は、\'pppppp \'、\'aaaa.txt \'などの場合があります。ディレクトリをリストするときには表示されません。パスワードを知っている場合にのみ、このファイルを表示またはダウンロードできます。 パスワードはこのファイルの内容であり、スペースまたは漢字を使用できます。',
|
||||
'public_path' => 'APIのロングリンクアクセスを使用する場合、ネットワークディスクファイルのパスが表示されますが、設定されていない場合はデフォルトでルートディレクトリになり、private_pathの上位にはなりません(publicはprivate以上のものを見ることができません。それ以外は異なります。)。',
|
||||
'sitename' => 'ウェブサイト名',
|
||||
'Onedrive_ver' => 'Onedriveバージョン',
|
||||
],
|
||||
'ko-kr' => [
|
||||
'admin' => '비밀번호를 관리하고 로그인 페이지를 표시하지 않으며 추가하지 않으면 로그인 할 수 없습니다.',
|
||||
'adminloginpage' => '설정하면 로그인 버튼과 페이지가 숨겨집니다. 로그인 관리 페이지는 더 이상 \ ?Admin\'이 아니라 \ ?이 설정의 값 \'입니다.',
|
||||
'domain_path' => '여러 개의 사용자 정의 도메인 이름을 사용하는 경우 각 도메인 이름에 표시되는 디렉토리를 지정하십시오. 형식은 a1.com:/dirto/path1|b1.com:/path2이며 private_path보다 우선합니다.',
|
||||
'diskname' => '이 디스크에 어떤 이름을 표시 하시겠습니까?',
|
||||
'disktag' => '레이블은 구성을 저장하는 데 사용되며 디스크가 여러 개인 경우 URL에 표시됩니다.',
|
||||
'downloadencrypt' => '',
|
||||
'background' => 'URL을 배경으로 설정하거나 표시하는.',
|
||||
'guestup_path' => '방문자의 업로드 경로 (맵 베드 경로)를 설정합니다.이 값을 설정하지 않으면 디렉토리의 내용이 파일로 표시되고 설정 후에는 업로드 인터페이스 만 표시되고 파일은 표시되지 않습니다 (로그인 후 표시).',
|
||||
'passfile' => '사용자 정의 비밀번호 파일의 이름은 \'pppppp\' \'aaaa.txt \'등이 될 수 있으며 디렉토리가 나열되어 있으면 표시되지 않으며 비밀번호를 알고있는 경우에만이 파일을 보거나 다운로드 할 수 있습니다. 암호는이 파일의 내용이며 공백이거나 한국어 일 수 있습니다.',
|
||||
'public_path' => 'API 긴 링크 액세스를 사용하는 경우 네트워크 디스크 파일의 경로가 표시됩니다. 설정되지 않은 경우 기본적으로 루트 디렉토리로 설정됩니다.',
|
||||
'sitename' => '웹 사이트 이름',
|
||||
'Onedrive_ver' => 'Onedrive 버전',
|
||||
],
|
||||
'fa' => [
|
||||
'admin' => 'رمز عبور ادمین، در صورت خالی بودن دکمه لاگین به نمایش در نمیآید',
|
||||
'adminloginpage' => 'در صورت تنظیم ، دکمه ورود نمایش داده نمی شود و صفحه ورود دیگر \?admin\ نیست بلکه \?{مقدار ورودی شما}\ است.',
|
||||
'domain_path' => 'تنظیم دامنه سفارشی، به صورت a1.com:/dirto/path1|b2.com:/path2',
|
||||
'diskname' => 'نام دیسک که میخواهید نشان دهید.',
|
||||
'disktag' => 'تگی که در ذخیره پیکربندی و نشانی اینترنتی استفاده میشود.',
|
||||
'downloadencrypt' => '',
|
||||
'background' => 'تنظیم عکس پشت زمینه به صورت url یا قرار دادن بک گراند به صورت دستی در مسیر نشان داده شده.',
|
||||
'guestup_path' => 'قبل از تنظیم این گزینه ، فایل آپلود guest را تنظیم کنید ، پرونده های موجود در این حالت به صورت عادی نشان داده می شوند.',
|
||||
'passfile' => 'رمز عبور dir در این فایل ذخیره می شود.',
|
||||
'public_path' => 'این مسیر Onedrive را هنگامی که از طریق آدرس طولانی API Gateway استفاده می کنید ، نشان دهید. فایل های نمایش عمومی کمتر از خصوصی.',
|
||||
'sitename' => 'نام سایت',
|
||||
'Onedrive_ver' => 'ورژن Onedrive',
|
||||
],
|
||||
],
|
||||
'SetSecretsFirst' => [
|
||||
'en-us' => 'Set API in Config first! or reinstall.',
|
||||
'zh-cn' => '先在环境变量设置API!或重装。',
|
||||
'zh-tw' => '先在環境變數設定API!或重裝。',
|
||||
'ja' => '最初に環境変数にAPIを設定してください!',
|
||||
'ko-kr' => '먼저 환경 변수에서 API를 설정하십시오! 또는 다시 설치하십시오.',
|
||||
'fa' => 'ابتدا API را در پیکربندی تنظیم کنید! یا دوباره نصب کنید.',
|
||||
],
|
||||
'RefreshtoLogin' => [
|
||||
'en-us' => '<font color="red">Refresh</font> and login.',
|
||||
'zh-cn' => '请<font color="red">刷新</font>页面后重新登录',
|
||||
'zh-tw' => '請<font color="red">重新整理</font>頁面後重新登入',
|
||||
'ja' => 'ページを<font color = "red">更新</font>して、再度ログインしてください',
|
||||
'ko-kr' => '페이지를 <font color = "red"> 새로 고침 </ font> 하시고 다시 로그인하십시오',
|
||||
'fa' => '<font color="red">رفرش</font> و لاگین.',
|
||||
],
|
||||
'AdminLogin' => [
|
||||
'en-us' => 'Admin Login',
|
||||
'zh-cn' => '管理登录',
|
||||
'zh-tw' => '管理登入',
|
||||
'ja' => 'ログインを管理する',
|
||||
'ko-kr' => '로그인 관리',
|
||||
'fa' => 'ورود ادمین',
|
||||
],
|
||||
'LoginSuccess' => [
|
||||
'en-us' => 'Login Success!',
|
||||
'zh-cn' => '登录成功,正在跳转',
|
||||
'zh-tw' => '登入成功,正在跳轉',
|
||||
'ja' => 'ログイン成功、ジャンプ',
|
||||
'ko-kr' => '로그인 성공, 점프',
|
||||
'fa' => 'ورود با موفقیت انجام شد!',
|
||||
],
|
||||
'InputPassword' => [
|
||||
'en-us' => 'Input Password',
|
||||
'zh-cn' => '输入密码',
|
||||
'zh-tw' => '輸入密碼',
|
||||
'ja' => 'パスワードを入力してください',
|
||||
'ko-kr' => '비밀번호 입력',
|
||||
'fa' => 'رمز عبور را وارد کنید',
|
||||
],
|
||||
'Login' => [
|
||||
'en-us' => 'Login',
|
||||
'zh-cn' => '登录',
|
||||
'zh-tw' => '登入',
|
||||
'ja' => 'サインイン',
|
||||
'ko-kr' => '로그인',
|
||||
'fa' => 'ورود',
|
||||
],
|
||||
'Encrypt' => [
|
||||
'en-us' => 'Encrypt',
|
||||
'zh-cn' => '加密',
|
||||
'zh-tw' => '加密',
|
||||
'ja' => '暗号化',
|
||||
'ko-kr' => '암호화',
|
||||
'fa' => 'رمزگذاری',
|
||||
],
|
||||
'SetpassfileBfEncrypt' => [
|
||||
'en-us' => 'Set \'passfile\' in Environments before encrypt',
|
||||
'zh-cn' => '先在环境变量设置passfile才能加密',
|
||||
'zh-tw' => '先在環境變數設定passfile才能加密',
|
||||
'ja' => '最初に暗号化する環境変数にパスファイルを設定します',
|
||||
'ko-kr' => '암호화하기 전에 환경 변수에 패스 파일을 설정하십시오',
|
||||
'fa' => 'قبل از رمزگذاری \"pass file \" را در محیط تنظیم کنید',
|
||||
],
|
||||
'updateProgram' => [
|
||||
'en-us' => 'Update Program',
|
||||
'zh-cn' => '一键更新',
|
||||
'zh-tw' => '一鍵更新',
|
||||
'ja' => 'ワンクリック更新',
|
||||
'ko-kr' => '원 클릭 업데이트',
|
||||
'fa' => 'برنامه را به روز کنید',
|
||||
],
|
||||
'UpdateSuccess' => [
|
||||
'en-us' => 'Program update Success!',
|
||||
'zh-cn' => '程序升级成功!',
|
||||
'zh-tw' => '程式升級成功!',
|
||||
'ja' => 'プログラムのアップグレードに成功しました!',
|
||||
'ko-kr' => '프로그램 업그레이드 성공!',
|
||||
'fa' => 'موفقیت به روز رسانی برنامه!',
|
||||
],
|
||||
'Setup' => [
|
||||
'en-us' => 'Setup',
|
||||
'zh-cn' => '设置',
|
||||
'zh-tw' => '設定',
|
||||
'ja' => '設定する',
|
||||
'ko-kr' => '설정',
|
||||
'fa' => 'نصب',
|
||||
],
|
||||
'Back' => [
|
||||
'en-us' => 'Back',
|
||||
'zh-cn' => '返回',
|
||||
'zh-tw' => '返回',
|
||||
'ja' => 'back',
|
||||
'ko-kr' => '돌아 가기',
|
||||
'fa' => 'بازگشت',
|
||||
],
|
||||
'Theme' => [
|
||||
'en-us' => 'Theme',
|
||||
'zh-cn' => '主题',
|
||||
'zh-tw' => '主題',
|
||||
],
|
||||
'NotNeedUpdate' => [
|
||||
'en-us' => 'Not Need Update',
|
||||
'zh-cn' => '不需要更新',
|
||||
'zh-tw' => '不需要更新',
|
||||
'ja' => '更新不要',
|
||||
'ko-kr' => '업데이트가 필요하지 않습니다',
|
||||
'fa' => 'آپدیت لازم نیست',
|
||||
],
|
||||
'PlatformConfig' => [
|
||||
'en-us' => 'Platform Config',
|
||||
'zh-cn' => '平台变量',
|
||||
'zh-tw' => '平台變數',
|
||||
'ja' => 'プラットフォーム変数',
|
||||
'ko-kr' => '플랫폼 변수',
|
||||
'fa' => 'پیکربندی پلتفرم',
|
||||
],
|
||||
'DragSort' => [
|
||||
'en-us' => 'Drag to Sort Disk',
|
||||
'zh-cn' => '拖拽改变顺序',
|
||||
'zh-tw' => '拖曳改變順序',
|
||||
],
|
||||
'SubmitSortdisks' => [
|
||||
'en-us' => 'Submit Sort',
|
||||
'zh-cn' => '确认排序',
|
||||
'zh-tw' => '確認排序',
|
||||
],
|
||||
'DelDisk' => [
|
||||
'en-us' => 'Del This Disk',
|
||||
'zh-cn' => '删除此盘',
|
||||
'zh-tw' => '刪除此盤',
|
||||
'ja' => 'このディスクを削除',
|
||||
'ko-kr' => '이 디스크를 삭제',
|
||||
'fa' => 'پاک کردن این دیسک',
|
||||
],
|
||||
'RenameDisk' => [
|
||||
'en-us' => 'Rename Disk Tag',
|
||||
'zh-cn' => '改变标签',
|
||||
'zh-tw' => '修改標籤',
|
||||
],
|
||||
'AddDisk' => [
|
||||
'en-us' => 'Add Onedrive Disk',
|
||||
'zh-cn' => '添加Onedrive盘',
|
||||
'zh-tw' => '新增Onedrive盤',
|
||||
'ja' => 'Onedriveを追加',
|
||||
'ko-kr' => 'Onedrive 추가',
|
||||
'fa' => 'اضافه کردن دیسک Onedrive',
|
||||
],
|
||||
'Home' => [
|
||||
'en-us' => 'Home',
|
||||
'zh-cn' => '首页',
|
||||
'zh-tw' => '首頁',
|
||||
'ja' => 'ホーム',
|
||||
'ko-kr' => '홈',
|
||||
'fa' => 'خانه',
|
||||
],
|
||||
'Preview' => [
|
||||
'en-us' => 'Preview',
|
||||
'zh-cn' => '预览',
|
||||
'zh-tw' => '預覽',
|
||||
],
|
||||
'List' => [
|
||||
'en-us' => 'List',
|
||||
'zh-cn' => '列表',
|
||||
'zh-tw' => '列表',
|
||||
],
|
||||
'NeedUpdate' => [
|
||||
'en-us' => 'Program can update<br>Click setup in Operate at top.',
|
||||
'zh-cn' => '可以升级程序<br>在上方管理菜单中<br>进入设置页面升级',
|
||||
'zh-tw' => '可以升級程式<br>在上方管理選單中<br>進入設定頁面升級',
|
||||
'ja' => 'プログラムをアップグレードできます<br>上記の管理メニューで<br>アップグレードする設定ページに入ります',
|
||||
'ko-kr' => '프로그램을 업그레이드 할 수 있습니다. <br> 위의 관리 메뉴에서 <br> 업그레이드 할 설정 페이지를 입력하십시오.',
|
||||
'fa' => 'برنامه می تواند آپدیت شود<br>روی گزینه نصب در بالای صفحه کلیک کنید.',
|
||||
],
|
||||
'Operate' => [
|
||||
'en-us' => 'Operate',
|
||||
'zh-cn' => '管理',
|
||||
'zh-tw' => '管理',
|
||||
'ja' => '管理',
|
||||
'ko-kr' => '관리',
|
||||
'fa' => 'مدیریت',
|
||||
],
|
||||
'Logout' => [
|
||||
'en-us' => 'Logout',
|
||||
'zh-cn' => '登出',
|
||||
'zh-tw' => '登出',
|
||||
'ja' => 'ログアウトする',
|
||||
'ko-kr' => '로그 아웃',
|
||||
'fa' => 'خروج',
|
||||
],
|
||||
'Create' => [
|
||||
'en-us' => 'Create',
|
||||
'zh-cn' => '新建',
|
||||
'zh-tw' => '建立',
|
||||
'ja' => '新しい',
|
||||
'ko-kr' => '새로운',
|
||||
'fa' => 'ایجاد کردن',
|
||||
],
|
||||
'Download' => [
|
||||
'en-us' => 'download',
|
||||
'zh-cn' => '下载',
|
||||
'zh-tw' => '下載',
|
||||
'ja' => 'ダウンロードする',
|
||||
'ko-kr' => '다운로드',
|
||||
'fa' => 'دانلود',
|
||||
],
|
||||
'ClicktoEdit' => [
|
||||
'en-us' => 'Click to edit',
|
||||
'zh-cn' => '点击后编辑',
|
||||
'zh-tw' => '點擊後編輯',
|
||||
'ja' => 'クリック後に編集',
|
||||
'ko-kr' => '클릭 후 편집',
|
||||
'fa' => 'برای ویرایش کلیک کنید',
|
||||
],
|
||||
'Save' => [
|
||||
'en-us' => 'Save',
|
||||
'zh-cn' => '保存',
|
||||
'zh-tw' => '儲存',
|
||||
'ja' => '保存する',
|
||||
'ko-kr' => '저장',
|
||||
'fa' => 'ذخیره',
|
||||
],
|
||||
'FileNotSupport' => [
|
||||
'en-us' => 'File not support preview.',
|
||||
'zh-cn' => '文件格式不支持预览',
|
||||
'zh-tw' => '檔案格式不支援預覽',
|
||||
'ja' => 'ファイル形式はプレビューをサポートしていません',
|
||||
'ko-kr' => '파일 형식은 미리보기를 지원하지 않습니다',
|
||||
'fa' => 'پیش نمایش برای این فایل پشتیبانی نمی شود.',
|
||||
],
|
||||
'File' => [
|
||||
'en-us' => 'File',
|
||||
'zh-cn' => '文件',
|
||||
'zh-tw' => '文件',
|
||||
'ja' => 'ファイル',
|
||||
'ko-kr' => '파일',
|
||||
'fa' => 'فایل',
|
||||
],
|
||||
'ShowThumbnails' => [
|
||||
'en-us' => 'Thumbnails',
|
||||
'zh-cn' => '图片缩略',
|
||||
'zh-tw' => '圖片縮略',
|
||||
'ja' => '画像のサムネイル',
|
||||
'ko-kr' => '사진 섬네일',
|
||||
'fa' => 'تصویر بندانگشتی',
|
||||
],
|
||||
'OriginalPic' => [
|
||||
'en-us' => 'OriginalPic',
|
||||
'zh-cn' => '原图',
|
||||
'zh-tw' => '原圖',
|
||||
],
|
||||
'CopyAllDownloadUrl' => [
|
||||
'en-us' => 'CopyAllDownloadUrl',
|
||||
'zh-cn' => '复制所有下载链接',
|
||||
'zh-tw' => '複製所有下載連結',
|
||||
'ja' => 'すべてのダウンロードリンクをコピー',
|
||||
'ko-kr' => '모든 다운로드 링크 복사',
|
||||
'fa' => 'کپی از تمام لینک ها',
|
||||
],
|
||||
'Search' => [
|
||||
'en-us' => 'Search',
|
||||
'zh-cn' => '搜索',
|
||||
'zh-tw' => '搜尋',
|
||||
],
|
||||
'EditTime' => [
|
||||
'en-us' => 'EditTime',
|
||||
'zh-cn' => '修改时间',
|
||||
'zh-tw' => '修改時間',
|
||||
'ja' => '変更時間',
|
||||
'ko-kr' => '수정 시간',
|
||||
'fa' => 'زمان ویرایش',
|
||||
],
|
||||
'Size' => [
|
||||
'en-us' => 'Size',
|
||||
'zh-cn' => '大小',
|
||||
'zh-tw' => '大小',
|
||||
'ja' => 'サイズ ',
|
||||
'ko-kr' => '사이즈',
|
||||
'fa' => 'سایز',
|
||||
],
|
||||
'Rename' => [
|
||||
'en-us' => 'Rename',
|
||||
'zh-cn' => '重命名',
|
||||
'zh-tw' => '重新命名',
|
||||
'ja' => '名前を変更',
|
||||
'ko-kr' => '이름 바꾸기',
|
||||
'fa' => 'تغییر نام',
|
||||
],
|
||||
'Move' => [
|
||||
'en-us' => 'Move',
|
||||
'zh-cn' => '移动',
|
||||
'zh-tw' => '移動',
|
||||
'ja' => '移動する',
|
||||
'ko-kr' => '이동',
|
||||
'fa' => 'انتقال',
|
||||
],
|
||||
'Copy' => [
|
||||
'en-us' => 'Copy',
|
||||
'zh-cn' => '复制',
|
||||
'zh-tw' => '複製',
|
||||
'ja' => 'コピー',
|
||||
'ko-kr' => '복사',
|
||||
'fa' => 'کپی',
|
||||
],
|
||||
'CannotMove' => [
|
||||
'en-us' => 'Can not Move!',
|
||||
'zh-cn' => '不能移动!',
|
||||
'zh-tw' => '不能移動!',
|
||||
'ja' => '動かない!',
|
||||
'ko-kr' => '움직일 수 없어!',
|
||||
'fa' => 'نمیتواند منتقل شود!',
|
||||
],
|
||||
'Delete' => [
|
||||
'en-us' => 'Delete',
|
||||
'zh-cn' => '删除',
|
||||
'zh-tw' => '刪除',
|
||||
'ja' => '削除する',
|
||||
'ko-kr' => '삭제',
|
||||
'fa' => 'حذف کردن',
|
||||
],
|
||||
'PrePage' => [
|
||||
'en-us' => 'PrePage',
|
||||
'zh-cn' => '上一页',
|
||||
'zh-tw' => '上一頁',
|
||||
'ja' => '前へ',
|
||||
'ko-kr' => '이전',
|
||||
'fa' => 'صفحه قبل',
|
||||
],
|
||||
'NextPage' => [
|
||||
'en-us' => 'NextPage',
|
||||
'zh-cn' => '下一页',
|
||||
'zh-tw' => '下一頁',
|
||||
'ja' => '次のページ',
|
||||
'ko-kr' => '다음 페이지',
|
||||
'fa' => 'صفحه بعد',
|
||||
],
|
||||
'Upload' => [
|
||||
'en-us' => 'Upload',
|
||||
'zh-cn' => '上传',
|
||||
'zh-tw' => '上傳',
|
||||
'ja' => 'アップロードする',
|
||||
'ko-kr' => '업로드',
|
||||
'fa' => 'آپلود',
|
||||
],
|
||||
'UploadFile' => [
|
||||
'en-us' => 'Upload File(s)',
|
||||
'zh-cn' => '上传文件',
|
||||
'zh-tw' => '上傳文件',
|
||||
],
|
||||
'UploadFolder' => [
|
||||
'en-us' => 'Upload Folder',
|
||||
'zh-cn' => '上传文件夹',
|
||||
'zh-tw' => '上傳資料夾',
|
||||
],
|
||||
'FileSelected' => [
|
||||
'en-us' => 'Select File',
|
||||
'zh-cn' => '选择文件',
|
||||
'zh-tw' => '選擇文件',
|
||||
'ja' => 'ファイルを選択',
|
||||
'ko-kr' => '파일 선택',
|
||||
'fa' => 'انتخاب فایل',
|
||||
],
|
||||
'NoFileSelected' => [
|
||||
'en-us' => 'Not Select File',
|
||||
'zh-cn' => '没有选择文件',
|
||||
'zh-tw' => '沒有選擇文件',
|
||||
'ja' => 'ファイルが選択されていません',
|
||||
'ko-kr' => '선택된 파일이 없습니다',
|
||||
'fa' => 'فایل را انتخاب نکنید',
|
||||
],
|
||||
'Submit' => [
|
||||
'en-us' => 'Submit',
|
||||
'zh-cn' => '确认',
|
||||
'zh-tw' => '確認',
|
||||
'ja' => '確認する',
|
||||
'ko-kr' => '확인',
|
||||
'fa' => 'ارسال',
|
||||
],
|
||||
'Close' => [
|
||||
'en-us' => '×',
|
||||
'zh-cn' => '×',
|
||||
'zh-tw' => '×',
|
||||
'ja' => '×',
|
||||
'ko-kr' => '×',
|
||||
'fa' => '×',
|
||||
],
|
||||
'InputPasswordUWant' => [
|
||||
'en-us' => 'Input Password you Want',
|
||||
'zh-cn' => '输入想要设置的密码',
|
||||
'zh-tw' => '輸入想要設置的密碼',
|
||||
'ja' => '設定するパスワードを入力してください',
|
||||
'ko-kr' => '설정하려는 비밀번호를 입력하십시오',
|
||||
'fa' => 'پسورد خود را وارد کنید',
|
||||
],
|
||||
'ParentDir' => [
|
||||
'en-us' => 'Parent Dir',
|
||||
'zh-cn' => '上一级目录',
|
||||
'zh-tw' => '上一級目錄',
|
||||
'ja' => '親ディレクトリ',
|
||||
'ko-kr' => '부모 디렉토리',
|
||||
'fa' => 'مسیر',
|
||||
],
|
||||
'Folder' => [
|
||||
'en-us' => 'Folder',
|
||||
'zh-cn' => '文件夹',
|
||||
'zh-tw' => '資料夾',
|
||||
'ja' => 'フォルダー',
|
||||
'ko-kr' => '폴더',
|
||||
'fa' => 'پوشه',
|
||||
],
|
||||
'Name' => [
|
||||
'en-us' => 'Name',
|
||||
'zh-cn' => '名称',
|
||||
'zh-tw' => '名稱',
|
||||
'ja' => '名前',
|
||||
'ko-kr' => '이름',
|
||||
'fa' => 'نام',
|
||||
],
|
||||
'Content' => [
|
||||
'en-us' => 'Content',
|
||||
'zh-cn' => '内容',
|
||||
'zh-tw' => '內容',
|
||||
'ja' => '内容',
|
||||
'ko-kr' => '내용',
|
||||
'fa' => 'محتوا',
|
||||
],
|
||||
'CancelEdit' => [
|
||||
'en-us' => 'Cancel Edit',
|
||||
'zh-cn' => '取消编辑',
|
||||
'zh-tw' => '取消編輯',
|
||||
'ja' => '編集をキャンセル',
|
||||
'ko-kr' => '편집 취소',
|
||||
'fa' => 'لغو ویرایش',
|
||||
],
|
||||
'GetFileNameFail' => [
|
||||
'en-us' => 'Fail to Get File Name!',
|
||||
'zh-cn' => '获取文件名失败!',
|
||||
'zh-tw' => '獲取檔案名失敗!',
|
||||
'ja' => 'ファイル名を取得できませんでした!',
|
||||
'ko-kr' => '파일 이름을 가져 오지 못했습니다!',
|
||||
'fa' => 'نام فایل به دست نیامد!',
|
||||
],
|
||||
'GetUploadLink' => [
|
||||
'en-us' => 'Get Upload Link',
|
||||
'zh-cn' => '获取上传链接',
|
||||
'zh-tw' => '獲取上傳連結',
|
||||
'ja' => 'アップロードリンクを取得',
|
||||
'ko-kr' => '업로드 링크 받기',
|
||||
'fa' => 'دریافت لینک آپلود',
|
||||
],
|
||||
'Calculate' => [
|
||||
'en-us' => 'Calculate',
|
||||
'zh-cn' => '计算',
|
||||
'zh-tw' => '計算',
|
||||
],
|
||||
'UpFileTooLarge' => [
|
||||
'en-us' => 'The File is too Large!',
|
||||
'zh-cn' => '文件过大,终止上传。',
|
||||
'zh-tw' => '文件過大,終止上傳。',
|
||||
'ja' => '超えると、アップロードは終了します。',
|
||||
'ko-kr' => '파일이 너무 커서 업로드가 종료되었습니다.',
|
||||
'fa' => 'فایل خیلی بزرگ است!',
|
||||
],
|
||||
'UploadStart' => [
|
||||
'en-us' => 'Upload Start',
|
||||
'zh-cn' => '开始上传',
|
||||
'zh-tw' => '開始上傳',
|
||||
'ja' => 'アップロードを開始',
|
||||
'ko-kr' => '업로드 시작',
|
||||
'fa' => 'شروع آپلود',
|
||||
],
|
||||
'UploadStartAt' => [
|
||||
'en-us' => 'Start At',
|
||||
'zh-cn' => '开始于',
|
||||
'zh-tw' => '開始於',
|
||||
'ja' => 'で開始',
|
||||
'ko-kr' => '에서 시작',
|
||||
'fa' => 'شروع از',
|
||||
],
|
||||
'ThisTime' => [
|
||||
'en-us' => 'This Time',
|
||||
'zh-cn' => '本次',
|
||||
'zh-tw' => '本次',
|
||||
'ja' => '今回は',
|
||||
'ko-kr' => '이번에는',
|
||||
'fa' => 'این زمان',
|
||||
],
|
||||
'LastUpload' => [
|
||||
'en-us' => 'Last time Upload',
|
||||
'zh-cn' => '上次上传',
|
||||
'zh-tw' => '上次上傳',
|
||||
'ja' => '上回は',
|
||||
'ko-kr' => '마지막 업로드',
|
||||
'fa' => 'آخرین زمان آپلود',
|
||||
],
|
||||
'AverageSpeed' => [
|
||||
'en-us' => 'AverageSpeed',
|
||||
'zh-cn' => '平均速度',
|
||||
'zh-tw' => '平均速度',
|
||||
'ja' => '平均速度',
|
||||
'ko-kr' => '평균 속도',
|
||||
'fa' => 'میانگین سرعت',
|
||||
],
|
||||
'CurrentSpeed' => [
|
||||
'en-us' => 'CurrentSpeed',
|
||||
'zh-cn' => '即时速度',
|
||||
'zh-tw' => '即時速度',
|
||||
'ja' => 'インスタントスピード',
|
||||
'ko-kr' => '즉각적인 속도',
|
||||
'fa' => 'سرعت فعلی',
|
||||
],
|
||||
'Expect' => [
|
||||
'en-us' => 'Expect',
|
||||
'zh-cn' => '预计还要',
|
||||
'zh-tw' => '預計還要',
|
||||
'ja' => '期待される',
|
||||
'ko-kr' => '예상',
|
||||
'fa' => 'انتظار',
|
||||
],
|
||||
'EndAt' => [
|
||||
'en-us' => 'End At',
|
||||
'zh-cn' => '结束于',
|
||||
'zh-tw' => '結束於',
|
||||
'ja' => 'で終了',
|
||||
'ko-kr' => '에 끝남',
|
||||
'fa' => 'پایان از',
|
||||
],
|
||||
'UploadErrorUpAgain' => [
|
||||
'en-us' => 'Maybe error, do upload again.',
|
||||
'zh-cn' => '可能出错,重新上传。',
|
||||
'zh-tw' => '可能出錯,重新上傳。',
|
||||
'ja' => '間違っている可能性があります。もう一度アップロードしてください。',
|
||||
'ko-kr' => '잘못되었을 수 있습니다. 다시 업로드하십시오.',
|
||||
'fa' => 'خطا، دوباره آپلود کنید',
|
||||
],
|
||||
'UploadComplete' => [
|
||||
'en-us' => 'Upload Complete',
|
||||
'zh-cn' => '上传完成',
|
||||
'zh-tw' => '上傳完成',
|
||||
'ja' => 'アップロード完了',
|
||||
'ko-kr' => '업로드 완료',
|
||||
'fa' => 'آپلود با موفقیت انجام شد',
|
||||
],
|
||||
'UploadFail23' => [
|
||||
'en-us' => 'Upload Fail, contain #.',
|
||||
'zh-cn' => '目录或文件名含有#,上传失败。',
|
||||
'zh-tw' => '目錄或檔案名含有#,上傳失敗。',
|
||||
'ja' => 'ディレクトリまたはファイル名に#が含まれています。アップロードに失敗しました。',
|
||||
'ko-kr' => '디렉토리 또는 파일 이름에 #이 포함되어 있습니다. 업로드하지 못했습니다.',
|
||||
'fa' => 'بارگذاری ناموفق، حاوی #.',
|
||||
],
|
||||
'defaultSitename' => [
|
||||
'en-us' => 'OneManager',
|
||||
],
|
||||
'SavingToken' => [
|
||||
'en-us' => 'Saving refresh_token!',
|
||||
'zh-cn' => '正在保存 refresh_token!',
|
||||
'zh-tw' => '正在儲存 refresh_token!',
|
||||
'ja' => 'refresh_tokenを保存しています!',
|
||||
'ko-kr' => 'refresh_token 저장 중!',
|
||||
'fa' => 'در حال ذخیره refresh_token!',
|
||||
],
|
||||
'MayinEnv' => [
|
||||
'en-us' => 'The \'Drive_ver\' may in Config',
|
||||
'zh-cn' => 'Drive_ver应该已经写入',
|
||||
'zh-tw' => 'Drive_ver應該已經寫入',
|
||||
'ja' => 'Drive_verは環境変数に書き込まれている必要があります',
|
||||
'ko-kr' => 'Drive_verが書き込まれている必要があります',
|
||||
'fa' => 'The \'Drive_ver\' may in Config',
|
||||
],
|
||||
'Wait' => [
|
||||
'en-us' => 'Wait',
|
||||
'zh-cn' => '稍等',
|
||||
'zh-tw' => '稍等',
|
||||
'ja' => 'ちょっと待って',
|
||||
'ko-kr' => '잠깐만',
|
||||
'fa' => 'منتظر بمانید',
|
||||
],
|
||||
'WaitJumpIndex' => [
|
||||
'en-us' => 'Wait 5s jump to Home page',
|
||||
'zh-cn' => '等5s跳到首页',
|
||||
'zh-tw' => '等5秒跳到首頁',
|
||||
'ja' => '5秒待ってホームページにジャンプします',
|
||||
'ko-kr' => '5 초 동안 홈페이지로 이동',
|
||||
'fa' => '۵ دقیقه صبر کنید تا به صفحه نخست برگردید',
|
||||
],
|
||||
'JumptoOffice' => [
|
||||
'en-us' => 'Login Office and Get a refresh_token',
|
||||
'zh-cn' => '跳转到Office,登录获取refresh_token',
|
||||
'zh-tw' => '跳轉到Office,登入獲取refresh_token',
|
||||
'ja' => 'Officeにジャンプしてログインし、refresh_tokenを取得します',
|
||||
'ko-kr' => '사무실로 이동하여 로그인하여 refresh_token을 받으십시오.',
|
||||
'fa' => 'وارد Office شوید و یک refresh_token دریافت کنید',
|
||||
],
|
||||
'OnedriveDiskTag' => [
|
||||
'en-us' => 'Onedrive Disk Tag',
|
||||
'zh-cn' => 'Onedrive 标签',
|
||||
'zh-tw' => 'Onedrive 標籤',
|
||||
'ja' => 'Onedriveタグ',
|
||||
'ko-kr' => 'Onedrive 태그',
|
||||
'fa' => 'برچسب دیسک Onedrive',
|
||||
],
|
||||
'OnedriveDiskName' => [
|
||||
'en-us' => 'Onedrive Showed Name',
|
||||
'zh-cn' => 'Onedrive 显示名称',
|
||||
'zh-tw' => 'Onedrive 顯示名稱',
|
||||
'ja' => 'Onedrive表示名',
|
||||
'ko-kr' => 'Onedrive 표시 이름',
|
||||
'fa' => 'نام نشان داده شده Onedrive',
|
||||
],
|
||||
'DriveVerMS' => [
|
||||
'en-us' => 'Onedrive, Onedrive for business',
|
||||
'zh-cn' => '国际版(商业版与个人版)',
|
||||
'zh-tw' => '國際版(商業版與個人版)',
|
||||
],
|
||||
'DriveVerCN' => [
|
||||
'en-us' => 'Onedrive in China',
|
||||
'zh-cn' => '世纪互联版',
|
||||
'zh-tw' => '世紀互聯版(中國版Onedrive)',
|
||||
'ja' => '中国のOnedrive',
|
||||
'ko-kr' => '중국 Onedrive',
|
||||
'fa' => 'Onedrive در چین',
|
||||
],
|
||||
'DriveVerShareurl' => [
|
||||
'en-us' => 'A share link of a folder',
|
||||
'zh-cn' => '共享链接',
|
||||
'zh-tw' => '共享連結',
|
||||
],
|
||||
'UseShareLink' => [
|
||||
'en-us' => 'Share a folder in Onedrive (enable EDIT for everyone), input the link url below.',
|
||||
'zh-cn' => '对一个Onedrive文件夹共享,允许所有人编辑,然后将共享链接填在下方',
|
||||
'zh-tw' => '對一個Onedrive資料夾共享,允許所有人編輯,然後將共享連結填在下方',
|
||||
],
|
||||
'CustomIdSecret' => [
|
||||
'en-us' => 'Use custom client id & secret instead of OneManager default',
|
||||
'zh-cn' => '自己申请应用ID与机密,不用OneManager默认的',
|
||||
'zh-tw' => '自己申請應用ID與機密,不用OneManager預設的',
|
||||
'ja' => 'アプリケーションIDとシークレットを自分で申請する',
|
||||
'ko-kr' => '응용 프로그램 ID 및 비밀 신청',
|
||||
'fa' => 'به طور پیش فرض اما از شناسه برنامه و سکرت استفاده کنید',
|
||||
],
|
||||
'GetSecretIDandKEY' => [
|
||||
'en-us' => 'Get custom client id & secret',
|
||||
'zh-cn' => '申请应用ID与机密',
|
||||
'zh-tw' => '申請應用ID與機密',
|
||||
'ja' => 'アプリケーションIDとシークレット',
|
||||
'fa' => 'دریافت شناسه برنامه و سکرت',
|
||||
],
|
||||
'UseSharepointInstead' => [
|
||||
'en-us' => 'Use space in Sharepoint website instead of Onedrive',
|
||||
'zh-cn' => '使用Sharepoint网站的空间,不使用Onedrive',
|
||||
'zh-tw' => '使用Sharepoint網站的空間,不使用Onedrive',
|
||||
],
|
||||
'GetSharepointSiteAddress' => [
|
||||
'en-us' => 'Login office.com and click the SharePoint, create a website or find an exist website, input the Site address below',
|
||||
'zh-cn' => '登录office.com,点击Sharepoint,创建一个网站(或使用原有网站),然后将它的站点地址填在下方',
|
||||
'zh-tw' => '登入office.com,點擊Sharepoint,建立一個網站(或使用原有網站),然後將它的站點地址填在下方',
|
||||
],
|
||||
'InputSharepointSiteAddress' => [
|
||||
'en-us' => 'https://xxxxx.sharepoint.com/sites(teams)/{name}',
|
||||
],
|
||||
'TagFormatAlert' => [
|
||||
'en-us' => 'Tag must start with a letter, end with a letter or digit and can only contain lowercase letters, digits, and dashes, at least 2 letters!',
|
||||
'zh-cn' => '标签只能以字母开头,以字母或数字结尾,至少2位',
|
||||
'zh-tw' => '標籤只能以字母開頭,以字母或數字結尾,至少2位',
|
||||
'ja' => 'タグは、文字で始まり、文字または数字で終わる必要があります。少なくとも2つ',
|
||||
'ko-kr' => '태그는 문자로 시작하고 문자 또는 숫자로 끝나야합니다 (2 이상).',
|
||||
'fa' => 'برچسب باید با یک حرف شروع شود، با یک حرف یا رقم پایان یابد و تنها میتواند حاوی حروف کوچک، ارقام و خط فاصله، حداقل ۲ حرف باشد!',
|
||||
],
|
||||
'ClickInstall' => [
|
||||
'en-us' => 'Click to install the project',
|
||||
'zh-cn' => '点击开始安装程序',
|
||||
'zh-tw' => '點擊開始安裝程式',
|
||||
'ja' => 'クリックしてインストールプロセスを開始します',
|
||||
'ko-kr' => '설치 과정을 시작하려면 클릭',
|
||||
'fa' => 'برای نصب پروژه کلیک کنید',
|
||||
],
|
||||
'LogintoBind' => [
|
||||
'en-us' => 'then login and bind your onedrive in setup',
|
||||
'zh-cn' => '然后登录后在设置中绑定你的onedrive。',
|
||||
'zh-tw' => '然後登入後在設定中綁定你的onedrive。',
|
||||
'ja' => '次に、ログインして、設定でonedriveをバインドします。',
|
||||
'ko-kr' => '그런 다음 로그인하여 onedrive를 설정에 바인딩하십시오.',
|
||||
'fa' => 'پس از آن وارد سیستم شوید و تنظیمات خود را در onedrive متصل کنید',
|
||||
],
|
||||
'MakesuerWriteable' => [
|
||||
'en-us' => 'Plase make sure the config.php is writeable. run writeable.sh.',
|
||||
'zh-cn' => '确认config.php可写。',
|
||||
'zh-tw' => '確認config.php可寫。',
|
||||
'ja' => 'config.phpが書き込み可能であることを確認してください。',
|
||||
'ko-kr' => 'config.php가 쓰기 가능한지 확인하십시오.',
|
||||
'fa' => 'اطمینان حاصل کنید که config.php قابل نوشتن است. writeable.sh را اجرا کنید.',
|
||||
],
|
||||
'MakesuerRewriteOn' => [
|
||||
'en-us' => 'Plase make sure the RewriteEngine is On.',
|
||||
'zh-cn' => '确认重写(伪静态)功能启用。',
|
||||
'zh-tw' => '確認重寫(偽靜態)功能啟用。',
|
||||
'ja' => '書き換え(擬似静的)機能が有効になっていることを確認します。',
|
||||
'ko-kr' => '다시 쓰기 (의사 정적) 기능이 활성화되어 있는지 확인하십시오.',
|
||||
'fa' => 'لطفاً مطمئن شوید که RewriteEngine روشن است.',
|
||||
],
|
||||
'CopyUrl' => [
|
||||
'en-us' => 'Copy URL',
|
||||
'zh-cn' => '复制链接',
|
||||
'zh-tw' => '複製連結',
|
||||
],
|
||||
'Success' => [
|
||||
'en-us' => 'Success',
|
||||
'zh-cn' => '成功',
|
||||
'zh-tw' => '成功',
|
||||
],
|
||||
'SetAdminPassword' => [
|
||||
'en-us' => 'Set Admin Password',
|
||||
'zh-cn' => '设置管理密码',
|
||||
'zh-tw' => '設定管理密碼',
|
||||
],
|
||||
'Refresh' => [
|
||||
'en-us' => 'Refresh',
|
||||
'zh-cn' => '刷新',
|
||||
'zh-tw' => '重新整理',
|
||||
'ja' => 'リフレッシュ',
|
||||
'ko-kr' => '새로 고침',
|
||||
'fa' => 'رفرش',
|
||||
],
|
||||
'SelectLanguage' => [
|
||||
'en-us' => 'Select Language',
|
||||
'zh-cn' => '选择语言',
|
||||
'zh-tw' => '選擇語言',
|
||||
'ja' => '言語を選択してください',
|
||||
'ko-kr' => '언어를 선택하십시오',
|
||||
'fa' => 'زبان را انتخاب کنید',
|
||||
],
|
||||
'RefreshCache' => [
|
||||
'en-us' => 'RefreshCache',
|
||||
'zh-cn' => '刷新缓存',
|
||||
'zh-tw' => '重新整理快取',
|
||||
'ja' => 'キャッシュを再構築',
|
||||
'ko-kr' => '캐시 플러시',
|
||||
'fa' => 'رفرش cache',
|
||||
],
|
||||
'CannotOneKeyUpate' => [
|
||||
'en-us' => 'Can not update by a click! run update.sh',
|
||||
'zh-cn' => '不能一键更新,可以运行update.sh',
|
||||
'zh-tw' => '不能一鍵更新,可以執行update.sh',
|
||||
],
|
||||
'QueryBranchs' => [
|
||||
'en-us' => 'Query Branchs',
|
||||
'zh-cn' => '查询分支',
|
||||
'zh-tw' => '查詢分支',
|
||||
],
|
||||
'ONEMANAGER_CONFIG_SAVE_ENV' => [
|
||||
'en-us' => 'Config save in Environments',
|
||||
'zh-cn' => '配置保存在环境变量',
|
||||
'zh-tw' => '配置儲存在環境變數',
|
||||
],
|
||||
'ONEMANAGER_CONFIG_SAVE_FILE' => [
|
||||
'en-us' => 'Config save in code file, may cause fee',
|
||||
'zh-cn' => '配置保存在代码文件中,可能产生费用',
|
||||
'zh-tw' => '配置儲存在程式碼文件中,可能產生費用',
|
||||
],
|
||||
];
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"start": "php -S 0.0.0.0:8080 index.php"
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
<?php
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
include 'vendor/autoload.php';
|
||||
include 'conststr.php';
|
||||
include 'common.php';
|
||||
|
||||
//echo '<pre>'. json_encode($_SERVER, JSON_PRETTY_PRINT).'</pre>';
|
||||
if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
|
||||
if (getenv('ONEMANAGER_CONFIG_SAVE')=='file') include 'platform/TencentSCF_file.php';
|
||||
else include 'platform/TencentSCF_env.php';
|
||||
} elseif (isset($_SERVER['FC_SERVER_PATH'])&&$_SERVER['FC_SERVER_PATH']==='/var/fc/runtime/php7.2') {
|
||||
include 'platform/AliyunFC.php';
|
||||
} elseif ($_SERVER['_APP_SHARE_DIR']=='/var/share/CFF/processrouter') {
|
||||
//if (getenv('ONEMANAGER_CONFIG_SAVE')=='file') include 'platform/HuaweiFG_file.php';
|
||||
//else include 'platform/HuaweiFG_env.php';
|
||||
echo 'FG' . PHP_EOL;
|
||||
} elseif ($_SERVER['BCE_CFC_RUNTIME_NAME']=='php7') {
|
||||
//set_include_path(get_include_path() . PATH_SEPARATOR . '/opt/php');
|
||||
//include 'BaiduBce.phar';
|
||||
include 'platform/BaiduCFC.php';
|
||||
} elseif (isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app') {
|
||||
include 'platform/Heroku.php';
|
||||
$path = getpath();
|
||||
//echo 'path:'. $path;
|
||||
$_GET = getGET();
|
||||
//echo '<pre>'. json_encode($_GET, JSON_PRETTY_PRINT).'</pre>';
|
||||
$re = main($path);
|
||||
$sendHeaders = array();
|
||||
foreach ($re['headers'] as $headerName => $headerVal) {
|
||||
header($headerName . ': ' . $headerVal, true);
|
||||
}
|
||||
http_response_code($re['statusCode']);
|
||||
echo $re['body'];
|
||||
} else {
|
||||
include 'platform/Normal.php';
|
||||
$path = getpath();
|
||||
//echo 'path:'. $path;
|
||||
$_GET = getGET();
|
||||
//echo '<pre>'. json_encode($_GET, JSON_PRETTY_PRINT).'</pre>';
|
||||
|
||||
$re = main($path);
|
||||
$sendHeaders = array();
|
||||
foreach ($re['headers'] as $headerName => $headerVal) {
|
||||
header($headerName . ': ' . $headerVal, true);
|
||||
}
|
||||
http_response_code($re['statusCode']);
|
||||
echo $re['body'];
|
||||
}
|
||||
|
||||
// Tencent SCF
|
||||
function main_handler($event, $context)
|
||||
{
|
||||
$event = json_decode(json_encode($event), true);
|
||||
$context = json_decode(json_encode($context), true);
|
||||
printInput($event, $context);
|
||||
unset($_POST);
|
||||
unset($_GET);
|
||||
unset($_COOKIE);
|
||||
unset($_SERVER);
|
||||
GetGlobalVariable($event);
|
||||
//echo '<pre>'. json_encode($_COOKIE, JSON_PRETTY_PRINT).'</pre>';
|
||||
$path = GetPathSetting($event, $context);
|
||||
|
||||
return main($path);
|
||||
}
|
||||
|
||||
// Aliyun FC & Huawei FG & Baidu CFC
|
||||
function handler($event, $context)
|
||||
{
|
||||
if (isset($_SERVER['FC_SERVER_PATH'])&&$_SERVER['FC_SERVER_PATH']==='/var/fc/runtime/php7.2') {
|
||||
// Aliyun FC
|
||||
set_error_handler("myErrorHandler");
|
||||
$tmp = array(
|
||||
'method' => $event->getMethod(),
|
||||
'clientIP' => $event->getAttribute("clientIP"),
|
||||
'requestURI' => $event->getAttribute("requestURI"),
|
||||
'path' => spurlencode($event->getAttribute("path"), '/'),
|
||||
'queryString' => $event->getQueryParams(),
|
||||
'headers' => $event->getHeaders(),
|
||||
'body' => $event->getBody()->getContents(),
|
||||
);
|
||||
$event = $tmp;
|
||||
$context = json_decode(json_encode($context), true);
|
||||
printInput($event, $context);
|
||||
unset($_POST);
|
||||
unset($_GET);
|
||||
unset($_COOKIE);
|
||||
unset($_SERVER);
|
||||
GetGlobalVariable($event);
|
||||
$path = GetPathSetting($event, $context);
|
||||
|
||||
$re = main($path);
|
||||
|
||||
return new RingCentral\Psr7\Response($re['statusCode'], $re['headers'], $re['body']);
|
||||
|
||||
} elseif ($_SERVER['_APP_SHARE_DIR']=='/var/share/CFF/processrouter') {
|
||||
// Huawei FG
|
||||
global $contextUserData;
|
||||
$contextUserData = $context;
|
||||
if ($context->getUserData('ONEMANAGER_CONFIG_SAVE')=='file') include_once 'platform/HuaweiFG_file.php';
|
||||
else include_once 'platform/HuaweiFG_env.php';
|
||||
|
||||
$event = json_decode(json_encode($event), true);
|
||||
if ($event['isBase64Encoded']) $event['body'] = base64_decode($event['body']);
|
||||
|
||||
printInput($event, $context);
|
||||
unset($_POST);
|
||||
unset($_GET);
|
||||
unset($_COOKIE);
|
||||
unset($_SERVER);
|
||||
GetGlobalVariable($event);
|
||||
//echo '<pre>'. json_encode($_COOKIE, JSON_PRETTY_PRINT).'</pre>';
|
||||
$path = GetPathSetting($event, $context);
|
||||
|
||||
return main($path);
|
||||
|
||||
} elseif ($_SERVER['BCE_CFC_RUNTIME_NAME']=='php7') {
|
||||
// Baidu CFC
|
||||
//$html = '<pre>'. json_encode($event, JSON_PRETTY_PRINT).'</pre>';
|
||||
//$html .= '<pre>'. json_encode($context, JSON_PRETTY_PRINT).'</pre>';
|
||||
//$html .= '<pre>'. json_encode($_SERVER, JSON_PRETTY_PRINT).'</pre>';
|
||||
//$html .= $event['path'];
|
||||
//$html .= $context['functionBrn'];
|
||||
//return json_encode(output($html), JSON_FORCE_OBJECT);
|
||||
|
||||
printInput($event, $context);
|
||||
unset($_POST);
|
||||
unset($_GET);
|
||||
unset($_COOKIE);
|
||||
unset($_SERVER);
|
||||
GetGlobalVariable($event);
|
||||
//echo '<pre>'. json_encode($_COOKIE, JSON_PRETTY_PRINT).'</pre>';
|
||||
$path = GetPathSetting($event, $context);
|
||||
|
||||
return json_encode(main($path), JSON_FORCE_OBJECT);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// used by Aliyun FC
|
||||
function myErrorHandler($errno, $errstr, $errfile, $errline) {
|
||||
if (!(error_reporting() & $errno)) {
|
||||
return false;
|
||||
}
|
||||
switch ($errno) {
|
||||
case E_USER_ERROR:
|
||||
$errInfo = array(
|
||||
"errorMessage" => $errstr,
|
||||
"errorType" => \ServerlessFC\friendly_error_type($errno),
|
||||
"stackTrace" => array(
|
||||
"file" => $errfile,
|
||||
"line" => $errline,
|
||||
),
|
||||
);
|
||||
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
|
||||
break;
|
||||
|
||||
default: // E_USER_WARNING | E_USER_NOTICE
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,459 @@
|
|||
<?php
|
||||
// https://help.aliyun.com/document_detail/53252.html
|
||||
// https://github.com/aliyun/fc-php-sdk/blob/master/src/AliyunFC/Client.php
|
||||
|
||||
function printInput($event, $context)
|
||||
{
|
||||
if (strlen(json_encode($event['body']))>500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
|
||||
echo urldecode(json_encode($event, JSON_PRETTY_PRINT)) . '
|
||||
|
||||
' . urldecode(json_encode($context, JSON_PRETTY_PRINT)) . '
|
||||
|
||||
';
|
||||
}
|
||||
|
||||
function GetGlobalVariable($event)
|
||||
{
|
||||
$_GET = $event['queryString'];
|
||||
foreach ($_GET as $k => $v) {
|
||||
if ($v=='') $_GET[$k] = true;
|
||||
}
|
||||
$postbody = explode("&",$event['body']);
|
||||
foreach ($postbody as $postvalues) {
|
||||
$pos = strpos($postvalues,"=");
|
||||
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
|
||||
}
|
||||
$cookiebody = explode("; ",$event['headers']['Cookie'][0]);
|
||||
foreach ($cookiebody as $cookievalues) {
|
||||
$pos = strpos($cookievalues,"=");
|
||||
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
|
||||
}
|
||||
$_SERVER['FC_SERVER_PATH'] = '/var/fc/runtime/php7.2';
|
||||
}
|
||||
|
||||
function GetPathSetting($event, $context)
|
||||
{
|
||||
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['Accept-Language'][0],';')[0],',')[0]);
|
||||
$_SERVER['accountId'] = $context['accountId'];
|
||||
$_SERVER['region'] = $context['region'];
|
||||
$_SERVER['service_name'] = $context['service']['name'];
|
||||
$_SERVER['function_name'] = $context['function']['name'];
|
||||
$path = $event['path'];
|
||||
$tmp = $event['requestURI'];
|
||||
if (strpos($tmp, '?')) $tmp = substr($tmp, 0, strpos($tmp, '?'));
|
||||
if ($path=='/'||$path=='') {
|
||||
$_SERVER['base_path'] = $tmp;
|
||||
} else {
|
||||
$_SERVER['base_path'] = substr($tmp, 0, -strlen($path)+1);
|
||||
}
|
||||
|
||||
if (substr($path,-1)=='/') $path=substr($path,0,-1);
|
||||
$_SERVER['is_guestup_path'] = is_guestup_path($path);
|
||||
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
|
||||
$_SERVER['REMOTE_ADDR'] = $event['clientIP'];
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['X-Requested-With'][0];
|
||||
return $path;
|
||||
}
|
||||
|
||||
function getConfig($str, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
if (in_array($str, $InnerEnv)) {
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
$env = json_decode(getenv($disktag), true);
|
||||
if (isset($env[$str])) {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode($env[$str]);
|
||||
else return $env[$str];
|
||||
}
|
||||
} else {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode(getenv($str));
|
||||
else return getenv($str);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function setConfig($arr, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
$disktags = explode("|", getConfig('disktag'));
|
||||
$diskconfig = json_decode(getenv($disktag), true);
|
||||
$tmp = [];
|
||||
$indisk = 0;
|
||||
$operatedisk = 0;
|
||||
foreach ($arr as $k => $v) {
|
||||
if (in_array($k, $InnerEnv)) {
|
||||
if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
|
||||
else $diskconfig[$k] = $v;
|
||||
$indisk = 1;
|
||||
} elseif ($k=='disktag_add') {
|
||||
array_push($disktags, $v);
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_del') {
|
||||
$disktags = array_diff($disktags, [ $v ]);
|
||||
$tmp[$v] = '';
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
|
||||
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
|
||||
} else {
|
||||
if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
|
||||
else $tmp[$k] = $v;
|
||||
}
|
||||
}
|
||||
if ($indisk) {
|
||||
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
|
||||
ksort($diskconfig);
|
||||
$tmp[$disktag] = json_encode($diskconfig);
|
||||
}
|
||||
if ($operatedisk) {
|
||||
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
|
||||
$tmp['disktag'] = str_replace($arr['disktag_rename'], $arr['disktag_newname'], getConfig('disktag'));
|
||||
$tmp[$arr['disktag_newname']] = getConfig($arr['disktag_rename']);
|
||||
$tmp[$arr['disktag_rename']] = '';
|
||||
} else {
|
||||
$disktags = array_unique($disktags);
|
||||
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
|
||||
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
|
||||
else $tmp['disktag'] = '';
|
||||
}
|
||||
}
|
||||
// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
|
||||
//';
|
||||
$response = updateEnvironment($tmp, $_SERVER['accountId'], $_SERVER['region'], $_SERVER['service_name'], $_SERVER['function_name'], getConfig('AccessKeyID'), getConfig('AccessKeySecret'));
|
||||
//WaitSCFStat();
|
||||
return $response;
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
global $constStr;
|
||||
if ($_GET['install2']) {
|
||||
$tmp['admin'] = $_POST['admin'];
|
||||
$response = setConfigResponse( setConfig($tmp) );
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
if (needUpdate()) {
|
||||
OnekeyUpate();
|
||||
return message('update to github version, reinstall.
|
||||
<script>
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=; path=/; \'+expires;
|
||||
</script>
|
||||
<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201);
|
||||
}
|
||||
return output('Jump
|
||||
<script>
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=; path=/; \'+expires;
|
||||
</script>
|
||||
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
|
||||
}
|
||||
if ($_GET['install1']) {
|
||||
//if ($_POST['admin']!='') {
|
||||
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||
$AccessKeyID = getConfig('AccessKeyID');
|
||||
if ($AccessKeyID=='') {
|
||||
$AccessKeyID = $_POST['AccessKeyID'];
|
||||
$tmp['AccessKeyID'] = $AccessKeyID;
|
||||
}
|
||||
$AccessKeySecret = getConfig('AccessKeySecret');
|
||||
if ($AccessKeySecret=='') {
|
||||
$AccessKeySecret = $_POST['AccessKeySecret'];
|
||||
$tmp['AccessKeySecret'] = $AccessKeySecret;
|
||||
}
|
||||
$response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['accountId'], $_SERVER['region'], $_SERVER['service_name'], $_SERVER['function_name'], $AccessKeyID, $AccessKeySecret) );
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
} else {
|
||||
$html .= '
|
||||
<form action="?install2" method="post" onsubmit="return notnull(this);">
|
||||
<label>'.getconstStr('SetAdminPassword').':<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>
|
||||
<input type="submit" value="'.getconstStr('Submit').'">
|
||||
</form>
|
||||
<script>
|
||||
function notnull(t)
|
||||
{
|
||||
if (t.admin.value==\'\') {
|
||||
alert(\''.getconstStr('SetAdminPassword').'\');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
</script>';
|
||||
$title = getconstStr('SetAdminPassword');
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
//}
|
||||
}
|
||||
if ($_GET['install0']) {
|
||||
$html .= '
|
||||
<form action="?install1" method="post" onsubmit="return notnull(this);">
|
||||
language:<br>';
|
||||
foreach ($constStr['languages'] as $key1 => $value1) {
|
||||
$html .= '
|
||||
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
|
||||
}
|
||||
if (getConfig('AccessKeyID')==''||getConfig('AccessKeySecret')=='') $html .= '
|
||||
<a href="https://usercenter.console.aliyun.com/?#/manage/ak" target="_blank">'.getconstStr('Create').' AccessKeyID & AccessKeySecret</a><br>
|
||||
<label>AccessKeyID:<input name="AccessKeyID" type="text" placeholder="" size=""></label><br>
|
||||
<label>AccessKeySecret:<input name="AccessKeySecret" type="text" placeholder="" size=""></label><br>';
|
||||
$html .= '
|
||||
<input type="submit" value="'.getconstStr('Submit').'">
|
||||
</form>
|
||||
<script>
|
||||
var nowtime= new Date();
|
||||
var timezone = 0-nowtime.getTimezoneOffset()/60;
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie="timezone="+timezone+"; path=/; "+expires;
|
||||
function changelanguage(str)
|
||||
{
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=\'+str+\'; path=/; \'+expires;
|
||||
location.href = location.href;
|
||||
}
|
||||
function notnull(t)
|
||||
{';
|
||||
if (getConfig('AccessKeyID')==''||getConfig('AccessKeySecret')=='') $html .= '
|
||||
if (t.AccessKeyID.value==\'\') {
|
||||
alert(\'input AccessKeyID\');
|
||||
return false;
|
||||
}
|
||||
if (t.AccessKeySecret.value==\'\') {
|
||||
alert(\'input SecretKey\');
|
||||
return false;
|
||||
}';
|
||||
$html .= '
|
||||
return true;
|
||||
}
|
||||
</script>';
|
||||
$title = getconstStr('SelectLanguage');
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
function FCAPI2016($config, $Method, $data = '')
|
||||
{
|
||||
$accountId = $config['accountId'];
|
||||
$region = $config['region'];
|
||||
$service_name = $config['service_name'];
|
||||
$function_name = $config['function_name'];
|
||||
$AccessKeyID = $config['AccessKeyID'];
|
||||
$AccessKeySecret = $config['AccessKeySecret'];
|
||||
|
||||
$host = $accountId . '.' . $region . '-internal.fc.aliyuncs.com';
|
||||
$path = '/2016-08-15/services/' . $service_name . '/functions/' . $function_name;
|
||||
$url = 'https://' . $host . $path;
|
||||
|
||||
$ContentMd5 = '';
|
||||
$ContentType = 'application/json';
|
||||
date_default_timezone_set('UTC'); // unset last timezone setting
|
||||
$Date = substr(gmdate("r", time()), 0, -5) . 'GMT';
|
||||
$CanonicalizedFCHeaders = '';
|
||||
$CanonicalizedResource = $path;
|
||||
|
||||
$signaturestr = $Method . "\n" . $ContentMd5 . "\n" . $ContentType . "\n" . $Date . "\n" . $CanonicalizedFCHeaders . $CanonicalizedResource;
|
||||
$signature = base64_encode(hash_hmac('sha256', $signaturestr, $AccessKeySecret, true));
|
||||
|
||||
$header['Host'] = $host;
|
||||
$header['Date'] = $Date;
|
||||
$header['Content-Type'] = $ContentType;
|
||||
$header['Authorization'] = 'FC ' . $AccessKeyID . ':' . $signature;
|
||||
$header['Content-Length'] = strlen($data);
|
||||
|
||||
//return curl($Method, $url, $data, $header)['body'];
|
||||
$p = 0;
|
||||
while ($response['stat']==0 && $p<3) {
|
||||
$response = curl($Method, $url, $data, $header);
|
||||
$p++;
|
||||
}
|
||||
|
||||
if ($response['stat']==0) {
|
||||
$tmp['ErrorCode'] = 'Network Error';
|
||||
$tmp['ErrorMessage'] = 'Can not connect ' . $host;
|
||||
return json_encode($tmp);
|
||||
}
|
||||
if ($response['stat']!=200) {
|
||||
$tmp = json_decode($response['body'], true);
|
||||
$tmp['ErrorMessage'] .= '<br>' . $response['stat'] . '<br>' . $signaturestr . '<br>' . json_encode($header) . PHP_EOL;
|
||||
return json_encode($tmp);
|
||||
}
|
||||
return $response['body'];
|
||||
}
|
||||
|
||||
function getfunctioninfo($config)
|
||||
{
|
||||
return FCAPI2016($config, 'GET');
|
||||
}
|
||||
|
||||
function updateEnvironment($Envs, $accountId, $region, $service_name, $function_name, $AccessKeyID, $AccessKeySecret)
|
||||
{
|
||||
//print_r($Envs);
|
||||
$config['accountId'] = $accountId;
|
||||
$config['region'] = $region;
|
||||
$config['service_name'] = $service_name;
|
||||
$config['function_name'] = $function_name;
|
||||
$config['AccessKeyID'] = $AccessKeyID;
|
||||
$config['AccessKeySecret'] = $AccessKeySecret;
|
||||
|
||||
$tmp = json_decode(getfunctioninfo($config), true);
|
||||
foreach ($tmp['environmentVariables'] as $key => $value ) {
|
||||
$tmp_env[$key] = $value;
|
||||
}
|
||||
foreach ($Envs as $key1 => $value1) {
|
||||
$tmp_env[$key1] = $value1;
|
||||
}
|
||||
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||
ksort($tmp_env);
|
||||
|
||||
$tmpdata['environmentVariables'] = $tmp_env;
|
||||
return FCAPI2016($config, 'PUT', json_encode($tmpdata));
|
||||
}
|
||||
|
||||
function SetbaseConfig($Envs, $accountId, $region, $service_name, $function_name, $AccessKeyID, $AccessKeySecret)
|
||||
{
|
||||
$config['accountId'] = $accountId;
|
||||
$config['region'] = $region;
|
||||
$config['service_name'] = $service_name;
|
||||
$config['function_name'] = $function_name;
|
||||
$config['AccessKeyID'] = $AccessKeyID;
|
||||
$config['AccessKeySecret'] = $AccessKeySecret;
|
||||
|
||||
$tmp = json_decode(getfunctioninfo($config), true);
|
||||
foreach ($tmp['environmentVariables'] as $key => $value ) {
|
||||
$tmp_env[$key] = $value;
|
||||
}
|
||||
foreach ($Envs as $key1 => $value1) {
|
||||
$tmp_env[$key1] = $value1;
|
||||
}
|
||||
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||
ksort($tmp_env);
|
||||
|
||||
$tmpdata['description'] = 'Onedrive index and manager in Aliyun FC.';
|
||||
$tmpdata['memorySize'] = 128;
|
||||
$tmpdata['timeout'] = 30;
|
||||
$tmpdata['environmentVariables'] = $tmp_env;
|
||||
|
||||
return FCAPI2016($config, 'PUT', json_encode($tmpdata));
|
||||
}
|
||||
|
||||
function updateProgram($accountId, $region, $service_name, $function_name, $AccessKeyID, $AccessKeySecret, $source)
|
||||
{
|
||||
$config['accountId'] = $accountId;
|
||||
$config['region'] = $region;
|
||||
$config['service_name'] = $service_name;
|
||||
$config['function_name'] = $function_name;
|
||||
$config['AccessKeyID'] = $AccessKeyID;
|
||||
$config['AccessKeySecret'] = $AccessKeySecret;
|
||||
|
||||
$tmp = json_decode(getfunctioninfo($config), true);
|
||||
|
||||
$tmpdata['code']['zipFile'] = base64_encode( file_get_contents($source) );
|
||||
|
||||
return FCAPI2016($config, 'PUT', json_encode($tmpdata));
|
||||
}
|
||||
|
||||
function api_error($response)
|
||||
{
|
||||
return isset($response['ErrorMessage']);
|
||||
}
|
||||
|
||||
function api_error_msg($response)
|
||||
{
|
||||
return $response['ErrorCode'] . '<br>
|
||||
' . $response['ErrorMessage'] . '<br><br>
|
||||
|
||||
accountId:' . $_SERVER['accountId'] . '<br>
|
||||
region:' . $_SERVER['region'] . '<br>
|
||||
service_name:' . $_SERVER['service_name'] . '<br>
|
||||
function_name:' . $_SERVER['function_name'] . '<br>
|
||||
|
||||
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||
}
|
||||
|
||||
function setConfigResponse($response)
|
||||
{
|
||||
return json_decode($response, true);
|
||||
}
|
||||
|
||||
function OnekeyUpate($auth = 'BingoKingo', $project = 'Tfo', $branch = 'master')
|
||||
{
|
||||
$source = '/tmp/code.zip';
|
||||
$outPath = '/tmp/';
|
||||
|
||||
// 从github下载对应tar.gz,并解压
|
||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||
$tarfile = '/tmp/github.tar.gz';
|
||||
file_put_contents($tarfile, file_get_contents($url));
|
||||
$phar = new PharData($tarfile);
|
||||
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
||||
|
||||
// 获取解压出的目录名
|
||||
/*
|
||||
@ob_start();
|
||||
passthru('ls /tmp | grep '.$auth.'-'.$project.'',$stat);
|
||||
$html.='状态:' . $stat . '
|
||||
结果:
|
||||
';
|
||||
$archivefolder = ob_get_clean();
|
||||
if (substr($archivefolder,-1)==PHP_EOL) $archivefolder = substr($archivefolder, 0, -1);
|
||||
$outPath .= $archivefolder;
|
||||
$html.=htmlspecialchars($archivefolder);
|
||||
//return $html;
|
||||
*/
|
||||
$tmp = scandir($outPath);
|
||||
$name = $auth.'-'.$project;
|
||||
foreach ($tmp as $f) {
|
||||
if ( substr($f, 0, strlen($name)) == $name) {
|
||||
$outPath .= $f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 将目录中文件打包成zip
|
||||
$zip=new ZipArchive();
|
||||
if($zip->open($source, ZipArchive::CREATE)){
|
||||
addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
|
||||
$zip->close(); //关闭处理的zip文件
|
||||
}
|
||||
|
||||
return updateProgram($_SERVER['accountId'], $_SERVER['region'], $_SERVER['service_name'], $_SERVER['function_name'], getConfig('AccessKeyID'), getConfig('AccessKeySecret'), $source);
|
||||
}
|
||||
|
||||
function addFileToZip($zip, $rootpath, $path = '')
|
||||
{
|
||||
if (substr($rootpath,-1)=='/') $rootpath = substr($rootpath, 0, -1);
|
||||
if (substr($path,0,1)=='/') $path = substr($path, 1);
|
||||
$handler=opendir(path_format($rootpath.'/'.$path)); //打开当前文件夹由$path指定。
|
||||
while($filename=readdir($handler)){
|
||||
if($filename != "." && $filename != ".."){//文件夹文件名字为'.'和‘..’,不要对他们进行操作
|
||||
$nowname = path_format($rootpath.'/'.$path."/".$filename);
|
||||
if(is_dir($nowname)){// 如果读取的某个对象是文件夹,则递归
|
||||
addFileToZip($zip, $rootpath, $path."/".$filename);
|
||||
}else{ //将文件加入zip对象
|
||||
$zip->addFile($nowname);
|
||||
$newname = $path."/".$filename;
|
||||
if (substr($newname,0,1)=='/') $newname = substr($newname, 1);
|
||||
$zip->renameName($nowname, $newname);
|
||||
}
|
||||
}
|
||||
}
|
||||
@closedir($path);
|
||||
}
|
|
@ -0,0 +1,415 @@
|
|||
<?php
|
||||
|
||||
function printInput($event, $context)
|
||||
{
|
||||
if (strlen(json_encode($event['body']))>500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
|
||||
echo urldecode(json_encode($event, JSON_PRETTY_PRINT)) . '
|
||||
|
||||
' . urldecode(json_encode($context, JSON_PRETTY_PRINT)) . '
|
||||
|
||||
';
|
||||
}
|
||||
|
||||
function GetGlobalVariable($event)
|
||||
{
|
||||
$_GET = $event['queryStringParameters'];
|
||||
foreach ($_GET as $k => $v) {
|
||||
if ($v == '') $_GET[$k] = true;
|
||||
}
|
||||
$postbody = explode("&",$event['body']);
|
||||
foreach ($postbody as $postvalues) {
|
||||
$pos = strpos($postvalues,"=");
|
||||
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
|
||||
}
|
||||
$cookiebody = explode("; ",$event['headers']['Cookie']);
|
||||
foreach ($cookiebody as $cookievalues) {
|
||||
$pos = strpos($cookievalues,"=");
|
||||
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
|
||||
}
|
||||
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['User-Agent'];
|
||||
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
|
||||
$_SERVER['BCE_CFC_RUNTIME_NAME'] = 'php7';
|
||||
}
|
||||
|
||||
function GetPathSetting($event, $context)
|
||||
{
|
||||
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['Accept-Language'],';')[0],',')[0]);
|
||||
$_SERVER['functionBrn'] = $context['functionBrn'];
|
||||
$_SERVER['base_path'] = '/';
|
||||
$path = $event['path'];
|
||||
if (substr($path,-1)=='/') $path=substr($path,0,-1);
|
||||
$_SERVER['is_guestup_path'] = is_guestup_path($path);
|
||||
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
|
||||
$_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp'];
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['X-Requested-With'];
|
||||
return $path;
|
||||
}
|
||||
|
||||
function getConfig($str, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
if (in_array($str, $InnerEnv)) {
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
$env = json_decode(getenv($disktag), true);
|
||||
if (isset($env[$str])) {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode($env[$str]);
|
||||
else return $env[$str];
|
||||
}
|
||||
} else {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode(getenv($str));
|
||||
else return getenv($str);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function setConfig($arr, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
$disktags = explode("|",getConfig('disktag'));
|
||||
$diskconfig = json_decode(getenv($disktag), true);
|
||||
$tmp = [];
|
||||
$indisk = 0;
|
||||
$operatedisk = 0;
|
||||
foreach ($arr as $k => $v) {
|
||||
if (in_array($k, $InnerEnv)) {
|
||||
if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
|
||||
else $diskconfig[$k] = $v;
|
||||
$indisk = 1;
|
||||
} elseif ($k=='disktag_add') {
|
||||
array_push($disktags, $v);
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_del') {
|
||||
$disktags = array_diff($disktags, [ $v ]);
|
||||
$tmp[$v] = '';
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
|
||||
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
|
||||
} else {
|
||||
if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
|
||||
else $tmp[$k] = $v;
|
||||
}
|
||||
}
|
||||
if ($indisk) {
|
||||
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
|
||||
ksort($diskconfig);
|
||||
$tmp[$disktag] = json_encode($diskconfig);
|
||||
}
|
||||
if ($operatedisk) {
|
||||
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
|
||||
$tmp['disktag'] = str_replace($arr['disktag_rename'], $arr['disktag_newname'], getConfig('disktag'));
|
||||
$tmp[$arr['disktag_newname']] = getConfig($arr['disktag_rename']);
|
||||
$tmp[$arr['disktag_rename']] = '';
|
||||
} else {
|
||||
$disktags = array_unique($disktags);
|
||||
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
|
||||
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
|
||||
else $tmp['disktag'] = '';
|
||||
}
|
||||
}
|
||||
// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
|
||||
//';
|
||||
$response = updateEnvironment($tmp, getConfig('SecretId'), getConfig('SecretKey'));
|
||||
return $response;
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
global $constStr;
|
||||
if ($_GET['install2']) {
|
||||
$tmp['admin'] = $_POST['admin'];
|
||||
$response = setConfigResponse( setConfig($tmp) );
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
if (needUpdate()) {
|
||||
OnekeyUpate();
|
||||
return message('update to github version, reinstall.
|
||||
<script>
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=; path=/; \'+expires;
|
||||
</script>
|
||||
<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201);
|
||||
}
|
||||
return output('Jump
|
||||
<script>
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=; path=/; \'+expires;
|
||||
</script>
|
||||
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
|
||||
}
|
||||
if ($_GET['install1']) {
|
||||
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||
$SecretId = getConfig('SecretId');
|
||||
if ($SecretId=='') {
|
||||
$SecretId = $_POST['SecretId'];
|
||||
$tmp['SecretId'] = $SecretId;
|
||||
}
|
||||
$SecretKey = getConfig('SecretKey');
|
||||
if ($SecretKey=='') {
|
||||
$SecretKey = $_POST['SecretKey'];
|
||||
$tmp['SecretKey'] = $SecretKey;
|
||||
}
|
||||
$response = setConfigResponse(SetbaseConfig($tmp, $SecretId, $SecretKey));
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
} else {
|
||||
$html .= '
|
||||
<form action="?install2" method="post" onsubmit="return notnull(this);">
|
||||
<label>'.getconstStr('SetAdminPassword').':<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>
|
||||
<input type="submit" value="'.getconstStr('Submit').'">
|
||||
</form>
|
||||
<script>
|
||||
function notnull(t)
|
||||
{
|
||||
if (t.admin.value==\'\') {
|
||||
alert(\''.getconstStr('SetAdminPassword').'\');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
</script>';
|
||||
$title = getconstStr('SetAdminPassword');
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
}
|
||||
if ($_GET['install0']) {
|
||||
$html .= '
|
||||
<form action="?install1" method="post" onsubmit="return notnull(this);">
|
||||
language:<br>';
|
||||
foreach ($constStr['languages'] as $key1 => $value1) {
|
||||
$html .= '
|
||||
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
|
||||
}
|
||||
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
|
||||
<a href="https://console.bce.baidu.com/iam/#/iam/accesslist" target="_blank">'.getconstStr('Create').' Access Key & Secret Key</a><br>
|
||||
<label>Access Key:<input name="SecretId" type="text" placeholder="" size=""></label><br>
|
||||
<label>Secret Key:<input name="SecretKey" type="text" placeholder="" size=""></label><br>';
|
||||
$html .= '
|
||||
<input type="submit" value="'.getconstStr('Submit').'">
|
||||
</form>
|
||||
<script>
|
||||
var nowtime= new Date();
|
||||
var timezone = 0-nowtime.getTimezoneOffset()/60;
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie="timezone="+timezone+"; path=/; "+expires;
|
||||
function changelanguage(str)
|
||||
{
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=\'+str+\'; path=/; \'+expires;
|
||||
location.href = location.href;
|
||||
}
|
||||
function notnull(t)
|
||||
{';
|
||||
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
|
||||
if (t.SecretId.value==\'\') {
|
||||
alert(\'input Access Key\');
|
||||
return false;
|
||||
}
|
||||
if (t.SecretKey.value==\'\') {
|
||||
alert(\'input Secret Key\');
|
||||
return false;
|
||||
}';
|
||||
$html .= '
|
||||
return true;
|
||||
}
|
||||
</script>';
|
||||
$title = getconstStr('SelectLanguage');
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
function CFCAPIv1($Brn, $AccessKey, $SecretKey, $Method, $End, $data = '')
|
||||
{
|
||||
// brn:bce:cfc:bj:c094b1ca1XXXXXXXXb8dea6ab482:function:fdsa:$LATEST
|
||||
$BRN = explode(':', $Brn);
|
||||
if ( !($BRN[0]=='brn' && $BRN[1]=='bce' && $BRN[2]=='cfc') ) {
|
||||
$tmp['code'] = 'BRN Error';
|
||||
$tmp['message'] = 'The BRN expect start with "brn:bce:cfc:", given: ' . $Brn . ' .';
|
||||
return json_encode($tmp);
|
||||
}
|
||||
$Region = $BRN[3];
|
||||
//$project_id = $BRN[4];
|
||||
$FunctionName = $BRN[6];
|
||||
$host = 'cfc.' . $Region . '.baidubce.com';
|
||||
date_default_timezone_set('UTC'); // unset last timezone setting
|
||||
$timestamp = date('Y-m-d\TH:i:s\Z');
|
||||
//date_default_timezone_set(get_timezone($_SERVER['timezone']));
|
||||
$authStringPrefix = 'bce-auth-v1/' . $AccessKey . '/' . $timestamp . '/1800' ;
|
||||
$path = '/v1/functions/' . $FunctionName . '/' . $End;
|
||||
$CanonicalURI = spurlencode($path, '/');
|
||||
$CanonicalQueryString = '';
|
||||
$CanonicalHeaders = 'host:' . $host;
|
||||
$CanonicalRequest = $Method . "\n" . $CanonicalURI . "\n" . $CanonicalQueryString . "\n" . $CanonicalHeaders;
|
||||
$SigningKey = hash_hmac('sha256', $authStringPrefix, $SecretKey);
|
||||
$Signature = hash_hmac('sha256', $CanonicalRequest, $SigningKey);
|
||||
$authorization = $authStringPrefix . '/host/' . $Signature;
|
||||
|
||||
$p = 0;
|
||||
while ($response['stat']==0 && $p<3) {
|
||||
$response = curl(
|
||||
$Method,
|
||||
'https://' . $host . $path,
|
||||
$data,
|
||||
[
|
||||
'Authorization' => $authorization,
|
||||
'Content-type' => 'application/json'
|
||||
]
|
||||
);
|
||||
$p++;
|
||||
}
|
||||
|
||||
if ($response['stat']==0) {
|
||||
$tmp['code'] = 'Network Error';
|
||||
$tmp['message'] = 'Can not connect ' . $host;
|
||||
return json_encode($tmp);
|
||||
}
|
||||
if ($response['stat']!=200) {
|
||||
$tmp = json_decode($response['body'], true);
|
||||
$tmp['message'] .= '<br>' . $response['stat'] . '<br>' . $timestamp . PHP_EOL;
|
||||
return json_encode($tmp);
|
||||
}
|
||||
return $response['body'];
|
||||
}
|
||||
|
||||
function getfunctioninfo($SecretId, $SecretKey)
|
||||
{
|
||||
return CFCAPIv1($_SERVER['functionBrn'], $SecretId, $SecretKey, 'GET', 'configuration');
|
||||
}
|
||||
|
||||
function updateEnvironment($Envs, $SecretId, $SecretKey)
|
||||
{
|
||||
$FunctionConfig = json_decode(getfunctioninfo($SecretId, $SecretKey), true);
|
||||
$tmp_env = $FunctionConfig['Environment']['Variables'];
|
||||
foreach ($Envs as $key1 => $value1) {
|
||||
$tmp_env[$key1] = $value1;
|
||||
}
|
||||
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||
ksort($tmp_env);
|
||||
|
||||
$tmp['Environment']['Variables'] = $tmp_env;
|
||||
$data = json_encode($tmp);
|
||||
|
||||
return CFCAPIv1($_SERVER['functionBrn'], $SecretId, $SecretKey, 'PUT', 'configuration', $data);
|
||||
}
|
||||
|
||||
function SetbaseConfig($Envs, $SecretId, $SecretKey)
|
||||
{
|
||||
$FunctionConfig = json_decode(getfunctioninfo($SecretId, $SecretKey), true);
|
||||
$tmp_env = $FunctionConfig['Environment']['Variables'];
|
||||
foreach ($Envs as $key1 => $value1) {
|
||||
$tmp_env[$key1] = $value1;
|
||||
}
|
||||
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||
ksort($tmp_env);
|
||||
|
||||
$tmp['Timeout'] = 30;
|
||||
$tmp['Description'] = 'Onedrive index and manager in Baidu CFC.';
|
||||
$tmp['Environment']['Variables'] = $tmp_env;
|
||||
$data = json_encode($tmp);
|
||||
|
||||
return CFCAPIv1($_SERVER['functionBrn'], $SecretId, $SecretKey, 'PUT', 'configuration', $data);
|
||||
}
|
||||
|
||||
function updateProgram($SecretId, $SecretKey, $source)
|
||||
{
|
||||
$tmp['ZipFile'] = base64_encode( file_get_contents($source) );
|
||||
$data = json_encode($tmp);
|
||||
return CFCAPIv1($_SERVER['functionBrn'], $SecretId, $SecretKey, 'PUT', 'code', $data);
|
||||
}
|
||||
|
||||
function api_error($response)
|
||||
{
|
||||
//return isset($response['code']);
|
||||
return !(isset($response['FunctionBrn']) && $response['FunctionBrn'] == $_SERVER['functionBrn']);
|
||||
}
|
||||
|
||||
function api_error_msg($response)
|
||||
{
|
||||
if (isset($response['code'])) $html = $response['code'] . '<br>
|
||||
' . $response['message'];
|
||||
else $html = var_dump($response);
|
||||
return $html . '<br><br>
|
||||
BRN: ' . $_SERVER['functionBrn'] . '<br>
|
||||
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||
}
|
||||
|
||||
function setConfigResponse($response)
|
||||
{
|
||||
//return $response;
|
||||
return json_decode( $response, true );
|
||||
}
|
||||
|
||||
function OnekeyUpate($auth = 'BingoKingo', $project = 'Tfo', $branch = 'master')
|
||||
{
|
||||
$source = '/tmp/code.zip';
|
||||
$outPath = '/tmp/';
|
||||
|
||||
// 从github下载对应tar.gz,并解压
|
||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||
$tarfile = '/tmp/github.tar.gz';
|
||||
file_put_contents($tarfile, file_get_contents($url));
|
||||
$phar = new PharData($tarfile);
|
||||
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
||||
|
||||
// 获取包中目录名
|
||||
$tmp = scandir('phar://'.$tarfile);
|
||||
$name = $auth.'-'.$project;
|
||||
foreach ($tmp as $f) {
|
||||
if ( substr($f, 0, strlen($name)) == $name) {
|
||||
$outPath .= $f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 放入配置文件
|
||||
//file_put_contents($outPath . '/config.php', file_get_contents(__DIR__.'/../config.php'));
|
||||
|
||||
// 将目录中文件打包成zip
|
||||
//$zip=new ZipArchive();
|
||||
$zip=new PharData($source);
|
||||
//if($zip->open($source, ZipArchive::CREATE)){
|
||||
addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
|
||||
// $zip->close(); //关闭处理的zip文件
|
||||
//}
|
||||
|
||||
return updateProgram(getConfig('SecretId'), getConfig('SecretKey'), $source);
|
||||
}
|
||||
|
||||
function addFileToZip($zip, $rootpath, $path = '')
|
||||
{
|
||||
if (substr($rootpath,-1)=='/') $rootpath = substr($rootpath, 0, -1);
|
||||
if (substr($path,0,1)=='/') $path = substr($path, 1);
|
||||
$handler=opendir(path_format($rootpath.'/'.$path)); //打开当前文件夹由$path指定。
|
||||
while($filename=readdir($handler)){
|
||||
if($filename != "." && $filename != ".."){//文件夹文件名字为'.'和‘..’,不要对他们进行操作
|
||||
$nowname = path_format($rootpath.'/'.$path."/".$filename);
|
||||
if(is_dir($nowname)){// 如果读取的某个对象是文件夹,则递归
|
||||
$zip->addEmptyDir($path."/".$filename);
|
||||
addFileToZip($zip, $rootpath, $path."/".$filename);
|
||||
}else{ //将文件加入zip对象
|
||||
$newname = $path."/".$filename;
|
||||
if (substr($newname,0,1)=='/') $newname = substr($newname, 1);
|
||||
$zip->addFile($nowname, $newname);
|
||||
//$zip->renameName($nowname, $newname);
|
||||
}
|
||||
}
|
||||
}
|
||||
@closedir($path);
|
||||
}
|
|
@ -0,0 +1,297 @@
|
|||
<?php
|
||||
|
||||
function getpath()
|
||||
{
|
||||
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]);
|
||||
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
$_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/');
|
||||
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
||||
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
|
||||
else $path = $_SERVER['REQUEST_URI'];
|
||||
$path = path_format( substr($path, strlen($_SERVER['base_path'])) );
|
||||
return substr($path, 1);
|
||||
//return spurlencode($path, '/');
|
||||
}
|
||||
|
||||
function getGET()
|
||||
{
|
||||
//error_log('POST:' . json_encode($_POST));
|
||||
if (!$_POST) {
|
||||
if (!!$HTTP_RAW_POST_DATA) {
|
||||
$tmpdata = $HTTP_RAW_POST_DATA;
|
||||
//error_log('RAW:' . $tmpdata);
|
||||
} else {
|
||||
$tmpdata = file_get_contents('php://input');
|
||||
//error_log('PHPINPUT:' . $tmpdata);
|
||||
}
|
||||
if (!!$tmpdata) {
|
||||
$postbody = explode("&", $tmpdata);
|
||||
foreach ($postbody as $postvalues) {
|
||||
$pos = strpos($postvalues,"=");
|
||||
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
|
||||
}
|
||||
//error_log('POSTformPHPINPUT:' . json_encode($_POST));
|
||||
}
|
||||
}
|
||||
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
||||
if ($p>0) {
|
||||
$getstr = substr($_SERVER['REQUEST_URI'], $p+1);
|
||||
$getstrarr = explode("&",$getstr);
|
||||
foreach ($getstrarr as $getvalues) {
|
||||
if ($getvalues != '') {
|
||||
$pos = strpos($getvalues, "=");
|
||||
//echo $pos;
|
||||
if ($pos > 0) {
|
||||
$getarry[urldecode(substr($getvalues, 0, $pos))] = urldecode(substr($getvalues, $pos + 1));
|
||||
} else {
|
||||
$getarry[urldecode($getvalues)] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($getarry)) {
|
||||
return $getarry;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function getConfig($str, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
if (in_array($str, $InnerEnv)) {
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
$env = json_decode(getenv($disktag), true);
|
||||
if (isset($env[$str])) {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode($env[$str]);
|
||||
else return $env[$str];
|
||||
}
|
||||
} else {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode(getenv($str));
|
||||
else return getenv($str);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function setConfig($arr, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
$disktags = explode("|",getConfig('disktag'));
|
||||
$diskconfig = json_decode(getenv($disktag), true);
|
||||
$tmp = [];
|
||||
$indisk = 0;
|
||||
$operatedisk = 0;
|
||||
foreach ($arr as $k => $v) {
|
||||
if (in_array($k, $InnerEnv)) {
|
||||
if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
|
||||
else $diskconfig[$k] = $v;
|
||||
$indisk = 1;
|
||||
} elseif ($k=='disktag_add') {
|
||||
array_push($disktags, $v);
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_del') {
|
||||
$disktags = array_diff($disktags, [ $v ]);
|
||||
$tmp[$v] = '';
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
|
||||
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
|
||||
} else {
|
||||
if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
|
||||
else $tmp[$k] = $v;
|
||||
}
|
||||
}
|
||||
if ($indisk) {
|
||||
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
|
||||
ksort($diskconfig);
|
||||
$tmp[$disktag] = json_encode($diskconfig);
|
||||
}
|
||||
if ($operatedisk) {
|
||||
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
|
||||
$tmp['disktag'] = str_replace($arr['disktag_rename'], $arr['disktag_newname'], getConfig('disktag'));
|
||||
$tmp[$arr['disktag_newname']] = getConfig($arr['disktag_rename']);
|
||||
$tmp[$arr['disktag_rename']] = null;
|
||||
} else {
|
||||
$disktags = array_unique($disktags);
|
||||
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
|
||||
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
|
||||
else $tmp['disktag'] = null;
|
||||
}
|
||||
}
|
||||
foreach ($tmp as $key => $val) if ($val=='') $tmp[$key]=null;
|
||||
// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
|
||||
//';
|
||||
return setHerokuConfig($tmp, getConfig('function_name'), getConfig('APIKey'));
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
global $constStr;
|
||||
if ($_GET['install1']) {
|
||||
if ($_POST['admin']!='') {
|
||||
$tmp['admin'] = $_POST['admin'];
|
||||
//$tmp['language'] = $_POST['language'];
|
||||
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||
$APIKey = getConfig('APIKey');
|
||||
if ($APIKey=='') {
|
||||
$APIKey = $_POST['APIKey'];
|
||||
$tmp['APIKey'] = $APIKey;
|
||||
}
|
||||
$function_name = getConfig('function_name');
|
||||
if ($function_name=='') {
|
||||
$tmp1 = substr($_SERVER['HTTP_HOST'], 0, strrpos($_SERVER['HTTP_HOST'], '.'));
|
||||
$maindomain = substr($tmp1, strrpos($tmp1, '.')+1);
|
||||
if ($maindomain=='herokuapp') $function_name = substr($tmp1, 0, strrpos($tmp1, '.'));
|
||||
else $function_name = 'visit from xxxx.herokuapp.com';
|
||||
$tmp['function_name'] = $function_name;
|
||||
}
|
||||
$response = json_decode(setHerokuConfig($tmp, $function_name, $APIKey)['body'], true);
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
} else {
|
||||
return output('Jump
|
||||
<script>
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=; path=/; \'+expires;
|
||||
</script>
|
||||
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
|
||||
}
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
}
|
||||
if ($_GET['install0']) {
|
||||
$html .= '
|
||||
<form action="?install1" method="post" onsubmit="return notnull(this);">
|
||||
language:<br>';
|
||||
foreach ($constStr['languages'] as $key1 => $value1) {
|
||||
$html .= '
|
||||
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
|
||||
}
|
||||
if (getConfig('APIKey')=='') $html .= '
|
||||
<a href="https://dashboard.heroku.com/account" target="_blank">'.getconstStr('Create').' API Key</a><br>
|
||||
<label>API Key:<input name="APIKey" type="text" placeholder="" size=""></label><br>';
|
||||
$html .= '
|
||||
<label>Set admin password:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>';
|
||||
$html .= '
|
||||
<input type="submit" value="'.getconstStr('Submit').'">
|
||||
</form>
|
||||
<script>
|
||||
var nowtime= new Date();
|
||||
var timezone = 0-nowtime.getTimezoneOffset()/60;
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie="timezone="+timezone+"; path=/; "+expires;
|
||||
function changelanguage(str)
|
||||
{
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=\'+str+\'; path=/; \'+expires;
|
||||
location.href = location.href;
|
||||
}
|
||||
function notnull(t)
|
||||
{
|
||||
if (t.admin.value==\'\') {
|
||||
alert(\'input admin\');
|
||||
return false;
|
||||
}';
|
||||
if (getConfig('APIKey')=='') $html .= '
|
||||
if (t.APIKey.value==\'\') {
|
||||
alert(\'input API Key\');
|
||||
return false;
|
||||
}';
|
||||
$html .= '
|
||||
return true;
|
||||
}
|
||||
</script>';
|
||||
$title = getconstStr('SelectLanguage');
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
function HerokuAPI($method, $url, $data = '', $apikey)
|
||||
{
|
||||
if ($method=='PATCH'||$method=='POST') {
|
||||
$headers['Content-Type'] = 'application/json';
|
||||
}
|
||||
$headers['Authorization'] = 'Bearer ' . $apikey;
|
||||
$headers['Accept'] = 'application/vnd.heroku+json; version=3';
|
||||
//if (!isset($headers['Accept'])) $headers['Accept'] = '*/*';
|
||||
//if (!isset($headers['Referer'])) $headers['Referer'] = $url;
|
||||
$sendHeaders = array();
|
||||
foreach ($headers as $headerName => $headerVal) {
|
||||
$sendHeaders[] = $headerName . ': ' . $headerVal;
|
||||
}
|
||||
error_log($method . $url . $data . $apikey);
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST,$method);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $sendHeaders);
|
||||
$response['body'] = curl_exec($ch);
|
||||
$response['stat'] = curl_getinfo($ch,CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
error_log($response['stat'].'
|
||||
'.$response['body'].'
|
||||
');
|
||||
return $response;
|
||||
}
|
||||
|
||||
function getHerokuConfig($function_name, $apikey)
|
||||
{
|
||||
return HerokuAPI('GET', 'https://api.heroku.com/apps/' . $function_name . '/config-vars', '', $apikey);
|
||||
}
|
||||
|
||||
function setHerokuConfig($env, $function_name, $apikey)
|
||||
{
|
||||
$data = json_encode($env);
|
||||
return HerokuAPI('PATCH', 'https://api.heroku.com/apps/' . $function_name . '/config-vars', $data, $apikey);
|
||||
}
|
||||
|
||||
function updateHerokuapp($function_name, $apikey, $source)
|
||||
{
|
||||
$tmp['source_blob']['url'] = $source;
|
||||
$data = json_encode($tmp);
|
||||
return HerokuAPI('POST', 'https://api.heroku.com/apps/' . $function_name . '/builds', $data, $apikey);
|
||||
}
|
||||
|
||||
function api_error($response)
|
||||
{
|
||||
return isset($response['id'])&&isset($response['message']);
|
||||
}
|
||||
|
||||
function api_error_msg($response)
|
||||
{
|
||||
return $response['id'] . '<br>
|
||||
' . $response['message'] . '<br><br>
|
||||
function_name:' . $_SERVER['function_name'] . '<br>
|
||||
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||
}
|
||||
|
||||
function OnekeyUpate($auth = 'BingoKingo', $project = 'Tfo', $branch = 'master')
|
||||
{
|
||||
//'original:https://github.com/qkqpttgf/OneManager-php/tarball/master/';
|
||||
//'mine:https://https://github.com/BingoKingo/Tfo/tarball/master/';
|
||||
$source = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||
return updateHerokuapp(getConfig('function_name'), getConfig('APIKey'), $source);
|
||||
}
|
||||
|
||||
function setConfigResponse($response)
|
||||
{
|
||||
return json_decode( $response['body'], true );
|
||||
}
|
|
@ -0,0 +1,472 @@
|
|||
<?php
|
||||
global $contextUserData;
|
||||
|
||||
function printInput($event, $context)
|
||||
{
|
||||
$tmp['eventID'] = $context->geteventID();
|
||||
$tmp['RemainingTimeInMilliSeconds'] = $context->getRemainingTimeInMilliSeconds();
|
||||
$tmp['AccessKey'] = $context->getAccessKey();
|
||||
$tmp['SecretKey'] = $context->getSecretKey();
|
||||
$tmp['UserData']['HW_urn'] = $context->getUserData('HW_urn');
|
||||
$tmp['FunctionName'] = $context->getFunctionName();
|
||||
$tmp['RunningTimeInSeconds'] = $context->getRunningTimeInSeconds();
|
||||
$tmp['Version'] = $context->getVersion();
|
||||
$tmp['MemorySize'] = $context->getMemorySize();
|
||||
$tmp['CPUNumber'] = $context->getCPUNumber();
|
||||
$tmp['ProjectID'] = $context->getProjectID();
|
||||
$tmp['Package'] = $context->Package();
|
||||
$tmp['Token'] = $context->getToken();
|
||||
$tmp['Logger'] = $context->getLogger();
|
||||
|
||||
if (strlen(json_encode($event['body']))>500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
|
||||
echo urldecode(json_encode($event, JSON_PRETTY_PRINT)) . '
|
||||
|
||||
' . urldecode(json_encode($tmp, JSON_PRETTY_PRINT)) . '
|
||||
|
||||
';
|
||||
}
|
||||
|
||||
function GetGlobalVariable($event)
|
||||
{
|
||||
$_GET = $event['queryStringParameters'];
|
||||
$postbody = explode("&",$event['body']);
|
||||
foreach ($postbody as $postvalues) {
|
||||
$pos = strpos($postvalues,"=");
|
||||
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
|
||||
}
|
||||
$cookiebody = explode("; ",$event['headers']['cookie']);
|
||||
foreach ($cookiebody as $cookievalues) {
|
||||
$pos = strpos($cookievalues,"=");
|
||||
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
|
||||
}
|
||||
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
|
||||
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
|
||||
$_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter';
|
||||
}
|
||||
|
||||
function GetPathSetting($event, $context)
|
||||
{
|
||||
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['accept-language'],';')[0],',')[0]);
|
||||
$_SERVER['function_name'] = $context->getFunctionName();
|
||||
$_SERVER['ProjectID'] = $context->getProjectID();
|
||||
$host_name = $event['headers']['host'];
|
||||
$_SERVER['HTTP_HOST'] = $host_name;
|
||||
$path = path_format($event['pathParameters'][''].'/');
|
||||
$_SERVER['base_path'] = path_format($event['path'].'/');
|
||||
if ( $_SERVER['base_path'] == $path ) {
|
||||
$_SERVER['base_path'] = '/';
|
||||
} else {
|
||||
$_SERVER['base_path'] = substr($_SERVER['base_path'], 0, -strlen($path));
|
||||
if ($_SERVER['base_path']=='') $_SERVER['base_path'] = '/';
|
||||
}
|
||||
if (substr($path,-1)=='/') $path=substr($path,0,-1);
|
||||
$_SERVER['is_guestup_path'] = is_guestup_path($path);
|
||||
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
|
||||
$_SERVER['REMOTE_ADDR'] = $event['headers']['x-real-ip'];
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
|
||||
return $path;
|
||||
}
|
||||
|
||||
function getConfig($str, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
global $contextUserData;
|
||||
if (in_array($str, $InnerEnv)) {
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
$env = json_decode($contextUserData->getUserData($disktag), true);
|
||||
if (isset($env[$str])) {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode($env[$str]);
|
||||
else return $env[$str];
|
||||
}
|
||||
} else {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode($contextUserData->getUserData($str));
|
||||
else return $contextUserData->getUserData($str);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function setConfig($arr, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
global $contextUserData;
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
$disktags = explode("|",getConfig('disktag'));
|
||||
$diskconfig = json_decode($contextUserData->getUserData($disktag), true);
|
||||
$tmp = [];
|
||||
$indisk = 0;
|
||||
$operatedisk = 0;
|
||||
foreach ($arr as $k => $v) {
|
||||
if (in_array($k, $InnerEnv)) {
|
||||
if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
|
||||
else $diskconfig[$k] = $v;
|
||||
$indisk = 1;
|
||||
} elseif ($k=='disktag_add') {
|
||||
array_push($disktags, $v);
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_del') {
|
||||
$disktags = array_diff($disktags, [ $v ]);
|
||||
$tmp[$v] = '';
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
|
||||
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
|
||||
} else {
|
||||
if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
|
||||
else $tmp[$k] = $v;
|
||||
}
|
||||
}
|
||||
if ($indisk) {
|
||||
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
|
||||
ksort($diskconfig);
|
||||
$tmp[$disktag] = json_encode($diskconfig);
|
||||
}
|
||||
if ($operatedisk) {
|
||||
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
|
||||
$tmp['disktag'] = str_replace($arr['disktag_rename'], $arr['disktag_newname'], getConfig('disktag'));
|
||||
$tmp[$arr['disktag_newname']] = getConfig($arr['disktag_rename']);
|
||||
$tmp[$arr['disktag_rename']] = '';
|
||||
} else {
|
||||
$disktags = array_unique($disktags);
|
||||
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
|
||||
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
|
||||
else $tmp['disktag'] = '';
|
||||
}
|
||||
}
|
||||
// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
|
||||
//';
|
||||
$response = updateEnvironment($tmp, getConfig('HW_urn'), getConfig('HW_key'), getConfig('HW_secret'));
|
||||
return $response;
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
global $constStr;
|
||||
global $contextUserData;
|
||||
if ($_GET['install2']) {
|
||||
$tmp['admin'] = $_POST['admin'];
|
||||
$response = setConfigResponse( setConfig($tmp) );
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
if (needUpdate()) {
|
||||
OnekeyUpate();
|
||||
return message('update to github version, reinstall.
|
||||
<script>
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=; path=/; \'+expires;
|
||||
</script>
|
||||
<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201);
|
||||
}
|
||||
return output('Jump
|
||||
<script>
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=; path=/; \'+expires;
|
||||
</script>
|
||||
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
|
||||
}
|
||||
if ($_GET['install1']) {
|
||||
//if ($_POST['admin']!='') {
|
||||
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||
$tmp['HW_urn'] = getConfig('HW_urn');
|
||||
if ($tmp['HW_urn']=='') {
|
||||
$tmp['HW_urn'] = $_POST['HW_urn'];
|
||||
}
|
||||
$tmp['HW_key'] = getConfig('HW_key');
|
||||
if ($tmp['HW_key']=='') {
|
||||
$tmp['HW_key'] = $_POST['HW_key'];
|
||||
}
|
||||
$tmp['HW_secret'] = getConfig('HW_secret');
|
||||
if ($tmp['HW_secret']=='') {
|
||||
$tmp['HW_secret'] = $_POST['HW_secret'];
|
||||
}
|
||||
$tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
|
||||
//$response = json_decode(SetbaseConfig($tmp, $HW_urn, $HW_name, $HW_pwd), true)['Response'];
|
||||
$response = setConfigResponse( SetbaseConfig($tmp, $tmp['HW_urn'], $tmp['HW_key'], $tmp['HW_secret']) );
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
} else {
|
||||
if ($tmp['ONEMANAGER_CONFIG_SAVE'] == 'file') {
|
||||
$html = getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '<br><a href="' . $_SERVER['base_path'] . '">' . getconstStr('Home') . '</a>';
|
||||
$title = 'Reinstall';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '
|
||||
<form action="?install2" method="post" onsubmit="return notnull(this);">
|
||||
<label>'.getconstStr('SetAdminPassword').':<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>
|
||||
<input type="submit" value="'.getconstStr('Submit').'">
|
||||
</form>
|
||||
<script>
|
||||
function notnull(t)
|
||||
{
|
||||
if (t.admin.value==\'\') {
|
||||
alert(\''.getconstStr('SetAdminPassword').'\');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
</script>';
|
||||
$title = getconstStr('SetAdminPassword');
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
//}
|
||||
}
|
||||
if ($_GET['install0']) {
|
||||
$html .= '
|
||||
<form action="?install1" method="post" onsubmit="return notnull(this);">
|
||||
language:<br>';
|
||||
foreach ($constStr['languages'] as $key1 => $value1) {
|
||||
$html .= '
|
||||
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
|
||||
}
|
||||
if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= '
|
||||
在函数代码操作页上方找到URN,鼠标放上去后显示URN,复制填入:<br>
|
||||
<label>URN:<input name="HW_urn" type="text" placeholder="" size=""></label><br>
|
||||
<a href="https://console.huaweicloud.com/iam/#/mine/accessKey" target="_blank">点击链接</a>,新增访问密钥,
|
||||
在下载的credentials.csv文件中找到对应信息,填入:<br>
|
||||
<label>Access Key Id:<input name="HW_key" type="text" placeholder="" size=""></label><br>
|
||||
<label>Secret Access Key:<input name="HW_secret" type="text" placeholder="" size=""></label><br>';
|
||||
$html .= '
|
||||
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'':'checked') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '</label><br>
|
||||
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
|
||||
$html .= '
|
||||
<input type="submit" value="'.getconstStr('Submit').'">
|
||||
</form>
|
||||
<script>
|
||||
var nowtime= new Date();
|
||||
var timezone = 0-nowtime.getTimezoneOffset()/60;
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie="timezone="+timezone+"; path=/; "+expires;
|
||||
function changelanguage(str)
|
||||
{
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=\'+str+\'; path=/; \'+expires;
|
||||
location.href = location.href;
|
||||
}
|
||||
function notnull(t)
|
||||
{';
|
||||
if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= '
|
||||
if (t.HW_urn.value==\'\') {
|
||||
alert(\'input URN\');
|
||||
return false;
|
||||
}
|
||||
if (t.HW_key.value==\'\') {
|
||||
alert(\'input name\');
|
||||
return false;
|
||||
}
|
||||
if (t.HW_secret.value==\'\') {
|
||||
alert(\'input pwd\');
|
||||
return false;
|
||||
}';
|
||||
$html .= '
|
||||
return true;
|
||||
}
|
||||
</script>';
|
||||
$title = getconstStr('SelectLanguage');
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
function FGAPIV2($HW_urn, $HW_key, $HW_secret, $Method, $End, $data = '')
|
||||
{
|
||||
if ($HW_urn==''||$HW_key==''||$HW_secret=='') {
|
||||
$tmp['error_code'] = 'Config Error';
|
||||
$tmp['error_msg'] = 'HW urn or access key id or secret is empty.';
|
||||
return json_encode($tmp);
|
||||
}
|
||||
|
||||
$URN = explode(':', $HW_urn);
|
||||
$Region = $URN[2];
|
||||
$project_id = $URN[3];
|
||||
|
||||
$host = 'functiongraph.' . $Region . '.myhuaweicloud.com';
|
||||
$path = '/v2/' . $project_id . '/fgs/functions/' . $HW_urn . '/' . $End;
|
||||
$url = 'https://' . $host . $path;
|
||||
$CanonicalURI = spurlencode($path, '/') . '/';
|
||||
$CanonicalQueryString = '';
|
||||
|
||||
date_default_timezone_set('UTC'); // unset last timezone setting
|
||||
$timestamp = date('Ymd\THis\Z');
|
||||
$header['X-Sdk-Date'] = $timestamp;
|
||||
$header['Host'] = $host;
|
||||
$header['Content-Type'] = 'application/json;charset=utf8';
|
||||
ksort($header);
|
||||
$CanonicalHeaders = '';
|
||||
$SignedHeaders = '';
|
||||
foreach ($header as $key => $value) {
|
||||
$CanonicalHeaders .= strtolower($key) . ':' . $value . "\n";
|
||||
$SignedHeaders .= strtolower($key) . ';';
|
||||
}
|
||||
$SignedHeaders = substr($SignedHeaders, 0, -1);
|
||||
$Hashedbody = hash("sha256", $data);
|
||||
$CanonicalRequest = $Method . "\n" . $CanonicalURI . "\n" . $CanonicalQueryString . "\n" . $CanonicalHeaders . "\n" . $SignedHeaders . "\n" . $Hashedbody;
|
||||
$HashedCanonicalRequest = hash("sha256", $CanonicalRequest);
|
||||
$Algorithm = 'SDK-HMAC-SHA256';
|
||||
$StringToSign = $Algorithm . "\n" . $timestamp . "\n" . $HashedCanonicalRequest;
|
||||
$signature = hash_hmac("sha256", $StringToSign, $HW_secret);
|
||||
$Authorization = "$Algorithm Access=$HW_key, SignedHeaders=$SignedHeaders, Signature=$signature";
|
||||
$header['Authorization'] = $Authorization;
|
||||
|
||||
//return curl($Method, $url, $data, $header)['body']; // . $CanonicalRequest;
|
||||
$p = 0;
|
||||
while ($response['stat']==0 && $p<3) {
|
||||
$response = curl($Method, $url, $data, $header);
|
||||
$p++;
|
||||
}
|
||||
|
||||
if ($response['stat']==0) {
|
||||
$tmp['error_code'] = 'Network Error';
|
||||
$tmp['error_msg'] = 'Can not connect ' . $host;
|
||||
return json_encode($tmp);
|
||||
}
|
||||
if ($response['stat']!=200) {
|
||||
$tmp = json_decode($response['body'], true);
|
||||
$tmp['error_code'] .= '.';
|
||||
$tmp['error_msg'] .= '<br>' . $response['stat'] . '<br>' . $CanonicalRequest . '<br>' . json_encode($header) . PHP_EOL;
|
||||
return json_encode($tmp);
|
||||
}
|
||||
return $response['body'];
|
||||
}
|
||||
|
||||
function getfunctioninfo($HW_urn, $HW_key, $HW_secret)
|
||||
{
|
||||
return FGAPIV2($HW_urn, $HW_key, $HW_secret, 'GET', 'config');
|
||||
}
|
||||
|
||||
function updateEnvironment($Envs, $HW_urn, $HW_key, $HW_secret)
|
||||
{
|
||||
//echo json_encode($Envs,JSON_PRETTY_PRINT);
|
||||
global $contextUserData;
|
||||
$tmp_env = json_decode(json_decode(getfunctioninfo($HW_urn, $HW_key, $HW_secret),true)['user_data'],true);
|
||||
foreach ($Envs as $key1 => $value1) {
|
||||
$tmp_env[$key1] = $value1;
|
||||
}
|
||||
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||
ksort($tmp_env);
|
||||
|
||||
$tmpdata['handler'] = 'index.handler';
|
||||
$tmpdata['memory_size'] = $contextUserData->getMemorySize()+1-1;
|
||||
$tmpdata['runtime'] = 'PHP7.3';
|
||||
$tmpdata['timeout'] = $contextUserData->getRunningTimeInSeconds()+1-1;
|
||||
$tmpdata['user_data'] = json_encode($tmp_env);
|
||||
|
||||
return FGAPIV2($HW_urn, $HW_key, $HW_secret, 'PUT', 'config', json_encode($tmpdata));
|
||||
}
|
||||
|
||||
function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret)
|
||||
{
|
||||
//echo json_encode($Envs,JSON_PRETTY_PRINT);
|
||||
if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $Envs = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
|
||||
$tmp_env = json_decode(json_decode(getfunctioninfo($HW_urn, $HW_key, $HW_secret),true)['user_data'],true);
|
||||
foreach ($Envs as $key1 => $value1) {
|
||||
$tmp_env[$key1] = $value1;
|
||||
}
|
||||
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||
ksort($tmp_env);
|
||||
|
||||
$tmpdata['handler'] = 'index.handler';
|
||||
$tmpdata['memory_size'] = 128;
|
||||
$tmpdata['runtime'] = 'PHP7.3';
|
||||
$tmpdata['timeout'] = 30;
|
||||
$tmpdata['description'] = 'Onedrive index and manager in Huawei FG.';
|
||||
$tmpdata['user_data'] = json_encode($tmp_env);
|
||||
|
||||
return FGAPIV2($HW_urn, $HW_key, $HW_secret, 'PUT', 'config', json_encode($tmpdata));
|
||||
}
|
||||
|
||||
function updateProgram($HW_urn, $HW_key, $HW_secret, $source)
|
||||
{
|
||||
$tmpdata['code_type'] = 'zip';
|
||||
$tmpdata['func_code']['file'] = base64_encode( file_get_contents($source) );
|
||||
|
||||
return FGAPIV2($HW_urn, $HW_key, $HW_secret, 'PUT', 'code', json_encode($tmpdata));
|
||||
}
|
||||
|
||||
function api_error($response)
|
||||
{
|
||||
return isset($response['error_msg']);
|
||||
}
|
||||
|
||||
function api_error_msg($response)
|
||||
{
|
||||
return $response['error_code'] . '<br>
|
||||
' . $response['error_msg'] . '<br>
|
||||
request_id: ' . $response['request_id'] . '<br><br>
|
||||
function_name: ' . $_SERVER['function_name'] . '<br>
|
||||
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||
}
|
||||
|
||||
function setConfigResponse($response)
|
||||
{
|
||||
return json_decode( $response, true );
|
||||
}
|
||||
|
||||
function OnekeyUpate($auth = 'BingoKingo', $project = 'Tfo', $branch = 'master')
|
||||
{
|
||||
$source = '/tmp/code.zip';
|
||||
$outPath = '/tmp/';
|
||||
|
||||
// 从github下载对应tar.gz,并解压
|
||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||
$tarfile = '/tmp/github.tar.gz';
|
||||
file_put_contents($tarfile, file_get_contents($url));
|
||||
$phar = new PharData($tarfile);
|
||||
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
||||
|
||||
// 获取解压出的目录名
|
||||
$tmp = scandir($outPath);
|
||||
$name = $auth.'-'.$project;
|
||||
foreach ($tmp as $f) {
|
||||
if ( substr($f, 0, strlen($name)) == $name) {
|
||||
$outPath .= $f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 将目录中文件打包成zip
|
||||
//$zip=new ZipArchive();
|
||||
$zip=new PharData($source);
|
||||
//if($zip->open($source, ZipArchive::CREATE)){
|
||||
addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
|
||||
// $zip->close(); //关闭处理的zip文件
|
||||
//}
|
||||
|
||||
return updateProgram(getConfig('HW_urn'), getConfig('HW_key'), getConfig('HW_secret'), $source);
|
||||
}
|
||||
|
||||
function addFileToZip($zip, $rootpath, $path = '')
|
||||
{
|
||||
if (substr($rootpath,-1)=='/') $rootpath = substr($rootpath, 0, -1);
|
||||
if (substr($path,0,1)=='/') $path = substr($path, 1);
|
||||
$handler=opendir(path_format($rootpath.'/'.$path)); //打开当前文件夹由$path指定。
|
||||
while($filename=readdir($handler)){
|
||||
if($filename != "." && $filename != ".."){//文件夹文件名字为'.'和‘..’,不要对他们进行操作
|
||||
$nowname = path_format($rootpath.'/'.$path."/".$filename);
|
||||
if(is_dir($nowname)){// 如果读取的某个对象是文件夹,则递归
|
||||
$zip->addEmptyDir($path."/".$filename);
|
||||
addFileToZip($zip, $rootpath, $path."/".$filename);
|
||||
}else{ //将文件加入zip对象
|
||||
$newname = $path."/".$filename;
|
||||
if (substr($newname,0,1)=='/') $newname = substr($newname, 1);
|
||||
$zip->addFile($nowname, $newname);
|
||||
//$zip->renameName($nowname, $newname);
|
||||
}
|
||||
}
|
||||
}
|
||||
@closedir($path);
|
||||
}
|
|
@ -0,0 +1,848 @@
|
|||
<?php
|
||||
global $contextUserData;
|
||||
|
||||
function printInput($event, $context)
|
||||
{
|
||||
$tmp['eventID'] = $context->geteventID();
|
||||
$tmp['RemainingTimeInMilliSeconds'] = $context->getRemainingTimeInMilliSeconds();
|
||||
$tmp['AccessKey'] = $context->getAccessKey();
|
||||
$tmp['SecretKey'] = $context->getSecretKey();
|
||||
$tmp['UserData']['HW_urn'] = $context->getUserData('HW_urn');
|
||||
$tmp['FunctionName'] = $context->getFunctionName();
|
||||
$tmp['RunningTimeInSeconds'] = $context->getRunningTimeInSeconds();
|
||||
$tmp['Version'] = $context->getVersion();
|
||||
$tmp['MemorySize'] = $context->getMemorySize();
|
||||
$tmp['CPUNumber'] = $context->getCPUNumber();
|
||||
$tmp['ProjectID'] = $context->getProjectID();
|
||||
$tmp['Package'] = $context->Package();
|
||||
$tmp['Token'] = $context->getToken();
|
||||
$tmp['Logger'] = $context->getLogger();
|
||||
|
||||
if (strlen(json_encode($event['body']))>500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
|
||||
echo urldecode(json_encode($event, JSON_PRETTY_PRINT)) . '
|
||||
|
||||
' . urldecode(json_encode($tmp, JSON_PRETTY_PRINT)) . '
|
||||
|
||||
';
|
||||
}
|
||||
|
||||
function GetGlobalVariable($event)
|
||||
{
|
||||
$_GET = $event['queryStringParameters'];
|
||||
$postbody = explode("&",$event['body']);
|
||||
foreach ($postbody as $postvalues) {
|
||||
$pos = strpos($postvalues,"=");
|
||||
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
|
||||
}
|
||||
$cookiebody = explode("; ",$event['headers']['cookie']);
|
||||
foreach ($cookiebody as $cookievalues) {
|
||||
$pos = strpos($cookievalues,"=");
|
||||
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
|
||||
}
|
||||
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
|
||||
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
|
||||
$_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter';
|
||||
}
|
||||
|
||||
function GetPathSetting($event, $context)
|
||||
{
|
||||
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['accept-language'],';')[0],',')[0]);
|
||||
$_SERVER['function_name'] = $context->getFunctionName();
|
||||
$_SERVER['ProjectID'] = $context->getProjectID();
|
||||
$host_name = $event['headers']['host'];
|
||||
$_SERVER['HTTP_HOST'] = $host_name;
|
||||
$path = path_format($event['pathParameters'][''].'/');
|
||||
$_SERVER['base_path'] = path_format($event['path'].'/');
|
||||
if ( $_SERVER['base_path'] == $path ) {
|
||||
$_SERVER['base_path'] = '/';
|
||||
} else {
|
||||
$_SERVER['base_path'] = substr($_SERVER['base_path'], 0, -strlen($path));
|
||||
if ($_SERVER['base_path']=='') $_SERVER['base_path'] = '/';
|
||||
}
|
||||
if (substr($path,-1)=='/') $path=substr($path,0,-1);
|
||||
$_SERVER['is_guestup_path'] = is_guestup_path($path);
|
||||
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
|
||||
$_SERVER['REMOTE_ADDR'] = $event['headers']['x-real-ip'];
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
|
||||
return $path;
|
||||
}
|
||||
|
||||
function getConfig($str, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
//include 'config.php';
|
||||
$s = file_get_contents(__DIR__ . '/../config.php');
|
||||
//$configs = substr($s, 18, -2);
|
||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||
if ($configs!='') {
|
||||
$envs = json_decode($configs, true);
|
||||
if (in_array($str, $InnerEnv)) {
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
if (isset($envs[$disktag][$str])) {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode($envs[$disktag][$str]);
|
||||
else return $envs[$disktag][$str];
|
||||
}
|
||||
} else {
|
||||
if (isset($envs[$str])) {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode($envs[$str]);
|
||||
else return $envs[$str];
|
||||
}
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function setConfig($arr, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
//include 'config.php';
|
||||
$s = file_get_contents(__DIR__ . '/../config.php');
|
||||
//$configs = substr($s, 18, -2);
|
||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||
if ($configs!='') $envs = json_decode($configs, true);
|
||||
$disktags = explode("|",getConfig('disktag'));
|
||||
$indisk = 0;
|
||||
$operatedisk = 0;
|
||||
foreach ($arr as $k => $v) {
|
||||
if (in_array($k, $InnerEnv)) {
|
||||
if (in_array($k, $Base64Env)) $envs[$disktag][$k] = base64y_encode($v);
|
||||
else $envs[$disktag][$k] = $v;
|
||||
$indisk = 1;
|
||||
} elseif ($k=='disktag_add') {
|
||||
array_push($disktags, $v);
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_del') {
|
||||
$disktags = array_diff($disktags, [ $v ]);
|
||||
$envs[$v] = '';
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
|
||||
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
|
||||
} else {
|
||||
if (in_array($k, $Base64Env)) $envs[$k] = base64y_encode($v);
|
||||
else $envs[$k] = $v;
|
||||
}
|
||||
}
|
||||
if ($indisk) {
|
||||
$diskconfig = $envs[$disktag];
|
||||
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
|
||||
ksort($diskconfig);
|
||||
$envs[$disktag] = $diskconfig;
|
||||
}
|
||||
if ($operatedisk) {
|
||||
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
|
||||
$envs['disktag'] = str_replace($arr['disktag_rename'], $arr['disktag_newname'], getConfig('disktag'));
|
||||
$envs[$arr['disktag_newname']] = $envs[$arr['disktag_rename']];
|
||||
$envs[$arr['disktag_rename']] = '';
|
||||
} else {
|
||||
$disktags = array_unique($disktags);
|
||||
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
|
||||
if ($disktag_s!='') $envs['disktag'] = substr($disktag_s, 0, -1);
|
||||
else $envs['disktag'] = '';
|
||||
}
|
||||
}
|
||||
$envs = array_filter($envs, 'array_value_isnot_null');
|
||||
ksort($envs);
|
||||
$response = updateEnvironment($envs, getConfig('HW_urn'), getConfig('HW_key'), getConfig('HW_secret'));
|
||||
return $response;
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
global $constStr;
|
||||
global $contextUserData;
|
||||
if ($_GET['install2']) {
|
||||
$tmp['admin'] = $_POST['admin'];
|
||||
$response = setConfigResponse( setConfig($tmp) );
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
if (needUpdate()) {
|
||||
OnekeyUpate();
|
||||
return message('update to github version, reinstall.
|
||||
<script>
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=; path=/; \'+expires;
|
||||
</script>
|
||||
<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201);
|
||||
}
|
||||
return output('Jump
|
||||
<script>
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=; path=/; \'+expires;
|
||||
</script>
|
||||
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
|
||||
}
|
||||
if ($_GET['install1']) {
|
||||
//if ($_POST['admin']!='') {
|
||||
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||
$tmp['HW_urn'] = getConfig('HW_urn');
|
||||
if ($tmp['HW_urn']=='') {
|
||||
$tmp['HW_urn'] = $_POST['HW_urn'];
|
||||
}
|
||||
$tmp['HW_key'] = getConfig('HW_key');
|
||||
if ($tmp['HW_key']=='') {
|
||||
$tmp['HW_key'] = $_POST['HW_key'];
|
||||
}
|
||||
$tmp['HW_secret'] = getConfig('HW_secret');
|
||||
if ($tmp['HW_secret']=='') {
|
||||
$tmp['HW_secret'] = $_POST['HW_secret'];
|
||||
}
|
||||
$tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
|
||||
//return message($html, $title, 201);
|
||||
$response = setConfigResponse( SetbaseConfig($tmp, $tmp['HW_urn'], $tmp['HW_key'], $tmp['HW_secret']) );
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
} else {
|
||||
if ($tmp['ONEMANAGER_CONFIG_SAVE'] != 'file') {
|
||||
$html = getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '<br><a href="' . $_SERVER['base_path'] . '">' . getconstStr('Home') . '</a>';
|
||||
$title = 'Reinstall';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '
|
||||
<form action="?install2" method="post" onsubmit="return notnull(this);">
|
||||
<label>'.getconstStr('SetAdminPassword').':<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>
|
||||
<input type="submit" value="'.getconstStr('Submit').'">
|
||||
</form>
|
||||
<script>
|
||||
function notnull(t)
|
||||
{
|
||||
if (t.admin.value==\'\') {
|
||||
alert(\''.getconstStr('SetAdminPassword').'\');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
</script>';
|
||||
$title = getconstStr('SetAdminPassword');
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
//}
|
||||
}
|
||||
if ($_GET['install0']) {
|
||||
$html .= '
|
||||
<form action="?install1" method="post" onsubmit="return notnull(this);">
|
||||
language:<br>';
|
||||
foreach ($constStr['languages'] as $key1 => $value1) {
|
||||
$html .= '
|
||||
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
|
||||
}
|
||||
if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= '
|
||||
在函数代码操作页上方找到URN,鼠标放上去后显示URN,复制填入:<br>
|
||||
<label>URN:<input name="HW_urn" type="text" placeholder="urn:fss:ap-XXXXXXXX:XXXXXXXXXXXXXXXXXXXXc01a1e9caXXX:function:default:XXXXX:latest" size=""></label><br>
|
||||
<a href="https://console.huaweicloud.com/iam/#/mine/accessKey" target="_blank">点击链接</a>,新增访问密钥,
|
||||
在下载的credentials.csv文件中找到对应信息,填入:<br>
|
||||
<label>Access Key Id:<input name="HW_key" type="text" placeholder="" size=""></label><br>
|
||||
<label>Secret Access Key:<input name="HW_secret" type="text" placeholder="" size=""></label><br>';
|
||||
$html .= '
|
||||
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'':'checked') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '</label><br>
|
||||
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
|
||||
$html .= '
|
||||
<input type="submit" value="'.getconstStr('Submit').'">
|
||||
</form>
|
||||
<script>
|
||||
var nowtime= new Date();
|
||||
var timezone = 0-nowtime.getTimezoneOffset()/60;
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie="timezone="+timezone+"; path=/; "+expires;
|
||||
function changelanguage(str)
|
||||
{
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=\'+str+\'; path=/; \'+expires;
|
||||
location.href = location.href;
|
||||
}
|
||||
function notnull(t)
|
||||
{';
|
||||
if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= '
|
||||
if (t.HW_urn.value==\'\') {
|
||||
alert(\'input URN\');
|
||||
return false;
|
||||
}
|
||||
if (t.HW_key.value==\'\') {
|
||||
alert(\'input name\');
|
||||
return false;
|
||||
}
|
||||
if (t.HW_secret.value==\'\') {
|
||||
alert(\'input pwd\');
|
||||
return false;
|
||||
}';
|
||||
$html .= '
|
||||
return true;
|
||||
}
|
||||
</script>';
|
||||
$title = getconstStr('SelectLanguage');
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
function getfunctioninfo($HW_urn, $HW_key, $HW_secret)
|
||||
{
|
||||
$URN = explode(':', $HW_urn);
|
||||
$Region = $URN[2];
|
||||
$project_id = $URN[3];
|
||||
$url = 'https://functiongraph.' . $Region . '.myhuaweicloud.com/v2/' . $project_id . '/fgs/functions/' . $HW_urn . '/config';
|
||||
$signer = new Signer();
|
||||
$signer->Key = $HW_key;
|
||||
$signer->Secret = $HW_secret;
|
||||
$req = new Request('GET', $url);
|
||||
$req->headers = array(
|
||||
'content-type' => 'application/json;charset=utf8',
|
||||
);
|
||||
$req->body = '';
|
||||
$curl = $signer->Sign($req);
|
||||
$response = curl_exec($curl);
|
||||
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
curl_close($curl);
|
||||
return $response;
|
||||
}
|
||||
|
||||
function getfunctioncode($HW_urn, $HW_key, $HW_secret)
|
||||
{
|
||||
$URN = explode(':', $HW_urn);
|
||||
$Region = $URN[2];
|
||||
$project_id = $URN[3];
|
||||
$url = 'https://functiongraph.' . $Region . '.myhuaweicloud.com/v2/' . $project_id . '/fgs/functions/' . $HW_urn . '/code';
|
||||
$signer = new Signer();
|
||||
$signer->Key = $HW_key;
|
||||
$signer->Secret = $HW_secret;
|
||||
$req = new Request('GET', $url);
|
||||
$req->headers = array(
|
||||
'content-type' => 'application/json;charset=utf8',
|
||||
);
|
||||
$req->body = '';
|
||||
$curl = $signer->Sign($req);
|
||||
$response = curl_exec($curl);
|
||||
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
curl_close($curl);
|
||||
//return $response;
|
||||
$url = json_decode($response, true)['func_code']['link'];
|
||||
// return $url;
|
||||
|
||||
|
||||
$bucket = splitfirst( splitfirst($url, '//')[1], '.')[0];
|
||||
$path = splitfirst( splitfirst($url, '//')[1], '/')[1];
|
||||
$date = gmdate('D, d M Y H:i:s') . ' GMT';
|
||||
//$date = 'Wed, 05 Aug 2020 06:34:50 GMT';
|
||||
$StringToSign = 'GET
|
||||
' . '
|
||||
' . '
|
||||
' . '
|
||||
' . 'x-obs-date:' . $date . '
|
||||
' . '/' . $bucket . '/' . $path;
|
||||
|
||||
$signature = base64_encode(hash_hmac('sha1', $StringToSign, $HW_secret, true));
|
||||
$response = curl('GET', $url, false, [ 'Authorization' => 'OBS ' . $HW_key . ':' . $signature, 'x-obs-date' => $date, 'Content-Type' => '' ]);
|
||||
//if ($response['stat']==200) return $response['body'];
|
||||
if ($response['stat']==0) return json_encode( [ 'error_code' => 'Network', 'error_msg' => 'Network error in getting code.' ] );
|
||||
else return $response['body'];
|
||||
}
|
||||
|
||||
function copyFolder($from, $to)
|
||||
{
|
||||
if (substr($from, -1)=='/') $from = substr($from, 0, -1);
|
||||
if (substr($to, -1)=='/') $to = substr($to, 0, -1);
|
||||
if (!file_exists($to)) mkdir($to, 0777);
|
||||
$handler=opendir($from);
|
||||
while($filename=readdir($handler)) {
|
||||
if($filename != '.' && $filename != '..'){
|
||||
$fromfile = $from.'/'.$filename;
|
||||
$tofile = $to.'/'.$filename;
|
||||
if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
|
||||
copyFolder($fromfile, $tofile);
|
||||
}else{
|
||||
copy($fromfile, $tofile);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handler);
|
||||
return 1;
|
||||
}
|
||||
|
||||
function updateEnvironment($Envs, $HW_urn, $HW_key, $HW_secret)
|
||||
{
|
||||
|
||||
//echo json_encode($Envs,JSON_PRETTY_PRINT);
|
||||
global $contextUserData;
|
||||
$source = '/tmp/code.zip';
|
||||
$outPath = '/tmp/code/';
|
||||
$oldcode = '/tmp/oldcode.zip';
|
||||
|
||||
// 获取当前代码,并解压
|
||||
$coderoot = __DIR__ . '/../';
|
||||
|
||||
copyFolder($coderoot, $outPath);
|
||||
|
||||
// 将配置写入
|
||||
$prestr = '<?php $configs = \'' . PHP_EOL;
|
||||
$aftstr = PHP_EOL . '\';';
|
||||
file_put_contents($outPath . 'config.php', $prestr . json_encode($Envs, JSON_PRETTY_PRINT) . $aftstr);
|
||||
|
||||
// 将目录中文件打包成zip
|
||||
//$zip=new ZipArchive();
|
||||
$zip=new PharData($source);
|
||||
//if($zip->open($source, ZipArchive::CREATE)){
|
||||
addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
|
||||
// $zip->close(); //关闭处理的zip文件
|
||||
//}
|
||||
|
||||
return updateProgram($HW_urn, $HW_key, $HW_secret, $source);
|
||||
}
|
||||
|
||||
function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret)
|
||||
{
|
||||
//echo json_encode($Envs,JSON_PRETTY_PRINT);
|
||||
if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $envs = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
|
||||
else {
|
||||
$Envs['ONEMANAGER_CONFIG_SAVE'] == '';
|
||||
$envs = $Envs;
|
||||
$tmp_env = json_decode(json_decode(getfunctioninfo($HW_urn, $HW_key, $HW_secret),true)['user_data'],true);
|
||||
foreach ($envs as $key1 => $value1) {
|
||||
$tmp_env[$key1] = $value1;
|
||||
}
|
||||
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||
ksort($tmp_env);
|
||||
$envs = $tmp_env;
|
||||
}
|
||||
|
||||
// https://functiongraph.cn-north-4.myhuaweicloud.com/v2/{project_id}/fgs/functions/{function_urn}/config
|
||||
$URN = explode(':', $HW_urn);
|
||||
$Region = $URN[2];
|
||||
$project_id = $URN[3];
|
||||
$url = 'https://functiongraph.' . $Region . '.myhuaweicloud.com/v2/' . $project_id . '/fgs/functions/' . $HW_urn . '/config';
|
||||
$signer = new Signer();
|
||||
$signer->Key = $HW_key;
|
||||
$signer->Secret = $HW_secret;
|
||||
$req = new Request('PUT', $url);
|
||||
$req->headers = array(
|
||||
'content-type' => 'application/json;charset=utf8',
|
||||
);
|
||||
$tmpdata['handler'] = 'index.handler';
|
||||
$tmpdata['memory_size'] = 128;
|
||||
$tmpdata['runtime'] = 'PHP7.3';
|
||||
$tmpdata['timeout'] = 30;
|
||||
$tmpdata['description'] = 'Onedrive index and manager in Huawei FG.';
|
||||
$tmpdata['user_data'] = json_encode($envs);
|
||||
$req->body = json_encode($tmpdata);
|
||||
$curl = $signer->Sign($req);
|
||||
$response = curl_exec($curl);
|
||||
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
curl_close($curl);
|
||||
//return $response;
|
||||
if (api_error(setConfigResponse($response))) {
|
||||
return $response;
|
||||
}
|
||||
$s = file_get_contents(__DIR__ . '/../config.php');
|
||||
//$configs = substr($s, 18, -2);
|
||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||
if ($configs!='') $tmp_env = json_decode($configs, true);
|
||||
foreach ($Envs as $k => $v) {
|
||||
$tmp_env[$k] = $v;
|
||||
}
|
||||
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null');
|
||||
ksort($tmp_env);
|
||||
$response = updateEnvironment($tmp_env, $HW_urn, $HW_key, $HW_secret);
|
||||
return $response;
|
||||
}
|
||||
|
||||
function updateProgram($HW_urn, $HW_key, $HW_secret, $source)
|
||||
{
|
||||
$URN = explode(':', $HW_urn);
|
||||
$Region = $URN[2];
|
||||
$project_id = $URN[3];
|
||||
$url = 'https://functiongraph.' . $Region . '.myhuaweicloud.com/v2/' . $project_id . '/fgs/functions/' . $HW_urn . '/code';
|
||||
$signer = new Signer();
|
||||
$signer->Key = $HW_key;
|
||||
$signer->Secret = $HW_secret;
|
||||
$req = new Request('PUT', $url);
|
||||
$req->headers = array(
|
||||
'content-type' => 'application/json;charset=utf8',
|
||||
);
|
||||
$tmpdata['code_type'] = 'zip';
|
||||
$tmpdata['func_code']['file'] = base64_encode( file_get_contents($source) );
|
||||
$req->body = json_encode($tmpdata);
|
||||
$curl = $signer->Sign($req);
|
||||
$response = curl_exec($curl);
|
||||
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
curl_close($curl);
|
||||
return $response;
|
||||
}
|
||||
|
||||
function api_error($response)
|
||||
{
|
||||
return isset($response['error_code']);
|
||||
}
|
||||
|
||||
function api_error_msg($response)
|
||||
{
|
||||
return $response['error_code'] . '<br>
|
||||
' . $response['error_msg'] . '<br>
|
||||
request_id: ' . $response['request_id'] . '<br><br>
|
||||
function_name: ' . $_SERVER['function_name'] . '<br>
|
||||
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||
}
|
||||
|
||||
function setConfigResponse($response)
|
||||
{
|
||||
return json_decode( $response, true );
|
||||
}
|
||||
|
||||
function OnekeyUpate($auth = 'BingoKingo', $project = 'Tfo', $branch = 'master')
|
||||
{
|
||||
$source = '/tmp/code.zip';
|
||||
$outPath = '/tmp/';
|
||||
|
||||
// 从github下载对应tar.gz,并解压
|
||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||
$tarfile = '/tmp/github.tar.gz';
|
||||
file_put_contents($tarfile, file_get_contents($url));
|
||||
$phar = new PharData($tarfile);
|
||||
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
||||
|
||||
// 获取解压出的目录名
|
||||
/*
|
||||
@ob_start();
|
||||
passthru('ls /tmp | grep '.$auth.'-'.$project.'',$stat);
|
||||
$html.='状态:' . $stat . '
|
||||
结果:
|
||||
';
|
||||
$archivefolder = ob_get_clean();
|
||||
if (substr($archivefolder,-1)==PHP_EOL) $archivefolder = substr($archivefolder, 0, -1);
|
||||
$outPath .= $archivefolder;
|
||||
$html.=htmlspecialchars($archivefolder);
|
||||
//return $html;
|
||||
*/
|
||||
$tmp = scandir($outPath);
|
||||
$name = $auth.'-'.$project;
|
||||
foreach ($tmp as $f) {
|
||||
if ( substr($f, 0, strlen($name)) == $name) {
|
||||
$outPath .= $f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 放入配置文件
|
||||
file_put_contents($outPath . '/config.php', file_get_contents(__DIR__.'/../config.php'));
|
||||
|
||||
// 将目录中文件打包成zip
|
||||
//$zip=new ZipArchive();
|
||||
$zip=new PharData($source);
|
||||
//if($zip->open($source, ZipArchive::CREATE)){
|
||||
addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
|
||||
// $zip->close(); //关闭处理的zip文件
|
||||
//}
|
||||
|
||||
return updateProgram(getConfig('HW_urn'), getConfig('HW_key'), getConfig('HW_secret'), $source);
|
||||
}
|
||||
|
||||
function addFileToZip($zip, $rootpath, $path = '')
|
||||
{
|
||||
if (substr($rootpath,-1)=='/') $rootpath = substr($rootpath, 0, -1);
|
||||
if (substr($path,0,1)=='/') $path = substr($path, 1);
|
||||
$handler=opendir(path_format($rootpath.'/'.$path)); //打开当前文件夹由$path指定。
|
||||
while($filename=readdir($handler)){
|
||||
if($filename != "." && $filename != ".."){//文件夹文件名字为'.'和‘..’,不要对他们进行操作
|
||||
$nowname = path_format($rootpath.'/'.$path."/".$filename);
|
||||
if(is_dir($nowname)){// 如果读取的某个对象是文件夹,则递归
|
||||
$zip->addEmptyDir($path."/".$filename);
|
||||
addFileToZip($zip, $rootpath, $path."/".$filename);
|
||||
}else{ //将文件加入zip对象
|
||||
$newname = $path."/".$filename;
|
||||
if (substr($newname,0,1)=='/') $newname = substr($newname, 1);
|
||||
$zip->addFile($nowname, $newname);
|
||||
//$zip->renameName($nowname, $newname);
|
||||
}
|
||||
}
|
||||
}
|
||||
@closedir($path);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
define("BasicDateFormat", "Ymd\THis\Z");
|
||||
define("Algorithm", "SDK-HMAC-SHA256");
|
||||
define("HeaderXDate", "X-Sdk-Date");
|
||||
define("HeaderHost", "host");
|
||||
define("HeaderAuthorization", "Authorization");
|
||||
define("HeaderContentSha256", "X-Sdk-Content-Sha256");
|
||||
|
||||
class Request
|
||||
{
|
||||
public $method = '';
|
||||
public $scheme = '';
|
||||
public $host = '';
|
||||
public $uri = '';
|
||||
public $query = array();
|
||||
public $headers = array();
|
||||
public $body = '';
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$args = func_get_args();
|
||||
$i = count($args);
|
||||
if ($i == 0) {
|
||||
$this->construct(NULL, NULL, NULL, NULL);
|
||||
} elseif ($i == 1) {
|
||||
$this->construct($args[0], NULL, NULL, NULL);
|
||||
} elseif ($i == 2) {
|
||||
$this->construct($args[0], $args[1], NULL, NULL);
|
||||
} elseif ($i == 3) {
|
||||
$this->construct($args[0], $args[1], $args[2], NULL);
|
||||
} else {
|
||||
$this->construct($args[0], $args[1], $args[2], $args[3]);
|
||||
}
|
||||
}
|
||||
|
||||
function construct($method, $url, $headers, $body)
|
||||
{
|
||||
if ($method != NULL) {
|
||||
$this->method = $method;
|
||||
}
|
||||
if ($url != NULL) {
|
||||
$spl = explode("://", $url, 2);
|
||||
$scheme = 'http';
|
||||
if (count($spl) > 1) {
|
||||
$scheme = $spl[0];
|
||||
$url = $spl[1];
|
||||
}
|
||||
$spl = explode("?", $url, 2);
|
||||
$url = $spl[0];
|
||||
$query = array();
|
||||
if (count($spl) > 1) {
|
||||
foreach (explode("&", $spl[1]) as $kv) {
|
||||
$spl = explode("=", $kv, 2);
|
||||
$key = $spl[0];
|
||||
if (count($spl) == 1) {
|
||||
$value = "";
|
||||
} else {
|
||||
$value = $spl[1];
|
||||
}
|
||||
if ($key != "") {
|
||||
$key = urldecode($key);
|
||||
$value = urldecode($value);
|
||||
if (array_key_exists($key, $query)) {
|
||||
array_push($query[$key], $value);
|
||||
} else {
|
||||
$query[$key] = array($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$spl = explode("/", $url, 2);
|
||||
$host = $spl[0];
|
||||
if (count($spl) == 1) {
|
||||
$url = "/";
|
||||
} else {
|
||||
$url = "/" . $spl[1];
|
||||
}
|
||||
$this->scheme = $scheme;
|
||||
$this->host = $host;
|
||||
$this->uri = urldecode($url);
|
||||
$this->query = $query;
|
||||
}
|
||||
if ($headers != NULL) {
|
||||
$this->headers = $headers;
|
||||
}
|
||||
if ($body != NULL) {
|
||||
$this->body = $body;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Signer
|
||||
{
|
||||
public $Key = '';
|
||||
public $Secret = '';
|
||||
|
||||
function escape($string)
|
||||
{
|
||||
$entities = array('+', "%7E");
|
||||
$replacements = array('%20', "~");
|
||||
return str_replace($entities, $replacements, urlencode($string));
|
||||
}
|
||||
|
||||
function findHeader($r, $header)
|
||||
{
|
||||
foreach ($r->headers as $key => $value) {
|
||||
if (!strcasecmp($key, $header)) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Build a CanonicalRequest from a regular request string
|
||||
//
|
||||
// CanonicalRequest =
|
||||
// HTTPRequestMethod + '\n' +
|
||||
// CanonicalURI + '\n' +
|
||||
// CanonicalQueryString + '\n' +
|
||||
// CanonicalHeaders + '\n' +
|
||||
// SignedHeaders + '\n' +
|
||||
// HexEncode(Hash(RequestPayload))
|
||||
function CanonicalRequest($r, $signedHeaders)
|
||||
{
|
||||
$CanonicalURI = $this->CanonicalURI($r);
|
||||
$CanonicalQueryString = $this->CanonicalQueryString($r);
|
||||
$canonicalHeaders = $this->CanonicalHeaders($r, $signedHeaders);
|
||||
$signedHeadersString = join(";", $signedHeaders);
|
||||
$hash = $this->findHeader($r, HeaderContentSha256);
|
||||
if (!$hash) {
|
||||
$hash = hash("sha256", $r->body);
|
||||
}
|
||||
return "$r->method\n$CanonicalURI\n$CanonicalQueryString\n$canonicalHeaders\n$signedHeadersString\n$hash";
|
||||
}
|
||||
|
||||
// CanonicalURI returns request uri
|
||||
function CanonicalURI($r)
|
||||
{
|
||||
$pattens = explode("/", $r->uri);
|
||||
$uri = array();
|
||||
foreach ($pattens as $v) {
|
||||
array_push($uri, $this->escape($v));
|
||||
}
|
||||
$urlpath = join("/", $uri);
|
||||
if (substr($urlpath, -1) != "/") {
|
||||
$urlpath = $urlpath . "/";
|
||||
}
|
||||
return $urlpath;
|
||||
}
|
||||
|
||||
// CanonicalQueryString
|
||||
function CanonicalQueryString($r)
|
||||
{
|
||||
$keys = array();
|
||||
foreach ($r->query as $key => $value) {
|
||||
array_push($keys, $key);
|
||||
}
|
||||
sort($keys);
|
||||
$a = array();
|
||||
foreach ($keys as $key) {
|
||||
$k = $this->escape($key);
|
||||
$value = $r->query[$key];
|
||||
if (is_array($value)) {
|
||||
sort($value);
|
||||
foreach ($value as $v) {
|
||||
$kv = "$k=" . $this->escape($v);
|
||||
array_push($a, $kv);
|
||||
}
|
||||
} else {
|
||||
$kv = "$k=" . $this->escape($value);
|
||||
array_push($a, $kv);
|
||||
}
|
||||
}
|
||||
return join("&", $a);
|
||||
}
|
||||
|
||||
// CanonicalHeaders
|
||||
function CanonicalHeaders($r, $signedHeaders)
|
||||
{
|
||||
$headers = array();
|
||||
foreach ($r->headers as $key => $value) {
|
||||
$headers[strtolower($key)] = trim($value);
|
||||
}
|
||||
$a = array();
|
||||
foreach ($signedHeaders as $key) {
|
||||
array_push($a, $key . ':' . $headers[$key]);
|
||||
}
|
||||
return join("\n", $a) . "\n";
|
||||
}
|
||||
|
||||
function curlHeaders($r)
|
||||
{
|
||||
$header = array();
|
||||
foreach ($r->headers as $key => $value) {
|
||||
array_push($header, strtolower($key) . ':' . trim($value));
|
||||
}
|
||||
return $header;
|
||||
}
|
||||
|
||||
// SignedHeaders
|
||||
function SignedHeaders($r)
|
||||
{
|
||||
$a = array();
|
||||
foreach ($r->headers as $key => $value) {
|
||||
array_push($a, strtolower($key));
|
||||
}
|
||||
sort($a);
|
||||
return $a;
|
||||
}
|
||||
|
||||
// Create a "String to Sign".
|
||||
function StringToSign($canonicalRequest, $t)
|
||||
{
|
||||
date_default_timezone_set('UTC');
|
||||
$date = date(BasicDateFormat, $t);
|
||||
$hash = hash("sha256", $canonicalRequest);
|
||||
return "SDK-HMAC-SHA256\n$date\n$hash";
|
||||
}
|
||||
|
||||
// Create the HWS Signature.
|
||||
function SignStringToSign($stringToSign, $signingKey)
|
||||
{
|
||||
return hash_hmac("sha256", $stringToSign, $signingKey);
|
||||
}
|
||||
|
||||
// Get the finalized value for the "Authorization" header. The signature parameter is the output from SignStringToSign
|
||||
function AuthHeaderValue($signature, $accessKey, $signedHeaders)
|
||||
{
|
||||
$signedHeadersString = join(";", $signedHeaders);
|
||||
return "SDK-HMAC-SHA256 Access=$accessKey, SignedHeaders=$signedHeadersString, Signature=$signature";
|
||||
}
|
||||
|
||||
public function Sign($r)
|
||||
{
|
||||
date_default_timezone_set('UTC');
|
||||
$date = $this->findHeader($r, HeaderXDate);
|
||||
if ($date) {
|
||||
$t = date_timestamp_get(date_create_from_format(BasicDateFormat, $date));
|
||||
}
|
||||
if (!@$t) {
|
||||
$t = time();
|
||||
$r->headers[HeaderXDate] = date(BasicDateFormat, $t);
|
||||
}
|
||||
$queryString = $this->CanonicalQueryString($r);
|
||||
if ($queryString != "") {
|
||||
$queryString = "?" . $queryString;
|
||||
}
|
||||
$signedHeaders = $this->SignedHeaders($r);
|
||||
$canonicalRequest = $this->CanonicalRequest($r, $signedHeaders);
|
||||
$stringToSign = $this->StringToSign($canonicalRequest, $t);
|
||||
$signature = $this->SignStringToSign($stringToSign, $this->Secret);
|
||||
$authValue = $this->AuthHeaderValue($signature, $this->Key, $signedHeaders);
|
||||
$r->headers[HeaderAuthorization] = $authValue;
|
||||
|
||||
$curl = curl_init();
|
||||
$uri = str_replace(array("%2F"), array("/"), rawurlencode($r->uri));
|
||||
$url = $r->scheme . '://' . $r->host . $uri . $queryString;
|
||||
$headers = $this->curlHeaders($r);
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $r->method);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $r->body);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
curl_setopt($curl, CURLOPT_NOBODY, FALSE);
|
||||
return $curl;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,368 @@
|
|||
<?php
|
||||
|
||||
function getpath()
|
||||
{
|
||||
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]);
|
||||
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
if (isset($_SERVER['DOCUMENT_ROOT'])&&$_SERVER['DOCUMENT_ROOT']==='/app') $_SERVER['base_path'] = '/';
|
||||
else $_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/');
|
||||
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
|
||||
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
||||
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
|
||||
else $path = $_SERVER['REQUEST_URI'];
|
||||
$path = path_format( substr($path, strlen($_SERVER['base_path'])) );
|
||||
return $path;
|
||||
//return substr($path, 1);
|
||||
//return spurlencode($path, '/');
|
||||
}
|
||||
|
||||
function getGET()
|
||||
{
|
||||
if (!$_POST) {
|
||||
if (!!$HTTP_RAW_POST_DATA) {
|
||||
$tmpdata = $HTTP_RAW_POST_DATA;
|
||||
} else {
|
||||
$tmpdata = file_get_contents('php://input');
|
||||
}
|
||||
if (!!$tmpdata) {
|
||||
$postbody = explode("&", $tmpdata);
|
||||
foreach ($postbody as $postvalues) {
|
||||
$pos = strpos($postvalues,"=");
|
||||
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
|
||||
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
||||
if ($p>0) {
|
||||
$getstr = substr($_SERVER['REQUEST_URI'], $p+1);
|
||||
$getstrarr = explode("&",$getstr);
|
||||
foreach ($getstrarr as $getvalues) {
|
||||
if ($getvalues != '') {
|
||||
$pos = strpos($getvalues, "=");
|
||||
//echo $pos;
|
||||
if ($pos > 0) {
|
||||
$getarry[urldecode(substr($getvalues, 0, $pos))] = urldecode(substr($getvalues, $pos + 1));
|
||||
} else {
|
||||
$getarry[urldecode($getvalues)] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($getarry)) {
|
||||
return $getarry;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function getConfig($str, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
|
||||
$slash = '/';
|
||||
if (strpos(__DIR__, ':')) $slash = '\\';
|
||||
$projectPath = splitlast(__DIR__, $slash)[0];
|
||||
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
|
||||
$s = file_get_contents($configPath);
|
||||
//$configs = substr($s, 18, -2);
|
||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||
if ($configs!='') {
|
||||
$envs = json_decode($configs, true);
|
||||
if (in_array($str, $InnerEnv)) {
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
if (isset($envs[$disktag][$str])) {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode($envs[$disktag][$str]);
|
||||
else return $envs[$disktag][$str];
|
||||
}
|
||||
} else {
|
||||
if (isset($envs[$str])) {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode($envs[$str]);
|
||||
else return $envs[$str];
|
||||
}
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function setConfig($arr, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
$slash = '/';
|
||||
if (strpos(__DIR__, ':')) $slash = '\\';
|
||||
$projectPath = splitlast(__DIR__, $slash)[0];
|
||||
$configPath = $projectPath . $slash . '.data' . $slash . 'config.php';
|
||||
$s = file_get_contents($configPath);
|
||||
//$configs = substr($s, 18, -2);
|
||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||
if ($configs!='') $envs = json_decode($configs, true);
|
||||
$disktags = explode("|", getConfig('disktag'));
|
||||
$indisk = 0;
|
||||
$operatedisk = 0;
|
||||
foreach ($arr as $k => $v) {
|
||||
if (in_array($k, $InnerEnv)) {
|
||||
if (in_array($k, $Base64Env)) $envs[$disktag][$k] = base64y_encode($v);
|
||||
else $envs[$disktag][$k] = $v;
|
||||
$indisk = 1;
|
||||
} elseif ($k=='disktag_add') {
|
||||
array_push($disktags, $v);
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_del') {
|
||||
$disktags = array_diff($disktags, [ $v ]);
|
||||
$envs[$v] = '';
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
|
||||
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
|
||||
} else {
|
||||
if (in_array($k, $Base64Env)) $envs[$k] = base64y_encode($v);
|
||||
else $envs[$k] = $v;
|
||||
}
|
||||
}
|
||||
if ($indisk) {
|
||||
$diskconfig = $envs[$disktag];
|
||||
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
|
||||
ksort($diskconfig);
|
||||
$envs[$disktag] = $diskconfig;
|
||||
}
|
||||
if ($operatedisk) {
|
||||
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
|
||||
$envs['disktag'] = str_replace($arr['disktag_rename'], $arr['disktag_newname'], getConfig('disktag'));
|
||||
$envs[$arr['disktag_newname']] = $envs[$arr['disktag_rename']];
|
||||
unset($envs[$arr['disktag_rename']]);
|
||||
} else {
|
||||
$disktags = array_unique($disktags);
|
||||
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
|
||||
if ($disktag_s!='') $envs['disktag'] = substr($disktag_s, 0, -1);
|
||||
else $envs['disktag'] = '';
|
||||
}
|
||||
}
|
||||
$envs = array_filter($envs, 'array_value_isnot_null');
|
||||
ksort($envs);
|
||||
|
||||
//echo '<pre>'. json_encode($envs, JSON_PRETTY_PRINT).'</pre>';
|
||||
$prestr = '<?php $configs = \'' . PHP_EOL;
|
||||
$aftstr = PHP_EOL . '\';';
|
||||
$response = file_put_contents($configPath, $prestr . json_encode($envs, JSON_PRETTY_PRINT) . $aftstr);
|
||||
if ($response>0) return json_encode( [ 'response' => 'success' ] );
|
||||
return json_encode( [ 'message' => 'Failed to write config.', 'code' => 'failed' ] );
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
global $constStr;
|
||||
if ($_GET['install2']) {
|
||||
if ($_POST['admin']!='') {
|
||||
$tmp['admin'] = $_POST['admin'];
|
||||
//$tmp['language'] = $_COOKIE['language'];
|
||||
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||
$response = setConfigResponse( setConfig($tmp) );
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
} else {
|
||||
return output('Jump
|
||||
<script>
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=; path=/; \'+expires;
|
||||
</script>
|
||||
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($_GET['install1']) {
|
||||
if (!ConfigWriteable()) {
|
||||
$html .= getconstStr('MakesuerWriteable');
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
/*if (!RewriteEngineOn()) {
|
||||
$html .= getconstStr('MakesuerRewriteOn');
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}*/
|
||||
$html .= '<button id="checkrewritebtn" onclick="checkrewrite();">'.getconstStr('MakesuerRewriteOn').'</button>
|
||||
<div id="formdiv" style="display: none">
|
||||
<form action="?install2" method="post" onsubmit="return notnull(this);">
|
||||
<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"><br>
|
||||
<input id="submitbtn" type="submit" value="'.getconstStr('Submit').'" disabled>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
var nowtime= new Date();
|
||||
var timezone = 0-nowtime.getTimezoneOffset()/60;
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie="timezone="+timezone+"; path=/; "+expires;
|
||||
function notnull(t)
|
||||
{
|
||||
if (t.admin.value==\'\') {
|
||||
alert(\''.getconstStr('SetAdminPassword').'\');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function checkrewrite()
|
||||
{
|
||||
url=location.protocol + "//" + location.host;
|
||||
//if (location.port!="") url += ":" + location.port;
|
||||
url += location.pathname;
|
||||
if (url.substr(-1)!="/") url += "/";
|
||||
url += "app.json";
|
||||
//alert(url);
|
||||
var xhr4 = new XMLHttpRequest();
|
||||
xhr4.open("GET", url);
|
||||
xhr4.setRequestHeader("x-requested-with","XMLHttpRequest");
|
||||
xhr4.send(null);
|
||||
xhr4.onload = function(e){
|
||||
console.log(xhr4.responseText+","+xhr4.status);
|
||||
if (xhr4.status==201) {
|
||||
document.getElementById("checkrewritebtn").style.display = "none";
|
||||
document.getElementById("submitbtn").disabled = false;
|
||||
document.getElementById("formdiv").style.display = "";
|
||||
} else {
|
||||
alert("Url: " + url + "\nExpect http code 201, but received " + xhr4.status);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>';
|
||||
$title = getconstStr('SetAdminPassword');
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
if ($_GET['install0']) {
|
||||
$html .= '
|
||||
<form action="?install1" method="post">
|
||||
language:<br>';
|
||||
foreach ($constStr['languages'] as $key1 => $value1) {
|
||||
$html .= '
|
||||
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
|
||||
}
|
||||
$html .= '
|
||||
<input type="submit" value="'.getconstStr('Submit').'">
|
||||
</form>
|
||||
<script>
|
||||
function changelanguage(str)
|
||||
{
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=\'+str+\'; path=/; \'+expires;
|
||||
location.href = location.href;
|
||||
}
|
||||
</script>';
|
||||
$title = getconstStr('SelectLanguage');
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
function ConfigWriteable()
|
||||
{
|
||||
$t = md5( md5(time()).rand(1000,9999) );
|
||||
$r = setConfig([ 'tmp' => $t ]);
|
||||
$tmp = getConfig('tmp');
|
||||
setConfig([ 'tmp' => '' ]);
|
||||
if ($tmp == $t) return true;
|
||||
if ($r) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function api_error($response)
|
||||
{
|
||||
return isset($response['message']);
|
||||
}
|
||||
|
||||
function api_error_msg($response)
|
||||
{
|
||||
return $response['code'] . '<br>
|
||||
' . $response['message'] . '<br>
|
||||
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||
}
|
||||
|
||||
function setConfigResponse($response)
|
||||
{
|
||||
return json_decode($response, true);
|
||||
}
|
||||
|
||||
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||
{
|
||||
$slash = '/';
|
||||
if (strpos(__DIR__, ':')) $slash = '\\';
|
||||
// __DIR__ is xxx/platform
|
||||
$projectPath = splitlast(__DIR__, $slash)[0];
|
||||
|
||||
// 从github下载对应tar.gz,并解压
|
||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||
$tarfile = $projectPath . $slash .'github.tar.gz';
|
||||
$githubfile = file_get_contents($url);
|
||||
if (!$githubfile) return 0;
|
||||
file_put_contents($tarfile, $githubfile);
|
||||
if (splitfirst(PHP_VERSION, '.')[0] == '7') {
|
||||
$phar = new PharData($tarfile); // need php7
|
||||
$phar->extractTo($projectPath, null, true);//路径 要解压的文件 是否覆盖
|
||||
} else {
|
||||
ob_start();
|
||||
passthru('tar -xzvf ' . $tarfile, $stat);
|
||||
ob_get_clean();
|
||||
}
|
||||
unlink($tarfile);
|
||||
|
||||
$outPath = '';
|
||||
$tmp = scandir($projectPath);
|
||||
$name = $auth . '-' . $project;
|
||||
foreach ($tmp as $f) {
|
||||
if ( substr($f, 0, strlen($name)) == $name) {
|
||||
$outPath = $projectPath . $slash . $f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//error_log($outPath);
|
||||
if ($outPath=='') return 0;
|
||||
|
||||
//unlink($outPath.'/config.php');
|
||||
$response = rename($projectPath . $slash . '.data' . $slash . 'config.php', $outPath . $slash . '.data' . $slash . 'config.php');
|
||||
if (!$response) {
|
||||
$tmp1['code'] = "Move Failed";
|
||||
$tmp1['message'] = "Can not move " . $projectPath . $slash . '.data' . $slash . 'config.php' . " to " . $outPath . $slash . '.data' . $slash . 'config.php';
|
||||
return json_encode($tmp1);
|
||||
}
|
||||
return moveFolder($outPath, $projectPath, $slash);
|
||||
}
|
||||
|
||||
function moveFolder($from, $to, $slash)
|
||||
{
|
||||
if (substr($from, -1)==$slash) $from = substr($from, 0, -1);
|
||||
if (substr($to, -1)==$slash) $to = substr($to, 0, -1);
|
||||
if (!file_exists($to)) mkdir($to, 0777);
|
||||
$handler=opendir($from);
|
||||
while($filename=readdir($handler)) {
|
||||
if($filename != '.' && $filename != '..'){
|
||||
$fromfile = $from . $slash . $filename;
|
||||
$tofile = $to . $slash . $filename;
|
||||
if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
|
||||
$response = moveFolder($fromfile, $tofile, $slash);
|
||||
if (api_error(setConfigResponse($response))) return $response;
|
||||
}else{
|
||||
//if (file_exists($tofile)) unlink($tofile);
|
||||
$response = rename($fromfile, $tofile);
|
||||
if (!$response) {
|
||||
$tmp['code'] = "Move Failed";
|
||||
$tmp['message'] = "Can not move " . $fromfile . " to " . $tofile;
|
||||
return json_encode($tmp);
|
||||
}
|
||||
if (file_exists($fromfile)) unlink($fromfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handler);
|
||||
rmdir($from);
|
||||
return json_encode( [ 'response' => 'success' ] );
|
||||
}
|
|
@ -0,0 +1,447 @@
|
|||
<?php
|
||||
|
||||
function printInput($event, $context)
|
||||
{
|
||||
if (strlen(json_encode($event['body']))>500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
|
||||
echo urldecode(json_encode($event, JSON_PRETTY_PRINT)) . '
|
||||
|
||||
' . urldecode(json_encode($context, JSON_PRETTY_PRINT)) . '
|
||||
|
||||
';
|
||||
}
|
||||
|
||||
function GetGlobalVariable($event)
|
||||
{
|
||||
$_GET = $event['queryString'];
|
||||
$postbody = explode("&",$event['body']);
|
||||
foreach ($postbody as $postvalues) {
|
||||
$pos = strpos($postvalues,"=");
|
||||
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
|
||||
}
|
||||
$cookiebody = explode("; ",$event['headers']['cookie']);
|
||||
foreach ($cookiebody as $cookievalues) {
|
||||
$pos = strpos($cookievalues,"=");
|
||||
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
|
||||
}
|
||||
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
|
||||
$_SERVER['HTTP_TRANSLATE']==$event['headers']['translate'];//'f'
|
||||
$_SERVER['USER'] = 'qcloud';
|
||||
}
|
||||
|
||||
function GetPathSetting($event, $context)
|
||||
{
|
||||
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['accept-language'],';')[0],',')[0]);
|
||||
$_SERVER['function_name'] = $context['function_name'];
|
||||
$_SERVER['namespace'] = $context['namespace'];
|
||||
$_SERVER['Region'] = getenv('TENCENTCLOUD_REGION');
|
||||
$host_name = $event['headers']['host'];
|
||||
$_SERVER['HTTP_HOST'] = $host_name;
|
||||
$serviceId = $event['requestContext']['serviceId'];
|
||||
if ( $serviceId === substr($host_name,0,strlen($serviceId)) ) {
|
||||
$_SERVER['base_path'] = '/'.$event['requestContext']['stage'].'/'.$_SERVER['function_name'].'/';
|
||||
$path = substr($event['path'], strlen('/'.$_SERVER['function_name'].'/'));
|
||||
} else {
|
||||
$_SERVER['base_path'] = $event['requestContext']['path'];
|
||||
$path = substr($event['path'], strlen($event['requestContext']['path']));
|
||||
}
|
||||
if (substr($path,-1)=='/') $path=substr($path,0,-1);
|
||||
$_SERVER['is_guestup_path'] = is_guestup_path($path);
|
||||
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
|
||||
$_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp'];
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
|
||||
return $path;
|
||||
}
|
||||
|
||||
function getConfig($str, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
if (in_array($str, $InnerEnv)) {
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
$env = json_decode(getenv($disktag), true);
|
||||
if (isset($env[$str])) {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode($env[$str]);
|
||||
else return $env[$str];
|
||||
}
|
||||
} else {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode(getenv($str));
|
||||
else return getenv($str);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function setConfig($arr, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
$disktags = explode("|",getConfig('disktag'));
|
||||
$diskconfig = json_decode(getenv($disktag), true);
|
||||
$tmp = [];
|
||||
$indisk = 0;
|
||||
$operatedisk = 0;
|
||||
foreach ($arr as $k => $v) {
|
||||
if (in_array($k, $InnerEnv)) {
|
||||
if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
|
||||
else $diskconfig[$k] = $v;
|
||||
$indisk = 1;
|
||||
} elseif ($k=='disktag_add') {
|
||||
array_push($disktags, $v);
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_del') {
|
||||
$disktags = array_diff($disktags, [ $v ]);
|
||||
$tmp[$v] = '';
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
|
||||
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
|
||||
} else {
|
||||
if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
|
||||
else $tmp[$k] = $v;
|
||||
}
|
||||
}
|
||||
if ($indisk) {
|
||||
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
|
||||
ksort($diskconfig);
|
||||
$tmp[$disktag] = json_encode($diskconfig);
|
||||
}
|
||||
if ($operatedisk) {
|
||||
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
|
||||
$tmp['disktag'] = str_replace($arr['disktag_rename'], $arr['disktag_newname'], getConfig('disktag'));
|
||||
$tmp[$arr['disktag_newname']] = getConfig($arr['disktag_rename']);
|
||||
$tmp[$arr['disktag_rename']] = '';
|
||||
} else {
|
||||
$disktags = array_unique($disktags);
|
||||
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
|
||||
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
|
||||
else $tmp['disktag'] = '';
|
||||
}
|
||||
}
|
||||
// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
|
||||
//';
|
||||
$response = updateEnvironment($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'));
|
||||
WaitSCFStat();
|
||||
return $response;
|
||||
}
|
||||
|
||||
function WaitSCFStat()
|
||||
{
|
||||
$trynum = 0;
|
||||
while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']!='Active' ) echo '
|
||||
'.++$trynum;
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
global $constStr;
|
||||
if ($_GET['install2']) {
|
||||
$tmp['admin'] = $_POST['admin'];
|
||||
$response = setConfigResponse( setConfig($tmp) );
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
if (needUpdate()) {
|
||||
OnekeyUpate();
|
||||
return message('update to github version, reinstall.
|
||||
<script>
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=; path=/; \'+expires;
|
||||
</script>
|
||||
<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201);
|
||||
}
|
||||
return output('Jump
|
||||
<script>
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=; path=/; \'+expires;
|
||||
</script>
|
||||
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
|
||||
}
|
||||
if ($_GET['install1']) {
|
||||
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||
$SecretId = getConfig('SecretId');
|
||||
if ($SecretId=='') {
|
||||
$SecretId = $_POST['SecretId'];
|
||||
$tmp['SecretId'] = $SecretId;
|
||||
}
|
||||
$SecretKey = getConfig('SecretKey');
|
||||
if ($SecretKey=='') {
|
||||
$SecretKey = $_POST['SecretKey'];
|
||||
$tmp['SecretKey'] = $SecretKey;
|
||||
}
|
||||
$tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
|
||||
$response = json_decode(SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response'];
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
} else {
|
||||
if ($tmp['ONEMANAGER_CONFIG_SAVE'] == 'file') {
|
||||
$html = getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '<br><a href="' . $_SERVER['base_path'] . '">' . getconstStr('Home') . '</a>';
|
||||
$title = 'Reinstall';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '
|
||||
<form action="?install2" method="post" onsubmit="return notnull(this);">
|
||||
<label>'.getconstStr('SetAdminPassword').':<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>
|
||||
<input type="submit" value="'.getconstStr('Submit').'">
|
||||
</form>
|
||||
<script>
|
||||
function notnull(t)
|
||||
{
|
||||
if (t.admin.value==\'\') {
|
||||
alert(\''.getconstStr('SetAdminPassword').'\');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
</script>';
|
||||
$title = getconstStr('SetAdminPassword');
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
}
|
||||
if ($_GET['install0']) {
|
||||
$html .= '
|
||||
<form action="?install1" method="post" onsubmit="return notnull(this);">
|
||||
language:<br>';
|
||||
foreach ($constStr['languages'] as $key1 => $value1) {
|
||||
$html .= '
|
||||
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
|
||||
}
|
||||
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
|
||||
<a href="https://console.cloud.tencent.com/cam/capi" target="_blank">' . getconstStr('Create') . ' SecretId & SecretKey</a><br>
|
||||
<label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br>
|
||||
<label>SecretKey:<input name="SecretKey" type="text" placeholder="" size=""></label><br>';
|
||||
$html .= '
|
||||
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'':'checked') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '</label><br>
|
||||
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
|
||||
$html .= '
|
||||
<input type="submit" value="'.getconstStr('Submit').'">
|
||||
</form>
|
||||
<script>
|
||||
var nowtime= new Date();
|
||||
var timezone = 0-nowtime.getTimezoneOffset()/60;
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie="timezone="+timezone+"; path=/; "+expires;
|
||||
function changelanguage(str)
|
||||
{
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=\'+str+\'; path=/; \'+expires;
|
||||
location.href = location.href;
|
||||
}
|
||||
function notnull(t)
|
||||
{';
|
||||
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
|
||||
if (t.SecretId.value==\'\') {
|
||||
alert(\'input SecretId\');
|
||||
return false;
|
||||
}
|
||||
if (t.SecretKey.value==\'\') {
|
||||
alert(\'input SecretKey\');
|
||||
return false;
|
||||
}';
|
||||
$html .= '
|
||||
return true;
|
||||
}
|
||||
</script>';
|
||||
$title = getconstStr('SelectLanguage');
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
function post2url($url, $data)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
//echo $response;
|
||||
return $response;
|
||||
}
|
||||
|
||||
function ReorganizeDate($arr)
|
||||
{
|
||||
$str = '';
|
||||
ksort($arr);
|
||||
foreach ($arr as $k1 => $v1) {
|
||||
$str .= '&' . $k1 . '=' . $v1;
|
||||
}
|
||||
$str = substr($str, 1); // remove first '&'. 去掉第一个&
|
||||
return $str;
|
||||
}
|
||||
|
||||
function getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey)
|
||||
{
|
||||
//$meth = 'GET';
|
||||
$meth = 'POST';
|
||||
$host = 'scf.tencentcloudapi.com';
|
||||
$tmpdata['Action'] = 'GetFunction';
|
||||
$tmpdata['FunctionName'] = $function_name;
|
||||
$tmpdata['Namespace'] = $Namespace;
|
||||
$tmpdata['Nonce'] = time();
|
||||
$tmpdata['Region'] = $Region;
|
||||
$tmpdata['SecretId'] = $SecretId;
|
||||
$tmpdata['Timestamp'] = time();
|
||||
$tmpdata['Token'] = '';
|
||||
$tmpdata['Version'] = '2018-04-16';
|
||||
$data = ReorganizeDate($tmpdata);
|
||||
$signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
|
||||
//echo urlencode($signStr);
|
||||
//return file_get_contents('https://'.$url.'&Signature='.urlencode($signStr));
|
||||
return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
|
||||
}
|
||||
|
||||
function updateEnvironment($Envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey)
|
||||
{
|
||||
//print_r($Envs);
|
||||
WaitSCFStat();
|
||||
//json_decode($a,true)['Response']['Environment']['Variables'][0]['Key']
|
||||
$tmp = json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Environment']['Variables'];
|
||||
foreach ($tmp as $tmp1) {
|
||||
$tmp_env[$tmp1['Key']] = $tmp1['Value'];
|
||||
}
|
||||
foreach ($Envs as $key1 => $value1) {
|
||||
$tmp_env[$key1] = $value1;
|
||||
}
|
||||
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||
//$tmp_env['Region'] = $Region;
|
||||
ksort($tmp_env);
|
||||
|
||||
$i = 0;
|
||||
foreach ($tmp_env as $key1 => $value1) {
|
||||
$tmpdata['Environment.Variables.'.$i.'.Key'] = $key1;
|
||||
$tmpdata['Environment.Variables.'.$i.'.Value'] = $value1;
|
||||
$i++;
|
||||
}
|
||||
$meth = 'POST';
|
||||
$host = 'scf.tencentcloudapi.com';
|
||||
$tmpdata['Action'] = 'UpdateFunctionConfiguration';
|
||||
$tmpdata['FunctionName'] = $function_name;
|
||||
$tmpdata['Namespace'] = $Namespace;
|
||||
$tmpdata['Nonce'] = time();
|
||||
$tmpdata['Region'] = $Region;
|
||||
$tmpdata['SecretId'] = $SecretId;
|
||||
$tmpdata['Timestamp'] = time();
|
||||
$tmpdata['Token'] = '';
|
||||
$tmpdata['Version'] = '2018-04-16';
|
||||
$data = ReorganizeDate($tmpdata);
|
||||
$signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
|
||||
//echo urlencode($signStr);
|
||||
return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
|
||||
}
|
||||
|
||||
function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey)
|
||||
{
|
||||
//echo json_encode($Envs,JSON_PRETTY_PRINT);
|
||||
if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $Envs = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
|
||||
/*$trynum = 0;
|
||||
while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
|
||||
'.++$trynum;*/
|
||||
//json_decode($a,true)['Response']['Environment']['Variables'][0]['Key']
|
||||
$tmp = json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Environment']['Variables'];
|
||||
foreach ($tmp as $tmp1) {
|
||||
$tmp_env[$tmp1['Key']] = $tmp1['Value'];
|
||||
}
|
||||
foreach ($Envs as $key1 => $value1) {
|
||||
$tmp_env[$key1] = $value1;
|
||||
}
|
||||
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||
//$tmp_env['Region'] = $Region;
|
||||
ksort($tmp_env);
|
||||
|
||||
$i = 0;
|
||||
foreach ($tmp_env as $key1 => $value1) {
|
||||
$tmpdata['Environment.Variables.'.$i.'.Key'] = $key1;
|
||||
$tmpdata['Environment.Variables.'.$i.'.Value'] = $value1;
|
||||
$i++;
|
||||
}
|
||||
$meth = 'POST';
|
||||
$host = 'scf.tencentcloudapi.com';
|
||||
$tmpdata['Action'] = 'UpdateFunctionConfiguration';
|
||||
$tmpdata['FunctionName'] = $function_name;
|
||||
$tmpdata['Namespace'] = $Namespace;
|
||||
$tmpdata['Nonce'] = time();
|
||||
$tmpdata['Region'] = $Region;
|
||||
$tmpdata['SecretId'] = $SecretId;
|
||||
$tmpdata['Timestamp'] = time();
|
||||
$tmpdata['Token'] = '';
|
||||
$tmpdata['Version'] = '2018-04-16';
|
||||
$tmpdata['Description'] = 'Onedrive index and manager in Tencent SCF.';
|
||||
$tmpdata['MemorySize'] = 64;
|
||||
$tmpdata['Timeout'] = 30;
|
||||
$data = ReorganizeDate($tmpdata);
|
||||
echo $data;
|
||||
$signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
|
||||
//echo urlencode($signStr);
|
||||
return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
|
||||
}
|
||||
|
||||
function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKey, $source)
|
||||
{
|
||||
WaitSCFStat();
|
||||
$meth = 'POST';
|
||||
$host = 'scf.tencentcloudapi.com';
|
||||
$tmpdata['Action'] = 'UpdateFunctionCode';
|
||||
$tmpdata['Code.GitUrl'] = $source['url'];
|
||||
$tmpdata['Code.GitBranch'] = $source['branch'];
|
||||
$tmpdata['CodeSource'] = 'Git';
|
||||
$tmpdata['FunctionName'] = $function_name;
|
||||
$tmpdata['Handler'] = 'index.main_handler';
|
||||
$tmpdata['Namespace'] = $Namespace;
|
||||
$tmpdata['Nonce'] = time();
|
||||
$tmpdata['Region'] = $Region;
|
||||
$tmpdata['SecretId'] = $SecretId;
|
||||
$tmpdata['Timestamp'] = time();
|
||||
$tmpdata['Token'] = '';
|
||||
$tmpdata['Version'] = '2018-04-16';
|
||||
$data = ReorganizeDate($tmpdata);
|
||||
$signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
|
||||
//echo urlencode($signStr);
|
||||
return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
|
||||
}
|
||||
|
||||
function api_error($response)
|
||||
{
|
||||
return isset($response['Error']);
|
||||
}
|
||||
|
||||
function api_error_msg($response)
|
||||
{
|
||||
return $response['Error']['Code'] . '<br>
|
||||
' . $response['Error']['Message'] . '<br><br>
|
||||
function_name:' . $_SERVER['function_name'] . '<br>
|
||||
Region:' . $_SERVER['Region'] . '<br>
|
||||
namespace:' . $_SERVER['namespace'] . '<br>
|
||||
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||
}
|
||||
|
||||
function OnekeyUpate($auth = 'BingoKingo', $project = 'Tfo', $branch = 'master')
|
||||
{
|
||||
$source['url'] = 'https://github.com/' . $auth . '/' . $project;
|
||||
$source['branch'] = $branch;
|
||||
return updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'), $source);
|
||||
}
|
||||
|
||||
function setConfigResponse($response)
|
||||
{
|
||||
return json_decode( $response, true )['Response'];
|
||||
}
|
|
@ -0,0 +1,629 @@
|
|||
<?php
|
||||
|
||||
function printInput($event, $context)
|
||||
{
|
||||
if (strlen(json_encode($event['body']))>500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
|
||||
echo urldecode(json_encode($event, JSON_PRETTY_PRINT)) . '
|
||||
|
||||
' . urldecode(json_encode($context, JSON_PRETTY_PRINT)) . '
|
||||
|
||||
';
|
||||
}
|
||||
|
||||
function GetGlobalVariable($event)
|
||||
{
|
||||
$_GET = $event['queryString'];
|
||||
$postbody = explode("&",$event['body']);
|
||||
foreach ($postbody as $postvalues) {
|
||||
$pos = strpos($postvalues,"=");
|
||||
$_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
|
||||
}
|
||||
$cookiebody = explode("; ",$event['headers']['cookie']);
|
||||
foreach ($cookiebody as $cookievalues) {
|
||||
$pos = strpos($cookievalues,"=");
|
||||
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
|
||||
}
|
||||
$_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
|
||||
$_SERVER['HTTP_TRANSLATE']==$event['headers']['translate'];//'f'
|
||||
$_SERVER['USER'] = 'qcloud';
|
||||
}
|
||||
|
||||
function GetPathSetting($event, $context)
|
||||
{
|
||||
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['accept-language'],';')[0],',')[0]);
|
||||
$_SERVER['function_name'] = $context['function_name'];
|
||||
$_SERVER['namespace'] = $context['namespace'];
|
||||
$_SERVER['Region'] = getenv('TENCENTCLOUD_REGION');
|
||||
$host_name = $event['headers']['host'];
|
||||
$_SERVER['HTTP_HOST'] = $host_name;
|
||||
$serviceId = $event['requestContext']['serviceId'];
|
||||
if ( $serviceId === substr($host_name,0,strlen($serviceId)) ) {
|
||||
$_SERVER['base_path'] = '/'.$event['requestContext']['stage'].'/'.$_SERVER['function_name'].'/';
|
||||
$path = substr($event['path'], strlen('/'.$_SERVER['function_name'].'/'));
|
||||
} else {
|
||||
$_SERVER['base_path'] = $event['requestContext']['path'];
|
||||
$path = substr($event['path'], strlen($event['requestContext']['path']));
|
||||
}
|
||||
if (substr($path,-1)=='/') $path=substr($path,0,-1);
|
||||
$_SERVER['is_guestup_path'] = is_guestup_path($path);
|
||||
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
|
||||
$_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp'];
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
|
||||
return $path;
|
||||
}
|
||||
|
||||
function getConfig($str, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
//include 'config.php';
|
||||
$s = file_get_contents('config.php');
|
||||
//$configs = substr($s, 18, -2);
|
||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||
if ($configs!='') {
|
||||
$envs = json_decode($configs, true);
|
||||
if (in_array($str, $InnerEnv)) {
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
if (isset($envs[$disktag][$str])) {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode($envs[$disktag][$str]);
|
||||
else return $envs[$disktag][$str];
|
||||
}
|
||||
} else {
|
||||
if (isset($envs[$str])) {
|
||||
if (in_array($str, $Base64Env)) return base64y_decode($envs[$str]);
|
||||
else return $envs[$str];
|
||||
}
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function setConfig($arr, $disktag = '')
|
||||
{
|
||||
global $InnerEnv;
|
||||
global $Base64Env;
|
||||
if ($disktag=='') $disktag = $_SERVER['disktag'];
|
||||
//include 'config.php';
|
||||
$s = file_get_contents('config.php');
|
||||
//$configs = substr($s, 18, -2);
|
||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||
if ($configs!='') $envs = json_decode($configs, true);
|
||||
$disktags = explode("|",getConfig('disktag'));
|
||||
$indisk = 0;
|
||||
$operatedisk = 0;
|
||||
foreach ($arr as $k => $v) {
|
||||
if (in_array($k, $InnerEnv)) {
|
||||
if (in_array($k, $Base64Env)) $envs[$disktag][$k] = base64y_encode($v);
|
||||
else $envs[$disktag][$k] = $v;
|
||||
$indisk = 1;
|
||||
} elseif ($k=='disktag_add') {
|
||||
array_push($disktags, $v);
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_del') {
|
||||
$disktags = array_diff($disktags, [ $v ]);
|
||||
$envs[$v] = '';
|
||||
$operatedisk = 1;
|
||||
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
|
||||
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
|
||||
} else {
|
||||
if (in_array($k, $Base64Env)) $envs[$k] = base64y_encode($v);
|
||||
else $envs[$k] = $v;
|
||||
}
|
||||
}
|
||||
if ($indisk) {
|
||||
$diskconfig = $envs[$disktag];
|
||||
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
|
||||
ksort($diskconfig);
|
||||
$envs[$disktag] = $diskconfig;
|
||||
}
|
||||
if ($operatedisk) {
|
||||
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
|
||||
$envs['disktag'] = str_replace($arr['disktag_rename'], $arr['disktag_newname'], getConfig('disktag'));
|
||||
$envs[$arr['disktag_newname']] = $envs[$arr['disktag_rename']];
|
||||
$envs[$arr['disktag_rename']] = '';
|
||||
} else {
|
||||
$disktags = array_unique($disktags);
|
||||
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
|
||||
if ($disktag_s!='') $envs['disktag'] = substr($disktag_s, 0, -1);
|
||||
else $envs['disktag'] = '';
|
||||
}
|
||||
}
|
||||
$envs = array_filter($envs, 'array_value_isnot_null');
|
||||
ksort($envs);
|
||||
$response = updateEnvironment($envs, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'));
|
||||
WaitSCFStat($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'));
|
||||
return $response;
|
||||
}
|
||||
|
||||
function WaitSCFStat($function_name, $Region, $Namespace, $SecretId, $SecretKey)
|
||||
{
|
||||
$trynum = 0;
|
||||
while( json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
|
||||
'.++$trynum;
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
global $constStr;
|
||||
if ($_GET['install2']) {
|
||||
$tmp['admin'] = $_POST['admin'];
|
||||
$response = setConfigResponse( setConfig($tmp) );
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
if (needUpdate()) {
|
||||
OnekeyUpate();
|
||||
return message('update to github version, reinstall.
|
||||
<script>
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=; path=/; \'+expires;
|
||||
</script>
|
||||
<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201);
|
||||
}
|
||||
return output('Jump
|
||||
<script>
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=; path=/; \'+expires;
|
||||
</script>
|
||||
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
|
||||
}
|
||||
if ($_GET['install1']) {
|
||||
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||
$SecretId = getConfig('SecretId');
|
||||
if ($SecretId=='') {
|
||||
$SecretId = $_POST['SecretId'];
|
||||
$tmp['SecretId'] = $SecretId;
|
||||
}
|
||||
$SecretKey = getConfig('SecretKey');
|
||||
if ($SecretKey=='') {
|
||||
$SecretKey = $_POST['SecretKey'];
|
||||
$tmp['SecretKey'] = $SecretKey;
|
||||
}
|
||||
$tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
|
||||
$response = json_decode(SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response'];
|
||||
if (api_error($response)) {
|
||||
$html = api_error_msg($response);
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
} else {
|
||||
if ($tmp['ONEMANAGER_CONFIG_SAVE'] != 'file') {
|
||||
$html = getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '<br><a href="' . $_SERVER['base_path'] . '">' . getconstStr('Home') . '</a>';
|
||||
$title = 'Reinstall';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '
|
||||
<form action="?install2" method="post" onsubmit="return notnull(this);">
|
||||
<label>'.getconstStr('SetAdminPassword').':<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>
|
||||
<input type="submit" value="'.getconstStr('Submit').'">
|
||||
</form>
|
||||
<script>
|
||||
function notnull(t)
|
||||
{
|
||||
if (t.admin.value==\'\') {
|
||||
alert(\''.getconstStr('SetAdminPassword').'\');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
</script>';
|
||||
$title = getconstStr('SetAdminPassword');
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
}
|
||||
if ($_GET['install0']) {
|
||||
$html .= '
|
||||
<form action="?install1" method="post" onsubmit="return notnull(this);">
|
||||
language:<br>';
|
||||
foreach ($constStr['languages'] as $key1 => $value1) {
|
||||
$html .= '
|
||||
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
|
||||
}
|
||||
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
|
||||
<a href="https://console.cloud.tencent.com/cam/capi" target="_blank">'.getconstStr('Create').' SecretId & SecretKey</a><br>
|
||||
<label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br>
|
||||
<label>SecretKey:<input name="SecretKey" type="text" placeholder="" size=""></label><br>';
|
||||
$html .= '
|
||||
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'':'checked') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '</label><br>
|
||||
<label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
|
||||
$html .= '
|
||||
<input type="submit" value="'.getconstStr('Submit').'">
|
||||
</form>
|
||||
<script>
|
||||
var nowtime= new Date();
|
||||
var timezone = 0-nowtime.getTimezoneOffset()/60;
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie="timezone="+timezone+"; path=/; "+expires;
|
||||
function changelanguage(str)
|
||||
{
|
||||
var expd = new Date();
|
||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||
var expires = "expires="+expd.toGMTString();
|
||||
document.cookie=\'language=\'+str+\'; path=/; \'+expires;
|
||||
location.href = location.href;
|
||||
}
|
||||
function notnull(t)
|
||||
{';
|
||||
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
|
||||
if (t.SecretId.value==\'\') {
|
||||
alert(\'input SecretId\');
|
||||
return false;
|
||||
}
|
||||
if (t.SecretKey.value==\'\') {
|
||||
alert(\'input SecretKey\');
|
||||
return false;
|
||||
}';
|
||||
$html .= '
|
||||
return true;
|
||||
}
|
||||
</script>';
|
||||
$title = getconstStr('SelectLanguage');
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
function post2url($url, $data)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
//echo $response;
|
||||
return $response;
|
||||
}
|
||||
|
||||
function ReorganizeDate($arr)
|
||||
{
|
||||
$str = '';
|
||||
ksort($arr);
|
||||
foreach ($arr as $k1 => $v1) {
|
||||
$str .= '&' . $k1 . '=' . $v1;
|
||||
}
|
||||
$str = substr($str, 1); // remove first '&'. 去掉第一个&
|
||||
return $str;
|
||||
}
|
||||
|
||||
function getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey)
|
||||
{
|
||||
//$meth = 'GET';
|
||||
$meth = 'POST';
|
||||
$host = 'scf.tencentcloudapi.com';
|
||||
$tmpdata['Action'] = 'GetFunction';
|
||||
$tmpdata['FunctionName'] = $function_name;
|
||||
$tmpdata['Namespace'] = $Namespace;
|
||||
$tmpdata['Nonce'] = time();
|
||||
$tmpdata['Region'] = $Region;
|
||||
$tmpdata['SecretId'] = $SecretId;
|
||||
$tmpdata['Timestamp'] = time();
|
||||
$tmpdata['Token'] = '';
|
||||
$tmpdata['Version'] = '2018-04-16';
|
||||
$data = ReorganizeDate($tmpdata);
|
||||
$signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
|
||||
//echo urlencode($signStr);
|
||||
//return file_get_contents('https://'.$url.'&Signature='.urlencode($signStr));
|
||||
return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
|
||||
}
|
||||
|
||||
function getfunctioncodeurl($function_name, $Region, $Namespace, $SecretId, $SecretKey)
|
||||
{
|
||||
//$meth = 'GET';
|
||||
$meth = 'POST';
|
||||
$host = 'scf.tencentcloudapi.com';
|
||||
$tmpdata['Action'] = 'GetFunctionAddress';
|
||||
$tmpdata['FunctionName'] = $function_name;
|
||||
$tmpdata['Namespace'] = $Namespace;
|
||||
$tmpdata['Nonce'] = time();
|
||||
$tmpdata['Region'] = $Region;
|
||||
$tmpdata['SecretId'] = $SecretId;
|
||||
$tmpdata['Timestamp'] = time();
|
||||
$tmpdata['Token'] = '';
|
||||
$tmpdata['Version'] = '2018-04-16';
|
||||
$data = ReorganizeDate($tmpdata);
|
||||
$signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
|
||||
//echo urlencode($signStr);
|
||||
//return file_get_contents('https://'.$url.'&Signature='.urlencode($signStr));
|
||||
return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
|
||||
}
|
||||
|
||||
function copyFolder($from, $to)
|
||||
{
|
||||
if (substr($from, -1)=='/') $from = substr($from, 0, -1);
|
||||
if (substr($to, -1)=='/') $to = substr($to, 0, -1);
|
||||
if (!file_exists($to)) mkdir($to, 0777);
|
||||
$handler=opendir($from);
|
||||
while($filename=readdir($handler)) {
|
||||
if($filename != '.' && $filename != '..'){
|
||||
$fromfile = $from.'/'.$filename;
|
||||
$tofile = $to.'/'.$filename;
|
||||
if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
|
||||
copyFolder($fromfile, $tofile);
|
||||
}else{
|
||||
copy($fromfile, $tofile);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handler);
|
||||
return 1;
|
||||
}
|
||||
|
||||
function updateEnvironment($Envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey)
|
||||
{
|
||||
// 获取当前代码并解压
|
||||
//$codeurl = json_decode(getfunctioncodeurl($function_name, $Region, $Namespace, $SecretId, $SecretKey), true)['Response']['Url'];
|
||||
//$codezip = '/tmp/oldcode.zip';
|
||||
$outPath = '/tmp/code/';
|
||||
|
||||
//file_put_contents($codezip, file_get_contents($codeurl));
|
||||
//$zip=new ZipArchive();
|
||||
//$zip->open($codezip);
|
||||
//$html = $zip->extractTo($outPath);
|
||||
|
||||
$coderoot = __DIR__ . '/../';
|
||||
copyFolder($coderoot, $outPath);
|
||||
|
||||
// 将配置写入
|
||||
$prestr = '<?php $configs = \'' . PHP_EOL;
|
||||
$aftstr = PHP_EOL . '\';';
|
||||
file_put_contents($outPath . 'config.php', $prestr . json_encode($Envs, JSON_PRETTY_PRINT) . $aftstr);
|
||||
|
||||
// 将目录中文件打包成zip
|
||||
$source = '/tmp/code.zip';
|
||||
//$zip=new ZipArchive();
|
||||
$zip=new PharData($source);
|
||||
//if($zip->open($source, ZipArchive::CREATE)){
|
||||
addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
|
||||
// $zip->close(); //关闭处理的zip文件
|
||||
//}
|
||||
|
||||
return updateProgram($function_name, $Region, $namespace, $SecretId, $SecretKey, $source);
|
||||
$tmp1['Response']['Error']['Message'] = $codeurl;
|
||||
error_log($tmp1['Response']['Error']['Message']);
|
||||
return json_encode($tmp1);
|
||||
}
|
||||
|
||||
function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey)
|
||||
{
|
||||
if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $tmp_env = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
|
||||
else {
|
||||
$Envs['ONEMANAGER_CONFIG_SAVE'] == '';
|
||||
$tmp = json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Environment']['Variables'];
|
||||
foreach ($tmp as $tmp1) {
|
||||
$tmp_env[$tmp1['Key']] = $tmp1['Value'];
|
||||
}
|
||||
foreach ($Envs as $key1 => $value1) {
|
||||
$tmp_env[$key1] = $value1;
|
||||
}
|
||||
$tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
|
||||
ksort($tmp_env);
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
foreach ($tmp_env as $key1 => $value1) {
|
||||
$tmpdata['Environment.Variables.'.$i.'.Key'] = $key1;
|
||||
$tmpdata['Environment.Variables.'.$i.'.Value'] = $value1;
|
||||
$i++;
|
||||
}
|
||||
|
||||
$meth = 'POST';
|
||||
$host = 'scf.tencentcloudapi.com';
|
||||
$tmpdata['Action'] = 'UpdateFunctionConfiguration';
|
||||
$tmpdata['FunctionName'] = $function_name;
|
||||
$tmpdata['Namespace'] = $Namespace;
|
||||
$tmpdata['Nonce'] = time();
|
||||
$tmpdata['Region'] = $Region;
|
||||
$tmpdata['SecretId'] = $SecretId;
|
||||
$tmpdata['Timestamp'] = time();
|
||||
$tmpdata['Token'] = '';
|
||||
$tmpdata['Version'] = '2018-04-16';
|
||||
$tmpdata['Description'] = 'Onedrive index and manager in Tencent SCF.';
|
||||
$tmpdata['MemorySize'] = 64;
|
||||
$tmpdata['Timeout'] = 30;
|
||||
$data = ReorganizeDate($tmpdata);
|
||||
//echo $data;
|
||||
$signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
|
||||
//echo urlencode($signStr);
|
||||
$response = post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
|
||||
if (api_error(setConfigResponse($response))) {
|
||||
return $response;
|
||||
}
|
||||
if ( json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Timeout'] < 25 ) {
|
||||
$tmp['Response']['Error']['Message'] = 'Operating, please try again.';
|
||||
$tmp['Response']['Error']['Code'] = 'Retry';
|
||||
return json_encode($tmp);
|
||||
}
|
||||
WaitSCFStat($function_name, $Region, $Namespace, $SecretId, $SecretKey);
|
||||
|
||||
$s = file_get_contents('config.php');
|
||||
//$configs = substr($s, 18, -2);
|
||||
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
|
||||
if ($configs!='') $envs = json_decode($configs, true);
|
||||
foreach ($Envs as $k => $v) {
|
||||
$envs[$k] = $v;
|
||||
}
|
||||
$envs = array_filter($envs, 'array_value_isnot_null');
|
||||
ksort($envs);
|
||||
$response = updateEnvironment($envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey);
|
||||
return $response;
|
||||
}
|
||||
|
||||
function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKey, $source)
|
||||
{
|
||||
$secretId = $SecretId;
|
||||
$secretKey = $SecretKey;
|
||||
$host = 'scf.tencentcloudapi.com';
|
||||
$service = "scf";
|
||||
$version = "2018-04-16";
|
||||
$action = "UpdateFunctionCode";
|
||||
$region = $Region;
|
||||
$timestamp = time();
|
||||
$algorithm = "TC3-HMAC-SHA256";
|
||||
|
||||
// step 1: build canonical request string
|
||||
$httpRequestMethod = "POST";
|
||||
$canonicalUri = "/";
|
||||
$canonicalQueryString = "";
|
||||
$canonicalHeaders = "content-type:application/json; charset=utf-8\n"."host:".$host."\n";
|
||||
$signedHeaders = "content-type;host";
|
||||
|
||||
//$tmpdata['Action'] = 'UpdateFunctionCode';
|
||||
$tmpdata['Code']['ZipFile'] = base64_encode( file_get_contents($source) );
|
||||
$tmpdata['CodeSource'] = 'ZipFile';
|
||||
$tmpdata['FunctionName'] = $function_name;
|
||||
$tmpdata['Handler'] = 'index.main_handler';
|
||||
//$tmpdata['Namespace'] = $Namespace;
|
||||
//$tmpdata['Nonce'] = time();
|
||||
//$tmpdata['Region'] = $Region;
|
||||
//$tmpdata['SecretId'] = $SecretId;
|
||||
//$tmpdata['Timestamp'] = time();
|
||||
//$tmpdata['Token'] = '';
|
||||
//$tmpdata['Version'] = '2018-04-16';
|
||||
$payload = json_encode($tmpdata);
|
||||
//$payload = '{"Limit": 1, "Filters": [{"Values": ["\u672a\u547d\u540d"], "Name": "instance-name"}]}';
|
||||
$hashedRequestPayload = hash("SHA256", $payload);
|
||||
$canonicalRequest = $httpRequestMethod."\n"
|
||||
.$canonicalUri."\n"
|
||||
.$canonicalQueryString."\n"
|
||||
.$canonicalHeaders."\n"
|
||||
.$signedHeaders."\n"
|
||||
.$hashedRequestPayload;
|
||||
//echo $canonicalRequest.PHP_EOL;
|
||||
|
||||
// step 2: build string to sign
|
||||
$date = gmdate("Y-m-d", $timestamp);
|
||||
$credentialScope = $date."/".$service."/tc3_request";
|
||||
$hashedCanonicalRequest = hash("SHA256", $canonicalRequest);
|
||||
$stringToSign = $algorithm."\n"
|
||||
.$timestamp."\n"
|
||||
.$credentialScope."\n"
|
||||
.$hashedCanonicalRequest;
|
||||
//echo $stringToSign.PHP_EOL;
|
||||
|
||||
// step 3: sign string
|
||||
$secretDate = hash_hmac("SHA256", $date, "TC3".$secretKey, true);
|
||||
$secretService = hash_hmac("SHA256", $service, $secretDate, true);
|
||||
$secretSigning = hash_hmac("SHA256", "tc3_request", $secretService, true);
|
||||
$signature = hash_hmac("SHA256", $stringToSign, $secretSigning);
|
||||
//echo $signature.PHP_EOL;
|
||||
|
||||
// step 4: build authorization
|
||||
$authorization = $algorithm
|
||||
." Credential=".$secretId."/".$credentialScope
|
||||
.", SignedHeaders=content-type;host, Signature=".$signature;
|
||||
//echo $authorization.PHP_EOL;
|
||||
|
||||
//$curl = "curl -X POST https://".$host
|
||||
// .' -H "Authorization: '.$authorization.'"'
|
||||
// .' -H "Content-Type: application/json; charset=utf-8"'
|
||||
// .' -H "Host: '.$host.'"'
|
||||
// .' -H "X-TC-Action: '.$action.'"'
|
||||
// .' -H "X-TC-Timestamp: '.$timestamp.'"'
|
||||
// .' -H "X-TC-Version: '.$version.'"'
|
||||
// .' -H "X-TC-Region: '.$region.'"'
|
||||
// ." -d '".$payload."'";
|
||||
//error_log( $curl.PHP_EOL );
|
||||
//return '{"response": {"Error": {"Message":"' . $curl . '"}}}';
|
||||
$headers['Authorization'] = $authorization;
|
||||
$headers['Content-Type'] = 'application/json; charset=utf-8';
|
||||
$headers['Host'] = $host;
|
||||
$headers['X-TC-Action'] = $action;
|
||||
$headers['X-TC-Timestamp'] = $timestamp;
|
||||
$headers['X-TC-Version'] = $version;
|
||||
$headers['X-TC-Region'] = $region;
|
||||
return curl('POST', 'https://'.$host, $payload, $headers)['body'];
|
||||
}
|
||||
|
||||
function api_error($response)
|
||||
{
|
||||
return isset($response['Error']);
|
||||
return ($response==null)||isset($response['Error']);
|
||||
}
|
||||
|
||||
function api_error_msg($response)
|
||||
{
|
||||
return $response['Error']['Code'] . '<br>
|
||||
' . $response['Error']['Message'] . '<br><br>
|
||||
function_name:' . $_SERVER['function_name'] . '<br>
|
||||
Region:' . $_SERVER['Region'] . '<br>
|
||||
namespace:' . $_SERVER['namespace'] . '<br>
|
||||
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||
}
|
||||
|
||||
function setConfigResponse($response)
|
||||
{
|
||||
return json_decode( $response, true )['Response'];
|
||||
}
|
||||
|
||||
function OnekeyUpate($auth = 'BingoKingo', $project = 'Tfo', $branch = 'master')
|
||||
{
|
||||
$source = '/tmp/code.zip';
|
||||
$outPath = '/tmp/';
|
||||
|
||||
// 从github下载对应tar.gz,并解压
|
||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||
$tarfile = '/tmp/github.tar.gz';
|
||||
file_put_contents($tarfile, file_get_contents($url));
|
||||
$phar = new PharData($tarfile);
|
||||
$html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
|
||||
|
||||
// 获取包中目录名
|
||||
$tmp = scandir('phar://'.$tarfile);
|
||||
$name = $auth.'-'.$project;
|
||||
foreach ($tmp as $f) {
|
||||
if ( substr($f, 0, strlen($name)) == $name) {
|
||||
$outPath .= $f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 放入配置文件
|
||||
file_put_contents($outPath . '/config.php', file_get_contents(__DIR__.'/../config.php'));
|
||||
|
||||
// 将目录中文件打包成zip
|
||||
//$zip=new ZipArchive();
|
||||
$zip=new PharData($source);
|
||||
//if($zip->open($source, ZipArchive::CREATE)){
|
||||
addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
|
||||
// $zip->close(); //关闭处理的zip文件
|
||||
//}
|
||||
|
||||
return updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'), $source);
|
||||
}
|
||||
|
||||
function addFileToZip($zip, $rootpath, $path = '')
|
||||
{
|
||||
if (substr($rootpath,-1)=='/') $rootpath = substr($rootpath, 0, -1);
|
||||
if (substr($path,0,1)=='/') $path = substr($path, 1);
|
||||
$handler=opendir(path_format($rootpath.'/'.$path)); //打开当前文件夹由$path指定。
|
||||
while($filename=readdir($handler)){
|
||||
if($filename != "." && $filename != ".."){//文件夹文件名字为'.'和‘..’,不要对他们进行操作
|
||||
$nowname = path_format($rootpath.'/'.$path."/".$filename);
|
||||
if(is_dir($nowname)){// 如果读取的某个对象是文件夹,则递归
|
||||
$zip->addEmptyDir($path."/".$filename);
|
||||
addFileToZip($zip, $rootpath, $path."/".$filename);
|
||||
}else{ //将文件加入zip对象
|
||||
$newname = $path."/".$filename;
|
||||
if (substr($newname,0,1)=='/') $newname = substr($newname, 1);
|
||||
$zip->addFile($nowname, $newname);
|
||||
//$zip->renameName($nowname, $newname);
|
||||
}
|
||||
}
|
||||
}
|
||||
@closedir($path);
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
# **Tfo**
|
||||
###### A website for two-point filestorage online (tfo)(20210115).
|
||||
|
||||
<img src="https://tfo.herokuapp.com/index/Uploaded/WebContents/Github/Tfo/Tfo.logo.svg" alt="Tfo's Logo" width="250" height="250"/>
|
||||
|
||||
## Featured theme files 主题特征性文件
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Files</th>
|
||||
<th>Postscript</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="3">Information</td>
|
||||
<td>
|
||||
<a href="./app.json" title="app.json">app.json</a>
|
||||
</td>
|
||||
<td rowspan="3">Tfo's information is described in these files for deployment</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="./readme.md" title="readme.md">readme.md</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="./conststr.php" title="conststr.php">conststr.php</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="7">UpdateAddress</td>
|
||||
<td>
|
||||
<a href="./platform/Heroku.php" title="Heroku.php">Heroku.php</a>
|
||||
</td>
|
||||
<td rowspan="7">Address to update is changed for easy management and updating</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="./platform/BaiduCFC.php" title="BaiduCFC.php">BaiduCFC.php</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="./platform/AliyunFC.php" title="AliyunFC.php">AliyunFC.php</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="./platform/TencentSCF_file.php" title="TencentSCF_file.php">TencentSCF_file.php</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="./platform/TencentSCF_env.php" title="TencentSCF_env.php">TencentSCF_env.php</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="./platform/HuaweiFG_file.php" title="HuaweiFG_file.php">HuaweiFG_file.php</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="./platform/HuaweiFG_env.php" title="HuaweiFG_env.php">HuaweiFG_env.php</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="1">Theme</td>
|
||||
<td>
|
||||
<a href="./theme/tfo.html" title="tfo.html">tfo.html</a>
|
||||
</td>
|
||||
<td rowspan="1">Tfo's theme for OneManager-php</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
具体地,您可以下载/复制体验一下或参考示例中运用tfo.html的[Li Share Storage Mini](https://tfo.herokuapp.com/ "Li Share Storage Mini")。需要注意:**主题默认隐藏了多盘**。目前,主题仍存在诸多问题,请谅解。PS:主题将要实现的功能有狠多,敬请期待...但是自愿附加组件如评论系统、站长工具、访问统计等涉及到其他平台的私密内容不包含在主题内,若有需要请自行寻找在后台添加。主题的php历史版本请到<a href="./theme/" title="Old Theme">Theme</a>文件夹查看。
|
||||
|
||||
## Deploy 部署
|
||||
### Deploy to Heroku
|
||||
Official: https://heroku.com
|
||||
Demo: https://herooneindex.herokuapp.com/
|
||||
|
||||
How to Install: Click the button [](https://heroku.com/deploy?template=https://github.com/qkqpttgf/OneManager-php) to Deploy a new app, or create an app then deploy via connect to your github fork.
|
||||
|
||||
|
||||
### Deploy to Glitch
|
||||
Official: https://glitch.com/
|
||||
Demo: https://onemanager.glitch.me/
|
||||
|
||||
How to Install: New Project -> Import form Github -> paste "https://github.com/qkqpttgf/OneManager-php", after done, Show -> In a New Window.
|
||||
|
||||
|
||||
### Deploy to Tencent Serverless Cloud Function (SCF 腾讯无服务器云函数)
|
||||
Official: https://cloud.tencent.com/product/scf
|
||||
DEMO: 无
|
||||
注意:SCF新增限制,环境变量整体最大4KB,所以最多添加4个盘。
|
||||
|
||||
How to Install:
|
||||
1,进入函数服务,上方选择地区,然后点击新建。
|
||||
2,输入函数名称,选择模板函数,在模糊搜索中输入onedrive,大小写随意,选择那个【获取onedrive信息.....】,点下一步,在代码界面不用动,直接点完成。
|
||||
3,点击触发管理,创建触发器,触发方式改成API网关触发,底下勾选启用集成响应,提交。
|
||||
4,在触发管理中可以看到一个 访问路径,访问它,开始安装。
|
||||
|
||||
(重点:勾选集成响应)
|
||||
|
||||
添加网盘时,SCF可能会反应不过来,不跳转到微软,导致添加失败,请不要删除这个盘,再添加一次相同标签的盘就可以了。
|
||||
|
||||
|
||||
### Deploy to Virtual Private Server (VPS 或空间)
|
||||
DEMO: 无
|
||||
How to Install:
|
||||
1.Start web service on your server (httpd or other), make sure you can visit it.
|
||||
启动web服务器,确保你能访问到。
|
||||
2.Make the rewrite works, the rule is in .htaccess file, make sure any query redirect to index.php.
|
||||
开启伪静态(重写)功能,规则在.htaccess文件中,ngnix从里面复制,我们的目的是不管访问什么都让index.php来处理。
|
||||
3.Upload code.
|
||||
上传好代码。
|
||||
4.Change the file config.php can be read&write (666 is suggested).
|
||||
让代码中的config.php文件程序可读写,推荐chmod 666 config.php。
|
||||
5.View the website in chrome or other.
|
||||
在浏览器中访问。
|
||||
|
||||
|
||||
### Deploy to Huawei cloud Function Graph (FG 华为云函数工作流)
|
||||
Official: https://console.huaweicloud.com/functiongraph/
|
||||
DEMO: 无
|
||||
注意:FG中,环境变量整体大小为2KB,所以最多添加2个盘。
|
||||
|
||||
How to Install:
|
||||
1,在函数列表,点右边创建函数
|
||||
2,输入名称,选择运行时语言为PHP7.3,点上传ZIP文件,选择文件,然后点右边的创建函数(这里的ZIP文件不能直接用从Github上下载的ZIP文件,要将它解压后,去掉外层文件夹后,再压缩为ZIP。)
|
||||
3,创建触发器:选API网关,安全认证选None,后端超时(毫秒)将5000改成30000,上面创建分组一下,其它的点点点
|
||||
4,访问触发器给的url,开始安装
|
||||
5,在触发器界面点触发器名称,跳到API网关管理,右边更多URL,可以添加自定义域名,自定义域名后发现还是要 xxxx.com/函数名 来访问,点上方的编辑,第1页不用改,点下一步,请求Path改成/,注意匹配模式是前缀匹配,Method为ANY,然后不用点下一步了,点立即完成,然后去发布生效
|
||||
|
||||
|
||||
### Deploy to Aliyun Function Compute (FC 阿里云函数计算)
|
||||
Official: https://fc.console.aliyun.com/
|
||||
DEMO: 无
|
||||
|
||||
How to Install:
|
||||
1,新建函数 -- HTTP函数
|
||||
2,运行环境选择php7.2
|
||||
3,触发器认证方式选择anonymous,请求方式里面,点一下GET,再点一下POST,最终框框里面有这2个
|
||||
4,上传代码
|
||||
5,触发器中点进去,找到配置自定义域名,点击前往,创建,路径中填 /* ,其它下拉选择。
|
||||
6,访问你的域名,开始安装
|
||||
|
||||
|
||||
### Deploy to Baidu Cloud Function Compute (CFC 百度云函数计算)
|
||||
Official: https://console.bce.baidu.com/cfc/#/cfc/functions
|
||||
DEMO: 无
|
||||
自定义域名需要另外使用API网关,并备案。
|
||||
|
||||
How to Install:
|
||||
1,在函数列表,点创建函数
|
||||
2,创建方式改为空白函数,点下一步
|
||||
3,输入名称,选择运行时为PHP7.2,点下一步
|
||||
4,触发器:下拉选择HTTP触发器,URL路径填 /{filepath+} ,HTTP方法全选,身份验证:不验证,点提交
|
||||
5,进入代码编辑页,编辑类型改上传函数ZIP包,选择文件(这里的ZIP文件不能直接用从Github上下载的ZIP文件,要将它解压后,去掉外层文件夹后,再压缩为ZIP。),开始上传
|
||||
6,点击右边触发器,复制并访问提供的url,开始安装
|
||||
|
||||
|
||||
## Features 特性
|
||||
When downloading files, the program produce a direct url, visitor download files from MS OFFICE via the direct url, the server expend a few bandwidth in produce.
|
||||
下载时,由程序解析出直链,浏览器直接从微软Onedrive服务器下载文件,服务器只消耗与微软通信的少量流量。
|
||||
When uploading files, the program produce a direct url, visitor upload files to MS OFFICE via the direct url, the server expend a few bandwidth in produce.
|
||||
上传时,由程序生成上传url,浏览器直接向微软Onedrive的这个url上传文件,服务器只消耗与微软通信的少量流量。
|
||||
The XXX_path in setting is the path in Onedrive, not in url, program will find the path in Onedrive.
|
||||
设置中的 XXX_path 是Onedrive里面的路径,并不是你url里面的,程序会去你Onedrive里面找这个路径。
|
||||
LOGO ICON: put your 'favicon.ico' in the path you showed, make sure xxxxx.com/favicon.ico can be visited.
|
||||
网站图标:将favicon.ico文件放在你要展示的目录中,确保 xxxxx.com/favicon.ico 可以访问到。
|
||||
Program will show content of 'readme.md' & 'head.md'.
|
||||
可以在文件列表显示head.md跟readme.md文件的内容。
|
||||
guest up path, is a folder that the guest can upload files, but can not be list (exclude admin).
|
||||
游客上传目录(也叫图床目录),是指定一个目录,让游客可以上传文件,不限格式,不限大小。这个目录里面的内容不列清单(除非管理登录)。
|
||||
If there is 'index.html' file, program will only show the content of 'index.html', not list the files.
|
||||
如果目录中有index.html文件,只会输出显示html文件,不显示程序框架。
|
||||
Click 'EditTime' or 'Size', the list will sort by time or size, Click 'File' can resume sort.
|
||||
点击“时间”、“大小”,可以排序显示,点“文件”恢复原样。
|
||||
|
||||
## Functional files 功能性文件
|
||||
### favicon.ico
|
||||
put it in the showing home folder of FIRST disk (maybe not root of onedrive). 放在第一个盘的显示目录(不一定是onedrive根目录)。
|
||||
### index.html
|
||||
show content of index.html as html. 将index.html以静态网页显示出来。
|
||||
### head.md readme.md
|
||||
it will showed at top or bottom as markdown. 以MD语法显示在顶部或底部。
|
||||
### head.omf foot.omf
|
||||
it will showed at top or bottom as html (javascript works!). 以html显示在顶部或底部(可以跑js)。
|
|
@ -0,0 +1,30 @@
|
|||
<?php if(!empty($_POST['user'])&&!empty($_POST['pass'])&&!empty($_POST['Verification'])){
|
||||
require_once 'https://raw.githubusercontent.com/PHPGangsta/GoogleAuthenticator/master/PHPGangsta/GoogleAuthenticator.php';
|
||||
|
||||
$ga = new PHPGangsta_GoogleAuthenticator();
|
||||
|
||||
//"安全密匙SecretKey" 入库,和账户关系绑定,客户端也是绑定这同一个"安全密匙SecretKey"
|
||||
$secret = '1GNPUHS46J0O6R7HN';
|
||||
|
||||
$oneCode = $_POST['Verification'];
|
||||
$checkResult = $ga->verifyCode($secret, $oneCode, 2);
|
||||
if($checkResult){
|
||||
$user = $_POST['user'];
|
||||
$pass = $_POST['pass'];
|
||||
if($user=='admin'&&$pass=='admin000'){
|
||||
exit('登录成功');
|
||||
}else{
|
||||
exit('密码错误');
|
||||
}
|
||||
}else{
|
||||
exit('验证码错误');
|
||||
}}?><!DOCTYPE html><html><head>
|
||||
<title>登录</title></head><body>
|
||||
<div>
|
||||
<form action="login.php" method="post">
|
||||
<p>账号:<input type="text" name="user" placeholder="账号"></p>
|
||||
<p>密码:<input type="pass" name="pass"></p>
|
||||
<p>验证码:<input type="number" name="Verification"></p>
|
||||
<input type="submit" value="提交">
|
||||
</form>
|
||||
</div></body></html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,572 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="<!--constStr@language-->">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><!--Title--></title>
|
||||
<link rel="shortcut icon" href="<!--base_path-->favicon.ico" type="image/x-icon">
|
||||
<!--https://p.sfx.ms/images/favicon.ico-->
|
||||
<style>
|
||||
/* 通用样式 */
|
||||
/* 用于消除默认自带样式 */
|
||||
html, body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: #333;
|
||||
font-family: "Segoe UI", Tahoma, Arial, sans-serif;
|
||||
overflow: hidden;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
ul {
|
||||
list-style: none;
|
||||
}
|
||||
input[type="radio"] {
|
||||
margin: 0;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* 兼容样式 */
|
||||
body {
|
||||
-webkit-user-select:none;
|
||||
-moz-user-select:none;
|
||||
-ms-user-select:none;
|
||||
user-select:none;
|
||||
}
|
||||
select:-moz-focusring {
|
||||
color: transparent;
|
||||
text-shadow: 0 0 0 #000;
|
||||
}
|
||||
|
||||
/* 自定义样式 */
|
||||
.container {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
max-width: 1100px;
|
||||
}
|
||||
.pull-left {
|
||||
float: left;
|
||||
}
|
||||
.pull-right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* 字体外部引用 */
|
||||
@font-face {
|
||||
font-family: 'iconfont'; /* project id 1634400 */
|
||||
src: url('//at.alicdn.com/t/font_1634400_9yg8f5s278.eot');
|
||||
src: url('//at.alicdn.com/t/font_1634400_9yg8f5s278.eot?#iefix') format('embedded-opentype'),
|
||||
url('//at.alicdn.com/t/font_1634400_9yg8f5s278.woff2') format('woff2'),
|
||||
url('//at.alicdn.com/t/font_1634400_9yg8f5s278.woff') format('woff'),
|
||||
url('//at.alicdn.com/t/font_1634400_9yg8f5s278.ttf') format('truetype'),
|
||||
url('//at.alicdn.com/t/font_1634400_9yg8f5s278.svg#iconfont') format('svg');
|
||||
}
|
||||
.iconfont {
|
||||
font-family:"iconfont" !important;
|
||||
font-size:16px;font-style:normal;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-webkit-text-stroke-width: 0.2px;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
/* header */
|
||||
header {
|
||||
width: 100%;
|
||||
/*height: 88px;*/
|
||||
line-height: 48px;
|
||||
font-size: 16px;
|
||||
background-color: #0078D4;
|
||||
}
|
||||
header nav {
|
||||
margin: 0 auto;
|
||||
padding: 0 10px;
|
||||
height: 48px;
|
||||
color: #FFF;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
header nav a {
|
||||
color: #FFF;
|
||||
font-weight: 600;
|
||||
}
|
||||
header nav .lang .language { outline: none; }
|
||||
header .control {
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
background-color: #f4f4f4;
|
||||
}
|
||||
header .control .control-item {
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
/* main */
|
||||
main {
|
||||
position: relative;
|
||||
height: 100%;
|
||||
}
|
||||
main .scroll {
|
||||
overflow-y: scroll;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
}
|
||||
main .main-item-list {
|
||||
padding-left: 32px;
|
||||
padding-right: 32px;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
font-size: 12px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
main .main-title h1 {
|
||||
margin: 0;
|
||||
padding: 32px;
|
||||
font-size: 20px;
|
||||
font-weight: 100;
|
||||
}
|
||||
main .main-items:hover {
|
||||
background-color: #F4F4F4;
|
||||
}
|
||||
main .main-items:hover .main-items-radio {
|
||||
display: inline-block!important;
|
||||
}
|
||||
main .main-item-list .inner-container {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
width: 100%;
|
||||
height: 32px;
|
||||
border-bottom: 1px solid #FFF;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
main .main-item-list .inner-container > div {
|
||||
padding-left: 12px;
|
||||
padding-right: 8px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
main .main-item-list .main-item-title {
|
||||
border-bottom: 1px solid #EAEAEA;
|
||||
}
|
||||
main .main-item-list .main-items-radio-box {
|
||||
width: 48px;
|
||||
height: 32px;
|
||||
line-height: 40px;
|
||||
text-align: center;
|
||||
}
|
||||
main .main-item-list .main-items-radio-box .main-items-radio {
|
||||
display: none;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
main .main-item-list .main-items-radio-box .main-items-radio[currstatus=true] {
|
||||
display: block;
|
||||
}
|
||||
main .main-item-list .main-items-icon {
|
||||
min-width: 38px;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
text-align: center;
|
||||
}
|
||||
main .main-item-title .main-items-icon {
|
||||
height: 32px!important;
|
||||
line-height: 9px!important;
|
||||
}
|
||||
main .main-item-title .main-items-icon:hover,
|
||||
main .main-item-list .main-items-displayName:hover,
|
||||
main .main-item-list .main-items-dateModified:hover,
|
||||
main .main-item-list .main-items-size:hover {
|
||||
background-color: #EAEAEA;
|
||||
}
|
||||
main .main-item-list .main-items-icon .iconfont {
|
||||
font-size: 20px;
|
||||
}
|
||||
main .main-item-list .main-items-icon img {
|
||||
display: inline-block;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
main .main-items {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
border-bottom: 1px solid #F4F4F4;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
main .main-item-list .main-items-displayName,
|
||||
main .main-item-list .main-items-fileName {
|
||||
width: 520px;
|
||||
}
|
||||
main .main-item-list .main-items-dateModified,
|
||||
main .main-item-list .main-items-dateTime {
|
||||
width: 250px;
|
||||
}
|
||||
main .main-item-list .main-items-size,
|
||||
main .main-item-list .main-items-fileSize {
|
||||
width: 180px;
|
||||
}
|
||||
main .main-item-list .main-items-radio-box,
|
||||
main .main-item-list .main-items-icon,
|
||||
main .main-item-list .main-items-fileName,
|
||||
main .main-item-list .main-items-dateTime,
|
||||
main .main-item-list .main-items-fileSize {
|
||||
padding: 11px 8px 11px 12px;
|
||||
height: 42px;
|
||||
line-height: 22px;
|
||||
font-family: "Microsoft Yahei UI", Verdana, Simsun, "Segoe UI", -apple-system, BlinkMacSystemFont, "Roboto", "Helvetica Neue", sans-serif;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
box-sizing: border-box;
|
||||
/*overflow: hidden;*/
|
||||
}
|
||||
main .main-item-list .main-items-fileName a {
|
||||
color: inherit;
|
||||
}
|
||||
main .main-item-list .main-items-fileName a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.more-disk{
|
||||
vertical-align: middle;
|
||||
overflow: hidden;
|
||||
text-overflow:ellipsis;
|
||||
white-space: nowrap;
|
||||
display: inline-block;
|
||||
max-width: 100px;
|
||||
}
|
||||
.more-disk div{
|
||||
list-style:none;
|
||||
position:absolute;
|
||||
display:none;background:#ffffff;border-radius:5px;margin:0 0 0 -10px;/*padding:0 7px;*/color:#205D67;z-index:1;
|
||||
box-shadow: 0 0.5em 3em rgba(161,177,204,.4);
|
||||
}
|
||||
.more-disk:hover div{display:block}
|
||||
.more-disk div li{line-height:normal;padding: 3px 10px;}
|
||||
.more-disk div li a{text-decoration: none; color:rgba(0,0,0,.3);}
|
||||
.more-disk div li a:hover{color:rgba(0,0,0,.87);}
|
||||
.more-disk div li a[now]{color:rgba(0,0,0,1);}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav class="container">
|
||||
<div class="title pull-left">
|
||||
<a href="<!--base_path-->"><!--Sitename--></a>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<!--LoginStart-->
|
||||
<a class="pull-left" onclick="/*login();*/"><!--constStr@Login--></a>
|
||||
<!--LoginEnd-->
|
||||
<!--AdminStart-->
|
||||
<a class="pull-left" onclick="logout();"><!--constStr@Logout--></a>
|
||||
<!--AdminEnd-->
|
||||
|
|
||||
<div class="pull-right lang">
|
||||
<select name="language" id="language" class="language" onchange="changelanguage(this.options[this.options.selectedIndex].value)">
|
||||
<option value="">Language</option>
|
||||
<!--SelectLanguageStart-->
|
||||
<option value="<!--SelectLanguageKey-->" <!--SelectLanguageSelected-->><!--SelectLanguageValue--></option>
|
||||
<!--SelectLanguageEnd-->
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<!--AdminStart-->
|
||||
<div class="control">
|
||||
<div class="container">
|
||||
<div class="control-item">
|
||||
<button class="control-items">
|
||||
<i class="iconfont control-items-icon"></i>
|
||||
<span class="control-items-content"><!--constStr@Create--></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--AdminEnd-->
|
||||
</header>
|
||||
<main>
|
||||
<!--ListStart-->
|
||||
<div class="scroll">
|
||||
<div class="container">
|
||||
<div class="main-title">
|
||||
<h1 class="main-title-path">
|
||||
<a href="<!--base_path-->"><!--constStr@Home--></a>
|
||||
<!--DiskPathArrayStart-->
|
||||
>
|
||||
<a href="<!--PathArrayLink-->"><!--PathArrayName--></a>
|
||||
<!--DiskPathArrayEnd-->
|
||||
</h1>
|
||||
</div>
|
||||
<!--IsFileStart-->
|
||||
<div class="main-item-list">
|
||||
<div class="main-items main-item-title">
|
||||
<div class="inner-container">
|
||||
<div>
|
||||
<div style="margin: 24px">
|
||||
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><!--FileEncodeUrl--></textarea>
|
||||
<a href="<!--FileUrl-->"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon> <!--constStr@Download--></a>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<!--IsimgFileStart-->
|
||||
<img src="<!--FileDownUrl-->" alt="<!--FileName-->" onload="if (this.offsetWidth>document.getElementById('url').offsetWidth) this.style.width='100%';" />
|
||||
<!--IsimgFileEnd-->
|
||||
<!--IsvideoFileStart-->
|
||||
<div id="video-a0"></div>
|
||||
<!--IsvideoFileEnd-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--IsFileEnd-->
|
||||
<!--IsFolderStart-->
|
||||
<div class="main-item-list">
|
||||
<div class="main-items main-item-title">
|
||||
<div class="inner-container">
|
||||
<!--AdminStart-->
|
||||
<div class="main-items-radio-box">
|
||||
<!-- <input class="main-items-radio main-items-check-all" type="radio" name="" id=""> -->
|
||||
</div>
|
||||
<!--AdminEnd-->
|
||||
<div class="main-items-icon">
|
||||
<i class="iconfont"></i>
|
||||
</div>
|
||||
<div class="main-items-displayName"><!--constStr@File--></div>
|
||||
<div class="main-items-dateModified"><!--constStr@EditTime--></div>
|
||||
<div class="main-items-size"><!--constStr@Size--></div>
|
||||
</div>
|
||||
</div>
|
||||
<!--FolderListStart-->
|
||||
<div class="main-items">
|
||||
<!--AdminStart-->
|
||||
<div class="main-items-radio-box">
|
||||
<input class="main-items-radio" type="radio" checked name="file" id="">
|
||||
</div>
|
||||
<!--AdminEnd-->
|
||||
<div class="main-items-icon">
|
||||
<img src="https://spoprod-a.akamaihd.net/files/fabric/assets/item-types-fluent/20/folder.svg" alt="folder icon">
|
||||
</div>
|
||||
<div class="main-items-fileName">
|
||||
<a href="<!--FileEncodeReplaceUrl-->/"><!--FileEncodeReplaceName--></a>
|
||||
</div>
|
||||
<div class="main-items-dateTime" ><!--lastModifiedDateTime--></div>
|
||||
<div class="main-items-fileSize" ><!--size--></div>
|
||||
</div>
|
||||
<!--FolderListEnd-->
|
||||
<!--FileListStart-->
|
||||
<div class="main-items">
|
||||
<!--AdminStart-->
|
||||
<div class="main-items-radio-box">
|
||||
<input class="main-items-radio" type="radio" checked name="file" id="">
|
||||
</div>
|
||||
<!--AdminEnd-->
|
||||
<div class="main-items-icon">
|
||||
<i class="iconfont"></i>
|
||||
</div>
|
||||
<div class="main-items-fileName">
|
||||
<a href="<!--FileEncodeReplaceUrl-->?preview" target="_blank"><!--FileEncodeReplaceName--></a>
|
||||
</div>
|
||||
<div class="main-items-dateTime" ><!--lastModifiedDateTime--></div>
|
||||
<div class="main-items-fileSize" ><!--size--></div>
|
||||
</div>
|
||||
<!--FileListEnd-->
|
||||
</div>
|
||||
<!--IsFolderEnd-->
|
||||
</div>
|
||||
</div>
|
||||
<!--ListEnd-->
|
||||
</main>
|
||||
<footer>
|
||||
<!-- OneDrive程序 -->
|
||||
</footer>
|
||||
<div id="mask" class="mask" style="display:none;"></div>
|
||||
<!--LoginStart-->
|
||||
<div id="login_div" class="operatediv" style="display:none">
|
||||
<div style="margin:50px">
|
||||
<a onclick="operatediv_close('login')" class="operatediv_close"><!--constStr@Close--></a>
|
||||
<center>
|
||||
<form action="<!--IsPreview?-->admin" method="post">
|
||||
<input id="login_input" name="password1" type="password" placeholder="<!--constStr@InputPassword-->">
|
||||
<input type="submit" value="<!--constStr@Login-->">
|
||||
</form>
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
<!--LoginEnd-->
|
||||
<script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
|
||||
<script>
|
||||
window.onload = function ()
|
||||
{
|
||||
// 获取所有radios元素
|
||||
var allRadios = document.getElementsByClassName("main-items-radio");
|
||||
RegisterRadioClick(allRadios);
|
||||
}
|
||||
|
||||
// 为所有radio注册点击事件
|
||||
function RegisterRadioClick(radios)
|
||||
{
|
||||
if (radios != null)
|
||||
{
|
||||
var radio;
|
||||
for (var i = 0; i < radios.length ; i++)
|
||||
{
|
||||
// 获取单个radio元素
|
||||
radio = radios[i];
|
||||
// 为每个radio元素设置当前状态为:False
|
||||
//radio.setAttribute("currStatus", "false");
|
||||
// 页面刚加载后,取消因缓存的checked属性
|
||||
radio.checked = false;
|
||||
// 为页面中每个radio元素注册点击事件
|
||||
radio.onclick = function()
|
||||
{
|
||||
// 获取当前点击对象的自定义属性
|
||||
var currStatus = this.getAttribute("currStatus");
|
||||
AllRadioCurrentStatus2False(radios);
|
||||
if (currStatus === "true")
|
||||
{
|
||||
AllRadioCurrentStatus2False(radios);
|
||||
this.setAttribute("currStatus", false);
|
||||
this.checked = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setAttribute("currStatus", true);
|
||||
this.checked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 把页面里所有radio元素自定义属性变成为false
|
||||
// 不然会出现需要点击两次才会被选中
|
||||
function AllRadioCurrentStatus2False(radios)
|
||||
{
|
||||
for (var i = 0; i < radios.length; i++)
|
||||
{
|
||||
radios[i].setAttribute("currStatus", false);
|
||||
}
|
||||
}
|
||||
function changelanguage(str)
|
||||
{
|
||||
if (str=='Language') str = '';
|
||||
document.cookie='language='+str+'; path=/';
|
||||
location.href = location.href;
|
||||
}
|
||||
<!--ListStart-->
|
||||
/*var root = '<!--base_disk_path-->';
|
||||
function path_format(path) {
|
||||
path = '/' + path + '/';
|
||||
while (path.indexOf('//') !== -1) {
|
||||
path = path.replace('//', '/')
|
||||
}
|
||||
return path
|
||||
}
|
||||
document.querySelectorAll('.main-title-path').forEach(function (e) {
|
||||
var path = e.innerText;
|
||||
if (path.substr(path.length-1)=='/') path = path.substr(0, path.length-1);
|
||||
var paths = path.split('/');
|
||||
e.innerHTML = '<a href="' + root + '"><!--constStr@Home--></a> > ';
|
||||
if (paths <= 2) return;
|
||||
for (var i = 1; i < paths.length - 1; i++) {
|
||||
var to = path_format(root + paths.slice(0, i + 1).join('/'));
|
||||
e.innerHTML += '<a href="' + to + '">' + paths[i] + '</a> > '
|
||||
}
|
||||
e.innerHTML += paths[paths.length - 1];
|
||||
e.innerHTML = e.innerHTML.replace(/\s\/\s$/, '')
|
||||
});*/
|
||||
<!--IsFileStart-->
|
||||
var $url = document.getElementById('url');
|
||||
if ($url) {
|
||||
$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
|
||||
$url.style.height = $url.scrollHeight + 'px';
|
||||
}
|
||||
<!--IsvideoFileStart-->
|
||||
function loadResources(type, src, callback) {
|
||||
let script = document.createElement(type);
|
||||
let loaded = false;
|
||||
if (typeof callback === 'function') {
|
||||
script.onload = script.onreadystatechange = () => {
|
||||
if (!loaded && (!script.readyState || /loaded|complete/.test(script.readyState))) {
|
||||
script.onload = script.onreadystatechange = null;
|
||||
loaded = true;
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (type === 'link') {
|
||||
script.href = src;
|
||||
script.rel = 'stylesheet';
|
||||
} else {
|
||||
script.src = src;
|
||||
}
|
||||
document.getElementsByTagName('head')[0].appendChild(script);
|
||||
}
|
||||
function addVideos(videos) {
|
||||
let host = 'https://s0.pstatp.com/cdn/expire-1-M';
|
||||
let unloadedResourceCount = 4;
|
||||
let callback = (() => {
|
||||
return () => {
|
||||
if (!--unloadedResourceCount) {
|
||||
createDplayers(videos);
|
||||
}
|
||||
};
|
||||
})(unloadedResourceCount, videos);
|
||||
loadResources(
|
||||
'link',
|
||||
host + '/dplayer/1.25.0/DPlayer.min.css',
|
||||
callback
|
||||
);
|
||||
loadResources(
|
||||
'script',
|
||||
host + '/dplayer/1.25.0/DPlayer.min.js',
|
||||
callback
|
||||
);
|
||||
loadResources(
|
||||
'script',
|
||||
host + '/hls.js/0.12.4/hls.light.min.js',
|
||||
callback
|
||||
);
|
||||
loadResources(
|
||||
'script',
|
||||
host + '/flv.js/1.5.0/flv.min.js',
|
||||
callback
|
||||
);
|
||||
}
|
||||
function createDplayers(videos) {
|
||||
for (i = 0; i < videos.length; i++) {
|
||||
console.log(videos[i]);
|
||||
new DPlayer({
|
||||
container: document.getElementById('video-a' + i),
|
||||
screenshot: true,
|
||||
video: {
|
||||
url: videos[i]
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
addVideos(['<!--FileDownUrl-->']);
|
||||
<!--IsvideoFileEnd-->
|
||||
<!--IsFileEnd-->
|
||||
<!--ListEnd-->
|
||||
<!--AdminStart-->
|
||||
function logout() {
|
||||
document.cookie = "admin=; path=/";
|
||||
location.href = location.href;
|
||||
}
|
||||
<!--AdminEnd-->
|
||||
<!--LoginStart-->
|
||||
function login() {
|
||||
document.getElementById('mask').style.display='';
|
||||
//document.getElementById('mask').style.width=document.documentElement.scrollWidth+'px';
|
||||
document.getElementById('mask').style.height=document.documentElement.scrollHeight<window.innerHeight?window.innerHeight:document.documentElement.scrollHeight+'px';
|
||||
document.getElementById('login_div').style.display='';
|
||||
document.getElementById('login_div').style.left=(document.body.clientWidth-document.getElementById('login_div').offsetWidth)/2 +'px';
|
||||
document.getElementById('login_div').style.top=(window.innerHeight-document.getElementById('login_div').offsetHeight)/2+document.body.scrollTop +'px';
|
||||
document.getElementById('login_input').focus();
|
||||
}
|
||||
<!--LoginEnd-->
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title><!--Sitename--> /<!--PathArrayStart--><!--PathArrayName-->/<!--PathArrayEnd--></title>
|
||||
</head>
|
||||
<body>
|
||||
<h1><!--Sitename--> /<!--DiskPathArrayStart--><!--PathArrayName-->/<!--DiskPathArrayEnd--></h1>
|
||||
<table>
|
||||
<tr><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr>
|
||||
<tr><th colspan="4"><hr></th></tr>
|
||||
<!--BackArrowStart-->
|
||||
<tr><td><a href="<!--BackArrowUrl-->">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr>
|
||||
<!--BackArrowEnd-->
|
||||
<!--ListStart-->
|
||||
<!--IsFolderStart-->
|
||||
<!--FolderListStart-->
|
||||
<tr><td><a href="<!--FileEncodeReplaceUrl-->/"><!--FileEncodeReplaceName-->/</a></td><td align="right"><!--lastModifiedDateTime--></td><td align="right"> - </td><td> </td></tr>
|
||||
<!--FolderListEnd-->
|
||||
<!--FileListStart-->
|
||||
<tr><td><a href="<!--FileEncodeReplaceUrl-->"><!--FileEncodeReplaceName--></a></td><td align="right"><!--lastModifiedDateTime--></td><td align="right"><!--size--></td><td> </td></tr>
|
||||
<!--FileListEnd-->
|
||||
<!--IsFolderEnd-->
|
||||
<!--ListEnd-->
|
||||
<tr><th colspan="4"><hr></th></tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,24 @@
|
|||
<html>
|
||||
<head>
|
||||
<title><!--Sitename--> - /<!--PathArrayStart--><!--PathArrayName-->/<!--PathArrayEnd--></title>
|
||||
</head>
|
||||
<body>
|
||||
<H1><!--Sitename--> - /<!--DiskPathArrayStart--><!--PathArrayName-->/<!--DiskPathArrayEnd--></H1><hr>
|
||||
<table>
|
||||
<!--BackArrowStart-->
|
||||
<tr><td colspan="3"><A HREF="<!--BackArrowUrl-->">[To Parent Directory]</A></td></tr>
|
||||
<!--BackArrowEnd-->
|
||||
<!--ListStart-->
|
||||
<!--IsFolderStart-->
|
||||
<!--FolderListStart-->
|
||||
<tr><td><!--lastModifiedDateTime--></td><td align="right" width="20%"><dir></td><td><A HREF="<!--FileEncodeReplaceUrl-->/"><!--FileEncodeReplaceName--></A></td></tr>
|
||||
<!--FolderListEnd-->
|
||||
<!--FileListStart-->
|
||||
<tr><td><!--lastModifiedDateTime--></td><td align="right" width="20%"><!--size--></td><td><A HREF="<!--FileEncodeReplaceUrl-->"><!--FileEncodeReplaceName--></A></td></tr>
|
||||
<!--FileListEnd-->
|
||||
<!--IsFolderEnd-->
|
||||
<!--ListEnd-->
|
||||
</table>
|
||||
<hr>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,377 @@
|
|||
<!--IconValuesStart-->
|
||||
{
|
||||
"music":"audiotrack",
|
||||
"video":"ondemand_video",
|
||||
"img":"image",
|
||||
"default":"insert_drive_file"
|
||||
}
|
||||
<!--IconValuesEnd-->
|
||||
<!DOCTYPE html>
|
||||
<html lang="<!--constStr@language-->">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
|
||||
<title><!--Title--></title>
|
||||
<link rel="icon" href="<!--base_path-->favicon.ico" type="image/x-icon">
|
||||
<link rel="shortcut icon" href="<!--base_path-->favicon.ico" type="image/x-icon">
|
||||
<link rel="stylesheet" href="//cdnjs.loli.net/ajax/libs/mdui/0.4.1/css/mdui.css">
|
||||
<style>
|
||||
body{background-color:#f2f5fa;padding-bottom:60px;<!--BackgroundStart-->background-position:center bottom;background-repeat:no-repeat;background-size:cover;background-attachment:fixed;background-image:url("<!--BackgroundUrl-->");<!--BackgroundEnd-->}
|
||||
.nexmoe-item{margin:20px -8px 0!important;padding:15px!important;border-radius:5px;background-color:#fff;-webkit-box-shadow:0 .5em 3em rgba(161,177,204,.4);box-shadow:0 .5em 3em rgba(161,177,204,.4);background-color:#fff}
|
||||
.mdui-img-fluid,.mdui-video-fluid{border-radius:5px;border:1px solid #eee}
|
||||
.mdui-list{padding:0}
|
||||
.mdui-list-item{margin:0!important;border-radius:5px;padding:0 10px 0 5px!important;border:1px solid #eee;margin-bottom:10px!important}
|
||||
.mdui-list-item:last-child{margin-bottom:0!important}
|
||||
.mdui-list-item:first-child{border:none}
|
||||
.mdui-toolbar{width:auto;margin-top:60px!important}
|
||||
.mdui-appbar .mdui-toolbar{height:56px;font-size:16px}
|
||||
.mdui-toolbar>*{padding:0 6px;margin:0 2px;}
|
||||
.mdui-toolbar>.mdui-typo-headline{padding:0 16px 0 0}
|
||||
.mdui-toolbar>i{padding:0}
|
||||
.mdui-toolbar>a{padding:0 16px;line-height:30px;border-radius:30px;border:1px solid #eee;opacity:.87}
|
||||
.mdui-toolbar>a:hover,a.mdui-typo-headline,a.active{opacity:1}
|
||||
.mdui-container{max-width:980px}
|
||||
.mdui-list>.th{background-color:initial}
|
||||
.mdui-list-item>a{width:100%;line-height:48px}
|
||||
.mdui-toolbar>a:last-child{opacity:1;background-color:#1e89f2;color:#ffff}
|
||||
.more-disk{display: inline-block;max-width: 100px;}
|
||||
.more-disk div{
|
||||
list-style:none;
|
||||
position:absolute;display:none;background:#ffffff;border-radius:5px;margin:0 0 0 -10px;/*padding:0 7px;*/color:#205D67;z-index:1;
|
||||
box-shadow: 0 0.5em 3em rgba(161,177,204,.4);
|
||||
}
|
||||
.more-disk:hover div{display:block}
|
||||
.more-disk div li{line-height:normal;padding: 3px 10px;}
|
||||
.more-disk div li a{text-decoration: none; color:rgba(0,0,0,.3);}
|
||||
.more-disk div li a:hover{color:rgba(0,0,0,.87);}
|
||||
.more-disk div li a[now]{color:rgba(0,0,0,1);}
|
||||
@media screen and (max-width:980px){
|
||||
.mdui-list-item .mdui-text-right{display:none}
|
||||
.mdui-container{width:100%!important;margin:0}
|
||||
/*.mdui-toolbar>*{display:none}*/
|
||||
.mdui-toolbar>a:last-child,.mdui-toolbar>.mdui-typo-headline,.mdui-toolbar>i:first-child{display:block}
|
||||
}
|
||||
</style>
|
||||
<!--customCss-->
|
||||
<script src="//cdnjs.loli.net/ajax/libs/mdui/0.4.1/js/mdui.min.js"></script>
|
||||
</head>
|
||||
<body class="mdui-theme-primary-blue-grey mdui-theme-accent-blue">
|
||||
<div class="mdui-container">
|
||||
<div class="mdui-container-fluid">
|
||||
<div class="mdui-toolbar nexmoe-item" id="toolbar">
|
||||
<a href="<!--base_path-->"><!--Sitename--></a>
|
||||
<!--MultiDiskAreaStart-->
|
||||
<i class="mdui-icon material-icons mdui-icon-dark" style="margin:0;">chevron_right</i>
|
||||
<div class="more-disk">
|
||||
<span><!--DiskNameNow--></span>
|
||||
<div>
|
||||
<!--MultiDisksStart-->
|
||||
<li><a href="<!--MultiDisksUrl-->" <!--MultiDisksNow-->><!--MultiDisksName--></a></li>
|
||||
<!--MultiDisksEnd-->
|
||||
</div>
|
||||
</div>
|
||||
<!--MultiDiskAreaEnd-->
|
||||
<!--PathArrayStart-->
|
||||
<i class="mdui-icon material-icons mdui-icon-dark" style="margin:0;">chevron_right</i>
|
||||
<a href="<!--PathArrayLink-->"><!--PathArrayName--></a>
|
||||
<!--PathArrayEnd-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--ListStart-->
|
||||
<div class="mdui-container-fluid">
|
||||
<!--EncryptedStart-->
|
||||
<div class="mdui-col-md-6 mdui-col-offset-md-3">
|
||||
<!--<center><h1 class="mdui-typo-display-2-opacity">这是一个受保护的文件夹,您需要提供访问密码才能查看。</h1></center>-->
|
||||
<form action="" method="post">
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<i class="mdui-icon material-icons">https</i>
|
||||
<label class="mdui-textfield-label"><!--constStr@InputPassword--></label>
|
||||
<input name="password1" class="mdui-textfield-input" type="password"/>
|
||||
</div>
|
||||
<br>
|
||||
<button type="submit" class="mdui-center mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme">
|
||||
<i class="mdui-icon material-icons">fingerprint</i>
|
||||
<!--constStr@Submit-->
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<!--EncryptedEnd-->
|
||||
<!--GuestUploadStart-->
|
||||
<!--
|
||||
<div class="nexmoe-item" style="padding: 100px!important;">
|
||||
<div class="mdui-typo-display-3-opacity" style="text-align:center;">OneImages</div>
|
||||
<form action="" method="post" enctype="multipart/form-data">
|
||||
<input class="mdui-center" type="file" style="margin: 50px 0;" name="file" />
|
||||
<div class="mdui-row-xs-3">
|
||||
<div class="mdui-col"></div>
|
||||
<div class="mdui-col">
|
||||
<button class="mdui-btn mdui-btn-block mdui-color-theme-accent mdui-ripple"><!--constStr@Upload--></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
-->
|
||||
<!--GuestUploadEnd-->
|
||||
<!--HeadomfStart-->
|
||||
<div class="mdui-typo mdui-shadow-3" style="padding: 20px;margin: 20px 0">
|
||||
<!--HeadomfContent-->
|
||||
</div>
|
||||
<!--HeadomfEnd-->
|
||||
<!--HeadmdStart-->
|
||||
<div class="mdui-typo mdui-shadow-3 markdown" style="padding: 20px;margin: 20px 0">
|
||||
<!--HeadmdContent-->
|
||||
</div>
|
||||
<!--HeadmdEnd-->
|
||||
<!--IsFileStart-->
|
||||
<!--IsimgFileStart-->
|
||||
<div class="nexmoe-item">
|
||||
<img class="mdui-img-fluid mdui-center" src="<!--FileDownUrl-->"/>
|
||||
</div>
|
||||
<!--IsimgFileEnd-->
|
||||
<!--IstxtFileStart-->
|
||||
<div class="nexmoe-item">
|
||||
<pre id="editor" style="white-space: pre-wrap;"><!--TxtContent--></pre>
|
||||
</div>
|
||||
<!--IstxtFileEnd-->
|
||||
<!--IsmusicFileStart-->
|
||||
<div class="nexmoe-item">
|
||||
<audio class="mdui-center" src="<!--FileDownUrl-->" controls autoplay style="width: 100%;" ></audio>
|
||||
</div>
|
||||
<!--IsmusicFileEnd-->
|
||||
<!--IsofficeFileStart-->
|
||||
<div class="nexmoe-item">
|
||||
<iframe id="office-a" src="https://view.officeapps.live.com/op/view.aspx?src=<!--FileEncodeDownUrl-->" style="width: 100%;height: 800px" frameborder="0"></iframe>
|
||||
</div>
|
||||
<!--IsofficeFileEnd-->
|
||||
<!--IsvideoFileStart-->
|
||||
<link class="dplayer-css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.js"></script>
|
||||
<div class="nexmoe-item">
|
||||
<div class="mdui-center" id="dplayer"></div>
|
||||
</div>
|
||||
<script>
|
||||
const dp = new DPlayer({
|
||||
container: document.getElementById('dplayer'),
|
||||
lang:'zh-cn',
|
||||
video: {
|
||||
url: '<!--FileDownUrl-->',
|
||||
type: 'auto'
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<!--IsvideoFileEnd-->
|
||||
<!--IsOtherFileStart-->
|
||||
<div class="nexmoe-item"><!--constStr@FileNotSupport--></div>
|
||||
<!--IsOtherFileEnd-->
|
||||
<a href="<!--FileEncodeReplaceUrl-->" class="mdui-fab mdui-fab-fixed mdui-ripple mdui-color-theme-accent"><i class="mdui-icon material-icons">file_download</i></a>
|
||||
<!--IsFileEnd-->
|
||||
<!--IsFolderStart-->
|
||||
<style>
|
||||
.thumb .th{
|
||||
display: none;
|
||||
}
|
||||
.thumb .mdui-text-right{
|
||||
display: none;
|
||||
}
|
||||
.thumb .mdui-list-item a ,.thumb .mdui-list-item {
|
||||
width:217px;
|
||||
height: 230px;
|
||||
float: left;
|
||||
margin: 10px 10px !important;
|
||||
}
|
||||
.thumb .mdui-col-xs-12,.thumb .mdui-col-sm-7{
|
||||
width:100% !important;
|
||||
height:230px;
|
||||
}
|
||||
.thumb .mdui-list-item .mdui-icon{
|
||||
font-size:100px;
|
||||
display: block;
|
||||
margin-top: 40px;
|
||||
color: #7ab5ef;
|
||||
}
|
||||
.thumb .mdui-list-item span{
|
||||
float: left;
|
||||
display: block;
|
||||
text-align: center;
|
||||
width:100%;
|
||||
position: absolute;
|
||||
top: 180px;
|
||||
}
|
||||
</style>
|
||||
<div class="nexmoe-item">
|
||||
|
||||
<div class="mdui-row">
|
||||
<ul class="mdui-list">
|
||||
<li class="mdui-list-item th">
|
||||
<div class="mdui-col-xs-12 mdui-col-sm-7"><!--constStr@File--> <i class="mdui-icon material-icons icon-sort" data-sort="name" data-order="downward">expand_more</i></div>
|
||||
<div class="mdui-col-sm-3 mdui-text-right"><!--constStr@EditTime--> <i class="mdui-icon material-icons icon-sort" data-sort="date" data-order="downward">expand_more</i></div>
|
||||
<div class="mdui-col-sm-2 mdui-text-right"><!--constStr@Size--> <i class="mdui-icon material-icons icon-sort" data-sort="size" data-order="downward">expand_more</i></div>
|
||||
</li>
|
||||
<!--BackArrowStart-->
|
||||
<li class="mdui-list-item mdui-ripple">
|
||||
<a href="<!--BackArrowUrl-->">
|
||||
<div class="mdui-col-xs-12 mdui-col-sm-7">
|
||||
<i class="mdui-icon material-icons">arrow_upward</i>
|
||||
..
|
||||
</div>
|
||||
<div class="mdui-col-sm-3 mdui-text-right"></div>
|
||||
<div class="mdui-col-sm-2 mdui-text-right"></div>
|
||||
</a>
|
||||
</li>
|
||||
<!--BackArrowEnd-->
|
||||
|
||||
<!--FolderListStart-->
|
||||
<li class="mdui-list-item mdui-ripple">
|
||||
<a href="<!--FileEncodeReplaceUrl-->/">
|
||||
<div class="mdui-col-xs-12 mdui-col-sm-7 mdui-text-truncate">
|
||||
<i class="mdui-icon material-icons">folder_open</i>
|
||||
<span><!--FileEncodeReplaceName--></span>
|
||||
</div>
|
||||
<div class="mdui-col-sm-3 mdui-text-right"><!--lastModifiedDateTime--></div>
|
||||
<div class="mdui-col-sm-2 mdui-text-right"><!--size--></div>
|
||||
</a>
|
||||
</li>
|
||||
<!--FolderListEnd-->
|
||||
<!--FileListStart-->
|
||||
<li class="mdui-list-item file mdui-ripple">
|
||||
<a href="<!--FileEncodeReplaceUrl-->?preview" target="_blank">
|
||||
<div class="mdui-col-xs-12 mdui-col-sm-7 mdui-text-truncate">
|
||||
<i class="mdui-icon material-icons"><!--IconValue--></i>
|
||||
<span><!--FileEncodeReplaceName--></span>
|
||||
</div>
|
||||
<div class="mdui-col-sm-3 mdui-text-right"><!--lastModifiedDateTime--></div>
|
||||
<div class="mdui-col-sm-2 mdui-text-right"><!--size--></div>
|
||||
</a>
|
||||
</li>
|
||||
<!--FileListEnd-->
|
||||
|
||||
<!--MorePageStart-->
|
||||
<form action="" method="POST" id="nextpageform">
|
||||
<input type="hidden" id="pagenum" name="pagenum" value="">
|
||||
<li class="mdui-list-item th">
|
||||
<div class="mdui-col-sm-6 mdui-left mdui-text-left">
|
||||
<!--PrePageStart-->
|
||||
<a onclick="nextpage(<!--PrePageNum-->);" class="mdui-btn mdui-btn-raised"><!--constStr@PrePage--></a>
|
||||
<!--PrePageEnd-->
|
||||
<!--NextPageStart-->
|
||||
<a onclick="nextpage(<!--NextPageNum-->);" class="mdui-btn mdui-btn-raised"><!--constStr@NextPage--></a>
|
||||
<!--NextPageEnd-->
|
||||
</div>
|
||||
<div class="mdui-col-sm-6 mdui-right mdui-text-right">
|
||||
<div class="mdui-right mdui-text-right"><span class="mdui-chip-title">Page: <!--MorePageListStart--><!--MorePageListEnd--><!--MorePageListNowStart--><!--PageNum--><!--MorePageListNowEnd-->/<!--MaxPageNum--></span></div>
|
||||
</div>
|
||||
</li>
|
||||
</form>
|
||||
<!--MorePageEnd-->
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<!--ReadmemdStart-->
|
||||
<div class="mdui-typo mdui-shadow-3 markdown" style="padding: 20px;margin: 20px 0">
|
||||
<!--ReadmemdContent-->
|
||||
</div>
|
||||
<!--ReadmemdEnd-->
|
||||
<!--FootomfStart-->
|
||||
<div class="mdui-typo mdui-shadow-3" style="padding: 20px;margin: 20px 0">
|
||||
<!--FootomfContent-->
|
||||
</div>
|
||||
<!--FootomfEnd-->
|
||||
</div>
|
||||
<!--ShowThumbnailsStart-->
|
||||
<a href="javascript:thumb();" class="mdui-fab mdui-fab-fixed mdui-ripple mdui-color-theme-accent"><i class="mdui-icon material-icons">format_list_bulleted</i></a>
|
||||
<!--ShowThumbnailsEnd-->
|
||||
<!--IsFolderEnd-->
|
||||
<!--ListEnd-->
|
||||
<!--MdRequireStart--><link rel="stylesheet" href="//unpkg.zhimg.com/github-markdown-css@3.0.1/github-markdown.css">
|
||||
<script type="text/javascript" src="//unpkg.zhimg.com/marked@0.6.2/marked.min.js"></script><!--MdRequireEnd-->
|
||||
<script>
|
||||
<!--MorePageStart-->
|
||||
function nextpage(num) {
|
||||
document.getElementById('pagenum').value=num;
|
||||
document.getElementById('nextpageform').submit();
|
||||
}
|
||||
<!--MorePageEnd-->
|
||||
$ = mdui.JQ;
|
||||
$.fn.extend({
|
||||
sortElements: function (comparator, getSortable) {
|
||||
getSortable = getSortable || function () { return this; };
|
||||
var placements = this.map(function () {
|
||||
var sortElement = getSortable.call(this),
|
||||
parentNode = sortElement.parentNode,
|
||||
nextSibling = parentNode.insertBefore(
|
||||
document.createTextNode(''),
|
||||
sortElement.nextSibling
|
||||
);
|
||||
return function () {
|
||||
parentNode.insertBefore(this, nextSibling);
|
||||
parentNode.removeChild(nextSibling);
|
||||
};
|
||||
});
|
||||
return [].sort.call(this, comparator).each(function (i) {
|
||||
placements[i].call(getSortable.call(this));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function downall() {
|
||||
let dl_link_list = Array.from(document.querySelectorAll("li a"))
|
||||
.map(x => x.href) // 所有list中的链接
|
||||
.filter(x => x.slice(-1) != "/"); // 筛选出非文件夹的文件下载链接
|
||||
let blob = new Blob([dl_link_list.join("\r\n")], {
|
||||
type: 'text/plain'
|
||||
}); // 构造Blog对象
|
||||
let a = document.createElement('a'); // 伪造一个a对象
|
||||
a.href = window.URL.createObjectURL(blob); // 构造href属性为Blob对象生成的链接
|
||||
a.download = "folder_download_link.txt"; // 文件名称,你可以根据你的需要构造
|
||||
a.click() // 模拟点击
|
||||
a.remove();
|
||||
}
|
||||
<!--ShowThumbnailsStart-->
|
||||
function thumb(){
|
||||
if($('.mdui-fab i').text() == "apps"){
|
||||
$('.mdui-fab i').text("format_list_bulleted");
|
||||
$('.nexmoe-item').removeClass('thumb');
|
||||
$('.nexmoe-item .mdui-icon').show();
|
||||
$('.nexmoe-item .mdui-list-item').css("background","");
|
||||
}else{
|
||||
$('.mdui-fab i').text("apps");
|
||||
$('.nexmoe-item').addClass('thumb');
|
||||
$('.mdui-col-xs-12 i.mdui-icon').each(function(){
|
||||
if($(this).text() == "image"){
|
||||
var thumbnails = $(this).parent().parent().attr('href');
|
||||
thumbnails = thumbnails.substr(0, thumbnails.length-8)+'?thumbnails&location';
|
||||
$(this).hide();
|
||||
$(this).parent().parent().parent().css("background","url("+thumbnails+") no-repeat center top");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
<!--ShowThumbnailsEnd-->
|
||||
$(function(){
|
||||
$('.file a').each(function(){
|
||||
$(this).on('click', function () {
|
||||
var form = $('<form target=_blank method=post></form>').attr('action', $(this).attr('href')).get(0);
|
||||
$(document.body).append(form);
|
||||
form.submit();
|
||||
$(form).remove();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
$('.icon-sort').on('click', function () {
|
||||
let sort_type = $(this).attr("data-sort"), sort_order = $(this).attr("data-order");
|
||||
let sort_order_to = (sort_order === "less") ? "more" : "less";
|
||||
$('li[data-sort]').sortElements(function (a, b) {
|
||||
let data_a = $(a).attr("data-sort-" + sort_type), data_b = $(b).attr("data-sort-" + sort_type);
|
||||
let rt = data_a.localeCompare(data_b, undefined, {numeric: true});
|
||||
return (sort_order === "more") ? 0-rt : rt;
|
||||
});
|
||||
$(this).attr("data-order", sort_order_to).text("expand_" + sort_order_to);
|
||||
});
|
||||
});
|
||||
document.querySelectorAll('.markdown').forEach(function (e) {
|
||||
e.innerHTML = marked(e.innerHTML);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,580 @@
|
|||
<!--IconValuesStart-->
|
||||
{
|
||||
"music":"audiotrack",
|
||||
"video":"ondemand_video",
|
||||
"img":"image",
|
||||
"default":"insert_drive_file"
|
||||
}
|
||||
<!--IconValuesEnd-->
|
||||
<!DOCTYPE html>
|
||||
<html lang="<!--constStr@language-->">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
|
||||
<title><!--Title--></title>
|
||||
<link rel="stylesheet" href="//cdnjs.loli.net/ajax/libs/mdui/0.4.1/css/mdui.css">
|
||||
<script src="//cdnjs.loli.net/ajax/libs/mdui/0.4.1/js/mdui.min.js"></script>
|
||||
<script src="//cdn.bootcss.com/jquery/1.12.3/jquery.min.js"></script>
|
||||
<script src="//cdn.staticfile.org/layer/2.3/layer.js"></script>
|
||||
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/glightbox/dist/css/glightbox.min.css">
|
||||
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css">
|
||||
<link rel="icon" href="<!--base_path-->favicon.ico" type="image/x-icon">
|
||||
<link rel="shortcut icon" href="<!--base_path-->favicon.ico" type="image/x-icon">
|
||||
|
||||
<style>
|
||||
body{<!--BackgroundStart-->background-repeat:no-repeat;background-size:cover;background-attachment:fixed;background-image:url("<!--BackgroundUrl-->");<!--BackgroundEnd-->}
|
||||
.mdui-appbar .mdui-toolbar{
|
||||
height:64px;
|
||||
font-size: 15px;
|
||||
}
|
||||
.mdui-toolbar>*{
|
||||
padding: 0 6px;
|
||||
margin: 0 2px;
|
||||
opacity:0.5;
|
||||
}
|
||||
.mdui-toolbar>.mdui-typo-headline{
|
||||
padding: 0 1px 0 0;
|
||||
}
|
||||
.mdui-toolbar>i{
|
||||
padding: 0;
|
||||
}
|
||||
.mdui-toolbar>a:hover,a.mdui-typo-headline,a.active{
|
||||
opacity:1;
|
||||
}
|
||||
.mdui-container{
|
||||
max-width:950px;
|
||||
}
|
||||
.mdui-list-item{
|
||||
-webkit-transition:none;
|
||||
transition:none;
|
||||
}
|
||||
.mdui-list>.th{
|
||||
background-color:initial;
|
||||
}
|
||||
.mdui-list-item>a{
|
||||
width:100%;
|
||||
line-height: 48px
|
||||
}
|
||||
.mdui-list-item{
|
||||
margin: 2px 0px;
|
||||
padding:0;
|
||||
}
|
||||
.mdui-toolbar>a:last-child{
|
||||
opacity:1;
|
||||
}
|
||||
#instantclick-bar {
|
||||
background: white;
|
||||
}
|
||||
.mdui-video-fluid {
|
||||
height: -webkit-fill-available;
|
||||
}
|
||||
.dplayer-video-wrap .dplayer-video {
|
||||
height: -webkit-fill-available !important;
|
||||
}
|
||||
.gslide iframe, .gslide video {
|
||||
height: -webkit-fill-available;
|
||||
}
|
||||
@media screen and (max-width:950px) {
|
||||
.mdui-list-item .mdui-text-right{
|
||||
display: none;
|
||||
}
|
||||
.mdui-container{
|
||||
width:100% !important;
|
||||
margin:0px;
|
||||
}
|
||||
.mdui-toolbar>*{
|
||||
display: none;
|
||||
}
|
||||
.mdui-toolbar>a:last-child,.mdui-toolbar>a:nth-last-of-type(2),.mdui-toolbar>.mdui-typo-headline,.mdui-toolbar>i:first-child,.mdui-toolbar-spacer{
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
.spec-col{padding:.9em;display:flex;align-items:center;white-space:nowrap;flex:1 50%;min-width:225px}
|
||||
.spec-type{font-size:1.35em}
|
||||
.spec-value{font-size:1.25em}
|
||||
.spec-text{float:left}
|
||||
.device-section{padding-top:30px}
|
||||
.spec-device-img{height:auto;height:340px;padding-bottom:30px}
|
||||
#dl-header{margin:0}
|
||||
#dl-section{padding-top:10px}
|
||||
#dl-latest{position:relative;top:50%;transform:translateY(-50%)}
|
||||
</style>
|
||||
</head>
|
||||
<body class=" mdui-appbar-with-toolbar mdui-theme-primary-indigo mdui-theme-accent-pink">
|
||||
<header class="mdui-appbar mdui-appbar-fixed mdui-color-theme mdui-appbar-inset">
|
||||
<div class="mdui-toolbar mdui-color-theme">
|
||||
<span class="mdui-btn mdui-typo-headline mdui-btn-icon mdui-ripple mdui-ripple-white" mdui-drawer="{target: '#main-drawer', swipe: true}" mdui-tooltip="{content: '菜单'}"><i class="mdui-icon material-icons">menu</i></span>
|
||||
<a href="<!--base_path-->" class="mdui-typo-headline"><!--Sitename--></a>
|
||||
<!--PathArrayStart-->
|
||||
<i class="mdui-icon material-icons mdui-icon-dark" style="margin:0;">chevron_right</i>
|
||||
<a href="<!--PathArrayLink-->"><!--PathArrayName--></a>
|
||||
<!--PathArrayEnd-->
|
||||
<div class="mdui-toolbar-spacer"></div>
|
||||
<!--ShowThumbnailsStart-->
|
||||
<a href="javascript:thumb();" id="thumb" class="mdui-btn mdui-btn-icon" mdui-tooltip="{content: '切换显示'}"><i class="mdui-icon material-icons">format_list_bulleted</i></a>
|
||||
<!--ShowThumbnailsEnd-->
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="mdui-drawer mdui-drawer-close mdui-color-indigo-50" id="main-drawer">
|
||||
<div class="mdui-grid-tile">
|
||||
<!--<a><img src="//image.suning.cn/uimg/ZR/share_order/158562104413864293.jpg"/></a>-->
|
||||
<div class="mdui-grid-tile-actions mdui-grid-tile-actions-gradient">
|
||||
<div class="mdui-grid-tile-text">
|
||||
<div class="mdui-grid-tile-title"><!--Title--></div>
|
||||
<div class="mdui-grid-tile-subtitle">OneManager</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mdui-list" mdui-collapse="{accordion: true}">
|
||||
<a href="<!--base_path-->" class="mdui-list-item mdui-ripple">
|
||||
<i class="mdui-list-item-icon mdui-icon material-icons">home</i>
|
||||
<div class="mdui-list-item-content"><!--constStr@Home--></div>
|
||||
</a>
|
||||
<!--MultiDiskAreaStart-->
|
||||
<!--MultiDisksStart-->
|
||||
<a href="<!--MultiDisksUrl-->" class="mdui-list-item mdui-ripple" <!--MultiDisksNow-->>
|
||||
<i class="mdui-list-item-icon mdui-icon material-icons">cloud</i>
|
||||
<div class="mdui-list-item-content"><!--MultiDisksName--></div>
|
||||
</a>
|
||||
<!--MultiDisksEnd-->
|
||||
<!--MultiDiskAreaEnd-->
|
||||
<a href="https://github.com/qkqpttgf/OneManager-php" class="mdui-list-item mdui-ripple">
|
||||
<i class="mdui-list-item-icon mdui-icon material-icons">code</i>
|
||||
<div class="mdui-list-item-content">Github</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--ListStart-->
|
||||
|
||||
<!--EncryptedStart-->
|
||||
<div class="mdui-col-md-6 mdui-col-offset-md-3">
|
||||
<!--<center><h1 class="mdui-typo-display-2-opacity">这是一个受保护的文件夹,您需要提供访问密码才能查看。</h1></center>-->
|
||||
<form action="" method="post">
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<i class="mdui-icon material-icons">https</i>
|
||||
<label class="mdui-textfield-label"><!--constStr@InputPassword--></label>
|
||||
<input name="password1" class="mdui-textfield-input" type="password"/>
|
||||
</div>
|
||||
<br>
|
||||
<button type="submit" class="mdui-center mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme">
|
||||
<i class="mdui-icon material-icons">fingerprint</i>
|
||||
<!--constStr@Submit-->
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<!--EncryptedEnd-->
|
||||
<!--GuestUploadStart-->
|
||||
<!--
|
||||
<div class="nexmoe-item" style="padding: 100px!important;">
|
||||
<div class="mdui-typo-display-3-opacity" style="text-align:center;">OneImages</div>
|
||||
<form action="" method="post" enctype="multipart/form-data">
|
||||
<input class="mdui-center" type="file" style="margin: 50px 0;" name="file" />
|
||||
<div class="mdui-row-xs-3">
|
||||
<div class="mdui-col"></div>
|
||||
<div class="mdui-col">
|
||||
<button class="mdui-btn mdui-btn-block mdui-color-theme-accent mdui-ripple"><!--constStr@Upload--></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
-->
|
||||
<!--GuestUploadEnd-->
|
||||
|
||||
<!--IsFileStart-->
|
||||
<div class="mdui-container-fluid">
|
||||
<!--IsimgFileStart-->
|
||||
<div class="nexmoe-item">
|
||||
<img class="mdui-img-fluid mdui-center" src="<!--FileDownUrl-->"/>
|
||||
</div>
|
||||
<!--IsimgFileEnd-->
|
||||
<!--IstxtFileStart-->
|
||||
<div class="nexmoe-item">
|
||||
<pre id="editor" style="white-space: pre-wrap;"><!--TxtContent--></pre>
|
||||
</div>
|
||||
<!--IstxtFileEnd-->
|
||||
<!--IsmusicFileStart-->
|
||||
<div class="nexmoe-item">
|
||||
<audio class="mdui-center" src="<!--FileDownUrl-->" controls autoplay style="width: 100%;" ></audio>
|
||||
</div>
|
||||
<!--IsmusicFileEnd-->
|
||||
<!--IsofficeFileStart-->
|
||||
<div class="nexmoe-item">
|
||||
<iframe id="office-a" src="https://view.officeapps.live.com/op/view.aspx?src=<!--FileEncodeDownUrl-->" style="width: 100%;height: 800px" frameborder="0"></iframe>
|
||||
</div>
|
||||
<!--IsofficeFileEnd-->
|
||||
<!--IsvideoFileStart-->
|
||||
<link class="dplayer-css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.js"></script>
|
||||
<div class="nexmoe-item">
|
||||
<div class="mdui-center" id="dplayer"></div>
|
||||
</div>
|
||||
<script>
|
||||
const dp = new DPlayer({
|
||||
container: document.getElementById('dplayer'),
|
||||
lang:'zh-cn',
|
||||
video: {
|
||||
url: '<!--FileDownUrl-->',
|
||||
type: 'auto'
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<!--IsvideoFileEnd-->
|
||||
<!--IsOtherFileStart-->
|
||||
<div class="nexmoe-item"><!--constStr@FileNotSupport--></div>
|
||||
<!--IsOtherFileEnd-->
|
||||
</div>
|
||||
<a href="<!--FileEncodeReplaceUrl-->" class="mdui-fab mdui-fab-fixed mdui-ripple mdui-color-theme-accent"><i class="mdui-icon material-icons">file_download</i></a>
|
||||
|
||||
<!--IsFileEnd-->
|
||||
|
||||
<!--IsFolderStart-->
|
||||
<div class="mdui-container">
|
||||
<div class="mdui-container-fluid"></div>
|
||||
<div class="mdui-container-fluid">
|
||||
<!--HeadomfStart-->
|
||||
<div class="mdui-typo mdui-shadow-3" style="padding: 20px;margin: 20px 0">
|
||||
<!--HeadomfContent-->
|
||||
</div>
|
||||
<!--HeadomfEnd-->
|
||||
<!--HeadmdStart-->
|
||||
<div class="mdui-typo mdui-shadow-3 markdown" style="padding: 20px;margin: 20px 0">
|
||||
<!--HeadmdContent-->
|
||||
</div>
|
||||
<!--HeadmdEnd-->
|
||||
<style>
|
||||
.thumb .th{
|
||||
display: none;
|
||||
}
|
||||
.thumb .mdui-text-right{
|
||||
display: none;
|
||||
}
|
||||
.thumb .mdui-list-item a ,.thumb .mdui-list-item {
|
||||
width:213px;
|
||||
height: 230px;
|
||||
float: left;
|
||||
margin: 10px 10px !important;
|
||||
}
|
||||
|
||||
.thumb .mdui-col-xs-12,.thumb .mdui-col-sm-7{
|
||||
width:100% !important;
|
||||
height:230px;
|
||||
}
|
||||
|
||||
.thumb .mdui-list-item .mdui-icon{
|
||||
font-size:100px;
|
||||
display: block;
|
||||
margin-top: 40px;
|
||||
color: #7ab5ef;
|
||||
}
|
||||
.thumb .mdui-list-item span{
|
||||
float: left;
|
||||
display: block;
|
||||
text-align: center;
|
||||
width:100%;
|
||||
position: absolute;
|
||||
top: 180px;
|
||||
}
|
||||
.thumb .forcedownload {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="nexmoe-item">
|
||||
<div class="mdui-row">
|
||||
<ul class="mdui-list">
|
||||
<li class="mdui-list-item th" style="padding-right:36px;">
|
||||
<div class="mdui-col-xs-12 mdui-col-sm-7"><!--constStr@File--> <i class="mdui-icon material-icons icon-sort" data-sort="name" data-order="downward">expand_more</i></div>
|
||||
<div class="mdui-col-sm-3 mdui-text-right"><!--constStr@EditTime--> <i class="mdui-icon material-icons icon-sort" data-sort="date" data-order="downward">expand_more</i></div>
|
||||
<div class="mdui-col-sm-2 mdui-text-right"><!--constStr@Size--> <i class="mdui-icon material-icons icon-sort" data-sort="size" data-order="downward">expand_more</i></div>
|
||||
</li>
|
||||
<!--BackArrowStart-->
|
||||
<li class="mdui-list-item mdui-ripple">
|
||||
<a href="<!--BackArrowUrl-->">
|
||||
<div class="mdui-col-xs-12 mdui-col-sm-7">
|
||||
<i class="mdui-icon material-icons">arrow_upward</i>
|
||||
..
|
||||
</div>
|
||||
<div class="mdui-col-sm-3 mdui-text-right"></div>
|
||||
<div class="mdui-col-sm-2 mdui-text-right"></div>
|
||||
</a>
|
||||
</li>
|
||||
<!--BackArrowEnd-->
|
||||
|
||||
<!--FolderListStart-->
|
||||
<li class="mdui-list-item mdui-ripple" data-sort data-sort-name="<!--FileEncodeReplaceName-->" data-sort-date="<!--lastModifiedDateTime-->" data-sort-size="<!--size-->" style="padding-right:36px;">
|
||||
<a href="<!--FileEncodeReplaceUrl-->/">
|
||||
<div class="mdui-col-xs-12 mdui-col-sm-7 mdui-text-truncate">
|
||||
<i class="mdui-icon material-icons">folder_open</i>
|
||||
<span><!--FileEncodeReplaceName--></span>
|
||||
</div>
|
||||
<div class="mdui-col-sm-3 mdui-text-right"><!--lastModifiedDateTime--></div>
|
||||
<div class="mdui-col-sm-2 mdui-text-right"><!--size--></div>
|
||||
</a>
|
||||
</li>
|
||||
<!--FolderListEnd-->
|
||||
<!--FileListStart-->
|
||||
<li class="mdui-list-item file mdui-ripple" data-sort data-sort-name="<!--FileEncodeReplaceName-->" data-sort-date="<!--lastModifiedDateTime-->" data-sort-size="<!--size-->" data-readypreview="<!--FileExt-->">
|
||||
<a class="<!--FileExtType-->" data-name="<!--FileEncodeReplaceName-->" href="<!--FileEncodeReplaceUrl-->?preview" target="_blank">
|
||||
<!--<?php if(isImage($item['name']) and $_COOKIE["image_mode"] == "1"):?>
|
||||
<img class="mdui-img-fluid" src="<?php echo get_absolute_path($root.$path).rawurlencode($item['name']); ?>">
|
||||
<?php else:?>-->
|
||||
<div class="mdui-col-xs-12 mdui-col-sm-7 mdui-text-truncate">
|
||||
<i class="mdui-icon material-icons"><!--IconValue--></i>
|
||||
<span><!--FileEncodeReplaceName--></span>
|
||||
</div>
|
||||
<div class="mdui-col-sm-3 mdui-text-right"><!--lastModifiedDateTime--></div>
|
||||
<div class="mdui-col-sm-2 mdui-text-right"><!--size--></div>
|
||||
</a>
|
||||
|
||||
<div class="forcedownload " >
|
||||
<a title="<!--constStr@Download-->" href="<!--FileEncodeReplaceUrl-->">
|
||||
<button class="mdui-btn mdui-ripple mdui-btn-icon"><i class="mdui-icon material-icons">file_download</i></button>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
<!--FileListEnd-->
|
||||
|
||||
<!--MorePageStart-->
|
||||
<form action="" method="POST" id="nextpageform">
|
||||
<input type="hidden" id="pagenum" name="pagenum" value="">
|
||||
<li class="mdui-list-item th">
|
||||
<div class="mdui-col-sm-6 mdui-left mdui-text-left">
|
||||
<!--PrePageStart-->
|
||||
<a onclick="nextpage(<!--PrePageNum-->);" class="mdui-btn mdui-btn-raised"><!--constStr@PrePage--></a>
|
||||
<!--PrePageEnd-->
|
||||
<!--NextPageStart-->
|
||||
<a onclick="nextpage(<!--NextPageNum-->);" class="mdui-btn mdui-btn-raised"><!--constStr@NextPage--></a>
|
||||
<!--NextPageEnd-->
|
||||
</div>
|
||||
<div class="mdui-col-sm-6 mdui-right mdui-text-right">
|
||||
<div class="mdui-right mdui-text-right"><span class="mdui-chip-title">Page: <!--MorePageListStart--><!--MorePageListEnd--><!--MorePageListNowStart--><!--PageNum--><!--MorePageListNowEnd-->/<!--MaxPageNum--></span></div>
|
||||
</div>
|
||||
</li>
|
||||
</form>
|
||||
<!--MorePageEnd-->
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<!--ReadmemdStart-->
|
||||
<div class="mdui-typo mdui-shadow-3 markdown" style="padding: 20px;margin: 20px 0">
|
||||
<!--ReadmemdContent-->
|
||||
</div>
|
||||
<!--ReadmemdEnd-->
|
||||
<!--FootomfStart-->
|
||||
<div class="mdui-typo mdui-shadow-3" style="padding: 20px;margin: 20px 0">
|
||||
<!--FootomfContent-->
|
||||
</div>
|
||||
<!--FootomfEnd-->
|
||||
</div>
|
||||
</div>
|
||||
<!--IsFolderEnd-->
|
||||
<!--ListEnd-->
|
||||
<script src="//cdn.jsdelivr.net/gh/mcstudios/glightbox/dist/js/glightbox.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script>
|
||||
<!--MdRequireStart--><link rel="stylesheet" href="//unpkg.zhimg.com/github-markdown-css@3.0.1/github-markdown.css">
|
||||
<script type="text/javascript" src="//unpkg.zhimg.com/marked@0.6.2/marked.min.js"></script><!--MdRequireEnd-->
|
||||
<script>
|
||||
<!--MorePageStart-->
|
||||
function nextpage(num) {
|
||||
document.getElementById('pagenum').value=num;
|
||||
document.getElementById('nextpageform').submit();
|
||||
}
|
||||
<!--MorePageEnd-->
|
||||
var $$ = mdui.JQ;
|
||||
$$(function() {
|
||||
$$('.file .iframe').each(function() {
|
||||
$$(this).on('click', function() {
|
||||
url=$$(this).attr('href');
|
||||
//url=url.substr(0,url.length-8);
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '<a target="_blank" href="'+url+'">'+ $$(this).find('span').text()+'(点击新窗口打开)</a>', //jia,
|
||||
//shadeClose: true,
|
||||
move: false,
|
||||
shade: false,
|
||||
maxmin: true,
|
||||
area: ['100%', '100%'],
|
||||
content: url //le
|
||||
,min: function(layero){
|
||||
//zi;
|
||||
layero.css({top: '90%'})
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
$('.file .dl').each(function () {
|
||||
$(this).on('click', function () {
|
||||
var form = $('<form target=_blank method=post></form>').attr('action', $(this).attr('href')).get(0);
|
||||
$(document.body).append(form);
|
||||
form.submit();
|
||||
$(form).remove();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
});
|
||||
window.TC=window.TC||{};
|
||||
jQuery(".file .audio").click(function(e){
|
||||
e.preventDefault();
|
||||
TC.preview_audio(this);
|
||||
});
|
||||
TC.preview_audio = function(aud){
|
||||
if(!TC.aplayer){
|
||||
TC.aplayerList=[];
|
||||
jQuery(".file .audio").each(function(){
|
||||
var ext = jQuery(this).data("readypreview");
|
||||
var n = jQuery(this).find("span").text();
|
||||
var l = n.replace("."+ext,".lrc");
|
||||
var la = jQuery('a[data-name="'+l+'"]');
|
||||
var lrc = undefined;
|
||||
if(la.length>0){
|
||||
lrc = la[0].href+"?s";
|
||||
}
|
||||
TC.aplayerList.push({
|
||||
name:n,
|
||||
url:this.href.substr(0,this.href.length-8),
|
||||
artist:" ",
|
||||
lrc:lrc
|
||||
});
|
||||
})
|
||||
jQuery('<div id="aplayer">').appendTo("body");
|
||||
TC.aplayer = new APlayer({
|
||||
container: document.getElementById('aplayer'),
|
||||
fixed: true,
|
||||
audio: TC.aplayerList,
|
||||
lrcType: 3
|
||||
});
|
||||
}
|
||||
var k=-1;
|
||||
for(var i in TC.aplayerList){
|
||||
if(TC.aplayerList[i].name==jQuery(aud).data("name")){
|
||||
k=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(k>=0){
|
||||
TC.aplayer.list.switch(k);
|
||||
TC.aplayer.play();
|
||||
TC.aplayer.setMode("normal");
|
||||
}
|
||||
}
|
||||
|
||||
$ = mdui.JQ;
|
||||
$.fn.extend({
|
||||
sortElements: function (comparator, getSortable) {
|
||||
getSortable = getSortable || function () { return this; };
|
||||
|
||||
var placements = this.map(function () {
|
||||
var sortElement = getSortable.call(this),
|
||||
parentNode = sortElement.parentNode,
|
||||
nextSibling = parentNode.insertBefore(
|
||||
document.createTextNode(''),
|
||||
sortElement.nextSibling
|
||||
);
|
||||
|
||||
return function () {
|
||||
parentNode.insertBefore(this, nextSibling);
|
||||
parentNode.removeChild(nextSibling);
|
||||
};
|
||||
});
|
||||
|
||||
return [].sort.call(this, comparator).each(function (i) {
|
||||
placements[i].call(getSortable.call(this));
|
||||
});
|
||||
}
|
||||
});
|
||||
var lightbox = GLightbox();
|
||||
function downall() {
|
||||
let dl_link_list = Array.from(document.querySelectorAll("li a"))
|
||||
.map(x => x.href) // 所有list中的链接
|
||||
.filter(x => x.slice(-1) != "/"); // 筛选出非文件夹的文件下载链接
|
||||
|
||||
let blob = new Blob([dl_link_list.join("\r\n")], {
|
||||
type: 'text/plain'
|
||||
}); // 构造Blog对象
|
||||
let a = document.createElement('a'); // 伪造一个a对象
|
||||
a.href = window.URL.createObjectURL(blob); // 构造href属性为Blob对象生成的链接
|
||||
a.download = "folder_download_link.txt"; // 文件名称,你可以根据你的需要构造
|
||||
a.click() // 模拟点击
|
||||
a.remove();
|
||||
}
|
||||
<!--ShowThumbnailsStart-->
|
||||
function thumb(){
|
||||
if($('#thumb i').text() == "apps"){
|
||||
$('#thumb i').text("format_list_bulleted");
|
||||
$('.nexmoe-item').removeClass('thumb');
|
||||
$('.nexmoe-item .mdui-icon').show();
|
||||
$('.nexmoe-item .mdui-list-item').css("background","");
|
||||
}else{
|
||||
$('#thumb i').text("apps");
|
||||
$('.nexmoe-item').addClass('thumb');
|
||||
$('.mdui-col-xs-12 i.mdui-icon').each(function(){
|
||||
//if($(this).text() == "image" || $(this).text() == "ondemand_video"){
|
||||
if($(this).text() == "image"){
|
||||
var thumbnails = $(this).parent().parent().attr('href');
|
||||
//var thumb =(href.indexOf('?') == -1)?'?t=220':'&t=220';
|
||||
thumbnails = thumbnails.substr(0, thumbnails.length-8)+'?thumbnails&location';
|
||||
$(this).hide();
|
||||
//$(this).parent().parent().parent().css("background","url("+href+thumb+") no-repeat center top");
|
||||
$(this).parent().parent().parent().css("background","url("+thumbnails+") no-repeat center top");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
<!--ShowThumbnailsEnd-->
|
||||
$(function(){
|
||||
$('.icon-sort').on('click', function () {
|
||||
let sort_type = $(this).attr("data-sort"), sort_order = $(this).attr("data-order");
|
||||
let sort_order_to = (sort_order === "less") ? "more" : "less";
|
||||
|
||||
$('li[data-sort]').sortElements(function (a, b) {
|
||||
let data_a = $(a).attr("data-sort-" + sort_type), data_b = $(b).attr("data-sort-" + sort_type);
|
||||
let rt = data_a.localeCompare(data_b, undefined, {numeric: true});
|
||||
return (sort_order === "more") ? 0-rt : rt;
|
||||
});
|
||||
|
||||
$(this).attr("data-order", sort_order_to).text("expand_" + sort_order_to);
|
||||
});
|
||||
});
|
||||
|
||||
var ckname='image_mode';
|
||||
function getCookie(name)
|
||||
{
|
||||
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
|
||||
if(arr=document.cookie.match(reg))
|
||||
return unescape(arr[2]);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
function setCookie(key,value,day){
|
||||
var exp = new Date();
|
||||
exp.setTime(exp.getTime() - 1);
|
||||
var cval=getCookie(key);
|
||||
if(cval!=null)
|
||||
document.cookie= key + "="+cval+";expires="+exp.toGMTString();
|
||||
var date = new Date();
|
||||
var nowDate = date.getDate();
|
||||
date.setDate(nowDate + day);
|
||||
var cookie = key+"="+value+"; expires="+date;
|
||||
document.cookie = cookie;
|
||||
return cookie;
|
||||
}
|
||||
$('#image_view').on('click', function () {
|
||||
if($(this).prop('checked') == true){
|
||||
setCookie(ckname,1,1);
|
||||
window.location.href=window.location.href;
|
||||
}else{
|
||||
setCookie(ckname,0,1);
|
||||
window.location.href=window.location.href;
|
||||
}
|
||||
});
|
||||
document.querySelectorAll('.markdown').forEach(function (e) {
|
||||
e.innerHTML = marked(e.innerHTML);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,24 @@
|
|||
<html>
|
||||
<head>
|
||||
<title><!--Sitename--> - /<!--PathArrayStart--><!--PathArrayName-->/<!--PathArrayEnd--></title>
|
||||
</head>
|
||||
<body>
|
||||
<H1><!--Sitename--> - /<!--DiskPathArrayStart--><!--PathArrayName-->/<!--DiskPathArrayEnd--></H1><hr>
|
||||
<table>
|
||||
<!--BackArrowStart-->
|
||||
<tr><td colspan="3"><A HREF="<!--BackArrowUrl-->">../</A></td></tr>
|
||||
<!--BackArrowEnd-->
|
||||
<!--ListStart-->
|
||||
<!--IsFolderStart-->
|
||||
<!--FolderListStart-->
|
||||
<tr><td><A HREF="<!--FileEncodeReplaceUrl-->/"><!--FileEncodeReplaceName-->/</A></td><td align="right"><!--lastModifiedDateTime--></td><td align="right">-</td></tr>
|
||||
<!--FolderListEnd-->
|
||||
<!--FileListStart-->
|
||||
<tr><td><A HREF="<!--FileEncodeReplaceUrl-->"><!--FileEncodeReplaceName--></A></td><td align="right"><!--lastModifiedDateTime--></td><td align="right"><!--size--></td></tr>
|
||||
<!--FileListEnd-->
|
||||
<!--IsFolderEnd-->
|
||||
<!--ListEnd-->
|
||||
</table>
|
||||
<hr>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,466 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<link rel="preconnect" href="https://cdn.jsdelivr.net" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||
<link rel="preconnect" href="https://renexmoe.vercel.app" />
|
||||
<meta charset="utf-8" />
|
||||
<link
|
||||
rel="shortcut icon"
|
||||
href="<!--base_path-->favicon.ico"
|
||||
type="image/x-icon"
|
||||
/>
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"
|
||||
/>
|
||||
<title><!--Title--></title>
|
||||
<meta name="description" content="A Onemanager-PHP site with Theme-renexmoe" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.1.2/css/app.css"><meta name="theme-color" content="#fff" />
|
||||
<!--BackgroundStart-->
|
||||
<style>
|
||||
body {
|
||||
--bg: url("<!--BackgroundUrl-->");
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
background-attachment: fixed;
|
||||
background-image: var(--bg);
|
||||
}
|
||||
|
||||
.mdui-shadow-3 {
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
window.disableddarkmode = true;
|
||||
</script>
|
||||
<!--BackgroundEnd-->
|
||||
|
||||
</head>
|
||||
<body
|
||||
class="mdui-appbar-with-toolbar mdui-theme-layout-auto mdui-loaded mdui-theme-accent-pink"
|
||||
>
|
||||
<header
|
||||
class="mdui-appbar mdui-appbar-fixed mdui-shadow-0 mdui-appbar-scroll-toolbar-hide"
|
||||
>
|
||||
<div class="mdui-toolbar">
|
||||
<span
|
||||
class="mdui-btn mdui-btn-icon mdui-ripple mdui-ripple-white"
|
||||
mdui-tooltip="{content: '菜单'}"
|
||||
onclick='mdui.$("body").toggleClass("mdui-drawer-body-left");'
|
||||
id="toggle-drawer"
|
||||
><i class="mdui-icon material-icons">menu</i></span
|
||||
>
|
||||
<a
|
||||
mdui-tooltip="{content: '返回'}"
|
||||
class="mdui-btn mdui-btn-icon mdui-ripple mdui-ripple-white mdui-hidden-sm-up"
|
||||
onclick="window.history.back()"
|
||||
>
|
||||
<i class="mdui-icon material-icons">arrow_back</i>
|
||||
</a>
|
||||
<a href="<!--base_path-->" class="mdui-typo-headline">
|
||||
<!--Sitename-->
|
||||
</a>
|
||||
<!--PathArrayStart-->
|
||||
<i class="mdui-icon material-icons mdui-hidden-xs" style="margin: 0"
|
||||
>chevron_right</i
|
||||
><a href="<!--PathArrayLink-->" class="mdui-typo-subheading mdui-hidden-xs">
|
||||
<!--PathArrayName--></a
|
||||
>
|
||||
<!--PathArrayEnd-->
|
||||
<div class="mdui-toolbar-spacer"></div>
|
||||
<!--AdminStart--><a
|
||||
href="javascript:;"
|
||||
class="mdui-btn mdui-btn-icon mdui-ripple mdui-hidden-sm-up refresh"
|
||||
mdui-tooltip="{content: '刷新缓存'}"
|
||||
><i class="mdui-icon material-icons">refresh</i></a
|
||||
>
|
||||
<!--AdminEnd-->
|
||||
</div>
|
||||
|
||||
</header>
|
||||
|
||||
<div class="mdui-drawer mdui-drawer-close" id="main-drawer">
|
||||
<div class="mdui-list" mdui-collapse="{accordion: true}">
|
||||
<!--LoginStart-->
|
||||
<li
|
||||
class="mdui-list-item mdui-ripple"
|
||||
href="javascript:void(0);"
|
||||
mdui-dialog="{target: '#login_input'}"
|
||||
>
|
||||
<a class="mdui-list-item-icon mdui-icon material-icons">account_circle</a
|
||||
><a class="mdui-list-item-content">登录</a>
|
||||
</li>
|
||||
<!--LoginEnd-->
|
||||
<!--AdminStart-->
|
||||
<li class="mdui-list-item mdui-ripple" href="?setup">
|
||||
<a class="mdui-list-item-icon mdui-icon material-icons" href="?setup"
|
||||
>account_circle</a
|
||||
><a class="mdui-list-item-content" href="?setup">管理</a>
|
||||
</li>
|
||||
<li
|
||||
class="mdui-list-item mdui-ripple"
|
||||
onclick="document.cookie=``;window.location.reload();"
|
||||
id="logout"
|
||||
>
|
||||
<i class="mdui-icon material-icons mdui-list-item-icon">exit_to_app</i>
|
||||
<div class="mdui-list-item-content">退出登陆</div>
|
||||
</li>
|
||||
<li class="mdui-list-item mdui-ripple" id="checkupdate">
|
||||
<i class="mdui-icon material-icons mdui-list-item-icon">update</i>
|
||||
<div class="mdui-list-item-content">检查主题更新</div>
|
||||
</li>
|
||||
<div class="mdui-divider"></div>
|
||||
<!--AdminEnd-->
|
||||
|
||||
<li
|
||||
class="mdui-list-item mdui-ripple"
|
||||
href="javascript:void(0);"
|
||||
onclick="renexmoe.toggle_theme();"
|
||||
>
|
||||
<a class="mdui-list-item-icon mdui-icon material-icons">brightness_4</a
|
||||
><a class="mdui-list-item-content">深色模式</a>
|
||||
</li>
|
||||
<li class="mdui-list-item mdui-ripple">
|
||||
<a
|
||||
href="<!--base_path-->"
|
||||
class="mdui-list-item-icon mdui-icon material-icons"
|
||||
>home</a
|
||||
><a href="<!--base_path-->" class="mdui-list-item-content">
|
||||
<!--constStr@Home--></a
|
||||
>
|
||||
</li>
|
||||
<!--MultiDiskAreaStart-->
|
||||
<div class="mdui-divider"></div>
|
||||
<!--MultiDisksStart--><a
|
||||
href="<!--MultiDisksUrl-->"
|
||||
class="mdui-list-item mdui-ripple"
|
||||
><i class="mdui-list-item-icon mdui-icon material-icons">cloud</i>
|
||||
<div class="mdui-list-item-content">
|
||||
<!--MultiDisksName-->
|
||||
</div>
|
||||
</a>
|
||||
<!--MultiDisksEnd-->
|
||||
<div class="mdui-divider"></div>
|
||||
<!--MultiDiskAreaEnd-->
|
||||
|
||||
<a
|
||||
href="https://github.com/qkqpttgf/OneManager-php"
|
||||
class="mdui-list-item mdui-ripple"
|
||||
><i class="mdui-list-item-icon mdui-icon material-icons">code</i>
|
||||
<div class="mdui-list-item-content">Github</div>
|
||||
</a>
|
||||
<li
|
||||
class="mdui-list-item mdui-ripple"
|
||||
href="javascript:void(0);"
|
||||
id="about_theme"
|
||||
>
|
||||
<i class="mdui-list-item-icon mdui-icon material-icons">info</i>
|
||||
<div class="mdui-list-item-content">关于该主题</div>
|
||||
</li>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mdui-container">
|
||||
<ul class="mdui-menu" id="admin-menu">
|
||||
<li class="mdui-menu-item">
|
||||
<a href="javascript:;" class="mdui-ripple back"
|
||||
><i class="mdui-menu-item-icon mdui-icon material-icons">arrow_back</i
|
||||
>返回上一页</a
|
||||
>
|
||||
</li>
|
||||
<!--AdminStart-->
|
||||
<li class="mdui-menu-item">
|
||||
<a href="javascript:;" class="mdui-ripple refresh"
|
||||
><i class="mdui-menu-item-icon mdui-icon material-icons">refresh</i
|
||||
>刷新缓存</a
|
||||
>
|
||||
</li>
|
||||
<!--AdminEnd-->
|
||||
</ul>
|
||||
<i id="mouseplace" style="position: absolute"></i>
|
||||
<form action="?admin" method="post">
|
||||
<div class="mdui-dialog" id="login_input">
|
||||
<div class="mdui-dialog-title">登录</div>
|
||||
<div class="mdui-dialog-content" style="height: 108px">
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<i class="mdui-icon material-icons">lock</i
|
||||
><label class="mdui-textfield-label">密码</label
|
||||
><input class="mdui-textfield-input" name="password1" type="new-password" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="mdui-dialog-actions">
|
||||
<button class="mdui-btn mdui-ripple" mdui-dialog-close="">取消</button
|
||||
><button class="mdui-btn mdui-ripple" type="submit" value="登录">
|
||||
登录
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<!--EncryptedStart-->
|
||||
<div class="mdui-col-md-6 mdui-col-offset-md-3">
|
||||
<br />
|
||||
<center>
|
||||
<div class="mdui-typo-title">
|
||||
这是一个受保护的文件夹,您需要提供访问密码才能查看。
|
||||
</div>
|
||||
</center>
|
||||
<form action="" method="post">
|
||||
<div class="mdui-textfield mdui-textfield-floating-label">
|
||||
<i class="mdui-icon material-icons">https</i
|
||||
><label class="mdui-textfield-label"> <!--constStr@InputPassword--></label
|
||||
><input name="password1" class="mdui-textfield-input" type="password" />
|
||||
</div>
|
||||
<br /><button
|
||||
type="submit"
|
||||
class="mdui-center mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme"
|
||||
>
|
||||
<i class="mdui-icon material-icons">fingerprint</i>
|
||||
<!--constStr@Submit-->
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<!--EncryptedEnd-->
|
||||
|
||||
<!--IsFolderStart-->
|
||||
<!--HeadomfStart-->
|
||||
<div class="mdui-typo mdui-shadow-3" style="padding: 20px; margin: 20px 0">
|
||||
<!--HeadomfContent-->
|
||||
</div>
|
||||
<!--HeadomfEnd-->
|
||||
<!--HeadmdStart-->
|
||||
<div class="mdui-chip mdui-ripple mdui-hidden-xs">
|
||||
<span class="mdui-chip-icon"
|
||||
><i class="mdui-icon material-icons">face</i></span
|
||||
><span class="mdui-chip-title">HEAD.md</span>
|
||||
</div>
|
||||
<div
|
||||
class="mdui-typo mdui-shadow-3 markdown"
|
||||
style="padding: 20px; margin: 20px 0"
|
||||
id="head"
|
||||
>
|
||||
<pre><code id="head-md"><!--HeadmdContent--></code></pre>
|
||||
</div>
|
||||
<!--HeadmdEnd-->
|
||||
|
||||
<div
|
||||
class="mdui-row mdui-shadow-3"
|
||||
style="padding: 5px; margin: 20px 0; border-radius: 8px"
|
||||
>
|
||||
<ul class="mdui-list">
|
||||
<li class="mdui-list-item mdui-ripple">
|
||||
<div class="mdui-row mdui-col-xs-12">
|
||||
<div class="mdui-col-xs-12 mdui-col-sm-7">
|
||||
<!--constStr@File--><i
|
||||
class="mdui-icon material-icons icon-sort"
|
||||
data-sort="name"
|
||||
data-order="downward"
|
||||
>expand_more</i
|
||||
>
|
||||
</div>
|
||||
<div class="mdui-col-sm-3 mdui-text-right">
|
||||
<!--constStr@EditTime--><i
|
||||
class="mdui-icon material-icons icon-sort"
|
||||
data-sort="date"
|
||||
data-order="downward"
|
||||
>expand_more</i
|
||||
>
|
||||
</div>
|
||||
<div class="mdui-col-sm-2 mdui-text-right">
|
||||
<!--constStr@Size--><i
|
||||
class="mdui-icon material-icons icon-sort"
|
||||
data-sort="size"
|
||||
data-order="downward"
|
||||
>expand_more</i
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<!--BackArrowStart-->
|
||||
<li class="mdui-list-item mdui-ripple">
|
||||
<div class="mdui-row mdui-col-sm-12">
|
||||
<a href="<!--BackArrowUrl-->">
|
||||
<div class="mdui-col-xs-7">
|
||||
<i class="mdui-icon material-icons">arrow_upward</i>
|
||||
</div>
|
||||
<div class="mdui-col-xs-3 mdui-text-right"></div>
|
||||
<div class="mdui-col-xs-2 mdui-text-right"></div>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
<!--BackArrowEnd-->
|
||||
<!--FolderListStart-->
|
||||
<li
|
||||
class="mdui-list-item mdui-ripple"
|
||||
data-sort
|
||||
data-sort-name="<!--FileEncodeReplaceName-->"
|
||||
data-sort-date="<!--lastModifiedDateTime-->"
|
||||
data-sort-size="<!--size-->"
|
||||
style="padding-right: 36px"
|
||||
>
|
||||
<div class="mdui-row mdui-col-sm-12">
|
||||
<a href="<!--FileEncodeReplaceUrl-->/">
|
||||
<div class="mdui-col-xs-12 mdui-col-sm-7 mdui-text-truncate">
|
||||
<i class="mdui-icon material-icons">folder_open</i
|
||||
><span> <!--FileEncodeReplaceName--></span>
|
||||
</div>
|
||||
<div class="mdui-col-sm-3 mdui-text-right">
|
||||
<!--lastModifiedDateTime-->
|
||||
</div>
|
||||
<div class="mdui-col-sm-2 mdui-text-right">
|
||||
<!--size-->
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
<!--FolderListEnd-->
|
||||
<!--FileListStart-->
|
||||
<li
|
||||
class="mdui-list-item file mdui-ripple"
|
||||
data-sort
|
||||
data-sort-name="<!--FileEncodeReplaceName-->"
|
||||
data-sort-date="<!--lastModifiedDateTime-->"
|
||||
data-sort-size="<!--size-->"
|
||||
data-readypreview="<!--FileExt-->"
|
||||
>
|
||||
<div class="mdui-row mdui-col-sm-12">
|
||||
<div class="mdui-col-xs-12 mdui-col-sm-7 mdui-text-truncate">
|
||||
<a
|
||||
class="<!--FileExtType-->"
|
||||
data-name="<!--FileEncodeReplaceName-->"
|
||||
href="<!--FileEncodeReplaceUrl-->?preview"
|
||||
aria-label="File"
|
||||
>
|
||||
<i class="mdui-icon material-icons"> <!--IconValue--></i>
|
||||
<span> <!--FileEncodeReplaceName--></span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="mdui-col-sm-3 mdui-text-right">
|
||||
<!--lastModifiedDateTime-->
|
||||
</div>
|
||||
<div class="mdui-col-sm-2 mdui-text-right">
|
||||
<!--size-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="forcedownload mdui-text-right">
|
||||
<a
|
||||
title="<!--constStr@Download-->"
|
||||
aria-label="Download"
|
||||
href="<!--FileEncodeReplaceUrl-->"
|
||||
target="_blank"
|
||||
><button class="mdui-btn mdui-ripple mdui-btn-icon">
|
||||
<i class="mdui-icon material-icons">file_download</i>
|
||||
</button></a
|
||||
>
|
||||
</div>
|
||||
</li>
|
||||
<!--FileListEnd-->
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<!--ReadmemdStart-->
|
||||
<div class="mdui-chip mdui-ripple mdui-hidden-xs">
|
||||
<span class="mdui-chip-icon"
|
||||
><i class="mdui-icon material-icons">face</i></span
|
||||
><span class="mdui-chip-title">README.md</span>
|
||||
</div>
|
||||
<div
|
||||
class="mdui-typo mdui-shadow-3 markdown"
|
||||
style="padding: 20px; margin: 20px 0"
|
||||
id="readme"
|
||||
>
|
||||
<pre><code id="readme-md"><!--ReadmemdContent--></code></pre>
|
||||
</div>
|
||||
<!--ReadmemdEnd-->
|
||||
<!--FootomfStart-->
|
||||
<div class="mdui-typo mdui-shadow-3" style="padding: 20px; margin: 20px 0">
|
||||
<!--FootomfContent-->
|
||||
</div>
|
||||
<!--FootomfEnd-->
|
||||
|
||||
<!--IsFolderEnd-->
|
||||
<!--IsFileStart-->
|
||||
<div id="file">
|
||||
<!--IsimgFileStart-->
|
||||
<img class="mdui-img-fluid mdui-center mdui-m-t-5" src="<!--FileDownUrl-->" />
|
||||
<!--IsimgFileEnd-->
|
||||
<!--IsmusicFileStart-->
|
||||
<audio
|
||||
class="mdui-center"
|
||||
src="<!--FileDownUrl-->"
|
||||
controls
|
||||
autoplay
|
||||
style="width: 100%; margin-top: 10%"
|
||||
></audio>
|
||||
<!--IsmusicFileEnd-->
|
||||
|
||||
<!--IsvideoFileStart-->
|
||||
<video class="mdui-video-fluid" controls style="margin-top: 20px">
|
||||
<source src="<!--FileDownUrl-->" />
|
||||
<p>
|
||||
Your browser doesn't support HTML5 video. Here is a
|
||||
<a href="<!--FileDownUrl-->">link to the video</a> instead.
|
||||
</p>
|
||||
</video>
|
||||
<!--IsvideoFileEnd-->
|
||||
<!--IsofficeFileStart-->
|
||||
<iframe
|
||||
id="office-a"
|
||||
src="https://view.officeapps.live.com/op/view.aspx?src=<!--FileEncodeDownUrl-->"
|
||||
style="width: 100%; height: 800px"
|
||||
frameborder="0"
|
||||
></iframe>
|
||||
<!--IsofficeFileEnd-->
|
||||
|
||||
<!--IspdfFileStart-->
|
||||
<embed src="<!--FileEncodeReplaceUrl-->" type="application/pdf">
|
||||
<!--IspdfFileEnd-->
|
||||
<!--IstxtFileStart-->
|
||||
<pre
|
||||
id="editor"
|
||||
style="
|
||||
white-space: pre-wrap;
|
||||
font-family: JetBrains Mono, Fira Code, Sarasa Mono SC, Cascadia Code, Menlo,
|
||||
Consolas, monaco, Noto Sans SC;
|
||||
"
|
||||
><code id="code"><!--TxtContent--></code></pre>
|
||||
<script>
|
||||
document.querySelector("#admin-menu").innerHTML +=
|
||||
'<li class="mdui-menu-item"><a href="javascript:void(0);"class="mdui-ripple highlight"><i class="mdui-menu-item-icon mdui-icon material-icons">style</i>markdown解析</a></li>';
|
||||
document.querySelector(
|
||||
".mdui-toolbar"
|
||||
).innerHTML += `<a href="javascript:;" class="mdui-btn mdui-btn-icon mdui-ripple mdui-hidden-sm-up highlight" mdui-tooltip="{content: 'markdown解析'}"><i class="mdui-icon material-icons">style</i></a>`;
|
||||
</script>
|
||||
|
||||
<!--IstxtFileEnd-->
|
||||
|
||||
<!--IsOtherFileStart-->
|
||||
<!--constStr@FileNotSupport-->
|
||||
<!--IsOtherFileEnd-->
|
||||
</div>
|
||||
<a
|
||||
href="<!--FileEncodeReplaceUrl-->"
|
||||
target="_blank"
|
||||
class="mdui-fab mdui-fab-fixed mdui-ripple mdui-color-theme-accent"
|
||||
><i class="mdui-icon material-icons">file_download</i></a
|
||||
>
|
||||
<script>
|
||||
document.querySelector("#admin-menu").innerHTML +=
|
||||
'<li class="mdui-menu-item"><a href="javascript:void(0);"class="mdui-ripple downloadurl"><i class="mdui-menu-item-icon mdui-icon material-icons">cloud_download</i>下载链接</a></li>';
|
||||
document.querySelector(
|
||||
".mdui-toolbar"
|
||||
).innerHTML += `<a href="javascript:;" class="mdui-btn mdui-btn-icon mdui-ripple mdui-hidden-sm-up downloadurl" mdui-tooltip="{content: '下载链接'}"><i class="mdui-icon material-icons">cloud_download</i></a>`;
|
||||
</script>
|
||||
<!--IsFileEnd-->
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
<!--IconValuesStart-->
|
||||
{ "music":"audiotrack", "video":"ondemand_video", "img":"image",
|
||||
"pdf":"picture_as_pdf", "default":"insert_drive_file"}
|
||||
<!--IconValuesEnd-->
|
||||
<script src="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.1.2/js/webpack-runtime.2c4e79a563c6e0c1c74f.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/186526/renexmoe-cdn@v1.1.2/js/app.7a662c514027ed87a34e.js"></script>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,71 @@
|
|||
#!bash
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "
|
||||
"$0" -i|u [-b branch]
|
||||
i a new install with empty config.
|
||||
u update use exist config.
|
||||
b install the branch after parameter b, default master
|
||||
|
||||
example:
|
||||
"$0" -i
|
||||
"$0" -u
|
||||
"$0" -b master
|
||||
"$0" -u -b master
|
||||
"$0" -ib test
|
||||
"
|
||||
# exit
|
||||
echo "###############
|
||||
0, new install
|
||||
1, update"
|
||||
read -p "Input:" c
|
||||
[ g"$c" == g"0" ] && install=1
|
||||
[ g"$c" == g"1" ] && update=1
|
||||
fi
|
||||
|
||||
i=0
|
||||
para[$i]=$0
|
||||
for av in "$@"
|
||||
do
|
||||
#echo $av
|
||||
((i++))
|
||||
para[$i]=$av
|
||||
if [ g"${av:0:1}" == g"-" ]; then
|
||||
while [ g"$av" != g"" ]
|
||||
do
|
||||
ag=${av:0:1}
|
||||
av=${av:1}
|
||||
[ g"$ag" == g"b" ] && isbranch=1
|
||||
[ g"$ag" == g"i" ] && install=1
|
||||
[ g"$ag" == g"u" ] && update=1
|
||||
done
|
||||
else
|
||||
if [ g"$isbranch" == g"1" ]; then
|
||||
branch="-b $av"
|
||||
isbranch=0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ g"$install" == g"1" -a g"$update" == g"1" ]; then
|
||||
echo "Both install & update, exit"
|
||||
exit
|
||||
fi
|
||||
if [ g"$install" != g"1" -a g"$update" != g"1" ]; then
|
||||
echo "Not install & Not update, exit"
|
||||
exit
|
||||
fi
|
||||
|
||||
gitsource='https://github.com/qkqpttgf/OneManager-php'
|
||||
|
||||
OneManagerPath=`cd $(dirname $0);pwd -P`
|
||||
cd ${OneManagerPath}
|
||||
|
||||
git clone ${branch} ${gitsource}
|
||||
[ g"$install" == g"1" ] || \mv -b .data/config.php OneManager-php/.data/
|
||||
\mv -b OneManager-php/* ./
|
||||
\mv -b OneManager-php/.[^.]* ./
|
||||
rm -rf *~
|
||||
#rm -rf .[^.]*~
|
||||
rm -rf OneManager-php
|
||||
chmod 666 .data/config.php
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit95653bfe69a47d1c8f876456a9c468fd::getLoader();
|
|
@ -0,0 +1,445 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
/**
|
||||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
||||
*
|
||||
* $loader = new \Composer\Autoload\ClassLoader();
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // to enable searching the include path (eg. for PEAR packages)
|
||||
* $loader->setUseIncludePath(true);
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @see http://www.php-fig.org/psr/psr-0/
|
||||
* @see http://www.php-fig.org/psr/psr-4/
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
// PSR-4
|
||||
private $prefixLengthsPsr4 = array();
|
||||
private $prefixDirsPsr4 = array();
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
private $prefixesPsr0 = array();
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
private $useIncludePath = false;
|
||||
private $classMap = array();
|
||||
private $classMapAuthoritative = false;
|
||||
private $missingClasses = array();
|
||||
private $apcuPrefix;
|
||||
|
||||
public function getPrefixes()
|
||||
{
|
||||
if (!empty($this->prefixesPsr0)) {
|
||||
return call_user_func_array('array_merge', $this->prefixesPsr0);
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
return $this->prefixDirsPsr4;
|
||||
}
|
||||
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirsPsr0;
|
||||
}
|
||||
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
return $this->fallbackDirsPsr4;
|
||||
}
|
||||
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $classMap Class to filename map
|
||||
*/
|
||||
public function addClassMap(array $classMap)
|
||||
{
|
||||
if ($this->classMap) {
|
||||
$this->classMap = array_merge($this->classMap, $classMap);
|
||||
} else {
|
||||
$this->classMap = $classMap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix, either
|
||||
* appending or prepending to the ones previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr0
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$this->fallbackDirsPsr0,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixesPsr0[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$this->prefixesPsr0[$first][$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace, either
|
||||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function addPsr4($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
// Register directories for the root namespace.
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr4
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$this->fallbackDirsPsr4,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||
// Register directories for a new namespace.
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
} elseif ($prepend) {
|
||||
// Prepend directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixDirsPsr4[$prefix]
|
||||
);
|
||||
} else {
|
||||
// Append directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$this->prefixDirsPsr4[$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix,
|
||||
* replacing any others previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 base directories
|
||||
*/
|
||||
public function set($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr0 = (array) $paths;
|
||||
} else {
|
||||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace,
|
||||
* replacing any others previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setPsr4($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr4 = (array) $paths;
|
||||
} else {
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include path for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
return $this->useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns off searching the prefix and fallback directories for classes
|
||||
* that have not been registered with the class map.
|
||||
*
|
||||
* @param bool $classMapAuthoritative
|
||||
*/
|
||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||
{
|
||||
$this->classMapAuthoritative = $classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should class lookup fail if not found in the current class map?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isClassMapAuthoritative()
|
||||
{
|
||||
return $this->classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
||||
*
|
||||
* @param string|null $apcuPrefix
|
||||
*/
|
||||
public function setApcuPrefix($apcuPrefix)
|
||||
{
|
||||
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The APCu prefix in use, or null if APCu caching is not enabled.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getApcuPrefix()
|
||||
{
|
||||
return $this->apcuPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
* @return bool|null True if loaded, null otherwise
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
includeFile($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|false The path if found, false otherwise
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
// class map lookup
|
||||
if (isset($this->classMap[$class])) {
|
||||
return $this->classMap[$class];
|
||||
}
|
||||
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
||||
return false;
|
||||
}
|
||||
if (null !== $this->apcuPrefix) {
|
||||
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
||||
if ($hit) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
$file = $this->findFileWithExtension($class, '.php');
|
||||
|
||||
// Search for Hack files if we are running on HHVM
|
||||
if (false === $file && defined('HHVM_VERSION')) {
|
||||
$file = $this->findFileWithExtension($class, '.hh');
|
||||
}
|
||||
|
||||
if (null !== $this->apcuPrefix) {
|
||||
apcu_add($this->apcuPrefix.$class, $file);
|
||||
}
|
||||
|
||||
if (false === $file) {
|
||||
// Remember that this class does not exist.
|
||||
$this->missingClasses[$class] = true;
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
private function findFileWithExtension($class, $ext)
|
||||
{
|
||||
// PSR-4 lookup
|
||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||
|
||||
$first = $class[0];
|
||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||
$subPath = $class;
|
||||
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
||||
$subPath = substr($subPath, 0, $lastPos);
|
||||
$search = $subPath . '\\';
|
||||
if (isset($this->prefixDirsPsr4[$search])) {
|
||||
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
||||
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
||||
if (file_exists($file = $dir . $pathEnd)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-4 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr4 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 lookup
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||
}
|
||||
|
||||
if (isset($this->prefixesPsr0[$first])) {
|
||||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr0 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 include paths.
|
||||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*/
|
||||
function includeFile($file)
|
||||
{
|
||||
include $file;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
Copyright (c) Nils Adermann, Jordi Boggiano
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Doctrine\\Common\\Cache\\' => array($vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache'),
|
||||
'App\\' => array($baseDir . '/app'),
|
||||
);
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit95653bfe69a47d1c8f876456a9c468fd
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
public static function loadClassLoader($class)
|
||||
{
|
||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit95653bfe69a47d1c8f876456a9c468fd', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit95653bfe69a47d1c8f876456a9c468fd', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require_once __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit95653bfe69a47d1c8f876456a9c468fd::getInitializer($loader));
|
||||
} else {
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->set($namespace, $path);
|
||||
}
|
||||
|
||||
$map = require __DIR__ . '/autoload_psr4.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->setPsr4($namespace, $path);
|
||||
}
|
||||
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
$loader->addClassMap($classMap);
|
||||
}
|
||||
}
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
// autoload_static.php @generated by Composer
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit95653bfe69a47d1c8f876456a9c468fd
|
||||
{
|
||||
public static $prefixLengthsPsr4 = array (
|
||||
'D' =>
|
||||
array (
|
||||
'Doctrine\\Common\\Cache\\' => 22,
|
||||
),
|
||||
'A' =>
|
||||
array (
|
||||
'App\\' => 4,
|
||||
),
|
||||
);
|
||||
|
||||
public static $prefixDirsPsr4 = array (
|
||||
'Doctrine\\Common\\Cache\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache',
|
||||
),
|
||||
'App\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/../..' . '/app',
|
||||
),
|
||||
);
|
||||
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit95653bfe69a47d1c8f876456a9c468fd::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit95653bfe69a47d1c8f876456a9c468fd::$prefixDirsPsr4;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
[
|
||||
{
|
||||
"name": "doctrine/cache",
|
||||
"version": "v1.6.2",
|
||||
"version_normalized": "1.6.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/cache.git",
|
||||
"reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/cache/zipball/eb152c5100571c7a45470ff2a35095ab3f3b900b",
|
||||
"reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"php": "~5.5|~7.0"
|
||||
},
|
||||
"conflict": {
|
||||
"doctrine/common": ">2.2,<2.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.8|~5.0",
|
||||
"predis/predis": "~1.0",
|
||||
"satooshi/php-coveralls": "~0.6"
|
||||
},
|
||||
"time": "2017-07-22T12:49:21+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.6.x-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Benjamin Eberlei",
|
||||
"email": "kontakt@beberlei.de"
|
||||
},
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Wage",
|
||||
"email": "jonwage@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Johannes Schmitt",
|
||||
"email": "schmittjoh@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Caching library offering an object-oriented API for many cache backends",
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"caching"
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
interface Cache
|
||||
{
|
||||
const STATS_HITS = 'hits';
|
||||
const STATS_MISSES = 'misses';
|
||||
const STATS_UPTIME = 'uptime';
|
||||
const STATS_MEMORY_USAGE = 'memory_usage';
|
||||
const STATS_MEMORY_AVAILABLE = 'memory_available';
|
||||
/**
|
||||
* Only for backward compatibility (may be removed in next major release)
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
const STATS_MEMORY_AVAILIABLE = 'memory_available';
|
||||
|
||||
/**
|
||||
* Fetches an entry from the cache.
|
||||
*
|
||||
* @param string $id The id of the cache entry to fetch.
|
||||
*
|
||||
* @return mixed The cached data or FALSE, if no cache entry exists for the given id.
|
||||
*/
|
||||
public function fetch($id);
|
||||
|
||||
/**
|
||||
* Tests if an entry exists in the cache.
|
||||
*
|
||||
* @param string $id The cache id of the entry to check for.
|
||||
*
|
||||
* @return bool TRUE if a cache entry exists for the given cache id, FALSE otherwise.
|
||||
*/
|
||||
public function contains($id);
|
||||
|
||||
/**
|
||||
* Puts data into the cache.
|
||||
*
|
||||
* If a cache entry with the given id already exists, its data will be replaced.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
* @param mixed $data The cache entry/data.
|
||||
* @param int $lifeTime The lifetime in number of seconds for this cache entry.
|
||||
* If zero (the default), the entry never expires (although it may be deleted from the cache
|
||||
* to make place for other entries).
|
||||
*
|
||||
* @return bool TRUE if the entry was successfully stored in the cache, FALSE otherwise.
|
||||
*/
|
||||
public function save($id, $data, $lifeTime = 0);
|
||||
|
||||
/**
|
||||
* Deletes a cache entry.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
*
|
||||
* @return bool TRUE if the cache entry was successfully deleted, FALSE otherwise.
|
||||
* Deleting a non-existing entry is considered successful.
|
||||
*/
|
||||
public function delete($id);
|
||||
|
||||
/**
|
||||
* Retrieves cached information from the data store.
|
||||
*
|
||||
* The server's statistics array has the following values:
|
||||
*
|
||||
* - <b>hits</b>
|
||||
* Number of keys that have been requested and found present.
|
||||
*
|
||||
* - <b>misses</b>
|
||||
* Number of items that have been requested and not found.
|
||||
*
|
||||
* - <b>uptime</b>
|
||||
* Time that the server is running.
|
||||
*
|
||||
* - <b>memory_usage</b>
|
||||
* Memory used by this server to store items.
|
||||
*
|
||||
* - <b>memory_available</b>
|
||||
* Memory allowed to use for storage.
|
||||
*
|
||||
* @since 2.2
|
||||
*
|
||||
* @return array|null An associative array with server's statistics if available, NULL otherwise.
|
||||
*/
|
||||
public function getStats();
|
||||
}
|
|
@ -0,0 +1,312 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Base class for cache provider implementations.
|
||||
*
|
||||
* @since 2.2
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
*/
|
||||
abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, MultiGetCache, MultiPutCache
|
||||
{
|
||||
const DOCTRINE_NAMESPACE_CACHEKEY = 'DoctrineNamespaceCacheKey[%s]';
|
||||
|
||||
/**
|
||||
* The namespace to prefix all cache ids with.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $namespace = '';
|
||||
|
||||
/**
|
||||
* The namespace version.
|
||||
*
|
||||
* @var integer|null
|
||||
*/
|
||||
private $namespaceVersion;
|
||||
|
||||
/**
|
||||
* Sets the namespace to prefix all cache ids with.
|
||||
*
|
||||
* @param string $namespace
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setNamespace($namespace)
|
||||
{
|
||||
$this->namespace = (string) $namespace;
|
||||
$this->namespaceVersion = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the namespace that prefixes all cache ids.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNamespace()
|
||||
{
|
||||
return $this->namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetch($id)
|
||||
{
|
||||
return $this->doFetch($this->getNamespacedId($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetchMultiple(array $keys)
|
||||
{
|
||||
if (empty($keys)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// note: the array_combine() is in place to keep an association between our $keys and the $namespacedKeys
|
||||
$namespacedKeys = array_combine($keys, array_map(array($this, 'getNamespacedId'), $keys));
|
||||
$items = $this->doFetchMultiple($namespacedKeys);
|
||||
$foundItems = array();
|
||||
|
||||
// no internal array function supports this sort of mapping: needs to be iterative
|
||||
// this filters and combines keys in one pass
|
||||
foreach ($namespacedKeys as $requestedKey => $namespacedKey) {
|
||||
if (isset($items[$namespacedKey]) || array_key_exists($namespacedKey, $items)) {
|
||||
$foundItems[$requestedKey] = $items[$namespacedKey];
|
||||
}
|
||||
}
|
||||
|
||||
return $foundItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function saveMultiple(array $keysAndValues, $lifetime = 0)
|
||||
{
|
||||
$namespacedKeysAndValues = array();
|
||||
foreach ($keysAndValues as $key => $value) {
|
||||
$namespacedKeysAndValues[$this->getNamespacedId($key)] = $value;
|
||||
}
|
||||
|
||||
return $this->doSaveMultiple($namespacedKeysAndValues, $lifetime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function contains($id)
|
||||
{
|
||||
return $this->doContains($this->getNamespacedId($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function save($id, $data, $lifeTime = 0)
|
||||
{
|
||||
return $this->doSave($this->getNamespacedId($id), $data, $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
return $this->doDelete($this->getNamespacedId($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getStats()
|
||||
{
|
||||
return $this->doGetStats();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function flushAll()
|
||||
{
|
||||
return $this->doFlush();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function deleteAll()
|
||||
{
|
||||
$namespaceCacheKey = $this->getNamespaceCacheKey();
|
||||
$namespaceVersion = $this->getNamespaceVersion() + 1;
|
||||
|
||||
if ($this->doSave($namespaceCacheKey, $namespaceVersion)) {
|
||||
$this->namespaceVersion = $namespaceVersion;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefixes the passed id with the configured namespace value.
|
||||
*
|
||||
* @param string $id The id to namespace.
|
||||
*
|
||||
* @return string The namespaced id.
|
||||
*/
|
||||
private function getNamespacedId($id)
|
||||
{
|
||||
$namespaceVersion = $this->getNamespaceVersion();
|
||||
|
||||
return sprintf('%s[%s][%s]', $this->namespace, $id, $namespaceVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the namespace cache key.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getNamespaceCacheKey()
|
||||
{
|
||||
return sprintf(self::DOCTRINE_NAMESPACE_CACHEKEY, $this->namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the namespace version.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
private function getNamespaceVersion()
|
||||
{
|
||||
if (null !== $this->namespaceVersion) {
|
||||
return $this->namespaceVersion;
|
||||
}
|
||||
|
||||
$namespaceCacheKey = $this->getNamespaceCacheKey();
|
||||
$this->namespaceVersion = $this->doFetch($namespaceCacheKey) ?: 1;
|
||||
|
||||
return $this->namespaceVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation of doFetchMultiple. Each driver that supports multi-get should owerwrite it.
|
||||
*
|
||||
* @param array $keys Array of keys to retrieve from cache
|
||||
* @return array Array of values retrieved for the given keys.
|
||||
*/
|
||||
protected function doFetchMultiple(array $keys)
|
||||
{
|
||||
$returnValues = array();
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if (false !== ($item = $this->doFetch($key)) || $this->doContains($key)) {
|
||||
$returnValues[$key] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $returnValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches an entry from the cache.
|
||||
*
|
||||
* @param string $id The id of the cache entry to fetch.
|
||||
*
|
||||
* @return mixed|false The cached data or FALSE, if no cache entry exists for the given id.
|
||||
*/
|
||||
abstract protected function doFetch($id);
|
||||
|
||||
/**
|
||||
* Tests if an entry exists in the cache.
|
||||
*
|
||||
* @param string $id The cache id of the entry to check for.
|
||||
*
|
||||
* @return bool TRUE if a cache entry exists for the given cache id, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doContains($id);
|
||||
|
||||
/**
|
||||
* Default implementation of doSaveMultiple. Each driver that supports multi-put should override it.
|
||||
*
|
||||
* @param array $keysAndValues Array of keys and values to save in cache
|
||||
* @param int $lifetime The lifetime. If != 0, sets a specific lifetime for these
|
||||
* cache entries (0 => infinite lifeTime).
|
||||
*
|
||||
* @return bool TRUE if the operation was successful, FALSE if it wasn't.
|
||||
*/
|
||||
protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
|
||||
{
|
||||
$success = true;
|
||||
|
||||
foreach ($keysAndValues as $key => $value) {
|
||||
if (!$this->doSave($key, $value, $lifetime)) {
|
||||
$success = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts data into the cache.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
* @param string $data The cache entry/data.
|
||||
* @param int $lifeTime The lifetime. If != 0, sets a specific lifetime for this
|
||||
* cache entry (0 => infinite lifeTime).
|
||||
*
|
||||
* @return bool TRUE if the entry was successfully stored in the cache, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doSave($id, $data, $lifeTime = 0);
|
||||
|
||||
/**
|
||||
* Deletes a cache entry.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
*
|
||||
* @return bool TRUE if the cache entry was successfully deleted, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doDelete($id);
|
||||
|
||||
/**
|
||||
* Flushes all cache entries.
|
||||
*
|
||||
* @return bool TRUE if the cache entries were successfully flushed, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doFlush();
|
||||
|
||||
/**
|
||||
* Retrieves cached information from the data store.
|
||||
*
|
||||
* @since 2.2
|
||||
*
|
||||
* @return array|null An associative array with server's statistics if available, NULL otherwise.
|
||||
*/
|
||||
abstract protected function doGetStats();
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache that can be flushed.
|
||||
*
|
||||
* Intended to be used for partial clearing of a cache namespace. For a more
|
||||
* global "flushing", see {@see FlushableCache}.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 1.4
|
||||
* @author Adirelle <adirelle@gmail.com>
|
||||
*/
|
||||
interface ClearableCache
|
||||
{
|
||||
/**
|
||||
* Deletes all cache entries in the current cache namespace.
|
||||
*
|
||||
* @return bool TRUE if the cache entries were successfully deleted, FALSE otherwise.
|
||||
*/
|
||||
public function deleteAll();
|
||||
}
|
|
@ -0,0 +1,286 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Base file cache driver.
|
||||
*
|
||||
* @since 2.3
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
* @author Tobias Schultze <http://tobion.de>
|
||||
*/
|
||||
abstract class FileCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* The cache directory.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $directory;
|
||||
|
||||
/**
|
||||
* The cache file extension.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $extension;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $umask;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $directoryStringLength;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $extensionStringLength;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $isRunningOnWindows;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $directory The cache directory.
|
||||
* @param string $extension The cache file extension.
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct($directory, $extension = '', $umask = 0002)
|
||||
{
|
||||
// YES, this needs to be *before* createPathIfNeeded()
|
||||
if ( ! is_int($umask)) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'The umask parameter is required to be integer, was: %s',
|
||||
gettype($umask)
|
||||
));
|
||||
}
|
||||
$this->umask = $umask;
|
||||
|
||||
if ( ! $this->createPathIfNeeded($directory)) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'The directory "%s" does not exist and could not be created.',
|
||||
$directory
|
||||
));
|
||||
}
|
||||
|
||||
if ( ! is_writable($directory)) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'The directory "%s" is not writable.',
|
||||
$directory
|
||||
));
|
||||
}
|
||||
|
||||
// YES, this needs to be *after* createPathIfNeeded()
|
||||
$this->directory = realpath($directory);
|
||||
$this->extension = (string) $extension;
|
||||
|
||||
$this->directoryStringLength = strlen($this->directory);
|
||||
$this->extensionStringLength = strlen($this->extension);
|
||||
$this->isRunningOnWindows = defined('PHP_WINDOWS_VERSION_BUILD');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cache directory.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDirectory()
|
||||
{
|
||||
return $this->directory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cache file extension.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExtension()
|
||||
{
|
||||
return $this->extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getFilename($id)
|
||||
{
|
||||
$hash = hash('sha256', $id);
|
||||
|
||||
// This ensures that the filename is unique and that there are no invalid chars in it.
|
||||
if (
|
||||
'' === $id
|
||||
|| ((strlen($id) * 2 + $this->extensionStringLength) > 255)
|
||||
|| ($this->isRunningOnWindows && ($this->directoryStringLength + 4 + strlen($id) * 2 + $this->extensionStringLength) > 258)
|
||||
) {
|
||||
// Most filesystems have a limit of 255 chars for each path component. On Windows the the whole path is limited
|
||||
// to 260 chars (including terminating null char). Using long UNC ("\\?\" prefix) does not work with the PHP API.
|
||||
// And there is a bug in PHP (https://bugs.php.net/bug.php?id=70943) with path lengths of 259.
|
||||
// So if the id in hex representation would surpass the limit, we use the hash instead. The prefix prevents
|
||||
// collisions between the hash and bin2hex.
|
||||
$filename = '_' . $hash;
|
||||
} else {
|
||||
$filename = bin2hex($id);
|
||||
}
|
||||
|
||||
return $this->directory
|
||||
. DIRECTORY_SEPARATOR
|
||||
. substr($hash, 0, 2)
|
||||
. DIRECTORY_SEPARATOR
|
||||
. $filename
|
||||
. $this->extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
return @unlink($filename) || ! file_exists($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
foreach ($this->getIterator() as $name => $file) {
|
||||
if ($file->isDir()) {
|
||||
// Remove the intermediate directories which have been created to balance the tree. It only takes effect
|
||||
// if the directory is empty. If several caches share the same directory but with different file extensions,
|
||||
// the other ones are not removed.
|
||||
@rmdir($name);
|
||||
} elseif ($this->isFilenameEndingWithExtension($name)) {
|
||||
// If an extension is set, only remove files which end with the given extension.
|
||||
// If no extension is set, we have no other choice than removing everything.
|
||||
@unlink($name);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$usage = 0;
|
||||
foreach ($this->getIterator() as $name => $file) {
|
||||
if (! $file->isDir() && $this->isFilenameEndingWithExtension($name)) {
|
||||
$usage += $file->getSize();
|
||||
}
|
||||
}
|
||||
|
||||
$free = disk_free_space($this->directory);
|
||||
|
||||
return array(
|
||||
Cache::STATS_HITS => null,
|
||||
Cache::STATS_MISSES => null,
|
||||
Cache::STATS_UPTIME => null,
|
||||
Cache::STATS_MEMORY_USAGE => $usage,
|
||||
Cache::STATS_MEMORY_AVAILABLE => $free,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create path if needed.
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool TRUE on success or if path already exists, FALSE if path cannot be created.
|
||||
*/
|
||||
private function createPathIfNeeded($path)
|
||||
{
|
||||
if ( ! is_dir($path)) {
|
||||
if (false === @mkdir($path, 0777 & (~$this->umask), true) && !is_dir($path)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a string content to file in an atomic way.
|
||||
*
|
||||
* @param string $filename Path to the file where to write the data.
|
||||
* @param string $content The content to write
|
||||
*
|
||||
* @return bool TRUE on success, FALSE if path cannot be created, if path is not writable or an any other error.
|
||||
*/
|
||||
protected function writeFile($filename, $content)
|
||||
{
|
||||
$filepath = pathinfo($filename, PATHINFO_DIRNAME);
|
||||
|
||||
if ( ! $this->createPathIfNeeded($filepath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! is_writable($filepath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$tmpFile = tempnam($filepath, 'swap');
|
||||
@chmod($tmpFile, 0666 & (~$this->umask));
|
||||
|
||||
if (file_put_contents($tmpFile, $content) !== false) {
|
||||
if (@rename($tmpFile, $filename)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@unlink($tmpFile);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Iterator
|
||||
*/
|
||||
private function getIterator()
|
||||
{
|
||||
return new \RecursiveIteratorIterator(
|
||||
new \RecursiveDirectoryIterator($this->directory, \FilesystemIterator::SKIP_DOTS),
|
||||
\RecursiveIteratorIterator::CHILD_FIRST
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name The filename
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isFilenameEndingWithExtension($name)
|
||||
{
|
||||
return '' === $this->extension
|
||||
|| strrpos($name, $this->extension) === (strlen($name) - $this->extensionStringLength);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Filesystem cache driver.
|
||||
*
|
||||
* @since 2.3
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
*/
|
||||
class FilesystemCache extends FileCache
|
||||
{
|
||||
const EXTENSION = '.doctrinecache.data';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($directory, $extension = self::EXTENSION, $umask = 0002)
|
||||
{
|
||||
parent::__construct($directory, $extension, $umask);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
$data = '';
|
||||
$lifetime = -1;
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
if ( ! is_file($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$resource = fopen($filename, "r");
|
||||
|
||||
if (false !== ($line = fgets($resource))) {
|
||||
$lifetime = (int) $line;
|
||||
}
|
||||
|
||||
if ($lifetime !== 0 && $lifetime < time()) {
|
||||
fclose($resource);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
while (false !== ($line = fgets($resource))) {
|
||||
$data .= $line;
|
||||
}
|
||||
|
||||
fclose($resource);
|
||||
|
||||
return unserialize($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
$lifetime = -1;
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
if ( ! is_file($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$resource = fopen($filename, "r");
|
||||
|
||||
if (false !== ($line = fgets($resource))) {
|
||||
$lifetime = (int) $line;
|
||||
}
|
||||
|
||||
fclose($resource);
|
||||
|
||||
return $lifetime === 0 || $lifetime > time();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
if ($lifeTime > 0) {
|
||||
$lifeTime = time() + $lifeTime;
|
||||
}
|
||||
|
||||
$data = serialize($data);
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
return $this->writeFile($filename, $lifeTime . PHP_EOL . $data);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache that can be flushed.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 1.4
|
||||
* @author Adirelle <adirelle@gmail.com>
|
||||
*/
|
||||
interface FlushableCache
|
||||
{
|
||||
/**
|
||||
* Flushes all cache entries, globally.
|
||||
*
|
||||
* @return bool TRUE if the cache entries were successfully flushed, FALSE otherwise.
|
||||
*/
|
||||
public function flushAll();
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers that allows to get many items at once.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 1.4
|
||||
* @author Asmir Mustafic <goetas@gmail.com>
|
||||
*/
|
||||
interface MultiGetCache
|
||||
{
|
||||
/**
|
||||
* Returns an associative array of values for keys is found in cache.
|
||||
*
|
||||
* @param string[] $keys Array of keys to retrieve from cache
|
||||
* @return mixed[] Array of retrieved values, indexed by the specified keys.
|
||||
* Values that couldn't be retrieved are not contained in this array.
|
||||
*/
|
||||
function fetchMultiple(array $keys);
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers that allows to put many items at once.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 1.6
|
||||
* @author Daniel Gorgan <danut007ro@gmail.com>
|
||||
*/
|
||||
interface MultiPutCache
|
||||
{
|
||||
/**
|
||||
* Returns a boolean value indicating if the operation succeeded.
|
||||
*
|
||||
* @param array $keysAndValues Array of keys and values to save in cache
|
||||
* @param int $lifetime The lifetime. If != 0, sets a specific lifetime for these
|
||||
* cache entries (0 => infinite lifeTime).
|
||||
*
|
||||
* @return bool TRUE if the operation was successful, FALSE if it wasn't.
|
||||
*/
|
||||
function saveMultiple(array $keysAndValues, $lifetime = 0);
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
20201215-1400.28
|
||||
fix: hackers can upload files to ANY folder (or create a new folder) in your Onedrive. add language zh-tw. now, on heroku, xhr can post. fix: 2 or more space in file name cause bugs.
|
||||
修复:构造代码后可以上传文件到你Onedrive的任意目录(甚至创建新目录)。新增zh-tw语言。xhr的post在heroku会接收了,改回post。修复:文件名有多个空格相连时造成bug。
|
||||
|
||||
20201106-1730.27
|
||||
Add theme. A code used in CloudFlare Workers. Admin not need password in folder. Add caddy2 rewrite rule. Add new platform Glitch. <font color=red>web hosting and VPS user should backup your config.php, after update, copy it to .data foloder.</font>
|
||||
添加主题。添加一段用于CF workers的代码。加密目录管理员不需要密码了。添加caddy2伪静态。新增Glitch平台。<font color=red>虚拟主机与VPS用户请备份config.php,升级后,手动将它覆盖到.data目录。</font>
|
||||
20200828-1420.26
|
||||
nginx rewrite rule exclude .well-known folder, as auto SSL. add web.config to rewrite in IIS. now in windwos can do with \ in path. in aliyun FC & huawei FG API, use my code. CN 21Vianet client_id&secret expire. update description now only show new.
|
||||
nginx的伪静态中排除.well-known目录,方便自动SSL。添加IIS的伪静态。与linux不同,处理windows下目录用\分隔。FC、FG中使用自己代码对接平台。<font color=red>世纪互联旧API即将过期失效,升级后世纪互联的盘需要删除重新添加。</font>更新说明只显示部分。
|
||||
20200817-1740.25
|
||||
when multy disks, now will default show disks as folders in root, if set autoJumpFirstDisk 1, it will auto jump to first disk.
|
||||
多盘时,在网站根目录,默认会将各盘当成文件夹显示,可以去设置中设置autoJumpFirstDisk为1,这样可以跟以前一样自动跳到第一个盘。
|
||||
20200816-1145.24
|
||||
add platform: Baidu CFC. add setting: mobile background.
|
||||
新增百度CFC平台。可以分别设置PC与手机的背景。
|
||||
20200808-1130.23
|
||||
FG: select save in env or file.
|
||||
在FG中安装时,选择配置保存在环境变量还是文件中。
|
||||
20200806-1130.23
|
||||
SCF: select save in env or file.
|
||||
在SCF中安装时,选择配置保存在环境变量还是文件中。
|
||||
20200804-1453.22
|
||||
fix: once error will stop the after files in uploading multy files. SCF can get region now, change install. SCF config save in code file now not in env, <font color=red>if use SCF, you must reinstall after update</font>.
|
||||
修复,当上传多个文件时,一个文件出错将导致后续文件不再上传。SCF可以获取到region了,安装过程修改。在SCF中,现在将配置保存到代码文件中,不受环境变量4K大小限制,<font color=red>升级后,用SCF的要重装</font>。
|
||||
20200723-1430.21
|
||||
fix content-type in "?json". can not custom microsoft API id & secret by a link now, so show the return uri.
|
||||
当使用"?json"时,现在content-type是json了。现在微软不能一键创建API应用了,提供回调URI。
|
||||
20200713-1800.20
|
||||
add platform: Huawei cloud Function Graph. now you can use "?json" to get a json of folder or file. fix some bug.
|
||||
新增白嫖平台:华为云函数工作流FG。可以用"?json"来获得目录或文件的json。修复bug。
|
||||
20200607-1856.19
|
||||
add platform: Aliyun Function Compute. add setting: replace sharepoint.com to a proxy server name. add setting: disableShowThumb,customTheme. add function: php hosting website can update by a click
|
||||
现在可以安装到阿里函数计算FC了。php空间可以一键更新了。可以设置某个盘替换sharpoint.com域名为你的反代域名。新增disableShowThumb,customTheme。
|
||||
20200503-1848.18
|
||||
Rebuild theme. Add custom Css & custom Script, add FunctionalityFile: head.omf & foot.omf.
|
||||
重建主题文件结构。增加自定义css与自定义script。增加2个功能文件:head.omf、foot.omf。
|
||||
20200402-1830.17
|
||||
Oneclick update can select which branch to update. Now use the accept language instead of the language config.
|
||||
一键更新可以选择哪个分支了。现在开始使用浏览器语言,抛弃language设置。
|
||||
20200326-0001.16
|
||||
You can add sharepoint site drive as a disk, <font color=red>you must reinstall after update</font>.
|
||||
可以将sharepoint网站添加成一个盘,<font color=red>由于结构改变,升级后只能重装</font>。
|
||||
20200321-1830.15
|
||||
本次更新后,'index.html'功能在其它主题会导致bug。
|
||||
文本类文件将缓存;添加hideFunctionalityFile开关;在添加网盘时会显示已经在用的标签。
|
||||
after this update, then 'index.html' function will bug in other theme.
|
||||
cache text file content;add hideFunctionalityFile;list exist disktags when AddDisk。
|
||||
20200311-2150.14
|
||||
Add a switch, can download a known file or not, while the folder is encrypted.
|
||||
Hide time and size in mobile.
|
||||
Now, you can get a random 'jpg' from a folder when you type '?random=jpg' after the folder.
|
||||
增加一个开关,在目录加密后能否下载其中的某个文件。
|
||||
在手机上浏览时,隐藏修改时间跟大小。
|
||||
加入一个功能,现在可以在某个目录后面加上'?random=jpg'来得到本目录里面的一张随机jpg。
|
||||
20200229-1300.13
|
||||
In SCF, some config can input Special symbols now, like ?&= 。
|
||||
在SCF中,某些配置可以输入特殊符号了,像background可以用?&=之类的了。
|
||||
20200225-1310.12
|
||||
Can update by one click any time. fix bugs: special tag, reupload.
|
||||
可以不管版本直接一键更新(覆盖)了。修复可以使用特殊onedrive标签的bug,修复断网续传的问题。
|
||||
20200222-2130.11
|
||||
you can set background now. fix bug: 2nd disk upload.
|
||||
可以设置背景图片了。第2个盘上传后链接不对。
|
||||
20200222-1700.09
|
||||
Can copy file and folder now.
|
||||
可以复制文件跟目录了。
|
||||
20200220-1220.08
|
||||
Multy Mode! You can add more Onedrive in one project (bind Onedrive in setup). And now, heroku apps can update in setup!
|
||||
多盘来了,在设置中添加Onedrive,另,heroku 上也能一键更新了!
|
||||
20200215-1850.07
|
||||
fix: head.md not show if no readme.md.
|
||||
修复当没有readme的时候就不显示head的问题。
|
||||
20200215-1700.06
|
||||
classic theme can read the head.md file now.
|
||||
classic主题可以处理head.md文件了。
|
||||
20200202-2010.05
|
||||
refresh token expires in 90 day, save a new token per month. classic theme add some icon for admin.
|
||||
refresh token 90天过期,所以每月保存一个新的token。classic主题加了点管理图标。
|
||||
20200129-2050.04
|
||||
if there is 'index.html', then do not show file but show the index.html, except admin.
|
||||
如果有index.html,就不显示文件列表了,直接显示index.html内容,除非是管理员。
|
||||
20200120.02
|
||||
fix domain_path do not work. domain_path正常工作了。
|
||||
20200118.01
|
||||
Can be deploy to heroku/SCF/normal space. SCF、heroku、普通VPS,三种环境都可以用了。
|
||||
Change imgup_path to guestup_path, plz make sure it after update. 将imgup_path改成guestup_path更符合用途,更新后请注意更改。
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<rewrite>
|
||||
<rules>
|
||||
<rule name="OneManagerIISRewrite" patternSyntax="Wildcard" stopProcessing="true">
|
||||
<match url="*" />
|
||||
<action type="Rewrite" url="index.php" appendQueryString="false" logRewrittenUrl="false" />
|
||||
</rule>
|
||||
</rules>
|
||||
</rewrite>
|
||||
</system.webServer>
|
||||
</configuration>
|
|
@ -0,0 +1,3 @@
|
|||
OneManagerPath=`cd $(dirname $0);pwd -P`
|
||||
cd ${OneManagerPath}
|
||||
chmod 666 .data/config.php
|
Loading…
Reference in New Issue