92 Commits
Author SHA1 Message Date
qkqpttgfandGitHub 646c963eba Update version 2021-12-01 16:12:57 +08:00
qkqpttgfandGitHub ae757bef84 add setup=auth, check if another building 2021-12-01 14:55:41 +08:00
qkqpttgfandGitHub 21c1120867 add setup=auth, check if another building 2021-12-01 14:54:29 +08:00
qkqpttgfandGitHub 05531b5fe1 add setup=auth 2021-12-01 14:51:43 +08:00
qkqpttgfandGitHub 8c270bb7eb add setup=auth 2021-12-01 14:50:41 +08:00
qkqpttgfandGitHub f439497c6a add setup=auth 2021-12-01 14:39:21 +08:00
qkqpttgfandGitHub 717b454256 add setup=auth 2021-12-01 14:38:07 +08:00
qkqpttgfandGitHub eee1c5511a add setup=auth 2021-12-01 14:36:52 +08:00
qkqpttgfandGitHub 92d4401070 add setup=auth 2021-12-01 14:30:36 +08:00
qkqpttgfandGitHub 7d56bde181 add setup=auth 2021-12-01 14:29:16 +08:00
qkqpttgfandGitHub 7fbc9c8285 add setup=auth 2021-12-01 14:26:01 +08:00
qkqpttgfandGitHub 41ca3bc56f try fix no driver in config sometime 2021-12-01 14:24:38 +08:00
qkqpttgfandGitHub 42e06e647d mv waitfunction before install, add setp=auth 2021-12-01 14:23:18 +08:00
qkqpttgfandGitHub 9fdd9227a5 remove ts, add 3gp 2021-11-27 12:38:49 +08:00
qkqpttgfandGitHub 6383864bb6 short fix back link when spacialChar 2021-11-26 14:54:39 +08:00
qkqpttgfandGitHub e6abbc6086 fix back link with spacialChar 2021-11-26 09:46:25 +08:00
qkqpttgfandGitHub 340c84ef76 try clear cache after upload done 2021-11-25 15:46:06 +08:00
qkqpttgfandGitHub a44ca9f83c login by jump not dialog 2021-11-25 14:06:13 +08:00
qkqpttgfandGitHub 78c616b52d fix sort when size is TB
#470 ,
2021-11-23 20:07:55 +08:00
qkqpttgfandGitHub e0d7bba0fb Redirect when folder not end with / (fix disktag with no /) 2021-11-23 19:59:41 +08:00
qkqpttgfandGitHub 51d7e13ca5 sort config in vercel file 2021-11-16 13:35:03 +08:00
qkqpttgfandGitHub af90ff91f7 fix ' in path cause js error 2021-11-16 11:24:28 +08:00
qkqpttgfandGitHub 06988494b3 order_by name asc 2021-11-14 17:17:17 +08:00
root 9d677c8aee fix: too many redirect in SCF/FC/FG/CFC 2021-11-10 11:42:19 +00:00
qkqpttgfandGitHub 724f357fc4 fix: too many redirect in SCF long link 2021-11-10 18:40:24 +08:00
qkqpttgfandGitHub 2f48674ef8 Update readme_cn.md 2021-11-08 18:56:39 +08:00
qkqpttgfandGitHub e34cfb173c Update readme.md 2021-11-08 18:55:59 +08:00
qkqpttgfandGitHub 7627fd78eb Update readme_cn.md 2021-11-08 18:48:53 +08:00
qkqpttgfandGitHub 83ee24fc90 check if exist curl in vps at php start, not install 2021-11-04 10:41:25 +08:00
qkqpttgfandGitHub 2dfd11c8d1 check if exist curl in vps at begin
#462 check curl mod
2021-11-04 10:39:57 +08:00
qkqpttgfandGitHub 4577a35b83 Redirect when folder not end with /
#465 fix
2021-11-04 10:36:28 +08:00
qkqpttgfandGitHub 880f90b026 try fix encrypt current directory at left-top 2021-11-01 18:50:13 +08:00
qkqpttgfandGitHub 51cc75c0f5 try fix encrypt current directory at left-top 2021-11-01 18:49:35 +08:00
qkqpttgfandGitHub 457e2cee18 try to check exist curl before install 2021-11-01 18:45:49 +08:00
qkqpttgfandGitHub 0d2f38af37 Create CFWorkers_rand.js 2021-10-28 10:56:24 +08:00
qkqpttgfandGitHub 0683524cd3 try fix + in FG 2021-10-25 10:58:10 +08:00
qkqpttgfandGitHub 22fb9dd669 try fix + in FG 2021-10-25 10:57:24 +08:00
qkqpttgfandGitHub 621aadecdf fix export&import with no localstorage 2021-10-22 13:36:26 +08:00
qkqpttgfandGitHub 330ec7680d fix fix a bug 2021-10-21 17:08:12 +08:00
qkqpttgfandGitHub d8a1832c01 fix a bug
#448 .
2021-10-21 16:43:52 +08:00
qkqpttgfandGitHub 89e4fa6f42 try fix login in specialChar folder will jump to error 2021-10-21 16:20:01 +08:00
qkqpttgfandGitHub 13e72665ac fix & in title 2021-10-21 12:49:24 +08:00
qkqpttgfandGitHub d02c9beb53 encrypt via fileID 2021-10-21 11:40:55 +08:00
qkqpttgfandGitHub 07664407c6 encrypt via fileID, try fix get pass from specialchars folder 2021-10-21 11:39:09 +08:00
qkqpttgfandGitHub 9623e03c3f try fix index.html in specialchars folder 2021-10-20 17:11:09 +08:00
qkqpttgfandGitHub b737194bea try fix readme in specialchars folder 2021-10-20 17:01:09 +08:00
qkqpttgfandGitHub a3108ad6e9 fix show special chars in url textarea 2021-10-20 11:34:14 +08:00
qkqpttgfandGitHub 239ddea6f3 try fix specialchars 2021-10-20 11:33:09 +08:00
qkqpttgfandGitHub d4adc8233e fix: AddDisk with no driver name
#449 .
2021-10-20 09:49:55 +08:00
qkqpttgfandGitHub 04721295fa fix random on a file cause error in php8
#446 fix
2021-10-19 14:36:15 +08:00
qkqpttgfandGitHub 5b232b3ef5 fix cant change disk order 2021-10-18 10:34:54 +08:00
qkqpttgfandGitHub 9381bcaab3 try fix & in base_path in FC 2021-10-15 17:26:29 +08:00
qkqpttgfandGitHub bab19ae9d3 try fix PathArray with & , last not preview 2021-10-15 16:54:54 +08:00
qkqpttgfandGitHub 07c715c7e0 try fix # in title 2021-10-15 13:44:06 +08:00
qkqpttgfandGitHub 37993f0113 try fix # 2021-10-15 13:26:57 +08:00
qkqpttgfandGitHub bec4e3c91f Create readme_cn.md 2021-10-15 10:57:23 +08:00
qkqpttgfandGitHub 44b8738b0c separate en/cn 2021-10-15 10:56:32 +08:00
qkqpttgfandGitHub 978c7722e4 fix too many redirect when adddisk with no admin
#259 thx
2021-10-14 10:00:43 +08:00
qkqpttgfandGitHub 212a7008dd focus at last, in cmd 2021-10-13 18:08:52 +08:00
qkqpttgfandGitHub f924b116db fix XSS in random file 2021-10-07 14:32:22 +08:00
qkqpttgfandGitHub 0220c29dbf fix cant upload 2021-10-07 12:39:49 +08:00
qkqpttgfandGitHub cb478ccf66 operate by id 2021-10-06 19:28:05 +08:00
qkqpttgfandGitHub 0a0162abe2 fix & 2021-10-06 16:32:23 +08:00
root 9205015782 fix CSRF, try fix %20 2021-10-06 08:01:31 +00:00
qkqpttgfandGitHub 76249edf4d Merge pull request #436 from ifwlzs/master
Update readme.md
2021-10-04 19:05:42 +08:00
ifwlzsandGitHub 5eb8fc8172 Update readme.md 2021-10-04 18:57:06 +08:00
qkqpttgfandGitHub 45a7b1e303 try fix filename have () or other in FC 2021-09-28 12:47:06 +08:00
qkqpttgfandGitHub d2fd1f3a05 try fix filename have [] in FC 2021-09-28 11:01:44 +08:00
qkqpttgfandGitHub bb31dee01d Merge pull request #427 from Sansui233/master
Update theme flatcard
2021-09-22 09:07:20 +08:00
Sansui233 8e53c2883d fix vertical align 2021-09-21 20:37:52 +08:00
Sansui233 a167ce1376 add responsive grid-view when thumbnails 2021-09-21 20:03:34 +08:00
Sansui233 4c14349c76 add grid-view 2021-09-21 20:03:34 +08:00
Sansui233 cec9cfd800 save 2021-09-21 20:03:33 +08:00
qkqpttgfandGitHub 76524fbced video add ts
#388
2021-09-10 09:21:31 +08:00
qkqpttgfandGitHub 369e5c3394 fileConduit 2021-09-08 18:07:03 +08:00
qkqpttgfandGitHub d2909b85bc fileConduit 2021-09-08 18:06:53 +08:00
root 8dea16da78 add littleFileCacheTime 2021-09-08 05:03:36 +00:00
qkqpttgfandGitHub ee23cd636f chang ' to "
#418 ,
2021-09-06 20:21:18 +08:00
qkqpttgfandGitHub c7f4089b2a add Hidden function "cmd" 2021-09-03 09:04:56 +08:00
root bdfee2c81b fix error in wait function 2021-08-26 10:09:57 +00:00
qkqpttgfandGitHub b6860e373a move BackHome up Title 2021-08-24 03:31:59 +00:00
qkqpttgfandGitHub f81284b3f9 wait app build in heroku 2021-08-23 13:18:54 +08:00
qkqpttgfandGitHub 8a4341cbd2 fix : cant find lower readme.md in Aliyundrive 2021-08-23 10:40:00 +08:00
qkqpttgfandGitHub 45648eb676 translate "change password" & "export, import"
#359
2021-08-21 12:07:25 +00:00
qkqpttgfandGitHub f3668b79e9 translate "change password" & "export, import" 2021-08-21 12:03:40 +00:00
qkqpttgfandGitHub 3aecc1ddf5 Update readme.md 2021-08-20 18:56:14 +08:00
qkqpttgfandGitHub 4f6241d445 fix: not put config when update 2021-08-20 10:51:14 +00:00
qkqpttgfandGitHub 5cdf343415 Update version 2021-08-20 10:35:01 +00:00
qkqpttgfandGitHub 24def8d1ab config save in file default in Vercel 2021-08-20 10:09:16 +00:00
qkqpttgfandGitHub d61ed7a03c Create Vercel.php 2021-08-20 10:07:33 +00:00
qkqpttgfandGitHub 536a8e60da Rename Vercel.php to Vercel_env.php 2021-08-20 10:06:58 +00:00
qkqpttgfandGitHub dc58b15913 fix bug, cant save config 2021-08-19 01:27:03 +00:00
22 changed files with 2185 additions and 548 deletions
+113
View File
@@ -0,0 +1,113 @@
// Hosts Array
// 服务器数组
const H = [
'https://herooneindex.herokuapp.com/',
'https://onemanager.glitch.me/',
'https://onemanager-php.vercel.app/'
]
// View Type
// 1 , only first host,
// 只第一条Host记录有用
// 2 , view top 2 host as odd/even days,
// 只有前两条记录有效,分别单双日运行
// 3 , view random host
// 所有记录随机访问
const T = 1
// CF proxy all, true/false
// 一切给CF代理,true或false
const CFproxy = true
// Used in cloudflare workers
// // // // // //
addEventListener('fetch', event => {
let url=new URL(event.request.url);
if (url.protocol == 'http:') {
// force HTTPS
url.protocol = 'https:'
event.respondWith( Response.redirect(url.href) )
} else {
let host = null;
if (T===1) {
host = H[0];
}
if (T===2) {
host = H[new Date().getDate()%2];
}
if (T===3) {
let n = H.length;
host = H[Math.round(Math.random()*n*10)%n];
}
//console.log(host)
if (host.substr(0, 7)!='http://'&&host.substr(0, 8)!='https://') host = 'http://' + host;
let 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, {
/*cf: {
cacheEverything: true,
cacheTtl: 1000,
mirage: true,
polish: "on",
minify: {
javascript: true,
css: true,
html: true,
}
},*/
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 (replace_path!='/'&&out_body.includes(replace_path)) out_body = out_body.replace(replace_path, replaced_path);
} else if (contentType.includes("text/html")) {
//f_url.href +
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;
}
+304 -145
View File
@@ -59,6 +59,8 @@ $EnvConfigs = [
'guestup_path' => 0b111, 'guestup_path' => 0b111,
'domainforproxy' => 0b111, 'domainforproxy' => 0b111,
'public_path' => 0b111, 'public_path' => 0b111,
'fileConduitSize' => 0b110,
'fileConduitCacheTime' => 0b110,
]; ];
$timezones = array( $timezones = array(
@@ -165,6 +167,13 @@ function main($path)
if (isset($_COOKIE['timezone'])&&$_COOKIE['timezone']!='') $_SERVER['timezone'] = $_COOKIE['timezone']; if (isset($_COOKIE['timezone'])&&$_COOKIE['timezone']!='') $_SERVER['timezone'] = $_COOKIE['timezone'];
if ($_SERVER['timezone']=='') $_SERVER['timezone'] = 0; if ($_SERVER['timezone']=='') $_SERVER['timezone'] = 0;
if (isset($_GET['WaitFunction'])) {
$response = WaitFunction($_GET['WaitFunction']);
//var_dump($response);
if ($response===true) return output("ok", 200);
elseif ($response===false) return output("", 206);
else return $response;
}
if (getConfig('admin')=='') return install(); if (getConfig('admin')=='') return install();
if (getConfig('adminloginpage')=='') { if (getConfig('adminloginpage')=='') {
$adminloginpage = 'admin'; $adminloginpage = 'admin';
@@ -172,19 +181,23 @@ function main($path)
$adminloginpage = getConfig('adminloginpage'); $adminloginpage = getConfig('adminloginpage');
} }
if (isset($_GET[$adminloginpage])) { if (isset($_GET[$adminloginpage])) {
if (isset($_GET['preview'])) { /*if (isset($_GET['preview'])) {
$url = $_SERVER['PHP_SELF'] . '?preview'; $url = $_SERVER['PHP_SELF'] . '?preview';
} else { } else {
$url = path_format($_SERVER['PHP_SELF'] . '/'); $url = path_format($_SERVER['PHP_SELF'] . '/');
} }*/
if (isset($_POST['password1'])) { if (isset($_POST['password1'])) {
$compareresult = compareadminsha1($_POST['password1'], $_POST['timestamp'], getConfig('admin')); $compareresult = compareadminsha1($_POST['password1'], $_POST['timestamp'], getConfig('admin'));
if ($compareresult=='') { if ($compareresult=='') {
return adminform('admin', adminpass2cookie('admin', getConfig('admin')), $url); $timestamp = time()+7*24*60*60;
$randnum = rand(10, 99999);
$admincookie = adminpass2cookie('admin', getConfig('admin'), $timestamp, $randnum);
$adminlocalstorage = adminpass2storage('admin', getConfig('admin'), $timestamp, $randnum);
return adminform('admin', $admincookie, $adminlocalstorage);
} else return adminform($compareresult); } else return adminform($compareresult);
} else return adminform(); } else return adminform();
} }
if ( isset($_COOKIE['admin'])&&compareadminmd5($_COOKIE['admin'], 'admin', getConfig('admin')) ) { if ( isset($_COOKIE['admin'])&&compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin']) ) {
$_SERVER['admin']=1; $_SERVER['admin']=1;
$_SERVER['needUpdate'] = needUpdate(); $_SERVER['needUpdate'] = needUpdate();
} else { } else {
@@ -198,13 +211,6 @@ function main($path)
$url = path_format($_SERVER['PHP_SELF'] . '/'); $url = path_format($_SERVER['PHP_SELF'] . '/');
return output('<script>alert(\''.getconstStr('SetSecretsFirst').'\');</script>', 302, [ 'Location' => $url ]); return output('<script>alert(\''.getconstStr('SetSecretsFirst').'\');</script>', 302, [ 'Location' => $url ]);
} }
if (isset($_GET['WaitFunction'])) {
$response = WaitFunction($_GET['WaitFunction']);
//var_dump($response);
if ($response===true) return output("ok", 200);
elseif ($response===false) return output("", 206);
else return $response;
}
$_SERVER['sitename'] = getConfig('sitename'); $_SERVER['sitename'] = getConfig('sitename');
if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = getconstStr('defaultSitename'); if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = getconstStr('defaultSitename');
@@ -243,26 +249,33 @@ function main($path)
return output('Please visit <a href="' . $tmp . '">' . $tmp . '</a>.', 302, [ 'Location' => $tmp ]); return output('Please visit <a href="' . $tmp . '">' . $tmp . '</a>.', 302, [ 'Location' => $tmp ]);
//return message('<meta http-equiv="refresh" content="2;URL='.$_SERVER['base_path'].'">Please visit from <a href="'.$_SERVER['base_path'].'">Home Page</a>.', 'Error', 404); //return message('<meta http-equiv="refresh" content="2;URL='.$_SERVER['base_path'].'">Please visit from <a href="'.$_SERVER['base_path'].'">Home Page</a>.', 'Error', 404);
} }
$path = substr($path, strlen('/' . $_SERVER['disktag'])); //$path = substr($path, strlen('/' . $_SERVER['disktag']));
$path = splitfirst($path, $_SERVER['disktag'])[1];
if ($_SERVER['disktag']!='') $_SERVER['base_disk_path'] = path_format($_SERVER['base_disk_path'] . '/' . $_SERVER['disktag'] . '/'); if ($_SERVER['disktag']!='') $_SERVER['base_disk_path'] = path_format($_SERVER['base_disk_path'] . '/' . $_SERVER['disktag'] . '/');
} }
} else $_SERVER['disktag'] = $disktags[0]; } else $_SERVER['disktag'] = $disktags[0];
// echo 'main.disktag:'.$_SERVER['disktag'].'path:'.$path.''; // echo 'main.disktag:'.$_SERVER['disktag'].'path:'.$path.'';
$_SERVER['list_path'] = getListpath($_SERVER['HTTP_HOST']); $_SERVER['list_path'] = getListpath($_SERVER['HTTP_HOST']);
if ($_SERVER['list_path']=='') $_SERVER['list_path'] = '/'; if ($_SERVER['list_path']=='') $_SERVER['list_path'] = '/';
$path1 = path_format($_SERVER['list_path'] . path_format($path));
if ($path1!='/' && substr($path1,-1)=='/') $path1 = substr($path1, 0, -1);
$_SERVER['is_guestup_path'] = is_guestup_path($path); $_SERVER['is_guestup_path'] = is_guestup_path($path);
$_SERVER['ajax']=0; $_SERVER['ajax']=0;
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) if ($_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest') $_SERVER['ajax']=1; if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) if ($_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest') $_SERVER['ajax']=1;
// Add disk // Add disk
if (isset($_GET['AddDisk'])) { if (isset($_GET['AddDisk'])) {
if ($_GET['AddDisk']===true) {
$tmp = path_format($_SERVER['base_path'] . '/' . $path);
return output('Please visit <a href="' . $tmp . '">' . $tmp . '</a>.', 301, [ 'Location' => $tmp ]);
}
if ($_SERVER['admin']) { if ($_SERVER['admin']) {
if (!class_exists($_GET['AddDisk'])) require 'disk' . $slash . $_GET['AddDisk'] . '.php'; if (!class_exists($_GET['AddDisk'])) require 'disk' . $slash . $_GET['AddDisk'] . '.php';
$drive = new $_GET['AddDisk']($_GET['disktag']); $drive = new $_GET['AddDisk']($_GET['disktag']);
return $drive->AddDisk(); return $drive->AddDisk();
} else { } else {
$url = $_SERVER['PHP_SELF']; $url = $_SERVER['PHP_SELF'];
if ($_GET) { /*if ($_GET) {
$tmp = null; $tmp = null;
$tmp = ''; $tmp = '';
foreach ($_GET as $k => $v) { foreach ($_GET as $k => $v) {
@@ -273,7 +286,8 @@ function main($path)
} }
$tmp = substr($tmp, 1); $tmp = substr($tmp, 1);
if ($tmp!='') $url .= '?' . $tmp; if ($tmp!='') $url .= '?' . $tmp;
} }*/
// not need GET adddisk, remove it
return output('<script>alert(\''.getconstStr('SetSecretsFirst').'\');</script>', 302, [ 'Location' => $url ]); return output('<script>alert(\''.getconstStr('SetSecretsFirst').'\');</script>', 302, [ 'Location' => $url ]);
} }
} }
@@ -289,6 +303,7 @@ function main($path)
if ($_SERVER['ajax']) { if ($_SERVER['ajax']) {
if ($_GET['action']=='del_upload_cache') { if ($_GET['action']=='del_upload_cache') {
// del '.tmp' without login. 无需登录即可删除.tmp后缀文件 // del '.tmp' without login. 无需登录即可删除.tmp后缀文件
savecache('path_' . $path1, '', $_SERVER['disktag'], 1); // clear cache.
return $drive->del_upload_cache($path); return $drive->del_upload_cache($path);
} }
if ($_GET['action']=='upbigfile') { if ($_GET['action']=='upbigfile') {
@@ -297,8 +312,6 @@ function main($path)
if (strpos($_GET['upbigfilename'], '../')!==false) return output('Not_Allow_Cross_Path', 400); if (strpos($_GET['upbigfilename'], '../')!==false) return output('Not_Allow_Cross_Path', 400);
if (strpos($_POST['upbigfilename'], '../')!==false) return output('Not_Allow_Cross_Path', 400); if (strpos($_POST['upbigfilename'], '../')!==false) return output('Not_Allow_Cross_Path', 400);
} }
$path1 = path_format($_SERVER['list_path'] . path_format($path));
if (substr($path1, -1)=='/') $path1=substr($path1, 0, -1);
return $drive->bigfileupload($path1); return $drive->bigfileupload($path1);
} }
} }
@@ -306,8 +319,6 @@ function main($path)
if ($_SERVER['admin']) { if ($_SERVER['admin']) {
$tmp = adminoperate($path); $tmp = adminoperate($path);
if ($tmp['statusCode'] > 0) { if ($tmp['statusCode'] > 0) {
$path1 = path_format($_SERVER['list_path'] . path_format($path));
if ($path1!='/'&&substr($path1,-1)=='/') $path1 = substr($path1, 0, -1);
savecache('path_' . $path1, '', $_SERVER['disktag'], 1); savecache('path_' . $path1, '', $_SERVER['disktag'], 1);
return $tmp; return $tmp;
} }
@@ -318,8 +329,6 @@ function main($path)
if (isset($_GET['thumbnails'])) { if (isset($_GET['thumbnails'])) {
if ($_SERVER['ishidden']<4) { if ($_SERVER['ishidden']<4) {
if (in_array(strtolower(substr($path, strrpos($path, '.') + 1)), $exts['img'])) { if (in_array(strtolower(substr($path, strrpos($path, '.') + 1)), $exts['img'])) {
$path1 = path_format($_SERVER['list_path'] . path_format($path));
if ($path1!='/'&&substr($path1, -1)=='/') $path1=substr($path1, 0, -1);
$thumb_url = $drive->get_thumbnails_url($path1); $thumb_url = $drive->get_thumbnails_url($path1);
if ($thumb_url!='') { if ($thumb_url!='') {
if ($_GET['location']) { if ($_GET['location']) {
@@ -345,16 +354,23 @@ function main($path)
if (!getConfig('downloadencrypt', $_SERVER['disktag'])) { if (!getConfig('downloadencrypt', $_SERVER['disktag'])) {
$files = json_decode('{"type":"folder"}', true); $files = json_decode('{"type":"folder"}', true);
} else { } else {
$path1 = path_format($_SERVER['list_path'] . path_format($path));
if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1, 0, -1);
$files = $drive->list_files($path1); $files = $drive->list_files($path1);
if ($files['type']=='folder') $files = json_decode('{"type":"folder"}', true); if ($files['type']=='folder') $files = json_decode('{"type":"folder"}', true);
} }
} else { } else {
$path1 = path_format($_SERVER['list_path'] . path_format($path));
if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1, 0, -1);
$files = $drive->list_files($path1); $files = $drive->list_files($path1);
} }
//if ($path!=='')
if ( $files['type']=='folder' && substr($path, -1)!=='/' ) {
$tmp = path_format($_SERVER['base_disk_path'] . $path . '/');
return output('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>308 Permanent Redirect</title>
</head><body>
<h1>Permanent Redirect</h1>
<p>The document has moved <a href="' . $tmp . '">here</a>.</p>
</body></html>', 308, [ 'Location' => $tmp ]);
}
if ($_GET['json']) { if ($_GET['json']) {
// return a json // return a json
@@ -366,32 +382,73 @@ function main($path)
return output(json_encode($files), 200, ['Content-Type' => 'application/json']); return output(json_encode($files), 200, ['Content-Type' => 'application/json']);
} }
// random file // random file
if (isset($_GET['random'])&&$_GET['random']!=='') { if (isset($_GET['random']))
if ($_SERVER['ishidden']<4) { if ($_GET['random']!==true) {
$tmp = []; if ($_SERVER['ishidden']<4) {
foreach (array_keys($files['list']) as $filename) { if (!isset($files['list'])) {
if (strtolower(splitlast($filename, '.')[1])==strtolower($_GET['random'])) $tmp[$filename] = $files['list'][$filename]['url']; $distfolder = splitlast($path, '/');
} if ($distfolder[1]=='') $tmpfolder = splitlast($distfolder[0], '/')[1];
$tmp = array_values($tmp); else $tmpfolder = $distfolder[1];
if (count($tmp)>0) { if ($tmpfolder=='') $tmpfolder = '/';
$url = $tmp[rand(0, count($tmp)-1)]; return output('No files in folder " ' . htmlspecialchars($tmpfolder) . ' ".', 404);
if (isset($_GET['url'])) return output($url, 200);
$header['Location'] = $url;
$domainforproxy = '';
$domainforproxy = getConfig('domainforproxy', $_SERVER['disktag']);
if ($domainforproxy!='') {
$url = proxy_replace_domain($url, $domainforproxy, $header);
} }
return output('', 302, $header); $tmp = [];
} else return output('No ' . $_GET['random'] . 'file', 404); foreach (array_keys($files['list']) as $filename) {
} else return output('Hidden', 401); if (strtolower(splitlast($filename, '.')[1])==strtolower($_GET['random'])) $tmp[$filename] = $files['list'][$filename]['url'];
} }
$tmp = array_values($tmp);
if (count($tmp)>0) {
$url = $tmp[rand(0, count($tmp)-1)];
if (isset($_GET['url'])) return output($url, 200);
$header['Location'] = $url;
$domainforproxy = '';
$domainforproxy = getConfig('domainforproxy', $_SERVER['disktag']);
if ($domainforproxy!='') {
$url = proxy_replace_domain($url, $domainforproxy, $header);
}
return output('', 302, $header);
} else return output('No "' . htmlspecialchars($_GET['random']) . '" files', 404);
} else return output('Hidden', 401);
} else return output('must provide a suffix, like "?random=gif".', 401);
// is file && not preview mode, download file // is file && not preview mode, download file
if ($files['type']=='file' && !isset($_GET['preview'])) { if ($files['type']=='file' && !isset($_GET['preview'])) {
if ( $_SERVER['ishidden']<4 || (!!getConfig('downloadencrypt', $_SERVER['disktag'])&&$files['name']!=getConfig('passfile')) ) { if ( $_SERVER['ishidden']<4 || (!!getConfig('downloadencrypt', $_SERVER['disktag'])&&$files['name']!=getConfig('passfile')) ) {
$url = $files['url']; $url = $files['url'];
if ( strtolower(splitlast($files['name'], '.')[1])=='html' ) return output($files['content']['body'], $files['content']['stat']); if ( strtolower(splitlast($files['name'], '.')[1])=='html' ) return output($files['content']['body'], $files['content']['stat']);
else { else {
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($files['time'])==strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) return output('', 304);
$fileConduitSize = getConfig('fileConduitSize', $_SERVER['disktag']);
$fileConduitCacheTime = getConfig('fileConduitCacheTime', $_SERVER['disktag']);
if (!!$fileConduitSize || !!$fileConduitCacheTime) {
if ($fileConduitSize>1) $fileConduitSize *= 1024*1024;
else $fileConduitSize = 1024*1024;
if ($fileConduitCacheTime>1) $fileConduitCacheTime *= 3600;
else $fileConduitCacheTime = 3600;
/*if ($_SERVER['HTTP_RANGE']!='') {
$header['Range'] = $_SERVER['HTTP_RANGE'];
$response = curl('GET', $files['url'], '', $header, 1);
//return output($header['Range'] . json_encode($response['returnhead']));
return output(
$response['body'],
$response['stat'],
//$response['returnhead'],
['Content-Type' => $files['mime'], 'Cache-Control' => 'max-age=' . $fileConduitCacheTime],
false
);
}*/
if ($files['size']<$fileConduitSize) return output(
base64_encode(file_get_contents($files['url'])),
200,
[
'Content-Type' => $files['mime'],
'Cache-Control' => 'max-age=' . $fileConduitCacheTime,
//'Cache-Control' => 'max-age=0',
'Last-Modified' => gmdate('D, d M Y H:i:s T', strtotime($files['time']))
],
true
);
}
if ($_SERVER['HTTP_RANGE']!='') $header['Range'] = $_SERVER['HTTP_RANGE']; if ($_SERVER['HTTP_RANGE']!='') $header['Range'] = $_SERVER['HTTP_RANGE'];
$header['Location'] = $url; $header['Location'] = $url;
$domainforproxy = ''; $domainforproxy = '';
@@ -466,20 +523,31 @@ function isreferhost() {
return false; return false;
} }
function adminpass2cookie($name, $pass) function adminpass2cookie($name, $pass, $timestamp)
{ {
$timestamp = time()+7*24*60*60;
return md5($name . ':' . md5($pass) . '@' . $timestamp) . "(" . $timestamp . ")"; return md5($name . ':' . md5($pass) . '@' . $timestamp) . "(" . $timestamp . ")";
} }
function compareadminmd5($admincookie, $name, $pass) function adminpass2storage($name, $pass, $timestamp, $rand) {
return md5($timestamp . '/' . $pass . '^' . $name . '*' . $rand) . "(" . $rand . ")";
}
function compareadminmd5($name, $pass, $cookie, $storage = 'default')
{ {
$c = splitfirst($admincookie, '('); $c = splitfirst($cookie, '(');
$c_md5 = $c[0]; $c_md5 = $c[0];
$c_time = substr($c[1], 0, -1); $c_time = substr($c[1], 0, -1);
if (!is_numeric($c_time)) return false; if (!is_numeric($c_time)) return false;
if (time() > $c_time) return false; if (time() > $c_time) return false;
if (md5($name . ':' . md5($pass) . '@' . $c_time) == $c_md5) return true; if ($storage == 'default') {
else return false; if (md5($name . ':' . md5($pass) . '@' . $c_time) == $c_md5) return true;
else return false;
} else {
$s = splitfirst($storage, '(');
$s_md5 = $s[0];
$s_rand = substr($s[1], 0, -1);
if (md5($c_time . '/' . $pass . '^' . $name . '*' . $s_rand) == $s_md5) return true;
else return false;
}
return false;
} }
function compareadminsha1($adminsha1, $timestamp, $pass) function compareadminsha1($adminsha1, $timestamp, $pass)
@@ -548,7 +616,7 @@ function filecache($disktag)
{ {
$dir = sys_get_temp_dir(); $dir = sys_get_temp_dir();
if (!is_writable($dir)) { if (!is_writable($dir)) {
$tmp = __DIR__ . '/tmp/'; $tmp = $_SERVER['HTTP_HOST'] . '/tmp/';
if (file_exists($tmp)) { if (file_exists($tmp)) {
if ( is_writable($tmp) ) $dir = $tmp; if ( is_writable($tmp) ) $dir = $tmp;
} elseif ( mkdir($tmp) ) $dir = $tmp; } elseif ( mkdir($tmp) ) $dir = $tmp;
@@ -568,10 +636,10 @@ function sortConfig(&$arr)
{ {
ksort($arr); ksort($arr);
$tags = explode('|', $arr['disktag']); if (isset($arr['disktag'])) {
unset($arr['disktag']); $tags = explode('|', $arr['disktag']);
if ($tags[0]!='') { unset($arr['disktag']);
foreach($tags as $tag) { foreach($tags as $tag) if (isset($arr[$tag])) {
$disks[$tag] = $arr[$tag]; $disks[$tag] = $arr[$tag];
unset($arr[$tag]); unset($arr[$tag]);
} }
@@ -704,6 +772,7 @@ function curl($method, $url, $data = '', $headers = [], $returnheader = 0, $loca
//$response['body'] = curl_exec($ch); //$response['body'] = curl_exec($ch);
if ($returnheader) { if ($returnheader) {
list($returnhead, $response['body']) = explode("\r\n\r\n", curl_exec($ch)); list($returnhead, $response['body']) = explode("\r\n\r\n", curl_exec($ch));
//echo "HEAD:" . $returnhead;
foreach (explode("\r\n", $returnhead) as $head) { foreach (explode("\r\n", $returnhead) as $head) {
$tmp = explode(': ', $head); $tmp = explode(': ', $head);
$heads[$tmp[0]] = $tmp[1]; $heads[$tmp[0]] = $tmp[1];
@@ -762,7 +831,7 @@ function gethiddenpass($path,$passfile)
$path1 = path_format($_SERVER['list_path'] . path_format($path)); $path1 = path_format($_SERVER['list_path'] . path_format($path));
if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1); if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
$password=getcache('path_' . $path1 . '/?password', $_SERVER['disktag']); $password=getcache('path_' . $path1 . '/?password', $_SERVER['disktag']);
if ($password=='') { if ($password===false) {
$ispassfile = get_content(path_format($path . '/' . urlencode($passfile))); $ispassfile = get_content(path_format($path . '/' . urlencode($passfile)));
//echo $path . '<pre>' . json_encode($ispassfile, JSON_PRETTY_PRINT) . '</pre>'; //echo $path . '<pre>' . json_encode($ispassfile, JSON_PRETTY_PRINT) . '</pre>';
if ($ispassfile['type']=='file') { if ($ispassfile['type']=='file') {
@@ -816,8 +885,8 @@ function message($message, $title = 'Message', $statusCode = 200, $wainstat = 0)
<meta charset=utf-8> <meta charset=utf-8>
<meta name=viewport content="width=device-width,initial-scale=1"> <meta name=viewport content="width=device-width,initial-scale=1">
<body> <body>
<h1>' . $title . '</h1>
<a href="' . $_SERVER['base_path'] . '">' . getconstStr('Back') . getconstStr('Home') . '</a> <a href="' . $_SERVER['base_path'] . '">' . getconstStr('Back') . getconstStr('Home') . '</a>
<h1>' . $title . '</h1>
<div id="dis" style="display: none;"> <div id="dis" style="display: none;">
' . $message . ' ' . $message . '
@@ -837,7 +906,7 @@ function message($message, $title = 'Message', $statusCode = 200, $wainstat = 0)
x += "."; x += ".";
min++; min++;
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
var url = "?WaitFunction" + (status!=""?"=" + status:""); var url = "?WaitFunction=" + (status!=""?status:"1");
xhr.open("GET", url); xhr.open("GET", url);
//xhr.setRequestHeader("Authorization", "Bearer "); //xhr.setRequestHeader("Authorization", "Bearer ");
xhr.onload = function(e) { xhr.onload = function(e) {
@@ -851,7 +920,7 @@ function message($message, $title = 'Message', $statusCode = 200, $wainstat = 0)
//setTimeout(function() { getStatus() }, 1000); //setTimeout(function() { getStatus() }, 1000);
} }
} else if (xhr.status==206) { } else if (xhr.status==206) {
errordiv.innerHTML = min + "<br>' . getconstStr('Wait') . '" + x; errordiv.innerHTML = "' . getconstStr('Wait') . '" + x + "<br>" + min;
setTimeout(function() { getStatus() }, 1000); setTimeout(function() { getStatus() }, 1000);
} else { } else {
errordiv.innerHTML = "ERROR<br>" + xhr.status + "<br>" + xhr.responseText; errordiv.innerHTML = "ERROR<br>" + xhr.status + "<br>" + xhr.responseText;
@@ -862,7 +931,6 @@ function message($message, $title = 'Message', $statusCode = 200, $wainstat = 0)
xhr.send(null); xhr.send(null);
} }
getStatus(); getStatus();
//setTimeout(function() { getStatus() }, 3000);
</script>'; </script>';
} else { } else {
$html .= ' $html .= '
@@ -918,11 +986,11 @@ function output($body, $statusCode = 200, $headers = ['Content-Type' => 'text/ht
function passhidden($path) function passhidden($path)
{ {
if ($_SERVER['admin']) return 0; if ($_SERVER['admin']) return 0;
$path = str_replace('+','%2B',$path); //$path = str_replace('+','%2B',$path);
$path = str_replace('&amp;','&', path_format(urldecode($path))); //$path = str_replace('&amp;','&', path_format(urldecode($path)));
if (getConfig('passfile') != '') { if (getConfig('passfile') != '') {
$path = spurlencode($path,'/'); //$path = spurlencode($path,'/');
if (substr($path,-1)=='/') $path=substr($path,0,-1); //if (substr($path,-1)=='/') $path=substr($path,0,-1);
$hiddenpass=gethiddenpass($path, getConfig('passfile')); $hiddenpass=gethiddenpass($path, getConfig('passfile'));
if ($hiddenpass != '') { if ($hiddenpass != '') {
return comppass($hiddenpass); return comppass($hiddenpass);
@@ -956,15 +1024,32 @@ function time_format($ISO)
return date('Y-m-d H:i:s',strtotime($ISO . " UTC")); return date('Y-m-d H:i:s',strtotime($ISO . " UTC"));
} }
function adminform($name = '', $pass = '', $path = '') function adminform($name = '', $pass = '', $storage = '', $path = '')
{ {
$html = '<html><head><title>' . getconstStr('AdminLogin') . '</title><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"></head>'; $html = '<html>
<head>
<title>' . getconstStr('AdminLogin') . '</title>
<meta charset=utf-8>
<meta name=viewport content="width=device-width,initial-scale=1">
</head>';
if ($name=='admin'&&$pass!='') { if ($name=='admin'&&$pass!='') {
$html .= '<meta http-equiv="refresh" content="3;URL=' . $path . '"> $html .= '
<body>' . getconstStr('LoginSuccess') . '</body></html>'; <!--<meta http-equiv="refresh" content="3;URL=' . $path . '">-->
<body>
' . getconstStr('LoginSuccess') . '
<script>
localStorage.setItem("admin", "' . $storage . '");
var url = location.href;
var search = location.search;
url = url.substr(0, url.length-search.length);
if (search.indexOf("preview")>0) url += "?preview";
location = url;
</script>
</body>
</html>';
$statusCode = 201; $statusCode = 201;
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
$_SERVER['Set-Cookie'] = $name . '=' . $pass . '; path=/; expires=' . date(DATE_COOKIE, strtotime('+7day')); $_SERVER['Set-Cookie'] = $name . '=' . $pass . '; path=' . $_SERVER['base_path'] . '; expires=' . date(DATE_COOKIE, strtotime('+7day'));
return output($html, $statusCode); return output($html, $statusCode);
} }
$statusCode = 401; $statusCode = 401;
@@ -1008,12 +1093,23 @@ function adminform($name = '', $pass = '', $path = '')
function adminoperate($path) function adminoperate($path)
{ {
global $drive; global $drive;
$path1 = path_format($_SERVER['list_path'] . path_format($path)); $path1 = path_format($_SERVER['list_path'] . '/' . $path);
if (substr($path1, -1)=='/') $path1=substr($path1, 0, -1); if (substr($path1, -1)=='/') $path1=substr($path1, 0, -1);
$tmpget = $_GET; $tmpget = $_GET;
$tmppost = $_POST; $tmppost = $_POST;
$tmparr['statusCode'] = 0; $tmparr['statusCode'] = 0;
if (isset($tmpget['RefreshCache'])) {
//$path1 = path_format($_SERVER['list_path'] . path_format($path));
//if ($path1!='/'&&substr($path1, -1)=='/') $path1=substr($path1, 0, -1);
savecache('path_' . $path1 . '/?password', '', $_SERVER['disktag'], 1);
savecache('customTheme', '', '', 1);
return message('<meta http-equiv="refresh" content="2;URL=./">
<meta name=viewport content="width=device-width,initial-scale=1">', getconstStr('RefreshCache'), 202);
}
if ( (isset($tmpget['rename_newname'])&&$tmpget['rename_newname']!=$tmpget['rename_oldname'] && $tmpget['rename_newname']!='') || (isset($tmppost['rename_newname'])&&$tmppost['rename_newname']!=$tmppost['rename_oldname'] && $tmppost['rename_newname']!='') ) { if ( (isset($tmpget['rename_newname'])&&$tmpget['rename_newname']!=$tmpget['rename_oldname'] && $tmpget['rename_newname']!='') || (isset($tmppost['rename_newname'])&&$tmppost['rename_newname']!=$tmppost['rename_oldname'] && $tmppost['rename_newname']!='') ) {
if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode'=>403];
if (isset($tmppost['rename_newname'])) $VAR = 'tmppost'; if (isset($tmppost['rename_newname'])) $VAR = 'tmppost';
else $VAR = 'tmpget'; else $VAR = 'tmpget';
// rename 重命名 // rename 重命名
@@ -1023,6 +1119,7 @@ function adminoperate($path)
return $drive->Rename($file, ${$VAR}['rename_newname']); return $drive->Rename($file, ${$VAR}['rename_newname']);
} }
if (isset($tmpget['delete_name']) || isset($tmppost['delete_name'])) { if (isset($tmpget['delete_name']) || isset($tmppost['delete_name'])) {
if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode'=>403];
if (isset($tmppost['delete_name'])) $VAR = 'tmppost'; if (isset($tmppost['delete_name'])) $VAR = 'tmppost';
else $VAR = 'tmpget'; else $VAR = 'tmpget';
// delete 删除 // delete 删除
@@ -1032,6 +1129,7 @@ function adminoperate($path)
return $drive->Delete($file); return $drive->Delete($file);
} }
if ( (isset($tmpget['operate_action'])&&$tmpget['operate_action']==getconstStr('Encrypt')) || (isset($tmppost['operate_action'])&&$tmppost['operate_action']==getconstStr('Encrypt')) ) { if ( (isset($tmpget['operate_action'])&&$tmpget['operate_action']==getconstStr('Encrypt')) || (isset($tmppost['operate_action'])&&$tmppost['operate_action']==getconstStr('Encrypt')) ) {
if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode'=>403];
if (isset($tmppost['operate_action'])) $VAR = 'tmppost'; if (isset($tmppost['operate_action'])) $VAR = 'tmppost';
else $VAR = 'tmpget'; else $VAR = 'tmpget';
// encrypt 加密 // encrypt 加密
@@ -1039,10 +1137,11 @@ function adminoperate($path)
if (${$VAR}['encrypt_folder']=='/') ${$VAR}['encrypt_folder']==''; if (${$VAR}['encrypt_folder']=='/') ${$VAR}['encrypt_folder']=='';
$folder['path'] = path_format($path1 . '/' . spurlencode(${$VAR}['encrypt_folder'], '/')); $folder['path'] = path_format($path1 . '/' . spurlencode(${$VAR}['encrypt_folder'], '/'));
$folder['name'] = ${$VAR}['encrypt_folder']; $folder['name'] = ${$VAR}['encrypt_folder'];
$folder['id'] = ${$VAR}['id']; $folder['id'] = ${$VAR}['encrypt_fileid'];
return $drive->Encrypt($folder, getConfig('passfile'), ${$VAR}['encrypt_newpass']); return $drive->Encrypt($folder, getConfig('passfile'), ${$VAR}['encrypt_newpass']);
} }
if (isset($tmpget['move_folder']) || isset($tmppost['move_folder'])) { if (isset($tmpget['move_folder']) || isset($tmppost['move_folder'])) {
if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode'=>403];
if (isset($tmppost['move_folder'])) $VAR = 'tmppost'; if (isset($tmppost['move_folder'])) $VAR = 'tmppost';
else $VAR = 'tmpget'; else $VAR = 'tmpget';
// move 移动 // move 移动
@@ -1067,6 +1166,7 @@ function adminoperate($path)
} }
} }
if (isset($tmpget['copy_name']) || isset($tmppost['copy_name'])) { if (isset($tmpget['copy_name']) || isset($tmppost['copy_name'])) {
if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode'=>403];
if (isset($tmppost['copy_name'])) $VAR = 'tmppost'; if (isset($tmppost['copy_name'])) $VAR = 'tmppost';
else $VAR = 'tmpget'; else $VAR = 'tmpget';
// copy 复制 // copy 复制
@@ -1076,6 +1176,7 @@ function adminoperate($path)
return $drive->Copy($file); return $drive->Copy($file);
} }
if (isset($tmppost['editfile'])) { if (isset($tmppost['editfile'])) {
if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode'=>403];
// edit 编辑 // edit 编辑
$file['path'] = $path1; $file['path'] = $path1;
$file['name'] = ''; $file['name'] = '';
@@ -1083,6 +1184,7 @@ function adminoperate($path)
return $drive->Edit($file, $tmppost['editfile']); return $drive->Edit($file, $tmppost['editfile']);
} }
if (isset($tmpget['create_name']) || isset($tmppost['create_name'])) { if (isset($tmpget['create_name']) || isset($tmppost['create_name'])) {
if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode'=>403];
if (isset($tmppost['create_name'])) $VAR = 'tmppost'; if (isset($tmppost['create_name'])) $VAR = 'tmppost';
else $VAR = 'tmpget'; else $VAR = 'tmpget';
// create 新建 // create 新建
@@ -1091,14 +1193,6 @@ function adminoperate($path)
$parent['id'] = ${$VAR}['create_fileid']; $parent['id'] = ${$VAR}['create_fileid'];
return $drive->Create($parent, ${$VAR}['create_type'], ${$VAR}['create_name'], ${$VAR}['create_text']); return $drive->Create($parent, ${$VAR}['create_type'], ${$VAR}['create_name'], ${$VAR}['create_text']);
} }
if (isset($tmpget['RefreshCache'])) {
//$path1 = path_format($_SERVER['list_path'] . path_format($path));
//if ($path1!='/'&&substr($path1, -1)=='/') $path1=substr($path1, 0, -1);
savecache('path_' . $path1 . '/?password', '', $_SERVER['disktag'], 1);
savecache('customTheme', '', '', 1);
return message('<meta http-equiv="refresh" content="2;URL=./">
<meta name=viewport content="width=device-width,initial-scale=1">', getconstStr('RefreshCache'), 202);
}
return $tmparr; return $tmparr;
} }
@@ -1116,6 +1210,7 @@ function splitfirst($str, $split)
$tmp[0] = ''; $tmp[0] = '';
$tmp[1] = substr($str, $len); $tmp[1] = substr($str, $len);
} }
if ($tmp[1]===false) $tmp[1] = '';
return $tmp; return $tmp;
} }
@@ -1133,6 +1228,7 @@ function splitlast($str, $split)
$tmp[0] = ''; $tmp[0] = '';
$tmp[1] = substr($str, $len); $tmp[1] = substr($str, $len);
} }
if ($tmp[1]===false) $tmp[1] = '';
return $tmp; return $tmp;
} }
@@ -1159,7 +1255,7 @@ function EnvOpt($needUpdate = 0)
$envs = substr(json_encode(array_keys ($EnvConfigs)), 1, -1); $envs = substr(json_encode(array_keys ($EnvConfigs)), 1, -1);
$html = '<title>OneManager '.getconstStr('Setup').'</title>'; $html = '<title>OneManager '.getconstStr('Setup').'</title>';
if (isset($_POST['updateProgram'])&&$_POST['updateProgram']==getconstStr('updateProgram')) { if (isset($_POST['updateProgram'])&&$_POST['updateProgram']==getconstStr('updateProgram')) if (compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) {
$response = setConfigResponse(OnekeyUpate($_POST['auth'], $_POST['project'], $_POST['branch'])); $response = setConfigResponse(OnekeyUpate($_POST['auth'], $_POST['project'], $_POST['branch']));
if (api_error($response)) { if (api_error($response)) {
$html = api_error_msg($response); $html = api_error_msg($response);
@@ -1167,12 +1263,12 @@ function EnvOpt($needUpdate = 0)
return message($html, $title, 400); return message($html, $title, 400);
} else { } else {
//WaitSCFStat(); //WaitSCFStat();
$html .= getconstStr('UpdateSuccess') . '<br><a href="">' . getconstStr('Back') . '</a><script>var status = "' . $response['status'] . '";</script>'; $html .= getconstStr('UpdateSuccess') . '<br><a href="">' . getconstStr('Back') . '</a><script>var status = "' . $response['DplStatus'] . '";</script>';
$title = getconstStr('Setup'); $title = getconstStr('Setup');
return message($html, $title, 202, 1); return message($html, $title, 202, 1);
} }
} } else return message('please login again', 'Need login', 403);
if (isset($_POST['submit1'])) { if (isset($_POST['submit1'])) if (compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) {
$_SERVER['disk_oprating'] = ''; $_SERVER['disk_oprating'] = '';
foreach ($_POST as $k => $v) { foreach ($_POST as $k => $v) {
if (isShowedEnv($k) || $k=='disktag_del' || $k=='disktag_add' || $k=='disktag_rename' || $k=='disktag_copy') { if (isShowedEnv($k) || $k=='disktag_del' || $k=='disktag_add' || $k=='disktag_rename' || $k=='disktag_copy') {
@@ -1217,13 +1313,13 @@ function EnvOpt($needUpdate = 0)
$html .= getconstStr('Success') . '!<br> $html .= getconstStr('Success') . '!<br>
<a href="">' . getconstStr('Back') . '</a> <a href="">' . getconstStr('Back') . '</a>
<script> <script>
var status = "' . $response['status'] . '"; var status = "' . $response['DplStatus'] . '";
</script>'; </script>';
$title = getconstStr('Setup'); $title = getconstStr('Setup');
return message($html, $title, 200, 1); return message($html, $title, 200, 1);
} }
} } else return message('please login again', 'Need login', 403);
if (isset($_POST['config_b'])) { if (isset($_POST['config_b'])) if (compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) {
if (!$_POST['pass']) return output("{\"Error\": \"No admin pass\"}", 403); if (!$_POST['pass']) return output("{\"Error\": \"No admin pass\"}", 403);
if (!is_numeric($_POST['timestamp'])) return output("{\"Error\": \"Error time\"}", 403); if (!is_numeric($_POST['timestamp'])) return output("{\"Error\": \"Error time\"}", 403);
if (abs(time() - $_POST['timestamp']/1000) > 5*60) return output("{\"Error\": \"Timeout\"}", 403); if (abs(time() - $_POST['timestamp']/1000) > 5*60) return output("{\"Error\": \"Timeout\"}", 403);
@@ -1280,8 +1376,8 @@ function EnvOpt($needUpdate = 0)
} else { } else {
return output("{\"Error\": \"Admin pass error\"}", 403); return output("{\"Error\": \"Admin pass error\"}", 403);
} }
} } else return message('please login again', 'Need login', 403);
if (isset($_POST['changePass'])) { if (isset($_POST['changePass'])) if (compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) {
if (!is_numeric($_POST['timestamp'])) return message("Error time<a href=\"\">" . getconstStr('Back') . "</a>", "Error", 403); if (!is_numeric($_POST['timestamp'])) return message("Error time<a href=\"\">" . getconstStr('Back') . "</a>", "Error", 403);
if (abs(time() - $_POST['timestamp']/1000) > 5*60) return message("Timeout<a href=\"\">" . getconstStr('Back') . "</a>", "Error", 403); if (abs(time() - $_POST['timestamp']/1000) > 5*60) return message("Timeout<a href=\"\">" . getconstStr('Back') . "</a>", "Error", 403);
if ($_POST['newPass1']==''||$_POST['newPass2']=='') return message("Empty new pass<a href=\"\">" . getconstStr('Back') . "</a>", "Error", 403); if ($_POST['newPass1']==''||$_POST['newPass2']=='') return message("Empty new pass<a href=\"\">" . getconstStr('Back') . "</a>", "Error", 403);
@@ -1293,25 +1389,62 @@ function EnvOpt($needUpdate = 0)
if (api_error($response)) { if (api_error($response)) {
return message(api_error_msg($response) . "<a href=\"\">" . getconstStr('Back') . "</a>", "Error", 403); return message(api_error_msg($response) . "<a href=\"\">" . getconstStr('Back') . "</a>", "Error", 403);
} else { } else {
return message("Success<a href=\"\">" . getconstStr('Back') . "</a><script>var status = \"" . $response['status'] . "\";</script>", "Success", 200, 1); return message("Success<a href=\"\">" . getconstStr('Back') . "</a><script>var status = \"" . $response['DplStatus'] . "\";</script>", "Success", 200, 1);
} }
} else { } else {
return message("Old pass error<a href=\"\">" . getconstStr('Back') . "</a>", "Error", 403); return message("Old pass error<a href=\"\">" . getconstStr('Back') . "</a>", "Error", 403);
} }
} } else return message('please login again', 'Need login', 403);
if (isset($_GET['preview'])) {
$preurl = $_SERVER['PHP_SELF'] . '?preview';
} else {
$preurl = path_format($_SERVER['PHP_SELF'] . '/');
}
$html .= ' $html .= '
<a href="' . $preurl . '">' . getconstStr('Back') . '</a><br> <a id="back" href="./">' . getconstStr('Back') . '</a><br>
<script>
if (location.search.indexOf("preview")>0) document.getElementById("back").href = "?preview";
</script>
'; ';
if ($_GET['setup']==='cmd') {
$statusCode = 200;
$html .= '
OneManager DIR: ' . __DIR__ . '
<form name="form1" method="POST" action="">
<input id="inputarea" name="cmd" style="width:100%" value="' . $_POST['cmd'] . '" placeholder="ls, pwd, cat"><br>
<input type="submit" value="post">
</form>';
if ($_POST['cmd']!='') {
$html .= '
<pre>';
@ob_start();
passthru($_POST['cmd'], $cmdstat);
$html .= '
stat: ' . $cmdstat . '
output:
';
if ($cmdstat>0) $statusCode = 400;
if ($cmdstat===1) $statusCode = 403;
if ($cmdstat===127) $statusCode = 404;
$html .= htmlspecialchars(ob_get_clean());
$html .= '</pre>';
}
$html .= '
<script>
setTimeout(function () {
let inputarea = document.getElementById(\'inputarea\');
//console.log(a + ", " + inputarea.value);
inputarea.focus();
inputarea.setSelectionRange(inputarea.value.length, inputarea.value.length);
}, 500);
</script>';
return message($html, 'Run cmd', $statusCode);
}
if ($_GET['setup']==='auth') {
return changeAuthKey();
}
if ($_GET['setup']==='platform') { if ($_GET['setup']==='platform') {
$frame .= ' $frame .= '
<table border=1 width=100%> <table border=1 width=100%>
<form name="common" action="" method="post">'; <form name="common" action="" method="post">
<input name="_admin" type="hidden" value="">';
foreach ($EnvConfigs as $key => $val) if (isCommonEnv($key) && isShowedEnv($key)) { foreach ($EnvConfigs as $key => $val) if (isCommonEnv($key) && isShowedEnv($key)) {
$frame .= ' $frame .= '
<tr> <tr>
@@ -1361,7 +1494,7 @@ function EnvOpt($needUpdate = 0)
<tr><td><input type="submit" name="submit1" value="' . getconstStr('Setup') . '"></td><td></td></tr> <tr><td><input type="submit" name="submit1" value="' . getconstStr('Setup') . '"></td><td></td></tr>
</form> </form>
</table><br>'; </table><br>';
} elseif (isset($_GET['disktag'])&&in_array($_GET['disktag'], $disktags)) { } elseif (isset($_GET['disktag'])&&$_GET['disktag']!==true&&in_array($_GET['disktag'], $disktags)) {
$disktag = $_GET['disktag']; $disktag = $_GET['disktag'];
$disk_tmp = null; $disk_tmp = null;
$diskok = driveisfine($disktag, $disk_tmp); $diskok = driveisfine($disktag, $disk_tmp);
@@ -1371,6 +1504,7 @@ function EnvOpt($needUpdate = 0)
<td> <td>
<form action="" method="post" style="margin: 0" onsubmit="return renametag(this);"> <form action="" method="post" style="margin: 0" onsubmit="return renametag(this);">
<input type="hidden" name="disktag_rename" value="' . $disktag . '"> <input type="hidden" name="disktag_rename" value="' . $disktag . '">
<input name="_admin" type="hidden" value="">
<input type="text" name="disktag_newname" value="' . $disktag . '" placeholder="' . getconstStr('EnvironmentsDescription')['disktag'] . '"> <input type="text" name="disktag_newname" value="' . $disktag . '" placeholder="' . getconstStr('EnvironmentsDescription')['disktag'] . '">
<input type="submit" name="submit1" value="' . getconstStr('RenameDisk') . '"> <input type="submit" name="submit1" value="' . getconstStr('RenameDisk') . '">
</form> </form>
@@ -1382,12 +1516,14 @@ function EnvOpt($needUpdate = 0)
<td> <td>
<form action="" method="post" style="margin: 0" onsubmit="return deldiskconfirm(this);"> <form action="" method="post" style="margin: 0" onsubmit="return deldiskconfirm(this);">
<input type="hidden" name="disktag_del" value="' . $disktag . '"> <input type="hidden" name="disktag_del" value="' . $disktag . '">
<input name="_admin" type="hidden" value="">
<input type="submit" name="submit1" value="' . getconstStr('DelDisk') . '"> <input type="submit" name="submit1" value="' . getconstStr('DelDisk') . '">
</form> </form>
</td> </td>
<td> <td>
<form action="" method="post" style="margin: 0" onsubmit="return cpdiskconfirm(this);"> <form action="" method="post" style="margin: 0" onsubmit="return cpdiskconfirm(this);">
<input type="hidden" name="disktag_copy" value="' . $disktag . '"> <input type="hidden" name="disktag_copy" value="' . $disktag . '">
<input name="_admin" type="hidden" value="">
<input type="submit" name="submit1" value="' . getconstStr('CopyDisk') . '"> <input type="submit" name="submit1" value="' . getconstStr('CopyDisk') . '">
</form> </form>
</td> </td>
@@ -1415,6 +1551,7 @@ function EnvOpt($needUpdate = 0)
$frame .= ' $frame .= '
<form name="' . $disktag . '" action="" method="post"> <form name="' . $disktag . '" action="" method="post">
<input name="_admin" type="hidden" value="">
<input type="hidden" name="disk" value="' . $disktag . '">'; <input type="hidden" name="disk" value="' . $disktag . '">';
foreach ($EnvConfigs as $key => $val) if (isInnerEnv($key) && isShowedEnv($key)) { foreach ($EnvConfigs as $key => $val) if (isInnerEnv($key) && isShowedEnv($key)) {
$frame .= ' $frame .= '
@@ -1497,6 +1634,7 @@ function EnvOpt($needUpdate = 0)
} }
} }
$frame .= ' $frame .= '
<input name="_admin" type="hidden" value="">
</tr> </tr>
<tr><td colspan="' . $num . '">' . getconstStr('DragSort') . '<input type="submit" name="submit1" value="' . getconstStr('SubmitSortdisks') . '"></td></tr> <tr><td colspan="' . $num . '">' . getconstStr('DragSort') . '<input type="submit" name="submit1" value="' . getconstStr('SubmitSortdisks') . '"></td></tr>
</form> </form>
@@ -1592,6 +1730,7 @@ function EnvOpt($needUpdate = 0)
} else { } else {
$frame .= ' $frame .= '
<form name="updateform" action="" method="post"> <form name="updateform" action="" method="post">
<input name="_admin" type="hidden" value="">
<input type="text" name="auth" size="6" placeholder="auth" value="qkqpttgf"> <input type="text" name="auth" size="6" placeholder="auth" value="qkqpttgf">
<input type="text" name="project" size="12" placeholder="project" value="OneManager-php"> <input type="text" name="project" size="12" placeholder="project" value="OneManager-php">
<button name="QueryBranchs" onclick="querybranchs();return false;">' . getconstStr('QueryBranchs') . '</button> <button name="QueryBranchs" onclick="querybranchs();return false;">' . getconstStr('QueryBranchs') . '</button>
@@ -1638,34 +1777,35 @@ function EnvOpt($needUpdate = 0)
}/* else { }/* else {
$frame .= getconstStr('NotNeedUpdate'); $frame .= getconstStr('NotNeedUpdate');
}*/ }*/
$frame .= '<br> $frame .= '<br><br>
<script src="https://cdn.bootcss.com/js-sha1/0.6.0/sha1.min.js"></script> <script src="https://cdn.bootcss.com/js-sha1/0.6.0/sha1.min.js"></script>
<table> <table>
<form id="change_pass" name="change_pass" action="" method="POST" onsubmit="return changePassword(this);"> <form id="change_pass" name="change_pass" action="" method="POST" onsubmit="return changePassword(this);">
<input name="_admin" type="hidden" value="">
<tr> <tr>
<td>old pass:</td><td><input type="password" name="oldPass"> <td>' . getconstStr('OldPassword') . ':</td><td><input type="password" name="oldPass">
<input type="hidden" name="timestamp"></td> <input type="hidden" name="timestamp"></td>
</tr> </tr>
<tr> <tr>
<td>new pass:</td><td><input type="password" name="newPass1"></td> <td>' . getconstStr('NewPassword') . ':</td><td><input type="password" name="newPass1"></td>
</tr> </tr>
<tr> <tr>
<td>reinput:</td><td><input type="password" name="newPass2"></td> <td>' . getconstStr('ReInput') . ':</td><td><input type="password" name="newPass2"></td>
</tr> </tr>
<tr> <tr>
<td></td><td><button name="changePass" value="changePass">Change Admin Pass</button></td> <td></td><td><button name="changePass" value="changePass">' . getconstStr('ChangAdminPassword') . '</button></td>
</tr> </tr>
</form> </form>
</table><br> </table><br>
<table> <table>
<form id="config_f" name="config" action="" method="POST" onsubmit="return false;"> <form id="config_f" name="config" action="" method="POST" onsubmit="return false;">
<tr> <tr>
<td>admin pass:<input type="password" name="pass"> <td>' . getconstStr('AdminPassword') . ':<input type="password" name="pass">
<button name="config_b" value="export" onclick="exportConfig(this);">export</button></td> <button name="config_b" value="export" onclick="exportConfig(this);">' . getconstStr('export') . '</button></td>
</tr> </tr>
<tr> <tr>
<td>config:<textarea name="config_t"></textarea> <td>' . getconstStr('config') . ':<textarea name="config_t"></textarea>
<button name="config_b" value="import" onclick="importConfig(this);">import</button></td> <button name="config_b" value="import" onclick="importConfig(this);">' . getconstStr('import') . '</button></td>
</tr> </tr>
</form> </form>
</table><br> </table><br>
@@ -1701,7 +1841,7 @@ function EnvOpt($needUpdate = 0)
xhr.onerror = function(e){ xhr.onerror = function(e){
alert("Network Error "+xhr.status); alert("Network Error "+xhr.status);
} }
xhr.send("pass=" + sha1(config_f.pass.value + "" + timestamp) + "&config_b=" + b.value + "&timestamp=" + timestamp); xhr.send("pass=" + sha1(config_f.pass.value + "" + timestamp) + "&config_b=" + b.value + "&timestamp=" + timestamp + "&_admin=" + localStorage.getItem("admin"));
} }
function importConfig(b) { function importConfig(b) {
if (config_f.pass.value=="") { if (config_f.pass.value=="") {
@@ -1741,7 +1881,7 @@ function EnvOpt($needUpdate = 0)
xhr.onerror = function(e){ xhr.onerror = function(e){
alert("Network Error "+xhr.status); alert("Network Error "+xhr.status);
} }
xhr.send("pass=" + sha1(config_f.pass.value + "" + timestamp) + "&config_t=" + encodeURIComponent(config_f.config_t.value) + "&config_b=" + b.value + "&timestamp=" + timestamp); xhr.send("pass=" + sha1(config_f.pass.value + "" + timestamp) + "&config_t=" + encodeURIComponent(config_f.config_t.value) + "&config_b=" + b.value + "&timestamp=" + timestamp + "&_admin=" + localStorage.getItem("admin"));
} }
function changePassword(f) { function changePassword(f) {
if (f.oldPass.value==""||f.newPass1.value==""||f.newPass2.value=="") { if (f.oldPass.value==""||f.newPass1.value==""||f.newPass2.value=="") {
@@ -1775,7 +1915,7 @@ function EnvOpt($needUpdate = 0)
</style> </style>
<table border=0> <table border=0>
<tr class="tabs">'; <tr class="tabs">';
if ($_GET['disktag']=='') { if ($_GET['disktag']==''||$_GET['disktag']===true||!in_array($_GET['disktag'], $disktags)) {
if ($_GET['setup']==='platform') $html .= ' if ($_GET['setup']==='platform') $html .= '
<td><a href="?setup">' . getconstStr('Home') . '</a></td> <td><a href="?setup">' . getconstStr('Home') . '</a></td>
<td>' . getconstStr('PlatformConfig') . '</td>'; <td>' . getconstStr('PlatformConfig') . '</td>';
@@ -1787,7 +1927,7 @@ function EnvOpt($needUpdate = 0)
<td><a href="?setup=platform">' . getconstStr('PlatformConfig') . '</a></td>'; <td><a href="?setup=platform">' . getconstStr('PlatformConfig') . '</a></td>';
foreach ($disktags as $disktag) { foreach ($disktags as $disktag) {
if ($disktag!='') { if ($disktag!='') {
if ($_GET['disktag']==$disktag) $html .= ' if ($_GET['disktag']===$disktag) $html .= '
<td>' . $disktag . '</td>'; <td>' . $disktag . '</td>';
else $html .= ' else $html .= '
<td><a href="?setup&disktag=' . $disktag . '">' . $disktag . '</a></td>'; <td><a href="?setup&disktag=' . $disktag . '">' . $disktag . '</a></td>';
@@ -1797,6 +1937,12 @@ function EnvOpt($needUpdate = 0)
</tr> </tr>
</table><br>'; </table><br>';
$html .= $frame; $html .= $frame;
$html .= '<script>
var inputAdminStorage = document.getElementsByName("_admin");
for (i=0;i<inputAdminStorage.length;i++) {
inputAdminStorage[i].value = localStorage.getItem("admin");
}
</script>';
return message($html, getconstStr('Setup')); return message($html, getconstStr('Setup'));
} }
@@ -1807,30 +1953,31 @@ function render_list($path = '', $files = [])
global $slash; global $slash;
if (isset($files['list']['index.html']) && !$_SERVER['admin']) { if (isset($files['list']['index.html']) && !$_SERVER['admin']) {
//$htmlcontent = fetch_files(spurlencode(path_format(urldecode($path) . '/index.html'), '/'))['content']; $htmlcontent = get_content(path_format($path . '/index.html'))['content'];
$htmlcontent = get_content(spurlencode(path_format(urldecode($path) . '/index.html'), '/'))['content'];
return output($htmlcontent['body'], $htmlcontent['stat']); return output($htmlcontent['body'], $htmlcontent['stat']);
} }
$path = str_replace('%20','%2520',$path); //$path = str_replace('%20','%2520',$path);
$path = str_replace('+','%2B',$path); //$path = str_replace('+','%2B',$path);
$path = str_replace('&','&amp;',path_format(urldecode($path))) ; $path1 = path_format(urldecode($path));
$path = str_replace('%20',' ',$path); //$path = str_replace('&','&amp;', $path) ;
$path = str_replace('#','%23',$path); //$path = str_replace('%20',' ',$path);
//$path = str_replace('#','%23',$path);
$p_path=''; $p_path='';
if ($path !== '/') { if ($path1 !== '/') {
if ($files['type']=='file') { if ($files['type']=='file') {
$pretitle = str_replace('&','&amp;', $files['name']); $pretitle = str_replace('&','&amp;', $files['name']);
$n_path = $pretitle; $n_path = $pretitle;
$tmp = splitlast(splitlast($path,'/')[0],'/'); $tmp = splitlast(splitlast($path1,'/')[0],'/');
if ($tmp[1]=='') { if ($tmp[1]=='') {
$p_path = $tmp[0]; $p_path = $tmp[0];
} else { } else {
$p_path = $tmp[1]; $p_path = $tmp[1];
} }
} else { } else {
if (substr($path, 0, 1)=='/') $pretitle = substr($path, 1); if (substr($path1, 0, 1)=='/') $pretitle = substr($path1, 1);
if (substr($path, -1)=='/') $pretitle = substr($pretitle, 0, -1); if (substr($path1, -1)=='/') $pretitle = substr($pretitle, 0, -1);
$tmp=splitlast($pretitle,'/'); $pretitle = str_replace('&','&amp;', $pretitle);
$tmp = splitlast($pretitle, '/');
if ($tmp[1]=='') { if ($tmp[1]=='') {
$n_path = $tmp[0]; $n_path = $tmp[0];
} else { } else {
@@ -1849,7 +1996,7 @@ function render_list($path = '', $files = [])
} }
$n_path = str_replace('&amp;','&',$n_path); $n_path = str_replace('&amp;','&',$n_path);
$p_path = str_replace('&amp;','&',$p_path); $p_path = str_replace('&amp;','&',$p_path);
$pretitle = str_replace('%23','#',$pretitle); //$pretitle = str_replace('%23','#',$pretitle);
$statusCode = 200; $statusCode = 200;
date_default_timezone_set(get_timezone($_SERVER['timezone'])); date_default_timezone_set(get_timezone($_SERVER['timezone']));
$authinfo = ' $authinfo = '
@@ -2184,8 +2331,9 @@ function render_list($path = '', $files = [])
$html = str_replace('<!--IsFileStart-->', '', $html); $html = str_replace('<!--IsFileStart-->', '', $html);
$html = str_replace('<!--IsFileEnd-->', '', $html); $html = str_replace('<!--IsFileEnd-->', '', $html);
} }
$html = str_replace('<!--FileEncodeUrl-->', encode_str_replace(path_format($_SERVER['base_disk_path'] . '/' . str_replace('&amp;', '&', $path))), $html); //$html = str_replace('<!--FileEncodeUrl-->', encode_str_replace(path_format($_SERVER['base_disk_path'] . '/' . $path)), $html);
$html = str_replace('<!--FileUrl-->', encode_str_replace(path_format($_SERVER['base_disk_path'] . '/' . str_replace('&amp;', '&', $path))), $html); $html = str_replace('<!--FileEncodeUrl-->', encode_str_replace(splitlast($path1, '/')[1]), $html);
$html = str_replace('<!--FileUrl-->', (path_format($_SERVER['base_disk_path'] . '/' . $path1)), $html);
$ext = strtolower(substr($path, strrpos($path, '.') + 1)); $ext = strtolower(substr($path, strrpos($path, '.') + 1));
if (in_array($ext, $exts['img'])) $ext = 'img'; if (in_array($ext, $exts['img'])) $ext = 'img';
@@ -2212,16 +2360,23 @@ function render_list($path = '', $files = [])
$html = str_replace('<!--Is'.$ext.'FileEnd-->', '', $html); $html = str_replace('<!--Is'.$ext.'FileEnd-->', '', $html);
} }
//while (strpos($html, '<!--FileDownUrl-->')) $html = str_replace('<!--FileDownUrl-->', $files['url'], $html); //while (strpos($html, '<!--FileDownUrl-->')) $html = str_replace('<!--FileDownUrl-->', $files['url'], $html);
while (strpos($html, '<!--FileDownUrl-->')) $html = str_replace('<!--FileDownUrl-->', encode_str_replace(path_format($_SERVER['base_disk_path'] . '/' . $path)), $html); //while (strpos($html, '<!--FileDownUrl-->')) $html = str_replace('<!--FileDownUrl-->', (path_format($_SERVER['base_disk_path'] . '/' . $path)), $html);
while (strpos($html, '<!--FileEncodeReplaceUrl-->')) $html = str_replace('<!--FileEncodeReplaceUrl-->', encode_str_replace(path_format($_SERVER['base_disk_path'] . '/' . $path)), $html); while (strpos($html, '<!--FileDownUrl-->')) $html = str_replace('<!--FileDownUrl-->', encode_str_replace(splitlast($path1, '/')[1]), $html);
//echo $path . "<br>\n";
//while (strpos($html, '<!--FileEncodeReplaceUrl-->')) $html = str_replace('<!--FileEncodeReplaceUrl-->', (path_format($_SERVER['base_disk_path'] . '/' . str_replace('&amp;', '&', $path))), $html);
while (strpos($html, '<!--FileEncodeReplaceUrl-->')) $html = str_replace('<!--FileEncodeReplaceUrl-->', encode_str_replace(splitlast($path1, '/')[1]), $html);
while (strpos($html, '<!--FileName-->')) $html = str_replace('<!--FileName-->', $files['name'], $html); while (strpos($html, '<!--FileName-->')) $html = str_replace('<!--FileName-->', $files['name'], $html);
while (strpos($html, '<!--FileEncodeDownUrl-->')) $html = str_replace('<!--FileEncodeDownUrl-->', urlencode($files['url']), $html); while (strpos($html, '<!--FileEncodeDownUrl-->')) $html = str_replace('<!--FileEncodeDownUrl-->', urlencode($files['url']), $html);
//while (strpos($html, '<!--FileEncodeDownUrl-->')) $html = str_replace('<!--FileEncodeDownUrl-->', urlencode(path_format($_SERVER['base_disk_path'] . '/' . $path)), $html); //while (strpos($html, '<!--FileEncodeDownUrl-->')) $html = str_replace('<!--FileEncodeDownUrl-->', urlencode($_SERVER['host'] . path_format($_SERVER['base_disk_path'] . '/' . $path)), $html);
$html = str_replace('<!--constStr@ClicktoEdit-->', getconstStr('ClicktoEdit'), $html); $html = str_replace('<!--constStr@ClicktoEdit-->', getconstStr('ClicktoEdit'), $html);
$html = str_replace('<!--constStr@CancelEdit-->', getconstStr('CancelEdit'), $html); $html = str_replace('<!--constStr@CancelEdit-->', getconstStr('CancelEdit'), $html);
$html = str_replace('<!--constStr@Save-->', getconstStr('Save'), $html); $html = str_replace('<!--constStr@Save-->', getconstStr('Save'), $html);
//while (strpos($html, '<!--TxtContent-->')) $html = str_replace('<!--TxtContent-->', htmlspecialchars(curl('GET', $files['url'], '', [], 0, 1)['body']), $html); if (strpos($html, '<!--TxtContent-->')) {
while (strpos($html, '<!--TxtContent-->')) $html = str_replace('<!--TxtContent-->', htmlspecialchars(get_content(spurlencode(path_format(urldecode($path)), '/'))['content']['body']), $html); //$tmp_content = get_content(spurlencode(path_format(urldecode($path)), '/'))['content']['body'];
$tmp_content = $files['content']['body'];
if (strlen($tmp_content)==$files['size']) $html = str_replace('<!--TxtContent-->', htmlspecialchars($tmp_content), $html);
else $html = str_replace('<!--TxtContent-->', $files['size']<1024*1024?htmlspecialchars(curl('GET', $files['url'], '', [], 0, 1)['body']):"File too large: " . $files['size'] . " B.", $html);
}
$html = str_replace('<!--constStr@FileNotSupport-->', getconstStr('FileNotSupport'), $html); $html = str_replace('<!--constStr@FileNotSupport-->', getconstStr('FileNotSupport'), $html);
//$html = str_replace('<!--constStr@File-->', getconstStr('File'), $html); //$html = str_replace('<!--constStr@File-->', getconstStr('File'), $html);
@@ -2248,6 +2403,7 @@ function render_list($path = '', $files = [])
$html = str_replace('<!--IsFolderEnd-->', '', $html); $html = str_replace('<!--IsFolderEnd-->', '', $html);
} }
$html = str_replace('<!--constStr@File-->', getconstStr('File'), $html); $html = str_replace('<!--constStr@File-->', getconstStr('File'), $html);
while (strpos($html, '<!--FolderId-->')) $html = str_replace('<!--FolderId-->', $files['id'], $html);
$html = str_replace('<!--constStr@ShowThumbnails-->', getconstStr('ShowThumbnails'), $html); $html = str_replace('<!--constStr@ShowThumbnails-->', getconstStr('ShowThumbnails'), $html);
$html = str_replace('<!--constStr@CopyAllDownloadUrl-->', getconstStr('CopyAllDownloadUrl'), $html); $html = str_replace('<!--constStr@CopyAllDownloadUrl-->', getconstStr('CopyAllDownloadUrl'), $html);
$html = str_replace('<!--constStr@EditTime-->', getconstStr('EditTime'), $html); $html = str_replace('<!--constStr@EditTime-->', getconstStr('EditTime'), $html);
@@ -2263,7 +2419,8 @@ function render_list($path = '', $files = [])
if ($file['type']=='folder') { if ($file['type']=='folder') {
if ($_SERVER['admin'] or !isHideFile($file['name'])) { if ($_SERVER['admin'] or !isHideFile($file['name'])) {
$filenum++; $filenum++;
$FolderListStr = str_replace('<!--FileEncodeReplaceUrl-->', encode_str_replace(path_format($_SERVER['base_disk_path'] . '/' . str_replace('&amp;', '&', $path) . '/' . $file['name'])), $FolderList); //$FolderListStr = str_replace('<!--FileEncodeReplaceUrl-->', encode_str_replace(path_format($_SERVER['base_disk_path'] . '/' . str_replace('&amp;', '&', $path) . '/' . $file['name'])), $FolderList);
$FolderListStr = str_replace('<!--FileEncodeReplaceUrl-->', encode_str_replace($file['name']), $FolderList);
$FolderListStr = str_replace('<!--FileId-->', $file['id'], $FolderListStr); $FolderListStr = str_replace('<!--FileId-->', $file['id'], $FolderListStr);
$FolderListStr = str_replace('<!--FileEncodeReplaceName-->', str_replace('&','&amp;', $file['showname']?$file['showname']:$file['name']), $FolderListStr); $FolderListStr = str_replace('<!--FileEncodeReplaceName-->', str_replace('&','&amp;', $file['showname']?$file['showname']:$file['name']), $FolderListStr);
$FolderListStr = str_replace('<!--lastModifiedDateTime-->', time_format($file['time']), $FolderListStr); $FolderListStr = str_replace('<!--lastModifiedDateTime-->', time_format($file['time']), $FolderListStr);
@@ -2285,7 +2442,8 @@ function render_list($path = '', $files = [])
$filenum++; $filenum++;
$ext = strtolower(substr($file['name'], strrpos($file['name'], '.') + 1)); $ext = strtolower(substr($file['name'], strrpos($file['name'], '.') + 1));
$FolderListStr = $FolderList; $FolderListStr = $FolderList;
while (strpos($FolderListStr, '<!--FileEncodeReplaceUrl-->')) $FolderListStr = str_replace('<!--FileEncodeReplaceUrl-->', encode_str_replace(path_format($_SERVER['base_disk_path'] . '/' . str_replace('&amp;', '&', $path) . '/' . $file['name'])), $FolderListStr); //while (strpos($FolderListStr, '<!--FileEncodeReplaceUrl-->')) $FolderListStr = str_replace('<!--FileEncodeReplaceUrl-->', encode_str_replace(path_format($_SERVER['base_disk_path'] . '/' . str_replace('&amp;', '&', $path) . '/' . $file['name'])), $FolderListStr);
while (strpos($FolderListStr, '<!--FileEncodeReplaceUrl-->')) $FolderListStr = str_replace('<!--FileEncodeReplaceUrl-->', encode_str_replace($file['name']), $FolderListStr);
$FolderListStr = str_replace('<!--FileExt-->', $ext, $FolderListStr); $FolderListStr = str_replace('<!--FileExt-->', $ext, $FolderListStr);
if (in_array($ext, $exts['music'])) $FolderListStr = str_replace('<!--FileExtType-->', 'audio', $FolderListStr); if (in_array($ext, $exts['music'])) $FolderListStr = str_replace('<!--FileExtType-->', 'audio', $FolderListStr);
elseif (in_array($ext, $exts['video'])) $FolderListStr = str_replace('<!--FileExtType-->', 'iframe', $FolderListStr); elseif (in_array($ext, $exts['video'])) $FolderListStr = str_replace('<!--FileExtType-->', 'iframe', $FolderListStr);
@@ -2408,7 +2566,7 @@ function render_list($path = '', $files = [])
while (strpos($html, '<!--base_disk_path-->')) $html = str_replace('<!--base_disk_path-->', (substr($_SERVER['base_disk_path'],-1)=='/'?substr($_SERVER['base_disk_path'],0,-1):$_SERVER['base_disk_path']), $html); while (strpos($html, '<!--base_disk_path-->')) $html = str_replace('<!--base_disk_path-->', (substr($_SERVER['base_disk_path'],-1)=='/'?substr($_SERVER['base_disk_path'],0,-1):$_SERVER['base_disk_path']), $html);
while (strpos($html, '<!--base_path-->')) $html = str_replace('<!--base_path-->', $_SERVER['base_path'], $html); while (strpos($html, '<!--base_path-->')) $html = str_replace('<!--base_path-->', $_SERVER['base_path'], $html);
while (strpos($html, '<!--Path-->')) $html = str_replace('<!--Path-->', str_replace('%23', '#', str_replace('&','&amp;', path_format($path.'/'))), $html); $html = str_replace('<!--Path-->', str_replace('\'', '\\\'', str_replace('%23', '#', str_replace('&','&amp;', path_format($path1.'/')))), $html);
while (strpos($html, '<!--constStr@Home-->')) $html = str_replace('<!--constStr@Home-->', getconstStr('Home'), $html); while (strpos($html, '<!--constStr@Home-->')) $html = str_replace('<!--constStr@Home-->', getconstStr('Home'), $html);
$html = str_replace('<!--customCss-->', getConfig('customCss'), $html); $html = str_replace('<!--customCss-->', getConfig('customCss'), $html);
@@ -2468,11 +2626,11 @@ function render_list($path = '', $files = [])
$tmp_path = str_replace('&','&amp;', substr(urldecode($_SERVER['PHP_SELF']), strlen($tmp_url))); $tmp_path = str_replace('&','&amp;', substr(urldecode($_SERVER['PHP_SELF']), strlen($tmp_url)));
while ($tmp_path!='') { while ($tmp_path!='') {
$tmp1 = splitfirst($tmp_path, '/'); $tmp1 = splitfirst($tmp_path, '/');
$folder1 = $tmp1[0]; $folder1 = str_replace('&amp;', '&', $tmp1[0]);
if ($folder1!='') { if ($folder1!='') {
$tmp_url .= str_replace('&amp;', '&', $folder1) . '/'; $tmp_url .= $folder1 . '/';
$PathArrayStr1 = str_replace('<!--PathArrayLink-->', encode_str_replace($folder1==$files['name']?'':$tmp_url), $PathArrayStr); $PathArrayStr1 = str_replace('<!--PathArrayLink-->', encode_str_replace($folder1==$files['name']?'':$tmp_url), $PathArrayStr);
$PathArrayStr1 = str_replace('<!--PathArrayName-->', $folder1, $PathArrayStr1); $PathArrayStr1 = str_replace('<!--PathArrayName-->', str_replace('&', '&amp;', $folder1), $PathArrayStr1);
$html .= $PathArrayStr1; $html .= $PathArrayStr1;
} }
$tmp_path = $tmp1[1]; $tmp_path = $tmp1[1];
@@ -2489,11 +2647,11 @@ function render_list($path = '', $files = [])
$tmp_path = str_replace('&','&amp;', substr(urldecode($_SERVER['PHP_SELF']), strlen($tmp_url))); $tmp_path = str_replace('&','&amp;', substr(urldecode($_SERVER['PHP_SELF']), strlen($tmp_url)));
while ($tmp_path!='') { while ($tmp_path!='') {
$tmp1 = splitfirst($tmp_path, '/'); $tmp1 = splitfirst($tmp_path, '/');
$folder1 = $tmp1[0]; $folder1 = str_replace('&amp;', '&', $tmp1[0]);
if ($folder1!='') { if ($folder1!='') {
$tmp_url .= str_replace('&amp;', '&', $folder1) . '/'; $tmp_url .= $folder1 . '/';
$PathArrayStr1 = str_replace('<!--PathArrayLink-->', encode_str_replace($folder1==$files['name']?'':$tmp_url), $PathArrayStr); $PathArrayStr1 = str_replace('<!--PathArrayLink-->', encode_str_replace($folder1==$files['name']?'':$tmp_url), $PathArrayStr);
$PathArrayStr1 = str_replace('<!--PathArrayName-->', ($folder1==$_SERVER['disktag']?(getConfig('diskname')==''?$_SERVER['disktag']:getConfig('diskname')):$folder1), $PathArrayStr1); $PathArrayStr1 = str_replace('<!--PathArrayName-->', str_replace('&', '&amp;', $folder1==$_SERVER['disktag']?(getConfig('diskname')==''?$_SERVER['disktag']:getConfig('diskname')):$folder1), $PathArrayStr1);
$html .= $PathArrayStr1; $html .= $PathArrayStr1;
} }
$tmp_path = $tmp1[1]; $tmp_path = $tmp1[1];
@@ -2586,7 +2744,7 @@ function render_list($path = '', $files = [])
$html = $tmp[0]; $html = $tmp[0];
$tmp = splitfirst($tmp[1], '<!--HeadomfEnd-->'); $tmp = splitfirst($tmp[1], '<!--HeadomfEnd-->');
if (isset($files['list']['head.omf'])) { if (isset($files['list']['head.omf'])) {
$headomf = str_replace('<!--HeadomfContent-->', get_content(spurlencode(path_format($path . '/head.omf'), '/'))['content']['body'], $tmp[0]); $headomf = str_replace('<!--HeadomfContent-->', get_content(path_format($path . '/' . $files['list']['head.omf']['name']))['content']['body'], $tmp[0]);
} }
$html .= $headomf . $tmp[1]; $html .= $headomf . $tmp[1];
@@ -2594,7 +2752,7 @@ function render_list($path = '', $files = [])
$html = $tmp[0]; $html = $tmp[0];
$tmp = splitfirst($tmp[1], '<!--HeadmdEnd-->'); $tmp = splitfirst($tmp[1], '<!--HeadmdEnd-->');
if (isset($files['list']['head.md'])) { if (isset($files['list']['head.md'])) {
$headmd = str_replace('<!--HeadmdContent-->', get_content(spurlencode(path_format($path . '/head.md'), '/'))['content']['body'], $tmp[0]); $headmd = str_replace('<!--HeadmdContent-->', get_content(path_format($path . '/' . $files['list']['head.md']['name']))['content']['body'], $tmp[0]);
$html .= $headmd . $tmp[1]; $html .= $headmd . $tmp[1];
while (strpos($html, '<!--HeadmdStart-->')) { while (strpos($html, '<!--HeadmdStart-->')) {
$html = str_replace('<!--HeadmdStart-->', '', $html); $html = str_replace('<!--HeadmdStart-->', '', $html);
@@ -2627,7 +2785,8 @@ function render_list($path = '', $files = [])
$html = $tmp[0]; $html = $tmp[0];
$tmp = splitfirst($tmp[1], '<!--ReadmemdEnd-->'); $tmp = splitfirst($tmp[1], '<!--ReadmemdEnd-->');
if (isset($files['list']['readme.md'])) { if (isset($files['list']['readme.md'])) {
$Readmemd = str_replace('<!--ReadmemdContent-->', get_content(spurlencode(path_format($path . '/readme.md'),'/'))['content']['body'], $tmp[0]); //$Readmemd = str_replace('<!--ReadmemdContent-->', get_content(spurlencode(path_format($path1 . '/' . $files['list']['readme.md']['name']),'/'))['content']['body'], $tmp[0]);
$Readmemd = str_replace('<!--ReadmemdContent-->', get_content(path_format($path . '/' . $files['list']['readme.md']['name']))['content']['body'], $tmp[0]);
$html .= $Readmemd . $tmp[1]; $html .= $Readmemd . $tmp[1];
while (strpos($html, '<!--ReadmemdStart-->')) { while (strpos($html, '<!--ReadmemdStart-->')) {
$html = str_replace('<!--ReadmemdStart-->', '', $html); $html = str_replace('<!--ReadmemdStart-->', '', $html);
@@ -2649,7 +2808,7 @@ function render_list($path = '', $files = [])
$html = $tmp[0]; $html = $tmp[0];
$tmp = splitfirst($tmp[1], '<!--FootomfEnd-->'); $tmp = splitfirst($tmp[1], '<!--FootomfEnd-->');
if (isset($files['list']['foot.omf'])) { if (isset($files['list']['foot.omf'])) {
$Footomf = str_replace('<!--FootomfContent-->', get_content(spurlencode(path_format($path . '/foot.omf'),'/'))['content']['body'], $tmp[0]); $Footomf = str_replace('<!--FootomfContent-->', get_content(path_format($path . '/' . $files['list']['foot.omf']['name']))['content']['body'], $tmp[0]);
} }
$html .= $Footomf . $tmp[1]; $html .= $Footomf . $tmp[1];
@@ -2729,9 +2888,9 @@ function render_list($path = '', $files = [])
} }
// 最后清除换行 // 最后清除换行
while (strpos($html, "\r\n\r\n")) $html = str_replace("\r\n\r\n", "\r\n", $html); //while (strpos($html, "\r\n\r\n")) $html = str_replace("\r\n\r\n", "\r\n", $html);
//while (strpos($html, "\r\r")) $html = str_replace("\r\r", "\r", $html); //while (strpos($html, "\r\r")) $html = str_replace("\r\r", "\r", $html);
while (strpos($html, "\n\n")) $html = str_replace("\n\n", "\n", $html); //while (strpos($html, "\n\n")) $html = str_replace("\n\n", "\n", $html);
//while (strpos($html, PHP_EOL.PHP_EOL)) $html = str_replace(PHP_EOL.PHP_EOL, PHP_EOL, $html); //while (strpos($html, PHP_EOL.PHP_EOL)) $html = str_replace(PHP_EOL.PHP_EOL, PHP_EOL, $html);
$exetime = round(microtime(true)-$_SERVER['php_starttime'],3); $exetime = round(microtime(true)-$_SERVER['php_starttime'],3);
+45 -1
View File
@@ -7,7 +7,7 @@ $exts['img'] = ['ico', 'bmp', 'gif', 'jpg', 'jpeg', 'jpe', 'jfif', 'tif', 'tiff'
$exts['music'] = ['mp3', 'wma', 'flac', 'ape', 'wav', 'ogg', 'm4a']; $exts['music'] = ['mp3', 'wma', 'flac', 'ape', 'wav', 'ogg', 'm4a'];
$exts['office'] = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']; $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['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['video'] = ['mp4', 'webm', 'mkv', 'mov', 'flv', 'blv', 'avi', 'wmv', 'm3u8', 'rm', '3gp', 'rmvb'];
$exts['zip'] = ['zip', 'rar', '7z', 'gz', 'tar']; $exts['zip'] = ['zip', 'rar', '7z', 'gz', 'tar'];
$constStr = [ $constStr = [
@@ -105,6 +105,8 @@ $constStr = [
'background' => 'Set an url as background photo.', 'background' => 'Set an url as background photo.',
'backgroundm' => 'Set an url as background in mobile phone.', 'backgroundm' => 'Set an url as background in mobile phone.',
'forceHttps' => 'if 1, force to redirect to https when visit via http.', 'forceHttps' => 'if 1, force to redirect to https when visit via http.',
'fileConduitCacheTime' => 'Input number, unit is hour, if set this, little file<1M(or fileConduitSize) will through program and cache in explorer, otherwise, default 302 to Microsoft',
'fileConduitSize' => 'Input number, unit is M(suggest less than 4M), if set this, little file<this value will through program and cache in explorer, otherwise, default 302 to Microsoft',
'theme' => 'Select theme for guest.', 'theme' => 'Select theme for guest.',
'timezone' => 'Set default timezone.', 'timezone' => 'Set default timezone.',
'guestup_path' => 'Set guest upload dir, before set this, the files in this dir will show as normal.', 'guestup_path' => 'Set guest upload dir, before set this, the files in this dir will show as normal.',
@@ -133,6 +135,8 @@ $constStr = [
'background' => '设置一个url作为背景。', 'background' => '设置一个url作为背景。',
'backgroundm' => '设置一个url作为手机端用的背景。', 'backgroundm' => '设置一个url作为手机端用的背景。',
'forceHttps' => '0或1。如果设置为1,会强制跳https', 'forceHttps' => '0或1。如果设置为1,会强制跳https',
'fileConduitCacheTime' => '填数字,单位是小时,如果设置,小于1M(或fileConduitSize)的小文件会从程序通过然后缓存在浏览器,不然,默认302跳微软',
'fileConduitSize' => '填数字,单位是M(建议4M以下),如果设置,小于这个值的小文件会从程序通过然后缓存在浏览器,不然,默认302跳微软',
'theme' => '为游客选择一个主题。', 'theme' => '为游客选择一个主题。',
'timezone' => '设置默认时区。', 'timezone' => '设置默认时区。',
'guestup_path' => '设置游客上传路径(图床路径),不设置这个值时该目录内容会正常列文件出来,设置后只有上传界面,不显示其中文件(登录后显示)。', 'guestup_path' => '设置游客上传路径(图床路径),不设置这个值时该目录内容会正常列文件出来,设置后只有上传界面,不显示其中文件(登录后显示)。',
@@ -1140,6 +1144,46 @@ $constStr = [
'zh-cn' => '查询分支', 'zh-cn' => '查询分支',
'zh-tw' => '查詢分支', 'zh-tw' => '查詢分支',
], ],
'OldPassword' => [
'en-us' => 'Old Password',
'zh-cn' => '旧密码',
'zh-tw' => '旧密碼',
],
'NewPassword' => [
'en-us' => 'New Password',
'zh-cn' => '新密码',
'zh-tw' => '新密碼',
],
'ReInput' => [
'en-us' => 'ReInput',
'zh-cn' => '再输入一次',
'zh-tw' => '再输入一次',
],
'ChangAdminPassword' => [
'en-us' => 'Chang Admin Password',
'zh-cn' => '修改管理密码',
'zh-tw' => '修改管理密碼',
],
'AdminPassword' => [
'en-us' => 'Admin Password',
'zh-cn' => '管理密码',
'zh-tw' => '管理密碼',
],
'export' => [
'en-us' => 'export',
'zh-cn' => '导出',
'zh-tw' => '导出',
],
'config' => [
'en-us' => 'config',
'zh-cn' => '配置',
'zh-tw' => '配置',
],
'import' => [
'en-us' => 'import',
'zh-cn' => '导入',
'zh-tw' => '导入',
],
'ONEMANAGER_CONFIG_SAVE_ENV' => [ 'ONEMANAGER_CONFIG_SAVE_ENV' => [
'en-us' => 'Config save in Environments', 'en-us' => 'Config save in Environments',
'zh-cn' => '配置保存在环境变量', 'zh-cn' => '配置保存在环境变量',
+5 -5
View File
@@ -194,8 +194,8 @@ class Aliyundrive {
$data['image_url_process'] = 'image/resize,w_1920/format,jpeg'; $data['image_url_process'] = 'image/resize,w_1920/format,jpeg';
$data['video_thumbnail_process'] = 'video/snapshot,t_0,f_jpg,w_300'; $data['video_thumbnail_process'] = 'video/snapshot,t_0,f_jpg,w_300';
$data['fields'] = '*'; $data['fields'] = '*';
$data['order_by'] = 'updated_at'; $data['order_by'] = 'name'; //updated_at
$data['order_direction'] = 'DESC'; $data['order_direction'] = 'ASC'; //DESC
$res = curl('POST', $url, json_encode($data), $header); $res = curl('POST', $url, json_encode($data), $header);
//error_log1($res['stat'] . $res['body']); //error_log1($res['stat'] . $res['body']);
@@ -631,7 +631,7 @@ class Aliyundrive {
} else { } else {
$str .= ' $str .= '
<script> <script>
var status = "' . $response['status'] . '"; var status = "' . $response['DplStatus'] . '";
var uploadList = setInterval(function(){ var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") { if (document.getElementById("dis").style.display=="none") {
console.log(min++); console.log(min++);
@@ -702,7 +702,7 @@ class Aliyundrive {
</form> </form>
</div> </div>
<script> <script>
var status = "' . $response['status'] . '"; var status = "' . $response['DplStatus'] . '";
function notnull(t) function notnull(t)
{ {
if (t.driveId.value==\'\') { if (t.driveId.value==\'\') {
@@ -768,7 +768,7 @@ class Aliyundrive {
} }
return true; return true;
} }
var status = "' . $response['status'] . '"; var status = "' . $response['DplStatus'] . '";
</script> </script>
'; ';
return message($html, $title, 201, 1); return message($html, $title, 201, 1);
+21 -14
View File
@@ -1,4 +1,7 @@
<?php <?php
// https://docs.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0
// https://docs.microsoft.com/zh-cn/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=http
// https://developer.microsoft.com/zh-cn/graph/graph-explorer
class Onedrive { class Onedrive {
protected $access_token; protected $access_token;
@@ -46,9 +49,6 @@ class Onedrive {
{ {
global $exts; global $exts;
if (!($files = getcache('path_' . $path, $this->disktag))) { if (!($files = getcache('path_' . $path, $this->disktag))) {
// https://docs.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0
// https://docs.microsoft.com/zh-cn/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=http
// https://developer.microsoft.com/zh-cn/graph/graph-explorer
$pos = splitlast($path, '/'); $pos = splitlast($path, '/');
$parentpath = $pos[0]; $parentpath = $pos[0];
if ($parentpath=='') $parentpath = '/'; if ($parentpath=='') $parentpath = '/';
@@ -131,7 +131,7 @@ class Onedrive {
} else { } else {
$files['error']['stat'] = 503; $files['error']['stat'] = 503;
$files['error']['code'] = 'unknownError'; $files['error']['code'] = 'unknownError';
$files['error']['message'] = 'unknownError'; $files['error']['message'] = 'unknownError ' . $arr['body'] . " ~";
} }
//$files = json_decode( '{"unknownError":{ "stat":'.$arr['stat'].',"message":"'.$arr['body'].'"}}', true); //$files = json_decode( '{"unknownError":{ "stat":'.$arr['stat'].',"message":"'.$arr['body'].'"}}', true);
//error_log1(json_encode($files, JSON_PRETTY_PRINT)); //error_log1(json_encode($files, JSON_PRETTY_PRINT));
@@ -180,6 +180,7 @@ class Onedrive {
return $files; return $files;
} }
//error_log1(json_encode($tmp)); //error_log1(json_encode($tmp));
//echo '<pre>' . json_encode($tmp, JSON_PRETTY_PRINT) . '</pre>';
return $tmp; return $tmp;
} }
@@ -350,15 +351,16 @@ class Onedrive {
$filename = spurlencode($file['name']); $filename = spurlencode($file['name']);
$filename = path_format($file['path'] . '/' . $filename); $filename = path_format($file['path'] . '/' . $filename);
//echo $filename; //echo $filename;
$result = $this->MSAPI('DELETE', $filename); if ($file['id']) $result = $this->MSAPI('DELETE', "/items/" . $file['id']);
else $result = $this->MSAPI('DELETE', $filename);
if ($result['stat']!=204) $r_body = json_encode($this->files_format(json_decode($result['body'], true))); if ($result['stat']!=204) $r_body = json_encode($this->files_format(json_decode($result['body'], true)));
return output($r_body, $result['stat']); return output($r_body, $result['stat']);
//return output($result['body'], $result['stat']); //return output($result['body'], $result['stat']);
} }
public function Encrypt($folder, $passfilename, $pass) { public function Encrypt($folder, $passfilename, $pass) {
$filename = path_format($folder['path'] . '/' . urlencode($passfilename)); $filename = '/items/' . $folder['id'] . ':/' . urlencode($passfilename);
if ($pass==='') { if ($pass==='') {
$result = $this->MSAPI('DELETE', $filename, ''); $result = $this->MSAPI('DELETE', $filename);
} else { } else {
$result = $this->MSAPI('PUT', $filename, $pass); $result = $this->MSAPI('PUT', $filename, $pass);
} }
@@ -372,7 +374,8 @@ class Onedrive {
$filename = spurlencode($file['name']); $filename = spurlencode($file['name']);
$filename = path_format($file['path'] . '/' . $filename); $filename = path_format($file['path'] . '/' . $filename);
$data = '{"parentReference":{"path": "/drive/root:' . $folder['path'] . '"}}'; $data = '{"parentReference":{"path": "/drive/root:' . $folder['path'] . '"}}';
$result = $this->MSAPI('PATCH', $filename, $data); if ($file['id']) $result = $this->MSAPI('PATCH', "/items/" . $file['id'], $data);
else $result = $this->MSAPI('PATCH', $filename, $data);
$path2 = spurlencode($folder['path'], '/'); $path2 = spurlencode($folder['path'], '/');
if ($path2!='/'&&substr($path2, -1)=='/') $path2 = substr($path2, 0, -1); if ($path2!='/'&&substr($path2, -1)=='/') $path2 = substr($path2, 0, -1);
savecache('path_' . $path2, json_decode('{}', true), $this->disktag, 1); savecache('path_' . $path2, json_decode('{}', true), $this->disktag, 1);
@@ -391,7 +394,8 @@ class Onedrive {
$newname = '.' . $namearr[1] . ' (' . date("Ymd\THis\Z") . ')'; $newname = '.' . $namearr[1] . ' (' . date("Ymd\THis\Z") . ')';
} }
$data = '{ "name": "' . $newname . '" }'; $data = '{ "name": "' . $newname . '" }';
$result = $this->MSAPI('copy', $filename, $data); if ($file['id']) $result = $this->MSAPI('copy', "/items/" . $file['id'], $data);
else $result = $this->MSAPI('copy', $filename, $data);
/*$num = 0; /*$num = 0;
while ($result['stat']==409 && json_decode($result['body'], true)['error']['code']=='nameAlreadyExists') { while ($result['stat']==409 && json_decode($result['body'], true)['error']['code']=='nameAlreadyExists') {
$num++; $num++;
@@ -510,7 +514,7 @@ class Onedrive {
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie=\'disktag=; path=/; \'+expires; document.cookie=\'disktag=; path=/; \'+expires;
var i = 0; var i = 0;
var status = "' . $response['status'] . '"; var status = "' . $response['DplStatus'] . '";
var uploadList = setInterval(function(){ var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") { if (document.getElementById("dis").style.display=="none") {
console.log(i++); console.log(i++);
@@ -607,6 +611,7 @@ class Onedrive {
texta[i].style.height = texta[i].scrollHeight + \'px\'; texta[i].style.height = texta[i].scrollHeight + \'px\';
} }
</script>'; </script>';
$tmptoken['Driver'] = get_class($this);
$tmptoken['refresh_token'] = $refresh_token; $tmptoken['refresh_token'] = $refresh_token;
$tmptoken['token_expires'] = time()+7*24*60*60; $tmptoken['token_expires'] = time()+7*24*60*60;
$response = setConfigResponse( setConfig($tmptoken, $this->disktag) ); $response = setConfigResponse( setConfig($tmptoken, $this->disktag) );
@@ -618,7 +623,7 @@ class Onedrive {
savecache('access_token', $ret['access_token'], $this->disktag, $ret['expires_in'] - 60); savecache('access_token', $ret['access_token'], $this->disktag, $ret['expires_in'] - 60);
$html .= '<script> $html .= '<script>
var i = 0; var i = 0;
var status = "' . $response['status'] . '"; var status = "' . $response['DplStatus'] . '";
var uploadList = setInterval(function(){ var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") { if (document.getElementById("dis").style.display=="none") {
console.log(i++); console.log(i++);
@@ -699,7 +704,7 @@ class Onedrive {
if ($_POST['Drive_ver']!='Sharelink') $url .= '?install1&disktag=' . $_GET['disktag'] . '&AddDisk=' . $_POST['Drive_ver']; if ($_POST['Drive_ver']!='Sharelink') $url .= '?install1&disktag=' . $_GET['disktag'] . '&AddDisk=' . $_POST['Drive_ver'];
$html .= '<script> $html .= '<script>
var i = 0; var i = 0;
var status = "' . $response['status'] . '"; var status = "' . $response['DplStatus'] . '";
var uploadList = setInterval(function(){ var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") { if (document.getElementById("dis").style.display=="none") {
console.log(i++); console.log(i++);
@@ -729,7 +734,7 @@ class Onedrive {
<label><input type="checkbox" name="NT_Drive_custom" onclick="document.getElementById(\'NT_secret\').style.display=(this.checked?\'\':\'none\');">' . getconstStr('CustomIdSecret') . '</label><br> <label><input type="checkbox" name="NT_Drive_custom" onclick="document.getElementById(\'NT_secret\').style.display=(this.checked?\'\':\'none\');">' . getconstStr('CustomIdSecret') . '</label><br>
<div id="NT_secret" style="display:none;margin:10px 35px"> <div id="NT_secret" style="display:none;margin:10px 35px">
<a href="https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps" target="_blank">' . getconstStr('GetSecretIDandKEY') . '</a><br> <a href="https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps" target="_blank">' . getconstStr('GetSecretIDandKEY') . '</a><br>
return_uri(Reply URL):<br>https://scfonedrive.github.io/<br> return_uri(Reply URL):<br>' . $this->redirect_uri . '<br>
client_id:<input type="text" name="NT_client_id" style="width:100%" placeholder="a1b2c345-90ab-cdef-ghij-klmnopqrstuv"><br> client_id:<input type="text" name="NT_client_id" style="width:100%" placeholder="a1b2c345-90ab-cdef-ghij-klmnopqrstuv"><br>
client_secret:<input type="text" name="NT_client_secret" style="width:100%"><br> client_secret:<input type="text" name="NT_client_secret" style="width:100%"><br>
</div> </div>
@@ -739,7 +744,7 @@ class Onedrive {
<label><input type="checkbox" name="CN_Drive_custom" onclick="document.getElementById(\'CN_secret\').style.display=(this.checked?\'\':\'none\');">' . getconstStr('CustomIdSecret') . '</label><br> <label><input type="checkbox" name="CN_Drive_custom" onclick="document.getElementById(\'CN_secret\').style.display=(this.checked?\'\':\'none\');">' . getconstStr('CustomIdSecret') . '</label><br>
<div id="CN_secret" style="display:none;margin:10px 35px"> <div id="CN_secret" style="display:none;margin:10px 35px">
<a href="https://portal.azure.cn/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps" target="_blank">' . getconstStr('GetSecretIDandKEY') . '</a><br> <a href="https://portal.azure.cn/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps" target="_blank">' . getconstStr('GetSecretIDandKEY') . '</a><br>
return_uri(Reply URL):<br>https://scfonedrive.github.io/<br> return_uri(Reply URL):<br>' . $this->redirect_uri . '<br>
client_id:<input type="text" name="CN_client_id" style="width:100%" placeholder="a1b2c345-90ab-cdef-ghij-klmnopqrstuv"><br> client_id:<input type="text" name="CN_client_id" style="width:100%" placeholder="a1b2c345-90ab-cdef-ghij-klmnopqrstuv"><br>
client_secret:<input type="text" name="CN_client_secret" style="width:100%"><br> client_secret:<input type="text" name="CN_client_secret" style="width:100%"><br>
</div> </div>
@@ -1007,6 +1012,8 @@ class Onedrive {
} else { } else {
if ($path=='' or $path=='/') { if ($path=='' or $path=='/') {
$url .= $method; $url .= $method;
} elseif (substr($path, 0, 6)=="/items") {
$url .= '/' . $method;
} else { } else {
$url .= ':/' . $method; $url .= ':/' . $method;
} }
+12 -5
View File
@@ -30,9 +30,11 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
header($headerName . ': ' . $headerVal, true); header($headerName . ': ' . $headerVal, true);
} }
http_response_code($re['statusCode']); http_response_code($re['statusCode']);
echo $re['body']; if ($re['isBase64Encoded']) echo base64_decode($re['body']);
else echo $re['body'];
} elseif (isset($_SERVER['DOCUMENT_ROOT'])&&$_SERVER['DOCUMENT_ROOT']==='/var/task/user') { } elseif (isset($_SERVER['DOCUMENT_ROOT'])&&$_SERVER['DOCUMENT_ROOT']==='/var/task/user') {
include 'platform/Vercel.php'; if (getenv('ONEMANAGER_CONFIG_SAVE')=='env') include 'platform/Vercel_env.php';
else include 'platform/Vercel.php';
$path = getpath(); $path = getpath();
//echo 'path:'. $path; //echo 'path:'. $path;
$_GET = getGET(); $_GET = getGET();
@@ -43,9 +45,13 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
header($headerName . ': ' . $headerVal, true); header($headerName . ': ' . $headerVal, true);
} }
http_response_code($re['statusCode']); http_response_code($re['statusCode']);
echo $re['body']; if ($re['isBase64Encoded']) echo base64_decode($re['body']);
else echo $re['body'];
} else { } else {
include 'platform/Normal.php'; include 'platform/Normal.php';
if (!function_exists('curl_init')) {
return message('<font color="red">Need curl</font>, please install php-curl.', 'Error', 500);
}
$path = getpath(); $path = getpath();
//echo 'path:'. $path; //echo 'path:'. $path;
$_GET = getGET(); $_GET = getGET();
@@ -57,7 +63,8 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
header($headerName . ': ' . $headerVal, true); header($headerName . ': ' . $headerVal, true);
} }
http_response_code($re['statusCode']); http_response_code($re['statusCode']);
echo $re['body']; if ($re['isBase64Encoded']) echo base64_decode($re['body']);
else echo $re['body'];
} }
// Tencent SCF // Tencent SCF
@@ -104,7 +111,7 @@ function handler($event, $context)
$re = main($path); $re = main($path);
return new RingCentral\Psr7\Response($re['statusCode'], $re['headers'], $re['body']); return new RingCentral\Psr7\Response($re['statusCode'], $re['headers'], $re['isBase64Encoded']?base64_decode($re['body']):$re['body']);
} elseif ($_SERVER['_APP_SHARE_DIR']=='/var/share/CFF/processrouter') { } elseif ($_SERVER['_APP_SHARE_DIR']=='/var/share/CFF/processrouter') {
// Huawei FG // Huawei FG
+78 -19
View File
@@ -37,17 +37,23 @@ function GetPathSetting($event, $context)
$_SERVER['region'] = $context['region']; $_SERVER['region'] = $context['region'];
$_SERVER['service_name'] = $context['service']['name']; $_SERVER['service_name'] = $context['service']['name'];
$_SERVER['function_name'] = $context['function']['name']; $_SERVER['function_name'] = $context['function']['name'];
$path = $event['path']; //$path = str_replace('%5D', ']', str_replace('%5B', '[', $event['path']));//%5B
$tmp = $event['requestURI']; //$path = $event['path'];
$path = $event['requestURI'];
if (strpos($path, '?')) $path = substr($path, 0, strpos($path, '?'));
$tmp = urldecode($event['requestURI']);
if (strpos($tmp, '?')) $tmp = substr($tmp, 0, strpos($tmp, '?')); if (strpos($tmp, '?')) $tmp = substr($tmp, 0, strpos($tmp, '?'));
if ($path=='/'||$path=='') { if ($path=='/'||$path=='') {
$_SERVER['base_path'] = $tmp; $_SERVER['base_path'] = $tmp;
} else { } else {
$_SERVER['base_path'] = substr($tmp, 0, strlen($tmp)-strlen($path)+1); $tmp = str_replace('&amp;', '&', $tmp);
while ($tmp!=urldecode($tmp)) $tmp = urldecode($tmp);
$tmp1 = urldecode($event['path']);
while ($tmp1!=urldecode($tmp1)) $tmp1 = urldecode($tmp1);
$_SERVER['base_path'] = substr($tmp, 0, strlen($tmp)-strlen($tmp1)+1);
//$_SERVER['base_path'] = substr($tmp, 0, strlen(urldecode($event['path'])));
} }
$_SERVER['base_path'] = spurlencode($_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['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
$_SERVER['REMOTE_ADDR'] = $event['clientIP']; $_SERVER['REMOTE_ADDR'] = $event['clientIP'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['X-Requested-With'][0]; $_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['X-Requested-With'][0];
@@ -60,8 +66,10 @@ function GetPathSetting($event, $context)
$_SERVER['REQUEST_SCHEME'] = $event['headers']['X-Forwarded-Proto'][0]; $_SERVER['REQUEST_SCHEME'] = $event['headers']['X-Forwarded-Proto'][0];
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']; $_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $event['headers']['Referer'][0])[2]; $_SERVER['referhost'] = explode('/', $event['headers']['Referer'][0])[2];
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['If-Modified-Since'][0];
$_SERVER['FC_SERVER_PATH'] = '/var/fc/runtime/php7.2'; $_SERVER['FC_SERVER_PATH'] = '/var/fc/runtime/php7.2';
return $path; return $path;
//return spurlencode($path, '/');
} }
function getConfig($str, $disktag = '') function getConfig($str, $disktag = '')
@@ -177,16 +185,16 @@ function install()
if ($_GET['install1']) { if ($_GET['install1']) {
//if ($_POST['admin']!='') { //if ($_POST['admin']!='') {
$tmp['timezone'] = $_COOKIE['timezone']; $tmp['timezone'] = $_COOKIE['timezone'];
$AccessKeyID = getConfig('AccessKeyID'); //$AccessKeyID = getConfig('AccessKeyID');
if ($AccessKeyID=='') { //if ($AccessKeyID=='') {
$AccessKeyID = $_POST['AccessKeyID']; $AccessKeyID = $_POST['AccessKeyID'];
$tmp['AccessKeyID'] = $AccessKeyID; $tmp['AccessKeyID'] = $AccessKeyID;
} //}
$AccessKeySecret = getConfig('AccessKeySecret'); //$AccessKeySecret = getConfig('AccessKeySecret');
if ($AccessKeySecret=='') { //if ($AccessKeySecret=='') {
$AccessKeySecret = $_POST['AccessKeySecret']; $AccessKeySecret = $_POST['AccessKeySecret'];
$tmp['AccessKeySecret'] = $AccessKeySecret; $tmp['AccessKeySecret'] = $AccessKeySecret;
} //}
$response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['accountId'], $_SERVER['region'], $_SERVER['service_name'], $_SERVER['function_name'], $AccessKeyID, $AccessKeySecret) ); $response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['accountId'], $_SERVER['region'], $_SERVER['service_name'], $_SERVER['function_name'], $AccessKeyID, $AccessKeySecret) );
if (api_error($response)) { if (api_error($response)) {
$html = api_error_msg($response); $html = api_error_msg($response);
@@ -221,12 +229,13 @@ language:<br>';
$html .= ' $html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; <label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
} }
if (getConfig('AccessKeyID')==''||getConfig('AccessKeySecret')=='') $html .= ' //if (getConfig('AccessKeyID')==''||getConfig('AccessKeySecret')=='')
<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 .= ' $html .= '
<input type="submit" value="'.getconstStr('Submit').'"> <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="password" placeholder="" size=""></label><br>';
$html .= '
<input type="submit" value="' . getconstStr('Submit') . '">
</form> </form>
<script> <script>
var nowtime= new Date(); var nowtime= new Date();
@@ -245,7 +254,8 @@ language:<br>';
} }
function notnull(t) function notnull(t)
{'; {';
if (getConfig('AccessKeyID')==''||getConfig('AccessKeySecret')=='') $html .= ' //if (getConfig('AccessKeyID')==''||getConfig('AccessKeySecret')=='')
$html .= '
if (t.AccessKeyID.value==\'\') { if (t.AccessKeyID.value==\'\') {
alert(\'input AccessKeyID\'); alert(\'input AccessKeyID\');
return false; return false;
@@ -261,7 +271,7 @@ language:<br>';
$title = getconstStr('SelectLanguage'); $title = getconstStr('SelectLanguage');
return message($html, $title, 201); return message($html, $title, 201);
} }
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind'); $html .= '<a href="?install0">' . getconstStr('ClickInstall').'</a>, ' . getconstStr('LogintoBind');
$title = 'Install'; $title = 'Install';
return message($html, $title, 201); return message($html, $title, 201);
} }
@@ -501,3 +511,52 @@ function myErrorHandler($errno, $errstr, $errfile, $errline) {
function WaitFunction() { function WaitFunction() {
return true; return true;
} }
function changeAuthKey() {
if ($_POST['AccessKeyID']!=''&&$_POST['AccessKeySecret']!='') {
$tmp['AccessKeyID'] = $_POST['AccessKeyID'];
$tmp['AccessKeySecret'] = $_POST['AccessKeySecret'];
$response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['accountId'], $_SERVER['region'], $_SERVER['service_name'], $_SERVER['function_name'], $tmp['AccessKeyID'], $tmp['AccessKeySecret']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<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="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.AccessKeyID.value==\'\') {
alert(\'input AccessKeyID\');
return false;
}
if (t.AccessKeySecret.value==\'\') {
alert(\'input SecretKey\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
+68 -14
View File
@@ -1,4 +1,6 @@
<?php <?php
// https://cloud.baidu.com/doc/CFC/s/jjwvz45ex
// https://cloud.baidu.com/doc/CFC/s/2jwvz44ns
function printInput($event, $context) function printInput($event, $context)
{ {
@@ -34,8 +36,6 @@ function GetPathSetting($event, $context)
$_SERVER['functionBrn'] = $context['functionBrn']; $_SERVER['functionBrn'] = $context['functionBrn'];
$_SERVER['base_path'] = '/'; $_SERVER['base_path'] = '/';
$path = $event['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['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
$_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp']; $_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['X-Requested-With']; $_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['X-Requested-With'];
@@ -50,6 +50,7 @@ function GetPathSetting($event, $context)
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']; $_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $event['headers']['Referer'])[2]; $_SERVER['referhost'] = explode('/', $event['headers']['Referer'])[2];
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f' $_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['If-Modified-Since'];
$_SERVER['BCE_CFC_RUNTIME_NAME'] = 'php7'; $_SERVER['BCE_CFC_RUNTIME_NAME'] = 'php7';
return $path; return $path;
} }
@@ -165,16 +166,16 @@ function install()
} }
if ($_GET['install1']) { if ($_GET['install1']) {
$tmp['timezone'] = $_COOKIE['timezone']; $tmp['timezone'] = $_COOKIE['timezone'];
$SecretId = getConfig('SecretId'); //$SecretId = getConfig('SecretId');
if ($SecretId=='') { //if ($SecretId=='') {
$SecretId = $_POST['SecretId']; $SecretId = $_POST['SecretId'];
$tmp['SecretId'] = $SecretId; $tmp['SecretId'] = $SecretId;
} //}
$SecretKey = getConfig('SecretKey'); //$SecretKey = getConfig('SecretKey');
if ($SecretKey=='') { //if ($SecretKey=='') {
$SecretKey = $_POST['SecretKey']; $SecretKey = $_POST['SecretKey'];
$tmp['SecretKey'] = $SecretKey; $tmp['SecretKey'] = $SecretKey;
} //}
$response = setConfigResponse(SetbaseConfig($tmp, $SecretId, $SecretKey)); $response = setConfigResponse(SetbaseConfig($tmp, $SecretId, $SecretKey));
if (api_error($response)) { if (api_error($response)) {
$html = api_error_msg($response); $html = api_error_msg($response);
@@ -208,12 +209,13 @@ language:<br>';
$html .= ' $html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; <label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
} }
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= ' //if (getConfig('SecretId')==''||getConfig('SecretKey')=='')
<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 .= ' $html .= '
<input type="submit" value="'.getconstStr('Submit').'"> <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="password" placeholder="" size=""></label><br>';
$html .= '
<input type="submit" value="' . getconstStr('Submit') . '">
</form> </form>
<script> <script>
var nowtime= new Date(); var nowtime= new Date();
@@ -232,7 +234,8 @@ language:<br>';
} }
function notnull(t) function notnull(t)
{'; {';
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= ' //if (getConfig('SecretId')==''||getConfig('SecretKey')=='')
$html .= '
if (t.SecretId.value==\'\') { if (t.SecretId.value==\'\') {
alert(\'input Access Key\'); alert(\'input Access Key\');
return false; return false;
@@ -435,3 +438,54 @@ function addFileToZip($zip, $rootpath, $path = '')
function WaitFunction() { function WaitFunction() {
return true; return true;
} }
function changeAuthKey() {
if ($_POST['SecretId']!=''&&$_POST['SecretKey']!='') {
$SecretId = $_POST['SecretId'];
$tmp['SecretId'] = $SecretId;
$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, 400);
} else {
$html = getconstStr('Success') . '
<script>
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<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="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.SecretId.value==\'\') {
alert(\'input Access Key\');
return false;
}
if (t.SecretKey.value==\'\') {
alert(\'input Secret Key\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
+82 -16
View File
@@ -170,11 +170,8 @@ function install()
$tmp['admin'] = $_POST['admin']; $tmp['admin'] = $_POST['admin'];
//$tmp['language'] = $_POST['language']; //$tmp['language'] = $_POST['language'];
$tmp['timezone'] = $_COOKIE['timezone']; $tmp['timezone'] = $_COOKIE['timezone'];
$APIKey = getConfig('APIKey'); $APIKey = $_POST['APIKey'];
if ($APIKey=='') { $tmp['APIKey'] = $APIKey;
$APIKey = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey;
}
$HerokuappId = getConfig('HerokuappId'); $HerokuappId = getConfig('HerokuappId');
if ($HerokuappId=='') { if ($HerokuappId=='') {
$function_name = getConfig('function_name'); $function_name = getConfig('function_name');
@@ -197,17 +194,27 @@ function install()
if (api_error($response)) { if (api_error($response)) {
$html = api_error_msg($response); $html = api_error_msg($response);
$title = 'Error'; $title = 'Error';
return message($html, $title, 400);
} else { } else {
return output('Jump $html = getconstStr('Success') . '
<script> <script>
var expd = new Date(); var expd = new Date();
expd.setTime(expd.getTime()+1000); expd.setTime(expd.getTime()+1000);
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires; document.cookie=\'language=; path=/; \'+expires;
</script> var status = "' . $response['DplStatus'] . '";
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302); var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
} }
return message($html, $title, 201);
} }
} }
if ($_GET['install0']) { if ($_GET['install0']) {
@@ -218,9 +225,9 @@ language:<br>';
$html .= ' $html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; <label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
} }
if (getConfig('APIKey')=='') $html .= ' $html .= '
<a href="https://dashboard.heroku.com/account" target="_blank">'.getconstStr('Create').' API Key</a><br> <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>'; <label>API Key:<input name="APIKey" type="password" placeholder="" size=""></label><br>';
$html .= ' $html .= '
<label>Set admin password:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>'; <label>Set admin password:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>';
$html .= ' $html .= '
@@ -247,7 +254,7 @@ language:<br>';
alert(\'input admin\'); alert(\'input admin\');
return false; return false;
}'; }';
if (getConfig('APIKey')=='') $html .= ' $html .= '
if (t.APIKey.value==\'\') { if (t.APIKey.value==\'\') {
alert(\'input API Key\'); alert(\'input API Key\');
return false; return false;
@@ -313,7 +320,11 @@ function updateHerokuapp($HerokuappId, $apikey, $source)
{ {
$tmp['source_blob']['url'] = $source; $tmp['source_blob']['url'] = $source;
$data = json_encode($tmp); $data = json_encode($tmp);
return HerokuAPI('POST', 'https://api.heroku.com/apps/' . $HerokuappId . '/builds', $data, $apikey); $response = HerokuAPI('POST', 'https://api.heroku.com/apps/' . $HerokuappId . '/builds', $data, $apikey);
$result = json_decode( $response['body'], true );
$result['DplStatus'] = $result['id'];
$response['body'] = json_encode($result);
return $response;
} }
function api_error($response) function api_error($response)
@@ -341,6 +352,61 @@ function setConfigResponse($response)
return json_decode( $response['body'], true ); return json_decode( $response['body'], true );
} }
function WaitFunction() { function WaitFunction($buildId = '') {
return true; // GET /apps/{app_id_or_name}/builds/{build_id}
if ($buildId=='1') return true;
$response = HerokuAPI('GET', 'https://api.heroku.com/apps/' . getConfig('HerokuappId') . '/builds/' . $buildId, '', getConfig('APIKey'));
if ($response['stat']==200) {
$result = json_decode($response['body'], true);
if ($result['status']=="succeeded") return true;
else return false;
} else {
$response['body'] .= $url;
return $response;
}
}
function changeAuthKey() {
if ($_POST['APIKey']!='') {
$APIKey = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey;
$response = setConfigResponse( setHerokuConfig($tmp, getConfig('HerokuappId'), $APIKey) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://dashboard.heroku.com/account" target="_blank">'.getconstStr('Create').' API Key</a><br>
<label>API Key:<input name="APIKey" type="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.APIKey.value==\'\') {
alert(\'input API Key\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
} }
+64 -17
View File
@@ -1,4 +1,7 @@
<?php <?php
// https://support.huaweicloud.com/api-functiongraph/functiongraph_06_0110.html
// https://support.huaweicloud.com/api-functiongraph/functiongraph_06_0111.html
global $contextUserData; global $contextUserData;
function printInput($event, $context) function printInput($event, $context)
@@ -49,6 +52,7 @@ function GetPathSetting($event, $context)
$host_name = $event['headers']['host']; $host_name = $event['headers']['host'];
$_SERVER['HTTP_HOST'] = $host_name; $_SERVER['HTTP_HOST'] = $host_name;
$path = path_format($event['pathParameters'][''].'/'); $path = path_format($event['pathParameters'][''].'/');
$path = str_replace('+', '%2B', $path);
$_SERVER['base_path'] = path_format($event['path'].'/'); $_SERVER['base_path'] = path_format($event['path'].'/');
if ( $_SERVER['base_path'] == $path ) { if ( $_SERVER['base_path'] == $path ) {
$_SERVER['base_path'] = '/'; $_SERVER['base_path'] = '/';
@@ -56,8 +60,6 @@ function GetPathSetting($event, $context)
$_SERVER['base_path'] = substr($_SERVER['base_path'], 0, -strlen($path)); $_SERVER['base_path'] = substr($_SERVER['base_path'], 0, -strlen($path));
if ($_SERVER['base_path']=='') $_SERVER['base_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['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
$_SERVER['REMOTE_ADDR'] = $event['headers']['x-real-ip']; $_SERVER['REMOTE_ADDR'] = $event['headers']['x-real-ip'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with']; $_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
@@ -71,6 +73,7 @@ function GetPathSetting($event, $context)
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']; $_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2]; $_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2];
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f' $_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['if-modified-since'];
$_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter'; $_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter';
return $path; return $path;
} }
@@ -190,18 +193,9 @@ function install()
if ($_GET['install1']) { if ($_GET['install1']) {
//if ($_POST['admin']!='') { //if ($_POST['admin']!='') {
$tmp['timezone'] = $_COOKIE['timezone']; $tmp['timezone'] = $_COOKIE['timezone'];
$tmp['HW_urn'] = getConfig('HW_urn'); $tmp['HW_urn'] = $_POST['HW_urn'];
if ($tmp['HW_urn']=='') { $tmp['HW_key'] = $_POST['HW_key'];
$tmp['HW_urn'] = $_POST['HW_urn']; $tmp['HW_secret'] = $_POST['HW_secret'];
}
$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']; $tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
//$response = json_decode(SetbaseConfig($tmp, $HW_urn, $HW_name, $HW_pwd), true)['Response']; //$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']) ); $response = setConfigResponse( SetbaseConfig($tmp, $tmp['HW_urn'], $tmp['HW_key'], $tmp['HW_secret']) );
@@ -243,13 +237,14 @@ language:<br>';
$html .= ' $html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; <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 .= ' //if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='')
$html .= '
在函数代码操作页上方找到URN,鼠标放上去后显示URN,复制填入:<br> 在函数代码操作页上方找到URN,鼠标放上去后显示URN,复制填入:<br>
<label>URN:<input name="HW_urn" type="text" placeholder="" size=""></label><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>,新增访问密钥, <a href="https://console.huaweicloud.com/iam/#/mine/accessKey" target="_blank">点击链接</a>,新增访问密钥,
在下载的credentials.csv文件中找到对应信息,填入:<br> 在下载的credentials.csv文件中找到对应信息,填入:<br>
<label>Access Key Id:<input name="HW_key" type="text" placeholder="" size=""></label><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>'; <label>Secret Access Key:<input name="HW_secret" type="password" placeholder="" size=""></label><br>';
$html .= ' $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'==$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>'; <label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
@@ -273,7 +268,8 @@ language:<br>';
} }
function notnull(t) function notnull(t)
{'; {';
if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= ' //if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='')
$html .= '
if (t.HW_urn.value==\'\') { if (t.HW_urn.value==\'\') {
alert(\'input URN\'); alert(\'input URN\');
return false; return false;
@@ -491,3 +487,54 @@ function addFileToZip($zip, $rootpath, $path = '')
function WaitFunction() { function WaitFunction() {
return true; return true;
} }
function changeAuthKey() {
if ($_POST['HW_key']!=''&&$_POST['HW_secret']!='') {
$tmp['HW_key'] = $_POST['HW_key'];
$tmp['HW_secret'] = $_POST['HW_secret'];
$response = setConfigResponse( SetbaseConfig($tmp, getConfig('HW_urn'), $tmp['HW_key'], $tmp['HW_secret']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<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="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.HW_key.value==\'\') {
alert(\'input Access Key Id\');
return false;
}
if (t.HW_secret.value==\'\') {
alert(\'input Secret Access Key\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
+66 -19
View File
@@ -1,4 +1,7 @@
<?php <?php
// https://support.huaweicloud.com/api-functiongraph/functiongraph_06_0110.html
// https://support.huaweicloud.com/api-functiongraph/functiongraph_06_0111.html
global $contextUserData; global $contextUserData;
function printInput($event, $context) function printInput($event, $context)
@@ -49,6 +52,7 @@ function GetPathSetting($event, $context)
$host_name = $event['headers']['host']; $host_name = $event['headers']['host'];
$_SERVER['HTTP_HOST'] = $host_name; $_SERVER['HTTP_HOST'] = $host_name;
$path = path_format($event['pathParameters'][''].'/'); $path = path_format($event['pathParameters'][''].'/');
$path = str_replace('+', '%2B', $path);
$_SERVER['base_path'] = path_format($event['path'].'/'); $_SERVER['base_path'] = path_format($event['path'].'/');
if ( $_SERVER['base_path'] == $path ) { if ( $_SERVER['base_path'] == $path ) {
$_SERVER['base_path'] = '/'; $_SERVER['base_path'] = '/';
@@ -56,8 +60,6 @@ function GetPathSetting($event, $context)
$_SERVER['base_path'] = substr($_SERVER['base_path'], 0, -strlen($path)); $_SERVER['base_path'] = substr($_SERVER['base_path'], 0, -strlen($path));
if ($_SERVER['base_path']=='') $_SERVER['base_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['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
$_SERVER['REMOTE_ADDR'] = $event['headers']['x-real-ip']; $_SERVER['REMOTE_ADDR'] = $event['headers']['x-real-ip'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with']; $_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
@@ -71,6 +73,7 @@ function GetPathSetting($event, $context)
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']; $_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2]; $_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2];
$_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f' $_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['if-modified-since'];
$_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter'; $_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter';
return $path; return $path;
} }
@@ -204,18 +207,9 @@ function install()
if ($_GET['install1']) { if ($_GET['install1']) {
//if ($_POST['admin']!='') { //if ($_POST['admin']!='') {
$tmp['timezone'] = $_COOKIE['timezone']; $tmp['timezone'] = $_COOKIE['timezone'];
$tmp['HW_urn'] = getConfig('HW_urn'); $tmp['HW_urn'] = $_POST['HW_urn'];
if ($tmp['HW_urn']=='') { $tmp['HW_key'] = $_POST['HW_key'];
$tmp['HW_urn'] = $_POST['HW_urn']; $tmp['HW_secret'] = $_POST['HW_secret'];
}
$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']; $tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
//return message($html, $title, 201); //return message($html, $title, 201);
$response = setConfigResponse( SetbaseConfig($tmp, $tmp['HW_urn'], $tmp['HW_key'], $tmp['HW_secret']) ); $response = setConfigResponse( SetbaseConfig($tmp, $tmp['HW_urn'], $tmp['HW_key'], $tmp['HW_secret']) );
@@ -257,13 +251,14 @@ language:<br>';
$html .= ' $html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; <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 .= ' //if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='')
$html .= '
在函数代码操作页上方找到URN,鼠标放上去后显示URN,复制填入:<br> 在函数代码操作页上方找到URN,鼠标放上去后显示URN,复制填入:<br>
<label>URN:<input name="HW_urn" type="text" placeholder="urn:fss:ap-XXXXXXXX:XXXXXXXXXXXXXXXXXXXXc01a1e9caXXX:function:default:XXXXX:latest" size=""></label><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>,新增访问密钥, <a href="https://console.huaweicloud.com/iam/#/mine/accessKey" target="_blank">点击链接</a>,新增访问密钥,
在下载的credentials.csv文件中找到对应信息,填入:<br> 在下载的credentials.csv文件中找到对应信息,填入:<br>
<label>Access Key Id:<input name="HW_key" type="text" placeholder="" size=""></label><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>'; <label>Secret Access Key:<input name="HW_secret" type="password" placeholder="" size=""></label><br>';
$html .= ' $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'==$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>'; <label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==$contextUserData->getUserData('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
@@ -287,17 +282,18 @@ language:<br>';
} }
function notnull(t) function notnull(t)
{'; {';
if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= ' //if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='')
$html .= '
if (t.HW_urn.value==\'\') { if (t.HW_urn.value==\'\') {
alert(\'input URN\'); alert(\'input URN\');
return false; return false;
} }
if (t.HW_key.value==\'\') { if (t.HW_key.value==\'\') {
alert(\'input name\'); alert(\'input Access Key Id\');
return false; return false;
} }
if (t.HW_secret.value==\'\') { if (t.HW_secret.value==\'\') {
alert(\'input pwd\'); alert(\'input Secret Access Key\');
return false; return false;
}'; }';
$html .= ' $html .= '
@@ -872,3 +868,54 @@ class Signer
function WaitFunction() { function WaitFunction() {
return true; return true;
} }
function changeAuthKey() {
if ($_POST['HW_key']!=''&&$_POST['HW_secret']!='') {
$tmp['HW_key'] = $_POST['HW_key'];
$tmp['HW_secret'] = $_POST['HW_secret'];
$response = setConfigResponse( SetbaseConfig($tmp, getConfig('HW_urn'), $tmp['HW_key'], $tmp['HW_secret']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<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="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.HW_key.value==\'\') {
alert(\'input Access Key Id\');
return false;
}
if (t.HW_secret.value==\'\') {
alert(\'input Secret Access Key\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
+6 -1
View File
@@ -278,8 +278,9 @@ language:<br>';
$title = getconstStr('SelectLanguage'); $title = getconstStr('SelectLanguage');
return message($html, $title, 201); return message($html, $title, 201);
} }
$html .= '<a href="?install0">'.getconstStr('ClickInstall').'</a>, '.getconstStr('LogintoBind');
$title = 'Install'; $title = 'Install';
$html = '<a href="?install0">' . getconstStr('ClickInstall') . '</a>, ' . getconstStr('LogintoBind');
return message($html, $title, 201); return message($html, $title, 201);
} }
@@ -389,3 +390,7 @@ function moveFolder($from, $to, $slash)
function WaitFunction() { function WaitFunction() {
return true; return true;
} }
function changeAuthKey() {
return message("Not need.", 'Change platform Auth token or key', 404);
}
+74 -12
View File
@@ -1,4 +1,7 @@
<?php <?php
// https://cloud.tencent.com/document/product/583/33846
// https://cloud.tencent.com/document/product/583/18581
// https://cloud.tencent.com/document/product/583/18580
function printInput($event, $context) function printInput($event, $context)
{ {
@@ -41,8 +44,6 @@ function GetPathSetting($event, $context)
$_SERVER['base_path'] = $event['requestContext']['path']; $_SERVER['base_path'] = $event['requestContext']['path'];
$path = substr($event['path'], strlen($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['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
$_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp']; $_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with']; $_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
@@ -56,7 +57,8 @@ function GetPathSetting($event, $context)
//$_SERVER['REQUEST_SCHEME'] = $event['headers']['x-forwarded-proto']; //$_SERVER['REQUEST_SCHEME'] = $event['headers']['x-forwarded-proto'];
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']; $_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2]; $_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2];
$_SERVER['HTTP_TRANSLATE']==$event['headers']['translate'];//'f' $_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['if-modified-since'];
$_SERVER['USER'] = 'qcloud'; $_SERVER['USER'] = 'qcloud';
return $path; return $path;
} }
@@ -167,16 +169,24 @@ function install()
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires; document.cookie=\'language=; path=/; \'+expires;
</script> </script>
<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201); <meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201, 1);
} }
return output('Jump return message(getconstStr('Success') . '
<script> <script>
var expd = new Date(); var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000)); expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires; document.cookie=\'language=; path=/; \'+expires;
</script> var i = 0;
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302); var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>', 201, 1);
} }
if ($_GET['install1']) { if ($_GET['install1']) {
$tmp['timezone'] = $_COOKIE['timezone']; $tmp['timezone'] = $_COOKIE['timezone'];
@@ -200,7 +210,7 @@ function install()
if ($tmp['ONEMANAGER_CONFIG_SAVE'] == 'file') { if ($tmp['ONEMANAGER_CONFIG_SAVE'] == 'file') {
$html = getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '<br><a href="' . $_SERVER['base_path'] . '">' . getconstStr('Home') . '</a>'; $html = getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '<br><a href="' . $_SERVER['base_path'] . '">' . getconstStr('Home') . '</a>';
$title = 'Reinstall'; $title = 'Reinstall';
return message($html, $title, 201); return message($html, $title, 201, 1);
} }
$html .= ' $html .= '
<form action="?install2" method="post" onsubmit="return notnull(this);"> <form action="?install2" method="post" onsubmit="return notnull(this);">
@@ -218,7 +228,7 @@ function install()
} }
</script>'; </script>';
$title = getconstStr('SetAdminPassword'); $title = getconstStr('SetAdminPassword');
return message($html, $title, 201); return message($html, $title, 201, 1);
} }
} }
if ($_GET['install0']) { if ($_GET['install0']) {
@@ -229,10 +239,11 @@ language:<br>';
$html .= ' $html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; <label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
} }
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= ' //if (getConfig('SecretId')==''||getConfig('SecretKey')=='')
$html .= '
<a href="https://console.cloud.tencent.com/cam/capi" target="_blank">' . getconstStr('Create') . ' SecretId & SecretKey</a><br> <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>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>SecretKey:<input name="SecretKey" type="text" placeholder="" size=""></label><br>'; <label>SecretKey:<input name="SecretKey" type="password" placeholder="" size=""></label><br>';
$html .= ' $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'==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>'; <label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
@@ -256,7 +267,8 @@ language:<br>';
} }
function notnull(t) function notnull(t)
{'; {';
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= ' //if (getConfig('SecretId')==''||getConfig('SecretKey')=='')
$html .= '
if (t.SecretId.value==\'\') { if (t.SecretId.value==\'\') {
alert(\'input SecretId\'); alert(\'input SecretId\');
return false; return false;
@@ -604,3 +616,53 @@ function addFileToZip($zip, $rootpath, $path = '')
} }
@closedir($path); @closedir($path);
} }
function changeAuthKey() {
if ($_POST['SecretId']!=''&&$_POST['SecretId']!='') {
$tmp['SecretId'] = $_POST['SecretId'];
$tmp['SecretKey'] = $_POST['SecretKey'];
$response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $tmp['SecretId'], $tmp['SecretKey']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<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="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.SecretId.value==\'\') {
alert(\'input SecretId\');
return false;
}
if (t.SecretKey.value==\'\') {
alert(\'input SecretKey\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
+78 -22
View File
@@ -1,4 +1,7 @@
<?php <?php
// https://cloud.tencent.com/document/product/583/33846
// https://cloud.tencent.com/document/product/583/18581
// https://cloud.tencent.com/document/product/583/18580
function printInput($event, $context) function printInput($event, $context)
{ {
@@ -41,8 +44,6 @@ function GetPathSetting($event, $context)
$_SERVER['base_path'] = $event['requestContext']['path']; $_SERVER['base_path'] = $event['requestContext']['path'];
$path = substr($event['path'], strlen($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['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
$_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp']; $_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp'];
$_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with']; $_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
@@ -56,7 +57,8 @@ function GetPathSetting($event, $context)
//$_SERVER['REQUEST_SCHEME'] = $event['headers']['x-forwarded-proto']; //$_SERVER['REQUEST_SCHEME'] = $event['headers']['x-forwarded-proto'];
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']; $_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2]; $_SERVER['referhost'] = explode('/', $event['headers']['referer'])[2];
$_SERVER['HTTP_TRANSLATE']==$event['headers']['translate'];//'f' $_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['if-modified-since'];
$_SERVER['USER'] = 'qcloud'; $_SERVER['USER'] = 'qcloud';
return $path; return $path;
} }
@@ -179,29 +181,31 @@ function install()
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires; document.cookie=\'language=; path=/; \'+expires;
</script> </script>
<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201); <meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201, 1);
} }
return output('Jump return message(getconstStr('Success') . '
<script> <script>
var expd = new Date(); var expd = new Date();
expd.setTime(expd.getTime()+(2*60*60*1000)); expd.setTime(expd.getTime()+(2*60*60*1000));
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires; document.cookie=\'language=; path=/; \'+expires;
</script> var i = 0;
<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302); var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>', 201, 1);
} }
if ($_GET['install1']) { if ($_GET['install1']) {
$tmp['timezone'] = $_COOKIE['timezone']; $tmp['timezone'] = $_COOKIE['timezone'];
$SecretId = getConfig('SecretId'); $SecretId = $_POST['SecretId'];
if ($SecretId=='') { $tmp['SecretId'] = $SecretId;
$SecretId = $_POST['SecretId']; $SecretKey = $_POST['SecretKey'];
$tmp['SecretId'] = $SecretId; $tmp['SecretKey'] = $SecretKey;
}
$SecretKey = getConfig('SecretKey');
if ($SecretKey=='') {
$SecretKey = $_POST['SecretKey'];
$tmp['SecretKey'] = $SecretKey;
}
$tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE']; $tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
$response = json_decode(SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response']; $response = json_decode(SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response'];
if (api_error($response)) { if (api_error($response)) {
@@ -212,7 +216,7 @@ function install()
if ($tmp['ONEMANAGER_CONFIG_SAVE'] != 'file') { if ($tmp['ONEMANAGER_CONFIG_SAVE'] != 'file') {
$html = getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '<br><a href="' . $_SERVER['base_path'] . '">' . getconstStr('Home') . '</a>'; $html = getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '<br><a href="' . $_SERVER['base_path'] . '">' . getconstStr('Home') . '</a>';
$title = 'Reinstall'; $title = 'Reinstall';
return message($html, $title, 201); return message($html, $title, 201, 1);
} }
$html .= ' $html .= '
<form action="?install2" method="post" onsubmit="return notnull(this);"> <form action="?install2" method="post" onsubmit="return notnull(this);">
@@ -230,7 +234,7 @@ function install()
} }
</script>'; </script>';
$title = getconstStr('SetAdminPassword'); $title = getconstStr('SetAdminPassword');
return message($html, $title, 201); return message($html, $title, 201, 1);
} }
} }
if ($_GET['install0']) { if ($_GET['install0']) {
@@ -241,10 +245,11 @@ language:<br>';
$html .= ' $html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; <label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
} }
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= ' //if (getConfig('SecretId')==''||getConfig('SecretKey')=='')
$html .= '
<a href="https://console.cloud.tencent.com/cam/capi" target="_blank">'.getconstStr('Create').' SecretId & SecretKey</a><br> <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>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>SecretKey:<input name="SecretKey" type="text" placeholder="" size=""></label><br>'; <label>SecretKey:<input name="SecretKey" type="password" placeholder="" size=""></label><br>';
$html .= ' $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'==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>'; <label><input type="radio" name="ONEMANAGER_CONFIG_SAVE" value="file" ' . ('file'==getenv('ONEMANAGER_CONFIG_SAVE')?'checked':'') . '>' . getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '</label><br>';
@@ -268,7 +273,8 @@ language:<br>';
} }
function notnull(t) function notnull(t)
{'; {';
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= ' //if (getConfig('SecretId')==''||getConfig('SecretKey')=='')
$html .= '
if (t.SecretId.value==\'\') { if (t.SecretId.value==\'\') {
alert(\'input SecretId\'); alert(\'input SecretId\');
return false; return false;
@@ -650,3 +656,53 @@ function WaitFunction() {
if ( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']=='Active' ) return true; if ( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']=='Active' ) return true;
else return false; else return false;
} }
function changeAuthKey() {
if ($_POST['SecretId']!=''&&$_POST['SecretId']!='') {
$tmp['SecretId'] = $_POST['SecretId'];
$tmp['SecretKey'] = $_POST['SecretKey'];
$response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $tmp['SecretId'], $tmp['SecretKey']) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<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="password" placeholder="" size=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.SecretId.value==\'\') {
alert(\'input SecretId\');
return false;
}
if (t.SecretKey.value==\'\') {
alert(\'input SecretKey\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
+170 -124
View File
@@ -67,18 +67,24 @@ function getGET()
function getConfig($str, $disktag = '') function getConfig($str, $disktag = '')
{ {
if (isInnerEnv($str)) { $projectPath = splitlast(__DIR__, '/')[0];
if ($disktag=='') $disktag = $_SERVER['disktag']; $configPath = $projectPath . '/.data/config.php';
$tmp = getenv($disktag); $s = file_get_contents($configPath);
if (is_array($tmp)) $env = $tmp; $configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
else $env = json_decode($tmp, true); if ($configs!='') {
if (isset($env[$str])) { $envs = json_decode($configs, true);
if (isBase64Env($str)) return base64y_decode($env[$str]); if (isInnerEnv($str)) {
else return $env[$str]; if ($disktag=='') $disktag = $_SERVER['disktag'];
if (isset($envs[$disktag][$str])) {
if (isBase64Env($str)) return base64y_decode($envs[$disktag][$str]);
else return $envs[$disktag][$str];
}
} else {
if (isset($envs[$str])) {
if (isBase64Env($str)) return base64y_decode($envs[$str]);
else return $envs[$str];
}
} }
} else {
if (isBase64Env($str)) return base64y_decode(getenv($str));
else return getenv($str);
} }
return ''; return '';
} }
@@ -86,47 +92,45 @@ function getConfig($str, $disktag = '')
function setConfig($arr, $disktag = '') function setConfig($arr, $disktag = '')
{ {
if ($disktag=='') $disktag = $_SERVER['disktag']; if ($disktag=='') $disktag = $_SERVER['disktag'];
$disktags = explode("|", getenv('disktag')); $projectPath = splitlast(__DIR__, '/')[0];
if ($disktag!='') { $configPath = $projectPath . '/.data/config.php';
$tmp = getenv($disktag); $s = file_get_contents($configPath);
if (is_array($tmp)) $diskconfig = $tmp; $configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
else $diskconfig = json_decode($tmp, true); if ($configs!='') $envs = json_decode($configs, true);
} $disktags = explode("|",getConfig('disktag'));
$tmp = [];
$indisk = 0; $indisk = 0;
$operatedisk = 0; $operatedisk = 0;
foreach ($arr as $k => $v) { foreach ($arr as $k => $v) {
if (isCommonEnv($k)) { if (isCommonEnv($k)) {
if (isBase64Env($k)) $tmp[$k] = base64y_encode($v); if (isBase64Env($k)) $envs[$k] = base64y_encode($v);
else $tmp[$k] = $v; else $envs[$k] = $v;
} elseif (isInnerEnv($k)) { } elseif (isInnerEnv($k)) {
if (isBase64Env($k)) $diskconfig[$k] = base64y_encode($v); if (isBase64Env($k)) $envs[$disktag][$k] = base64y_encode($v);
else $diskconfig[$k] = $v; else $envs[$disktag][$k] = $v;
$indisk = 1; $indisk = 1;
} elseif ($k=='disktag_add') { } elseif ($k=='disktag_add') {
array_push($disktags, $v); array_push($disktags, $v);
$operatedisk = 1; $operatedisk = 1;
} elseif ($k=='disktag_del') { } elseif ($k=='disktag_del') {
$disktags = array_diff($disktags, [ $v ]); $disktags = array_diff($disktags, [ $v ]);
$tmp[$v] = ''; $envs[$v] = '';
$operatedisk = 1; $operatedisk = 1;
} elseif ($k=='disktag_copy') { } elseif ($k=='disktag_copy') {
$newtag = $v . '_' . date("Ymd_His"); $newtag = $v . '_' . date("Ymd_His");
$tagvalue = getenv($v); $envs[$newtag] = $envs[$v];
if (is_array($tagvalue)) $tmp[$newtag] = json_encode($tagvalue);
else $tmp[$newtag] = $tagvalue;
array_push($disktags, $newtag); array_push($disktags, $newtag);
$operatedisk = 1; $operatedisk = 1;
} elseif ($k=='disktag_rename' || $k=='disktag_newname') { } elseif ($k=='disktag_rename' || $k=='disktag_newname') {
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1; if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
} else { } else {
$tmp[$k] = json_encode($v); $envs[$k] = $v;
} }
} }
if ($indisk) { if ($indisk) {
$diskconfig = $envs[$disktag];
$diskconfig = array_filter($diskconfig, 'array_value_isnot_null'); $diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
ksort($diskconfig); ksort($diskconfig);
$tmp[$disktag] = json_encode($diskconfig); $envs[$disktag] = $diskconfig;
} }
if ($operatedisk) { if ($operatedisk) {
if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') { if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') {
@@ -135,23 +139,22 @@ function setConfig($arr, $disktag = '')
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']); if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
else array_push($tags, $tag); else array_push($tags, $tag);
} }
$tmp['disktag'] = implode('|', $tags); $envs['disktag'] = implode('|', $tags);
$tagvalue = getenv($arr['disktag_rename']); $envs[$arr['disktag_newname']] = $envs[$arr['disktag_rename']];
if (is_array($tagvalue)) $tmp[$arr['disktag_newname']] = json_encode($tagvalue); $envs[$arr['disktag_rename']] = '';
else $tmp[$arr['disktag_newname']] = $tagvalue;
$tmp[$arr['disktag_rename']] = null;
} else { } else {
$disktags = array_unique($disktags); $disktags = array_unique($disktags);
foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|'; foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1); if ($disktag_s!='') $envs['disktag'] = substr($disktag_s, 0, -1);
else $tmp['disktag'] = null; else $envs['disktag'] = '';
} }
} }
foreach ($tmp as $key => $val) if ($val=='') $tmp[$key]=null; $envs = array_filter($envs, 'array_value_isnot_null');
//ksort($envs);
//error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($tmp, JSON_PRETTY_PRINT)); //sortConfig($envs);
//echo json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($tmp, JSON_PRETTY_PRINT); //error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($envs, JSON_PRETTY_PRINT));
return setVercelConfig($tmp, getConfig('HerokuappId'), getConfig('APIKey')); //echo json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($envs, JSON_PRETTY_PRINT);
return setVercelConfig($envs, getConfig('HerokuappId'), getConfig('APIKey'));
} }
function install() function install()
@@ -184,16 +187,24 @@ function install()
$title = 'Error'; $title = 'Error';
return message($html, $title, 400); return message($html, $title, 400);
} else { } else {
/*$html = '<script> $html = getconstStr('Success') . '
var status = "' . $response['status'] . '"; <script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var expd = new Date(); var expd = new Date();
expd.setTime(expd.getTime()+1000); expd.setTime(expd.getTime()+1000);
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires; document.cookie=\'language=; path=/; \'+expires;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>'; </script>';
return message($html, $title, 201, 1);*/ return message($html, $title, 201, 1);
$data["dplId"] = $response['status'];
return output(json_encode($data), 201);
} }
} }
} }
@@ -205,10 +216,9 @@ language:<br>';
$html .= ' $html .= '
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>'; <label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
} }
//if (getConfig('APIKey')=='')
$html .= '<br> $html .= '<br>
<a href="https://vercel.com/account/tokens" target="_blank">' . getconstStr('Create') . ' token</a><br> <a href="https://vercel.com/account/tokens" target="_blank">' . getconstStr('Create') . ' token</a><br>
<label>Token:<input name="APIKey" type="password" placeholder="" value="' . getConfig('APIKey') . '"></label><br>'; <label>Token:<input name="APIKey" type="password" placeholder="" value=""></label><br>';
$html .= '<br> $html .= '<br>
<label>Set admin password:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>'; <label>Set admin password:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>';
$html .= ' $html .= '
@@ -241,52 +251,7 @@ language:<br>';
alert(\'input Token\'); alert(\'input Token\');
return false; return false;
} }
t.style.display = "none"; return true;
errordiv.innerHTML = "' . getconstStr('Wait') . '";
var xhr = new XMLHttpRequest();
xhr.open("POST", t.action);
xhr.onload = function(e) {
if (xhr.status==201) {
var res = JSON.parse(xhr.responseText);
getStatus(res.dplId, t.APIKey.value);
} else {
t.style.display = "";
errordiv.innerHTML = xhr.status + "<br>" + xhr.responseText;
}
}
xhr.send("admin=" + t.admin.value + "&APIKey=" + t.APIKey.value);
var x = "";
var min = 0;
function getStatus(id, VercelToken) {
x += ".";
min++;
var xhr = new XMLHttpRequest();
var url = "https://api.vercel.com/v11/now/deployments/" + id;
xhr.open("GET", url);
xhr.setRequestHeader("Authorization", "Bearer " + VercelToken);
xhr.onload = function(e) {
if (xhr.status==200) {
var deployStat = JSON.parse(xhr.responseText).readyState;
if (deployStat=="READY") {
x = "";
min = 0;
errordiv.innerHTML = "Deploy done.";
location.href = "/";
} else {
errordiv.innerHTML = deployStat + ", " + min + ".<br>' . getconstStr('Wait') . ' " + x;
if (deployStat!=="ERROR") setTimeout(function() { getStatus(id, VercelToken) }, 1000);
}
} else {
t.style.display = "";
console.log(xhr.status);
console.log(xhr.responseText);
}
}
xhr.send(null);
}
return false;
} }
</script>'; </script>';
$title = getconstStr('SelectLanguage'); $title = getconstStr('SelectLanguage');
@@ -303,39 +268,47 @@ language:<br>';
return message($html, $title, 201); return message($html, $title, 201);
} }
// POST /v8/projects/:id/env 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, 1);
$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 setVercelConfig($envs, $appId, $token) function setVercelConfig($envs, $appId, $token)
{ {
$url = "https://api.vercel.com/v8/projects/" . $appId . "/env"; sortConfig($envs);
$header["Authorization"] = "Bearer " . $token; $outPath = '/tmp/code/';
$header["Content-Type"] = "application/json"; $outPath_Api = $outPath . 'api/';
$response = curl("GET", $url, "", $header); $coderoot = __DIR__;
$result = json_decode($response['body'], true); $coderoot = splitlast($coderoot, '/')[0] . '/';
foreach ($result["envs"] as $key => $value) { //echo $outPath_Api . '<br>' . $coderoot . '<br>';
$existEnvs[$value["key"]] = $value["id"]; copyFolder($coderoot, $outPath_Api);
} $prestr = '<?php $configs = \'' . PHP_EOL;
$response = null; $aftstr = PHP_EOL . '\';';
foreach ($envs as $key => $value) { file_put_contents($outPath_Api . '.data/config.php', $prestr . json_encode($envs, JSON_PRETTY_PRINT) . $aftstr);
$tmp = null;
$tmp["type"] = "encrypted"; return VercelUpdate($appId, $token, $outPath);
$tmp["key"] = $key;
$tmp["value"] = $value;
$tmp["target"] = [ "development", "production", "preview" ];
if (isset($existEnvs[$key])) {
if ($value) $response = curl("PATCH", $url . "/" . $existEnvs[$key], json_encode($tmp), $header);
else $response = curl("DELETE", $url . "/" . $existEnvs[$key], "", $header);
} else {
if ($value) $response = curl("POST", $url, json_encode($tmp), $header);
}
//echo $key . " = " . $value . ", <br>" . json_encode($response, JSON_PRETTY_PRINT) . "<br>";
if ($response['stat']!=200) return $response['body'];
}
return VercelUpdate($appId, $token);
} }
function VercelUpdate($appId, $token, $sourcePath = "") function VercelUpdate($appId, $token, $sourcePath = "")
{ {
$url = "https://api.vercel.com/v12/now/deployments"; if (checkBuilding($appId, $token)) return '{"error":{"message":"Another building is in progress."}}';
$url = "https://api.vercel.com/v13/deployments";
$header["Authorization"] = "Bearer " . $token; $header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json"; $header["Content-Type"] = "application/json";
$data["name"] = "OneManager"; $data["name"] = "OneManager";
@@ -351,11 +324,29 @@ function VercelUpdate($appId, $token, $sourcePath = "")
//echo json_encode($data, JSON_PRETTY_PRINT) . " ,data<br>"; //echo json_encode($data, JSON_PRETTY_PRINT) . " ,data<br>";
$response = curl("POST", $url, json_encode($data), $header); $response = curl("POST", $url, json_encode($data), $header);
//echo json_encode($response, JSON_PRETTY_PRINT) . " ,res<br>";
$result = json_decode($response["body"], true); $result = json_decode($response["body"], true);
$result['status'] = $result['id']; $result['DplStatus'] = $result['id'];
return json_encode($result); return json_encode($result);
} }
function checkBuilding($projectId, $token)
{
$r = 0;
$url = "https://api.vercel.com/v6/deployments/?projectId=" . $projectId;
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$response = curl("GET", $url, '', $header);
//echo json_encode($response, JSON_PRETTY_PRINT) . " ,res<br>";
$result = json_decode($response["body"], true);
foreach ( $result['deployments'] as $deployment ) {
if ($deployment['state']!=="READY") $r++;
}
return $r;
//if ($r===0) return true;
//else return false;
}
function getEachFiles(&$file, $base, $path = "") function getEachFiles(&$file, $base, $path = "")
{ {
//if (substr($base, -1)=="/") $base = substr($base, 0, -1); //if (substr($base, -1)=="/") $base = substr($base, 0, -1);
@@ -414,7 +405,7 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
$outPath = ''; $outPath = '';
$tmp = scandir($tmppath); $tmp = scandir($tmppath);
$name = $auth . '-' . $project; $name = $auth . '-' . $project;
mkdir($tmppath . "/" . $name, 0777); mkdir($tmppath . "/" . $name, 0777, 1);
foreach ($tmp as $f) { foreach ($tmp as $f) {
if ( substr($f, 0, strlen($name)) == $name) { if ( substr($f, 0, strlen($name)) == $name) {
rename($tmppath . '/' . $f, $tmppath . "/" . $name . '/api'); rename($tmppath . '/' . $f, $tmppath . "/" . $name . '/api');
@@ -426,13 +417,23 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
//error_log1($outPath); //error_log1($outPath);
if ($outPath=='') return '{"error":{"message":"no outpath"}}'; if ($outPath=='') return '{"error":{"message":"no outpath"}}';
// put in config
$coderoot = __DIR__;
$coderoot = splitlast($coderoot, '/')[0] . '/';
copy($coderoot . '.data/config.php', $outPath . '/api/.data/config.php');
return VercelUpdate(getConfig('HerokuappId'), getConfig('APIKey'), $outPath); return VercelUpdate(getConfig('HerokuappId'), getConfig('APIKey'), $outPath);
} }
function WaitFunction($deployid) { function WaitFunction($deployid = '') {
if ($buildId=='1') {
$tmp['stat'] = 400;
$tmp['body'] = 'id must provided.';
return $tmp;
}
$header["Authorization"] = "Bearer " . getConfig('APIKey'); $header["Authorization"] = "Bearer " . getConfig('APIKey');
$header["Content-Type"] = "application/json"; $header["Content-Type"] = "application/json";
$url = "https://api.vercel.com/v11/now/deployments/" . $deployid; $url = "https://api.vercel.com/v11/deployments/" . $deployid;
$response = curl("GET", $url, "", $header); $response = curl("GET", $url, "", $header);
if ($response['stat']==200) { if ($response['stat']==200) {
$result = json_decode($response['body'], true); $result = json_decode($response['body'], true);
@@ -444,3 +445,48 @@ function WaitFunction($deployid) {
return $response; return $response;
} }
} }
function changeAuthKey() {
if ($_POST['APIKey']!='') {
$APIKey = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey;
$response = setConfigResponse( setVercelConfig($tmp, getConfig('HerokuappId'), $APIKey) );
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://vercel.com/account/tokens" target="_blank">' . getconstStr('Create') . ' token</a><br>
<label>Token:<input name="APIKey" type="password" placeholder="" value=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.APIKey.value==\'\') {
alert(\'Input Token\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
+474
View File
@@ -0,0 +1,474 @@
<?php
// https://vercel.com/docs/api#endpoints/deployments/create-a-new-deployment
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['HTTP_FLY_CLIENT_IP'])) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_FLY_CLIENT_IP'];
if ($_SERVER['REQUEST_SCHEME']!='http'&&$_SERVER['REQUEST_SCHEME']!='https') {
if ($_SERVER['HTTP_X_FORWARDED_PROTO']!='') {
$tmp = explode(',', $_SERVER['HTTP_X_FORWARDED_PROTO'])[0];
if ($tmp=='http'||$tmp=='https') $_SERVER['REQUEST_SCHEME'] = $tmp;
}
if ($_SERVER['HTTP_FLY_FORWARDED_PROTO']!='') $_SERVER['REQUEST_SCHEME'] = $_SERVER['HTTP_FLY_FORWARDED_PROTO'];
}
$_SERVER['host'] = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
$_SERVER['referhost'] = explode('/', $_SERVER['HTTP_REFERER'])[2];
$_SERVER['base_path'] = "/";
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'])) );
$_SERVER['DOCUMENT_ROOT'] = '/var/task/user';
return $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 = '')
{
if (isInnerEnv($str)) {
if ($disktag=='') $disktag = $_SERVER['disktag'];
$tmp = getenv($disktag);
if (is_array($tmp)) $env = $tmp;
else $env = json_decode($tmp, true);
if (isset($env[$str])) {
if (isBase64Env($str)) return base64y_decode($env[$str]);
else return $env[$str];
}
} else {
if (isBase64Env($str)) return base64y_decode(getenv($str));
else return getenv($str);
}
return '';
}
function setConfig($arr, $disktag = '')
{
if ($disktag=='') $disktag = $_SERVER['disktag'];
$disktags = explode("|", getenv('disktag'));
if ($disktag!='') {
$tmp = getenv($disktag);
if (is_array($tmp)) $diskconfig = $tmp;
else $diskconfig = json_decode($tmp, true);
}
$tmp = [];
$indisk = 0;
$operatedisk = 0;
foreach ($arr as $k => $v) {
if (isCommonEnv($k)) {
if (isBase64Env($k)) $tmp[$k] = base64y_encode($v);
else $tmp[$k] = $v;
} elseif (isInnerEnv($k)) {
if (isBase64Env($k)) $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_copy') {
$newtag = $v . '_' . date("Ymd_His");
$tagvalue = getenv($v);
if (is_array($tagvalue)) $tmp[$newtag] = json_encode($tagvalue);
else $tmp[$newtag] = $tagvalue;
array_push($disktags, $newtag);
$operatedisk = 1;
} elseif ($k=='disktag_rename' || $k=='disktag_newname') {
if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1;
} else {
$tmp[$k] = json_encode($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']!='') {
$tags = [];
foreach ($disktags as $tag) {
if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']);
else array_push($tags, $tag);
}
$tmp['disktag'] = implode('|', $tags);
$tagvalue = getenv($arr['disktag_rename']);
if (is_array($tagvalue)) $tmp[$arr['disktag_newname']] = json_encode($tagvalue);
else $tmp[$arr['disktag_newname']] = $tagvalue;
$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;
//error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($tmp, JSON_PRETTY_PRINT));
//echo json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp' . json_encode($tmp, JSON_PRETTY_PRINT);
return setVercelConfig($tmp, getConfig('HerokuappId'), 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 = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey;
$token = $APIKey;
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$aliases = json_decode(curl("GET", "https://api.vercel.com/v3/now/aliases", "", $header)['body'], true);
$host = splitfirst($_SERVER["host"], "//")[1];
foreach ($aliases["aliases"] as $key => $aliase) {
if ($host==$aliase["alias"]) $projectId = $aliase["projectId"];
}
$tmp['HerokuappId'] = $projectId;
$response = json_decode(setVercelConfig($tmp, $projectId, $APIKey), true);
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var expd = new Date();
expd.setTime(expd.getTime()+1000);
var expires = "expires="+expd.toGMTString();
document.cookie=\'language=; path=/; \'+expires;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
}
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>';
}
$html .= '<br>
<a href="https://vercel.com/account/tokens" target="_blank">' . getconstStr('Create') . ' token</a><br>
<label>Token:<input name="APIKey" type="password" placeholder="" value=""></label><br>';
$html .= '<br>
<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>
<div id="showerror"></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;
var errordiv = document.getElementById("showerror");
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 (t.APIKey.value==\'\') {
alert(\'input Token\');
return false;
}
return true;
}
</script>';
$title = getconstStr('SelectLanguage');
return message($html, $title, 201);
}
if (substr($_SERVER["host"], -10)=="vercel.app") {
$html .= '<a href="?install0">' . getconstStr('ClickInstall') . '</a>, ' . getconstStr('LogintoBind');
$html .= "<br>Remember: you MUST wait 30-60s after each operate / do some change, that make sure Vercel has done the building<br>" ;
} else {
$html.= "Please visit form *.vercel.app";
}
$title = 'Install';
return message($html, $title, 201);
}
// POST /v8/projects/:id/env
function setVercelConfig($envs, $appId, $token)
{
$url = "https://api.vercel.com/v8/projects/" . $appId . "/env";
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$response = curl("GET", $url, "", $header);
$result = json_decode($response['body'], true);
foreach ($result["envs"] as $key => $value) {
$existEnvs[$value["key"]] = $value["id"];
}
foreach ($envs as $key => $value) {
$response = null;
$tmp = null;
$tmp["type"] = "encrypted";
$tmp["key"] = $key;
$tmp["value"] = $value;
$tmp["target"] = [ "development", "production", "preview" ];
if (isset($existEnvs[$key])) {
if ($value) $response = curl("PATCH", $url . "/" . $existEnvs[$key], json_encode($tmp), $header);
else $response = curl("DELETE", $url . "/" . $existEnvs[$key], "", $header);
} else {
if ($value) $response = curl("POST", $url, json_encode($tmp), $header);
}
//echo $key . " = " . $value . ", <br>" . $response . json_encode($response, JSON_PRETTY_PRINT) . "<br>";
if (!!$response && $response['stat']!=200) return $response['body'];
}
return VercelUpdate($appId, $token);
}
function VercelUpdate($appId, $token, $sourcePath = "")
{
if (checkBuilding($appId, $token)) return '{"error":{"message":"Another building is in progress."}}';
$url = "https://api.vercel.com/v13/deployments";
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$data["name"] = "OneManager";
$data["project"] = $appId;
$data["target"] = "production";
$data["routes"][0]["src"] = "/(.*)";
$data["routes"][0]["dest"] = "/api/index.php";
$data["functions"]["api/index.php"]["runtime"] = "vercel-php@0.4.0";
if ($sourcePath=="") $sourcePath = splitlast(splitlast(__DIR__, "/")[0], "/")[0];
//echo $sourcePath . "<br>";
getEachFiles($file, $sourcePath);
$data["files"] = $file;
//echo json_encode($data, JSON_PRETTY_PRINT) . " ,data<br>";
$response = curl("POST", $url, json_encode($data), $header);
//echo json_encode($response, JSON_PRETTY_PRINT) . " ,res<br>";
$result = json_decode($response["body"], true);
$result['DplStatus'] = $result['id'];
return json_encode($result);
}
function checkBuilding($projectId, $token)
{
$r = 0;
$url = "https://api.vercel.com/v6/deployments/?projectId=" . $projectId;
$header["Authorization"] = "Bearer " . $token;
$header["Content-Type"] = "application/json";
$response = curl("GET", $url, '', $header);
//echo json_encode($response, JSON_PRETTY_PRINT) . " ,res<br>";
$result = json_decode($response["body"], true);
foreach ( $result['deployments'] as $deployment ) {
if ($deployment['state']!=="READY") $r++;
}
return $r;
//if ($r===0) return true;
//else return false;
}
function getEachFiles(&$file, $base, $path = "")
{
//if (substr($base, -1)=="/") $base = substr($base, 0, -1);
//if (substr($path, -1)=="/") $path = substr($path, 0, -1);
$handler=opendir(path_format($base . "/" . $path));
while($filename=readdir($handler)) {
if($filename != '.' && $filename != '..' && $filename != '.git'){
$fromfile = path_format($base . "/" . $path . "/" . $filename);
//echo $fromfile . "<br>";
if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
$response = getEachFiles($file, $base, path_format($path . "/" . $filename));
if (api_error(setConfigResponse($response))) return $response;
}else{
$tmp['file'] = path_format($path . "/" . $filename);
$tmp['data'] = file_get_contents($fromfile);
$file[] = $tmp;
}
}
}
closedir($handler);
return json_encode( [ 'response' => 'success' ] );
}
function api_error($response)
{
return isset($response['error']);
}
function api_error_msg($response)
{
return $response['error']['code'] . '<br>
' . $response['error']['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')
{
$tmppath = '/tmp';
// 从github下载对应tar.gz,并解压
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
$tarfile = $tmppath . '/github.tar.gz';
$githubfile = file_get_contents($url);
if (!$githubfile) return '{"error":{"message":"fail to download from github"}}';
file_put_contents($tarfile, $githubfile);
$phar = new PharData($tarfile); // need php5.3, 7, 8
$phar->extractTo($tmppath, null, true);//路径 要解压的文件 是否覆盖
unlink($tarfile);
$outPath = '';
$tmp = scandir($tmppath);
$name = $auth . '-' . $project;
mkdir($tmppath . "/" . $name, 0777);
foreach ($tmp as $f) {
if ( substr($f, 0, strlen($name)) == $name) {
rename($tmppath . '/' . $f, $tmppath . "/" . $name . '/api');
$outPath = $tmppath . "/" . $name;
break;
}
}
//echo $outPath . "<br>";
//error_log1($outPath);
if ($outPath=='') return '{"error":{"message":"no outpath"}}';
return VercelUpdate(getConfig('HerokuappId'), getConfig('APIKey'), $outPath);
}
function WaitFunction($deployid) {
if ($buildId=='1') {
$tmp['stat'] = 400;
$tmp['body'] = 'id must provided.';
return $tmp;
}
$header["Authorization"] = "Bearer " . getConfig('APIKey');
$header["Content-Type"] = "application/json";
$url = "https://api.vercel.com/v11/deployments/" . $deployid;
$response = curl("GET", $url, "", $header);
if ($response['stat']==200) {
$result = json_decode($response['body'], true);
if ($result['readyState']=="READY") return true;
if ($result['readyState']=="ERROR") return $response;
return false;
} else {
$response['body'] .= $url;
return $response;
}
}
function changeAuthKey() {
if ($_POST['APIKey']!='') {
$APIKey = $_POST['APIKey'];
$tmp['APIKey'] = $APIKey;
$response = json_decode(setVercelConfig($tmp, getConfig('HerokuappId'), $APIKey), true);
if (api_error($response)) {
$html = api_error_msg($response);
$title = 'Error';
return message($html, $title, 400);
} else {
$html = getconstStr('Success') . '
<script>
var status = "' . $response['DplStatus'] . '";
var i = 0;
var uploadList = setInterval(function(){
if (document.getElementById("dis").style.display=="none") {
console.log(i++);
} else {
clearInterval(uploadList);
location.href = "' . path_format($_SERVER['base_path'] . '/') . '";
}
}, 1000);
</script>';
return message($html, $title, 201, 1);
}
}
$html = '
<form action="" method="post" onsubmit="return notnull(this);">
<a href="https://vercel.com/account/tokens" target="_blank">' . getconstStr('Create') . ' token</a><br>
<label>Token:<input name="APIKey" type="password" placeholder="" value=""></label><br>
<input type="submit" value="' . getconstStr('Submit') . '">
</form>
<script>
function notnull(t)
{
if (t.APIKey.value==\'\') {
alert(\'Input Token\');
return false;
}
return true;
}
</script>';
return message($html, 'Change platform Auth token or key', 200);
}
+170 -101
View File
@@ -1,137 +1,206 @@
# NOTICE: the release is used as archive. [中文readme](readme_cn.md)
# 注意:release只是用来存档的。
Please read the descriptions of settings before raising an issue. # NOTICE:
请将设置中所有的设置项的说明都读一遍,有些问题就不用问了。
The Releases is used as archive, not newest code.
Please read the descriptions of settings before raising an issue.
---
# Deploy to Heroku # Deploy to Heroku
Official: https://heroku.com
Demo: https://herooneindex.herokuapp.com/
How to Install: ### Official
> ~~Click the button [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/qkqpttgf/OneManager-php) to Deploy a new app~~(`"We couldn't deploy your app because the source code violates the Salesforce Acceptable Use and External-Facing Services Policy."`)
> Fork this project, create a heroku app, then turn to Deploy tab, deploy via connect to your github fork.
https://heroku.com
### Demo
https://herooneindex.herokuapp.com/
### How to Install
> ~~Click the button [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) to Deploy a new app~~(`"We couldn't deploy your app because the source code violates the Salesforce Acceptable Use and External-Facing Services Policy."`)
>
> Star this project, then Fork, create a app in Heroku, then turn to the Deploy tab, "Deployment method" via "Connect GitHub", select your github fork.
---
# Deploy to Glitch # 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. ### 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 Vercel # Deploy to Vercel
Official: https://vercel.com/
Demo: null
Notice:
> 1, you must wait 30-50s to make sure deploy READY after change config;
> 2, the max size of environment is 4k, so you can add 3 onedrive or less;
> 3, Vercel limit 100 deploy every day.
How to Install: https://scfonedrive.github.io/Vercel/Deploy.html . ### Official
https://vercel.com/
### Demo
https://onemanager-php.vercel.app/
### Notice
> 1. you must wait 30-50s to make sure deploy READY after change config;
>
> 2. Vercel limit 100 deploy every day.
### How to Install
https://scfonedrive.github.io/Vercel/Deploy.html .
---
# Deploy to Tencent Serverless Cloud Function (SCF)
### Official
https://cloud.tencent.com/product/scf
### DEMO
null
### How to Install
see CN readme.
----
# Deploy to Tencent Serverless Cloud Function (SCF 腾讯无服务器云函数) # Deploy to Huawei cloud Function Graph (FG)
Official: https://cloud.tencent.com/product/scf
DEMO: 无
注意:SCF新增限制,环境变量整体最大4KB,所以最多添加4个盘。
How to Install: ### Official
1,进入函数服务,上方选择地区,然后点击新建。
2,输入函数名称,选择模板函数,在模糊搜索中输入onedrive,大小写随意,选择那个【获取onedrive信息.....】,点下一步,在代码界面不用动,直接点完成。
3,点击触发管理,创建触发器,触发方式改成API网关触发,底下勾选启用集成响应,提交。
4,在触发管理中可以看到一个 访问路径,访问它,开始安装。
(重点:勾选集成响应) https://console.huaweicloud.com/functiongraph/
添加网盘时,SCF可能会反应不过来,不跳转到微软,导致添加失败,请不要删除这个盘,再添加一次相同标签的盘就可以了。 ### DEMO
null
# Deploy to Huawei cloud Function Graph (FG 华为云函数工作流) ### How to Install
Official: https://console.huaweicloud.com/functiongraph/
DEMO: 无
注意:FG中,环境变量整体大小为2KB,所以最多添加2个盘(一个onedrive一个aliyundrive)。
How to Install: see CN readme.
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 阿里云函数计算) # Deploy to Aliyun Function Compute (FC)
Official: https://fc.console.aliyun.com/
DEMO: 无
How to Install: ### Official:
1,新建函数 -- HTTP函数
2,运行环境选择php7.2
3,触发器认证方式选择anonymous,请求方式里面,点一下GET,再点一下POST,最终框框里面有这2个
4,上传代码
5,触发器中点进去,找到配置自定义域名,点击前往,创建,路径中填 /* ,其它下拉选择。
6,访问你的域名,开始安装
https://fc.console.aliyun.com/
# Deploy to Baidu Cloud Function Compute (CFC 百度云函数计算) ### DEMO
Official: https://console.bce.baidu.com/cfc/#/cfc/functions
DEMO: 无
自定义域名需要另外使用API网关,并备案。
How to Install: null
1,在函数列表,点创建函数
2,创建方式改为空白函数,点下一步
3,输入名称,选择运行时为PHP7.2,点下一步
4,触发器:下拉选择HTTP触发器,URL路径填 /{filepath+} ,HTTP方法全选,身份验证:不验证,点提交
5,进入代码编辑页,编辑类型改上传函数ZIP包,选择文件(这里的ZIP文件不能直接用从Github上下载的ZIP文件,要将它解压后,去掉外层文件夹后,再压缩为ZIP。),开始上传
6,点击右边触发器,复制并访问提供的url,开始安装
### How to Install
# Deploy to Virtual Private Server (VPS 或空间) see CN readme.
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 .data/config.php can be read&write (666 is suggested).
使web身份可读写代码中的.data/config.php文件,推荐chmod 666 .data/config.php。
5.View the website in chrome or other.
在浏览器中访问。
---
# Features 特性 # Deploy to Baidu Cloud Function Compute (CFC)
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服务器下载文件,服务器只消耗与微软通信的少量流量。 ### Official
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上传文件,服务器只消耗与微软通信的少量流量。 https://console.bce.baidu.com/cfc/#/cfc/functions
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里面找这个路径。 ### DEMO
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 可以访问到。 null
Program will show content of 'readme.md' & 'head.md'.
可以在文件列表显示head.md跟readme.md文件的内容。 ### How to Install
guest up path, is a folder that the guest can upload files, but can not be list (exclude admin).
游客上传目录(也叫图床目录),是指定一个目录,让游客可以上传文件,不限格式,不限大小。这个目录里面的内容不列清单(除非管理登录)。 see CN readme.
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.
点击“时间”、“大小”,可以排序显示,点“文件”恢复原样。 # Deploy to Virtual Private Server (VPS) or php host
### DEMO
null
### How to Install
1. Start web service on your server (httpd or other), make sure you can visit it.
2. Make the rewrite works, the rule is in .htaccess file, make sure any query redirect to index.php.
3. Upload code.
4. Change the file .data/config.php can be read&write (666 is suggested).
5. View the website in chrome or other.
----
# 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.
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.
The XXX_path in setting is the path in Onedrive, not in url, program will find the path in Onedrive.
LOGO ICON: put your 'favicon.ico' in the path you showed, make sure xxxxx.com/favicon.ico can be visited.
Program will show content of 'readme.md' & 'head.md'.
guest upload 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.
Click 'EditTime' or 'Size', the list will sort by time or size, Click 'File' can resume sort.
----
# Functional files
# Functional files 功能性文件
### favicon.ico ### favicon.ico
put it in the showing home folder of FIRST disk (maybe not root of onedrive). 放在第一个盘的显示目录(不一定是onedrive根目录)。
put it in the showing home folder of FIRST disk (maybe not root of onedrive).
### index.html ### index.html
show content of index.html as html. 将index.html以静态网页显示出来。
### head.md readme.md show content of index.html as html.
it will showed at top or bottom as markdown. 以MD语法显示在顶部或底部。
### head.omf foot.omf ### head.md
it will showed at top or bottom as html (javascript works!). 以html显示在顶部或底部(可以跑js)。
### readme.md
it will showed at top or bottom as markdown.
### head.omf
### foot.omf
it will showed at top or bottom as html (javascript works!).
----
# A cup of coffee # A cup of coffee
paypal.me/qkqpttgf
https://paypal.me/qkqpttgf
-----
# Chat # Chat
QQ Group: 212088653 (请看完上面的中英双语再加群,谢谢!)
Telegram Group: https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw ### Telegram Group
https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw
+246
View File
@@ -0,0 +1,246 @@
[Readme EN](readme.md)
# 注意:
Releases只是当存档在用的,并不是最新代码。
请将设置中所有的设置项的说明都读一遍,有些问题就不用问了。
---
# 部署到 Heroku
### 官网
https://heroku.com
### Demo
https://herooneindex.herokuapp.com/
### 安装
> 给这个项目点star,然后fork,在Heroku创建一个app,然后点进Deploy页,在"Deployment method"处点"Connect GitHub",选择你的fork。
---
# 部署到 Glitch
### 官网
https://glitch.com/
### Demo
https://onemanager.glitch.me/
### 安装
点 [New Project] -> 点 [Import form Github] -> 粘贴 "https://github.com/qkqpttgf/OneManager-php" ,结束后,左上角点 [Show] -> [In a New Window]。
---
# 部署到 Vercel
### 官网
https://vercel.com/
### Demo
https://onemanager-php.vercel.app/
### 注意
> 1. 每次更改配置后都要等 30-50s 来确保部署成功;
>
> 2. Vercel 每天限制 100 次部署。
### 安装(英文)
https://scfonedrive.github.io/Vercel/Deploy.html
---
# 部署到腾讯无服务器云函数 Serverless Cloud Function (SCF)
### 官网
https://cloud.tencent.com/product/scf
### DEMO
暂无
### 注意事项
SCF新增限制,环境变量整体最大4KB,所以最多添加4个盘(可以在安装时选择将配置保存在文件来避开限制)。
### 安装
1. 进入函数服务,上方选择地区,然后点击新建。
2. 输入函数名称,选择模板函数,在模糊搜索中输入onedrive,大小写随意,选择那个【获取onedrive信息.....】,点下一步,在代码界面不用动,直接点完成。
3. 点击触发管理,创建触发器,触发方式改成API网关触发,底下勾选启用集成响应,提交。
4. 在触发管理中可以看到一个 访问路径,访问它,开始安装。
(重点:**勾选集成响应**)
> **添加网盘时,SCF可能会反应不过来,不跳转到微软,导致添加失败,请不要删除这个盘,再添加一次相同标签的盘就可以了。**
----
# 部署到华为云函数工作流 Function Graph (FG)
### 官网
https://console.huaweicloud.com/functiongraph/
### DEMO
暂无
### 注意事项
FG中,环境变量整体大小为2KB,所以最多添加2个盘(一个onedrive一个aliyundrive)(可以在安装时选择将配置保存在文件来避开限制)。
### 安装
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,然后不用点下一步了,点【立即完成】,然后去【发布】生效
----
# 部署到阿里云函数计算 Function Compute (FC)
### 官网
https://fc.console.aliyun.com/
### DEMO
### 安装
1. 新建函数 -- HTTP函数
2. 运行环境选择php7.2
3. 触发器认证方式选择anonymous,请求方式里面,点一下GET,再点一下POST,最终框框里面有这2个
4. 上传代码(这里的ZIP文件不能直接用从Github上下载的ZIP文件,要将它解压后,去掉外层文件夹后,再压缩为ZIP。)
5. 触发器中点进去,找到配置自定义域名,点击前往,创建,路径中填 /* ,其它下拉选择。
6. 访问你的域名,开始安装
---
# 部署到百度云函数计算 Cloud Function Compute (CFC)
### 官网
https://console.bce.baidu.com/cfc/#/cfc/functions
### DEMO
暂无
### 注意事项
**自定义域名需要另外使用API网关,并备案。**
### 安装
1. 在函数列表,点创建函数
2. 创建方式改为空白函数,点下一步
3. 输入名称,选择运行时为PHP7.2,点下一步
4. 触发器:下拉选择HTTP触发器,URL路径填 /{filepath+} ,HTTP方法全选,身份验证:不验证,点提交
5. 进入代码编辑页,编辑类型改上传函数ZIP包,选择文件(这里的ZIP文件不能直接用从Github上下载的ZIP文件,要将它解压后,去掉外层文件夹后,再压缩为ZIP。),开始上传
6. 点击右边触发器,复制并访问提供的url,开始安装
---
# 部署到VPS (Virtual Private Server) 或 空间
### DEMO
暂无
### 安装
1. 启动web服务器,确保你能访问到。
2. 开启伪静态(重写)功能,规则在.htaccess文件中,ngnix从里面复制,我们的目的是不管访问什么都让index.php来处理。
3. 上传好代码。
4. 使web身份可读写代码中的.data/config.php文件,推荐chmod 666 .data/config.php。
5. 在浏览器中访问。
----
# 特性
下载时,由程序解析出直链,浏览器直接从微软Onedrive服务器下载文件,服务器只消耗与微软通信的少量流量。
上传时,由程序生成上传url,浏览器直接向微软Onedrive的这个url上传文件,服务器只消耗与微软通信的少量流量。
设置中的 XXX_path 是Onedrive里面的路径,并不是你url里面的,程序会去你Onedrive里面找这个路径。
网站图标:将favicon.ico文件放在你要展示的目录中,确保 xxxxx.com/favicon.ico 可以访问到。
可以在文件列表显示head.md跟readme.md文件的内容。
游客上传目录(也叫图床目录),是指定一个目录,让游客可以上传文件,不限格式,不限大小。这个目录里面的内容不列清单(除非管理登录)。
如果目录中有index.html文件,只会输出显示html文件,不显示程序框架。
点击“时间”、“大小”,可以排序显示,点“文件”恢复原样。
----
# 功能性文件
### favicon.ico
放在第一个盘的显示目录(不一定是onedrive根目录)。
### index.html
将index.html以静态网页显示出来。
### head.md
### readme.md
以MD语法显示在顶部或底部。
### head.omf
### foot.omf
以html显示在顶部或底部(可以跑js)。
----
# 捐赠
https://paypal.me/qkqpttgf
-----
# 群聊
**请看完上面的中英双语再加群,谢谢!**
### QQ 群:
212088653
### Telegram Group
https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw
+28 -16
View File
@@ -94,12 +94,12 @@
</ul></li> </ul></li>
<!--AdminEnd--> <!--AdminEnd-->
&nbsp; &nbsp;
<select class="changelanguage" name="language" onchange="changelanguage(this.options[this.options.selectedIndex].value)"> <!--<select class="changelanguage" name="language" onchange="changelanguage(this.options[this.options.selectedIndex].value)">
<option value="">Language</option> <option value="">Language</option>
<!--SelectLanguageStart--> <!--SelectLanguageStart-->
<option value="<!--SelectLanguageKey-->" <!--SelectLanguageSelected-->><!--SelectLanguageValue--></option> <option value="<!--SelectLanguageKey-->" <!--SelectLanguageSelected-->><!--SelectLanguageValue--></option>
<!--SelectLanguageEnd--> <!--SelectLanguageEnd-->
</select> </select>-->
</div> </div>
<!--NeedUpdateStart--> <!--NeedUpdateStart-->
<div style='position:absolute;'><font color='red'><!--constStr@NeedUpdate--></font></div> <div style='position:absolute;'><font color='red'><!--constStr@NeedUpdate--></font></div>
@@ -202,6 +202,7 @@
<div id="txt"> <div id="txt">
<!--AdminStart--> <!--AdminStart-->
<form id="txt-form" action="" method="POST"> <form id="txt-form" action="" method="POST">
<input name="_admin" type="hidden" value="">
<a onclick="document.getElementById('txt-a').readOnly='';document.getElementById('txt-save').style.display='';document.getElementById('txt-editbutton').style.display='none';document.getElementById('txt-cancelbutton').style.display='';" id="txt-editbutton"><ion-icon name="create"></ion-icon><!--constStr@ClicktoEdit--></a> <a onclick="document.getElementById('txt-a').readOnly='';document.getElementById('txt-save').style.display='';document.getElementById('txt-editbutton').style.display='none';document.getElementById('txt-cancelbutton').style.display='';" id="txt-editbutton"><ion-icon name="create"></ion-icon><!--constStr@ClicktoEdit--></a>
<a onclick="document.getElementById('txt-a').readOnly='readonly';document.getElementById('txt-save').style.display='none';document.getElementById('txt-editbutton').style.display='';document.getElementById('txt-cancelbutton').style.display='none';" id="txt-cancelbutton" style="display:none"><ion-icon name="close"></ion-icon><!--constStr@CancelEdit--></a>&nbsp;&nbsp;&nbsp; <a onclick="document.getElementById('txt-a').readOnly='readonly';document.getElementById('txt-save').style.display='none';document.getElementById('txt-editbutton').style.display='';document.getElementById('txt-cancelbutton').style.display='none';" id="txt-cancelbutton" style="display:none"><ion-icon name="close"></ion-icon><!--constStr@CancelEdit--></a>&nbsp;&nbsp;&nbsp;
<a id="txt-save" style="display:none"><ion-icon name="save"></ion-icon><!--constStr@Save--></a> <a id="txt-save" style="display:none"><ion-icon name="save"></ion-icon><!--constStr@Save--></a>
@@ -209,6 +210,12 @@
<textarea id="txt-a" name="editfile" readonly style="width: 100%; margin-top: 2px;" <!--AdminStart-->onchange="document.getElementById('txt-save').onclick=function(){document.getElementById('txt-form').submit();}"<!--AdminEnd--> ><!--TxtContent--></textarea> <textarea id="txt-a" name="editfile" readonly style="width: 100%; margin-top: 2px;" <!--AdminStart-->onchange="document.getElementById('txt-save').onclick=function(){document.getElementById('txt-form').submit();}"<!--AdminEnd--> ><!--TxtContent--></textarea>
<!--AdminStart--> <!--AdminStart-->
</form> </form>
<script>
var inputAdminStorage = document.getElementsByName("_admin");
for (i=0;i<inputAdminStorage.length;i++) {
inputAdminStorage[i].value = localStorage.getItem("admin");
}
</script>
<!--AdminEnd--> <!--AdminEnd-->
</div> </div>
<!--IstxtFileEnd--> <!--IstxtFileEnd-->
@@ -222,7 +229,7 @@
<table class="list-table" id="list-table"> <table class="list-table" id="list-table">
<tr id="tr0"> <tr id="tr0">
<th class="file"> <th class="file">
<a onclick="sortby('a');"><!--constStr@File--></a> <a id="file_a0" fileid="<!--FolderId-->" onclick="sortby('a');"><!--constStr@File--></a>
<!--ShowThumbnailsStart--> <!--ShowThumbnailsStart-->
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
<label><input type="checkbox" id="originalpic"><!--constStr@OriginalPic--></label> <label><input type="checkbox" id="originalpic"><!--constStr@OriginalPic--></label>
@@ -522,7 +529,10 @@
<!--IsFileStart--> <!--IsFileStart-->
var $url = document.getElementById('url'); var $url = document.getElementById('url');
if ($url) { if ($url) {
$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML; //$url.innerHTML = location.protocol + '//' + location.host + $url.innerHTML;
let url = location.href;
url = url.substr(0, url.length-8);
$url.innerHTML = url.replace(/&amp;/g, '&amp;amp;');
$url.style.height = $url.scrollHeight + 'px'; $url.style.height = $url.scrollHeight + 'px';
} }
<!--IsofficeFileStart--> <!--IsofficeFileStart-->
@@ -601,12 +611,12 @@
}); });
} }
} }
addVideos(['<!--FileEncodeUrl-->']); addVideos(["<!--FileEncodeUrl-->"]);
<!--IsvideoFileEnd--> <!--IsvideoFileEnd-->
<!--IspdfFileStart--> <!--IspdfFileStart-->
pdfjsLib.GlobalWorkerOptions.workerSrc = '//cdn.bootcss.com/pdf.js/2.3.200/pdf.worker.min.js'; pdfjsLib.GlobalWorkerOptions.workerSrc = '//cdn.bootcss.com/pdf.js/2.3.200/pdf.worker.min.js';
var loadingTask = pdfjsLib.getDocument({ var loadingTask = pdfjsLib.getDocument({
url: '<!--FileDownUrl-->', url: "<!--FileDownUrl-->",
cMapUrl: "//cdn.jsdelivr.net/npm/pdfjs-dist@2.2.228/cmaps/", cMapUrl: "//cdn.jsdelivr.net/npm/pdfjs-dist@2.2.228/cmaps/",
cMapPacked: true, cMapPacked: true,
rangeChunkSize: 65535 rangeChunkSize: 65535
@@ -775,6 +785,7 @@
} }
function size_reformat(str) { function size_reformat(str) {
if (str.substr(-1)==' ') str=str.substr(0,str.length-1); if (str.substr(-1)==' ') str=str.substr(0,str.length-1);
if (str.substr(-2)=='TB') num=str.substr(0,str.length-3)*1024*1024*1024*1024;
if (str.substr(-2)=='GB') num=str.substr(0,str.length-3)*1024*1024*1024; if (str.substr(-2)=='GB') num=str.substr(0,str.length-3)*1024*1024*1024;
if (str.substr(-2)=='MB') num=str.substr(0,str.length-3)*1024*1024; if (str.substr(-2)=='MB') num=str.substr(0,str.length-3)*1024*1024;
if (str.substr(-2)=='KB') num=str.substr(0,str.length-3)*1024; if (str.substr(-2)=='KB') num=str.substr(0,str.length-3)*1024;
@@ -988,7 +999,7 @@
delete uploading[upbigfilename]; delete uploading[upbigfilename];
} }
} }
xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified +'&filemd5='+ filemd5); xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified +'&filemd5='+ filemd5 + '&_admin=' + localStorage.getItem("admin"));
<!--GuestStart--> <!--GuestStart-->
} }
} }
@@ -1239,7 +1250,7 @@
getuplink(i); getuplink(i);
}*/ }*/
} }
xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified + '&filesha1=' + filesha1 + '&chunksize=' + chunksize); xhr1.send('upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&filelastModified='+ file.lastModified + '&filesha1=' + filesha1 + '&chunksize=' + chunksize + '&_admin=' + localStorage.getItem("admin"));
} }
} }
} }
@@ -1325,7 +1336,7 @@
} }
delete uploading[filename]; delete uploading[filename];
} }
xhr1.send('uploadid=' + uploadid + '&fileid=' + fileid + '&etag=' + JSON.stringify(res['ETag'])); xhr1.send('uploadid=' + uploadid + '&fileid=' + fileid + '&etag=' + JSON.stringify(res['ETag']) + '&_admin=' + localStorage.getItem("admin"));
} else { } else {
var binary = this.result; var binary = this.result;
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
@@ -1396,7 +1407,7 @@
} }
delete uploading[filename]; delete uploading[filename];
} }
xhr1.send('uploadid=' + uploadid + '&fileid=' + fileid + '&etag=' + JSON.stringify(res['ETag'])); xhr1.send('uploadid=' + uploadid + '&fileid=' + fileid + '&etag=' + JSON.stringify(res['ETag']) + '&_admin=' + localStorage.getItem("admin"));
// uploadbuttonshow(); // uploadbuttonshow();
} else { } else {
readblob(asize); readblob(asize);
@@ -1439,7 +1450,7 @@
var expd = new Date(); var expd = new Date();
expd.setTime(expd.getTime()+1000); expd.setTime(expd.getTime()+1000);
var expires = "expires="+expd.toGMTString(); var expires = "expires="+expd.toGMTString();
document.cookie = "admin=; path=/; "+expires; document.cookie = "admin=; path=<!--base_path-->; "+expires;
location.href = location.href; location.href = location.href;
} }
/*for some mobile browser*/ /*for some mobile browser*/
@@ -1467,17 +1478,18 @@
document.getElementById('mask').style.display=''; document.getElementById('mask').style.display='';
//document.getElementById('mask').style.width=document.documentElement.scrollWidth+'px'; //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('mask').style.height=document.documentElement.scrollHeight<window.innerHeight?window.innerHeight:document.documentElement.scrollHeight+'px';
var str;
if (num=='') { if (num=='') {
var str=''; str = '';
var fileid=''; num = 0;
} else { } else {
var str=decodeURIComponent(document.getElementById('file_a'+num).href); str = decodeURIComponent(document.getElementById('file_a'+num).href);
if (str.substr(-1)==' ') str=str.substr(0, str.length-1); if (str.substr(-1)==' ') str=str.substr(0, str.length-1);
if (str.substr(-1)=='/') str=str.substr(0, str.length-1); if (str.substr(-1)=='/') str=str.substr(0, str.length-1);
if (str.substr(-8)=='?preview') str=str.substr(0, str.length-8); if (str.substr(-8)=='?preview') str=str.substr(0, str.length-8);
if (str.lastIndexOf('/')>-1) str=str.substr(str.lastIndexOf('/')+1); if (str.lastIndexOf('/')>-1) str=str.substr(str.lastIndexOf('/')+1);
var fileid=document.getElementById('file_a'+num).attributes['fileid'].nodeValue;
} }
var fileid = document.getElementById('file_a'+num).attributes['fileid'].nodeValue;
document.getElementById(action + '_div').style.display=''; document.getElementById(action + '_div').style.display='';
document.getElementById(action + '_label').innerText=str;//.replace(/&/,'&amp;'); document.getElementById(action + '_label').innerText=str;//.replace(/&/,'&amp;');
document.getElementById(action + '_sid').value=num; document.getElementById(action + '_sid').value=num;
@@ -1533,7 +1545,7 @@
document.getElementById(str+'_div').style.display='none'; document.getElementById(str+'_div').style.display='none';
document.getElementById('mask').style.display='none'; document.getElementById('mask').style.display='none';
} }
xhr.send(serializeForm(str+'_form')); xhr.send(serializeForm(str+'_form') + '&_admin=' + localStorage.getItem("admin"));
return false; return false;
} }
function addelement(html) { function addelement(html) {
+48 -4
View File
@@ -49,14 +49,29 @@
.more-disk a{flex-grow: 1;text-align: center;font-size: 15px;padding:14px 20px;transition-duration: 0.4s;background-color: #f4f5f8; color: #353535;display: inline-block;} .more-disk a{flex-grow: 1;text-align: center;font-size: 15px;padding:14px 20px;transition-duration: 0.4s;background-color: #f4f5f8; color: #353535;display: inline-block;}
.more-disk a:hover, .more-disk a[now]{ background-color: rgb(79 116 220); color: white; } .more-disk a:hover, .more-disk a[now]{ background-color: rgb(79 116 220); color: white; }
.list-table{width:100%;padding:0 20px 20px 20px;border-spacing:0} .list-table{width:100%;padding:0 20px 20px 20px;border-spacing:0}
.list-table tr{height:33px} .list-table tr{height:2rem; line-height: 1.5rem;}
.list-table tr[data-to]:hover{background: rgb(79 116 220);color:white;} .list-table tr[data-to]:hover{background: rgb(79 116 220);color:white;}
.list-table tr[data-to]:hover a{color:white} .list-table tr[data-to]:hover a{color:white}
.list-table tr:first-child{background:rgba(245,245,245,0)} .list-table tr:first-child{background:rgba(245,245,245,0)}
.list-table tr[data-to]:hover .operate ul li a{color:black}
.list-table tr ion-icon {vertical-align: middle; height: 2rem;}
.list-table td,.list-table th{padding:0 10px;text-align:left} .list-table td,.list-table th{padding:0 10px;text-align:left}
.list-table td.file a {vertical-align: middle;}
.list-table .size,.list-table .updated_at{text-align:right} .list-table .size,.list-table .updated_at{text-align:right}
.updated_at{width:25%} .updated_at{width:25%}
.size{width:15%} .size{width:15%}
.list-table tbody.grid-view {display: flex;flex-wrap: wrap;position: relative;width: 100%;grid-template: repeat(auto-fill, 100px) / repeat(auto-fill, minmax(100px, 50%));grid-auto-rows: 100px;}
.list-table tbody.grid-view td, .list-table tbody.grid-view th {padding:0;}
.list-table tbody.grid-view img {height: 150px;width: 100%;object-fit: cover;position:relative;}
.list-table tbody.grid-view #tr0{width: 100%;height: 33px;background-color: unset !important;}
.list-table tbody.grid-view tr {width: unset;height: 150px;background-color: #efefef;margin: 2px;position: relative;flex-grow: 1;min-width: 100px;}
.list-table tbody.grid-view td.file {display: block;width: 100%;height: 100%;}
.list-table tbody.grid-view td.file a {width: 100%;height: 100%;display: inline-block;position:relative}
.list-table tbody.grid-view td.file a > span {position: absolute;left: 3px;}
.list-table tbody.grid-view td.file .download {display: none;}
.list-table tbody.grid-view td.file ion-icon{position: absolute;top: calc(50% - 25px);left: calc(50% - 25px);width: 50px;height: 50px;color: #0002}
.list-table tbody.grid-view td.updated_at {position: absolute;bottom: 0px;height: 1.5em;overflow-y: hidden;width: 100%;background-image: linear-gradient(#ffffff00, #0000008f);color: #fffc;z-index: 3;}
.list-table tbody.grid-view td.size {display: none;}
.mask{position:absolute;left:0px;top:0px;width:100%;background-color:#000;filter:alpha(opacity=50);opacity:0.5;z-index:2;} .mask{position:absolute;left:0px;top:0px;width:100%;background-color:#000;filter:alpha(opacity=50);opacity:0.5;z-index:2;}
<!--AdminStart--> <!--AdminStart-->
#top-op {position: absolute;color: white;font-size: 12px;} #top-op {position: absolute;color: white;font-size: 12px;}
@@ -66,7 +81,6 @@
body .active ul{position:absolute;display:inline-table;} /*for some mobile browser */ body .active ul{position:absolute;display:inline-table;} /*for some mobile browser */
.operate ul li{padding:7px;list-style:none;display:block;} .operate ul li{padding:7px;list-style:none;display:block;}
.operate ul li:hover {background-color: #f4f5f8;} .operate ul li:hover {background-color: #f4f5f8;}
.list-table tr[data-to]:hover .operate ul li a{color:black}
#tr0{height: 40px;} #tr0{height: 40px;}
<!--AdminEnd--> <!--AdminEnd-->
.operatediv{position:absolute;border-radius: 8px;background-color:#ffffff;z-index:2;box-shadow: 5px 5px 10px 0 #00000033;padding: 15px 4px;} .operatediv{position:absolute;border-radius: 8px;background-color:#ffffff;z-index:2;box-shadow: 5px 5px 10px 0 #00000033;padding: 15px 4px;}
@@ -677,9 +691,39 @@
} }
<!--ReadmemdEnd--> <!--ReadmemdEnd-->
<!--ShowThumbnailsStart--> <!--ShowThumbnailsStart-->
var isGrid = false;
var isthumbLoaded = false;
function showthumbnails(obj) { function showthumbnails(obj) {
images = [<!--ImgExts-->]; images = [<!--ImgExts-->];
var files=document.getElementsByName('filelist'); var files=document.getElementsByName('filelist');
if (document.getElementById('originalpic').checked==true){
if(isGrid){
var list_body = document.getElementById('list-table').firstElementChild
list_body.classList.remove('grid-view')
isGrid = false
}
}else {
if(!isGrid){
// turn to grid view
var list_body = document.getElementById('list-table').firstElementChild
list_body.classList.add('grid-view')
isGrid = true
if (isthumbLoaded) {
return
}else {
isthumbLoaded = true
}
} else {
var list_body = document.getElementById('list-table').firstElementChild
list_body.classList.remove('grid-view')
isGrid = false
return
}
}
for ($i=0;$i<files.length;$i++) { for ($i=0;$i<files.length;$i++) {
str=files[$i].innerText; str=files[$i].innerText;
if (str.substr(-1)==' ') str=str.substr(0,str.length-1); if (str.substr(-1)==' ') str=str.substr(0,str.length-1);
@@ -698,7 +742,7 @@
} }
} }
} }
obj.disabled='disabled'; // obj.disabled='disabled';
} }
function get_thumbnails_url(url, name, filea) { function get_thumbnails_url(url, name, filea) {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
@@ -706,7 +750,7 @@
xhr.send(''); xhr.send('');
xhr.onload = function(e){ xhr.onload = function(e){
if (xhr.status==200) { if (xhr.status==200) {
if (xhr.responseText!='') filea.innerHTML='<img src="'+xhr.responseText+'" alt="'+name+'">'; if (xhr.responseText!='') filea.innerHTML= '<span>' + filea.innerHTML + '</span>' + '<img src="'+xhr.responseText+'" alt="'+name+'">';
} else console.log(xhr.status+'\n'+xhr.responseText); } else console.log(xhr.status+'\n'+xhr.responseText);
} }
} }
+3 -7
View File
@@ -98,13 +98,9 @@
<div class="mdui-drawer mdui-drawer-close" id="main-drawer"> <div class="mdui-drawer mdui-drawer-close" id="main-drawer">
<div class="mdui-list" mdui-collapse="{accordion: true}"> <div class="mdui-list" mdui-collapse="{accordion: true}">
<!--LoginStart--> <!--LoginStart-->
<li <li class="mdui-list-item mdui-ripple" href="?admin" >
class="mdui-list-item mdui-ripple" <a class="mdui-list-item-icon mdui-icon material-icons">account_circle</a>
href="javascript:void(0);" <a class="mdui-list-item-content" href="?admin">登录</a>
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> </li>
<!--LoginEnd--> <!--LoginEnd-->
<!--AdminStart--> <!--AdminStart-->
+25 -1
View File
@@ -1,7 +1,31 @@
20211201-1602.41
add a latent function, you can edit platform token(or API key) via '?setup=auth' when the token invalid, not need edit it in Environment(or Config Var) manually, (even in Vercel, config saved in file, and can't modiy it manually).
新增隐藏功能,在平台操作代码的token或API key失效时,可以在 '?setup=auth' 修改它,不用去环境变量修改了(特别地,Vercel保存在代码中时都改不到)。
20211129
check if there is another deployment building when start deploy.
Vercel部署时检测是否有另一个部署。
20211104
check if exist php-curl or not in php host and VPS.
在VPS中检测是否有php-curl。
20211021
specialchars, fix: list folder, encrypt folder, preview files, rename, show in title, error on back link after login at specialchars folder, etc.
针对特殊字符,解决目录的列表,目录的加密,文件的预览,目录与文件重命名,在网页标题的显示,在特殊字符处登录后跳转出错等问题。
20211006
oprate files by fileID, write a localStorage when login to anti CSRF.
管理时对文件id操作,管理登录时写入一个localStorage预防CSRF。
20210908
add fileConduitSize&fileConduitCacheTime, little files can stream from program, better to show html/js as local file.
增加fileConduitSizefileConduitCacheTime,小文件可以从服务器中转,以对html/js本地化更好的支持。
20210903
add a latent function, you can run some command by '?setup=cmd', be care, please dont try "top", and set times by "ping -c 4".
新增隐藏功能,你可以通过'?setup=cmd'来跑一些命令,注意不要试图跑top,另外ping请-c设置次数。
20210820-1810.40
because Vercel must redeploy after change Environment Variables, and it must <4k, so decide that, save config in code file. <font color=red>in Vercel, after update, please install again. if you want continue use Environment, please add a ( name: "ONEMANAGER_CONFIG_SAVE", value: "env" ) in Environment Variables in Project Settings before update.</font>
因为Vercel修改环境变量也必须重新部署才生效,而且环境变量只能小于4k,所以决定将配置保存在代码文件中。<font color=red>升级更新后,用Vercel的请重新安装。如果还想继续使用环境变量,请在更新前,在Project Settings的Environment Variables中,新增一个( name: "ONEMANAGER_CONFIG_SAVE", value: "env" )的环境变量。</font>
20210817-2030.39 20210817-2030.39
fix bugs in Vercel. add wait function in operating. change update method in SCF. add payme in readme. fix bugs in Vercel. add wait function in operating. change update method in SCF. add payme in readme.
修复一些Vercel上的bug。在操作完后添加等待功能,确认平台已经准备好。SCF的更新方式改变。在readme中添加讨饭链接。 修复一些Vercel上的bug。在操作完后添加等待功能,确认平台已经准备好。SCF的更新方式改变。在readme中添加讨饭链接。
20210804-1535.38 20210804-1535.38
try fix "&"/"&amp;" in filename. try show an img too height. change upload chunk size when upload speed>10M/s. fix forceHttps when custom domain in Glitch. fix ionicons svg lost.try use file id when rename. background (or other) based on width/height not only width. fix some bugs. Pre-Add platform Vercel, just wait bugs fixed. try fix "&"/"&amp;" in filename. try show an img too height. change upload chunk size when upload speed>10M/s. fix forceHttps when custom domain in Glitch. fix ionicons svg lost.try use file id when rename. background (or other) based on width/height not only width. fix some bugs. Pre-Add platform Vercel, just wait bugs fixed.
尝试修复文件名含 "&"/"&amp;"。尝试在一屏内显示过长的图片。上传时分割的块大小随着上传速度改变。修复Glitch中使用自定义域名时forceHttps问题。修复ionicons图标失踪。尝试在重命名时使用file id来操作。背景(或其它)基于长宽来看是竖屏还是横屏,不再只看宽度。修复其它bug。预加入Vercel平台,等修复bugs。 尝试修复文件名含 "&"/"&amp;"。尝试在一屏内显示过长的图片。上传时分割的块大小随着上传速度改变。修复Glitch中使用自定义域名时forceHttps问题。修复ionicons图标失踪。尝试在重命名时使用file id来操作。背景(或其它)基于长宽来看是竖屏还是横屏,不再只看宽度。修复其它bug。预加入Vercel平台,等修复bugs。