change login page, rm JumpFirstDisk, 403 in operating root, change sorting disk, remake disktags tab, add global md config
change login page, rm JumpFirstDisk, 403 in operating root, change sorting disk, remake disktags tab, add global md configpull/525/head
parent
be58a17328
commit
bc86e38c71
127
common.php
127
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,
|
||||
|
@ -183,7 +187,7 @@ function main($path)
|
|||
} else {
|
||||
$adminloginpage = getConfig('adminloginpage');
|
||||
}
|
||||
if (isset($_GET[$adminloginpage])) {
|
||||
if (isset($_GET['login'])&&$_GET['login']==$adminloginpage) {
|
||||
/*if (isset($_GET['preview'])) {
|
||||
$url = $_SERVER['PHP_SELF'] . '?preview';
|
||||
} else {
|
||||
|
@ -222,7 +226,6 @@ function main($path)
|
|||
return output('Please visit <a href="' . $tmp . '">' . $tmp . '</a>.', 301, [ 'Location' => $tmp ]);
|
||||
}
|
||||
if ($_SERVER['admin']) {
|
||||
$_SERVER['disktag'] = '';
|
||||
if (!class_exists($_GET['AddDisk'])) require 'disk' . $slash . $_GET['AddDisk'] . '.php';
|
||||
$drive = new $_GET['AddDisk']($_GET['disktag']);
|
||||
return $drive->AddDisk();
|
||||
|
@ -261,7 +264,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, '/');
|
||||
|
@ -295,19 +298,17 @@ function main($path)
|
|||
|
||||
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);
|
||||
|
@ -326,6 +327,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) {
|
||||
|
@ -1133,6 +1140,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;
|
||||
|
@ -1646,11 +1654,9 @@ output:
|
|||
}
|
||||
</script>';
|
||||
} else {
|
||||
//$_GET['disktag'] = '';
|
||||
$Driver_arr = scandir(__DIR__ . $slash . 'disk');
|
||||
if (count($disktags)>1) {
|
||||
$frame .= '
|
||||
<script src="//cdn.bootcss.com/Sortable/1.8.3/Sortable.js"></script>
|
||||
<script src="http://sortablejs.github.io/Sortable/Sortable.js"></script>
|
||||
<style>
|
||||
.sortable-ghost {
|
||||
opacity: 0.4;
|
||||
|
@ -1661,24 +1667,26 @@ output:
|
|||
cursor: move;
|
||||
}
|
||||
</style>
|
||||
' . getconstStr('DragSort') . ':
|
||||
<form id="sortdisks_form" action="" method="post" style="margin: 0" onsubmit="return dragsort(this);">
|
||||
<table border=1>
|
||||
<form id="sortdisks_form" action="" method="post" style="margin: 0" onsubmit="return dragsort(this);">
|
||||
<tr id="sortdisks">
|
||||
<input type="hidden" name="disktag_sort" value="">';
|
||||
<tbody id="sortdisks">
|
||||
<input type="hidden" name="disktag_sort" value="">';
|
||||
$num = 0;
|
||||
foreach ($disktags as $disktag) {
|
||||
if ($disktag!='') {
|
||||
$num++;
|
||||
$frame .= '
|
||||
<td>' . $disktag . '</td>';
|
||||
<tr class="sorthandle"><td>' . $num . '</td><td> ' . $disktag . '</td></tr>';
|
||||
}
|
||||
}
|
||||
$frame .= '
|
||||
<input name="_admin" type="hidden" value="">
|
||||
</tr>
|
||||
<tr><td colspan="' . $num . '">' . getconstStr('DragSort') . '<input type="submit" name="submit1" value="' . getconstStr('SubmitSortdisks') . '"></td></tr>
|
||||
</form>
|
||||
</tbody>
|
||||
<input name="_admin" type="hidden" value="">
|
||||
</table>
|
||||
<input type="submit" name="submit1" value="' . getconstStr('SubmitSortdisks') . '">
|
||||
</form>
|
||||
|
||||
<script>
|
||||
var disks=' . json_encode($disktags) . ';
|
||||
function change(arr, oldindex, newindex) {
|
||||
|
@ -1711,7 +1719,8 @@ output:
|
|||
}
|
||||
return true;
|
||||
}
|
||||
Sortable.create(document.getElementById(\'sortdisks\'), {
|
||||
new Sortable(document.getElementById(\'sortdisks\'), {
|
||||
handle: \'.sorthandle\',
|
||||
animation: 150,
|
||||
onEnd: function (evt) { //拖拽完毕之后发生该事件
|
||||
//console.log(evt.oldIndex);
|
||||
|
@ -1724,6 +1733,7 @@ output:
|
|||
});
|
||||
</script><br>';
|
||||
}
|
||||
$Driver_arr = scandir(__DIR__ . $slash . 'disk');
|
||||
$frame .= '
|
||||
<select name="DriveType" onchange="changedrivetype(this.options[this.options.selectedIndex].value)">';
|
||||
foreach ($Driver_arr as $v1) {
|
||||
|
@ -2013,31 +2023,30 @@ output:
|
|||
}
|
||||
$html .= '
|
||||
<style type="text/css">
|
||||
.tabs td { padding: 5px; }
|
||||
.tabs { padding: 10px; white-space: nowrap; overflow-x: auto;}
|
||||
.tabs a { margin:0 10px; }
|
||||
</style>
|
||||
<table border=0>
|
||||
<tr class="tabs">';
|
||||
<div class="tabs">';
|
||||
if ($_GET['disktag']==''||$_GET['disktag']===true||!in_array($_GET['disktag'], $disktags)) {
|
||||
if ($_GET['setup']==='platform') $html .= '
|
||||
<td><a href="?setup">' . getconstStr('Home') . '</a></td>
|
||||
<td>' . getconstStr('PlatformConfig') . '</td>';
|
||||
<a href="?setup">' . getconstStr('Home') . '</a>
|
||||
' . getconstStr('PlatformConfig') . '';
|
||||
else $html .= '
|
||||
<td>' . getconstStr('Home') . '</td>
|
||||
<td><a href="?setup=platform">' . getconstStr('PlatformConfig') . '</a></td>';
|
||||
' . getconstStr('Home') . '
|
||||
<a href="?setup=platform">' . getconstStr('PlatformConfig') . '</a>';
|
||||
} else $html .= '
|
||||
<td><a href="?setup">' . getconstStr('Home') . '</a></td>
|
||||
<td><a href="?setup=platform">' . getconstStr('PlatformConfig') . '</a></td>';
|
||||
<a href="?setup">' . getconstStr('Home') . '</a>
|
||||
<a href="?setup=platform">' . getconstStr('PlatformConfig') . '</a>';
|
||||
foreach ($disktags as $disktag) {
|
||||
if ($disktag!='') {
|
||||
if ($_GET['disktag']===$disktag) $html .= '
|
||||
<td>' . $disktag . '</td>';
|
||||
' . $disktag . '';
|
||||
else $html .= '
|
||||
<td><a href="?setup&disktag=' . $disktag . '">' . $disktag . '</a></td>';
|
||||
<a href="?setup&disktag=' . $disktag . '">' . $disktag . '</a>';
|
||||
}
|
||||
}
|
||||
$html .= '
|
||||
</tr>
|
||||
</table><br>';
|
||||
</div><br>';
|
||||
$html .= $frame;
|
||||
$html .= '<script>
|
||||
var inputAdminStorage = document.getElementsByName("_admin");
|
||||
|
@ -2848,6 +2857,15 @@ function render_list($path = '', $files = [])
|
|||
$tmp = splitfirst($tmp[1], '<!--HeadomfEnd-->');
|
||||
if (isset($files['list']['head.omf'])) {
|
||||
$headomf = str_replace('<!--HeadomfContent-->', get_content(path_format($path . '/' . $files['list']['head.omf']['name']))['content']['body'], $tmp[0]);
|
||||
} elseif (getConfig('globalHeadOmfUrl')) {
|
||||
if (!$headomfcontent = getcache('HeadomfContent')) {
|
||||
$headomfres = curl('GET', getConfig('globalHeadOmfUrl'), '', [], 0, 1);
|
||||
if ($headomfres['stat']==200) {
|
||||
$headomfcontent = $headomfres['body'];
|
||||
savecache('HeadomfContent', $headomfcontent);
|
||||
} else $headomfcontent = $headomfres['stat'];
|
||||
}
|
||||
$headomf = str_replace('<!--HeadomfContent-->', $headomfcontent, $tmp[0]);
|
||||
}
|
||||
$html .= $headomf . $tmp[1];
|
||||
|
||||
|
@ -2861,6 +2879,20 @@ function render_list($path = '', $files = [])
|
|||
$html = str_replace('<!--HeadmdStart-->', '', $html);
|
||||
$html = str_replace('<!--HeadmdEnd-->', '', $html);
|
||||
}
|
||||
} elseif (getConfig('globalHeadMdUrl')) {
|
||||
if (!$headmdcontent = getcache('HeadmdContent')) {
|
||||
$headmdres = curl('GET', getConfig('globalHeadMdUrl'), '', [], 0, 1);
|
||||
if ($headmdres['stat']==200) {
|
||||
$headmdcontent = $headmdres['body'];
|
||||
savecache('HeadmdContent', $headmdcontent);
|
||||
} else $headmdcontent = $headmdres['stat'];
|
||||
}
|
||||
$headmd = str_replace('<!--HeadmdContent-->', $headmdcontent, $tmp[0]);
|
||||
$html .= $headmd . $tmp[1];
|
||||
while (strpos($html, '<!--HeadmdStart-->')) {
|
||||
$html = str_replace('<!--HeadmdStart-->', '', $html);
|
||||
$html = str_replace('<!--HeadmdEnd-->', '', $html);
|
||||
}
|
||||
} else {
|
||||
$html .= $tmp[1];
|
||||
$tmp[1] = 'a';
|
||||
|
@ -2895,6 +2927,20 @@ function render_list($path = '', $files = [])
|
|||
$html = str_replace('<!--ReadmemdStart-->', '', $html);
|
||||
$html = str_replace('<!--ReadmemdEnd-->', '', $html);
|
||||
}
|
||||
} elseif (getConfig('globalReadmeMdUrl')) {
|
||||
if (!$readmemdcontent = getcache('ReadmemdContent')) {
|
||||
$readmemdres = curl('GET', getConfig('globalReadmeMdUrl'), '', [], 0, 1);
|
||||
if ($readmemdres['stat']==200) {
|
||||
$readmemdcontent = $readmemdres['body'];
|
||||
savecache('ReadmemdContent', $readmemdcontent);
|
||||
} else $readmemdcontent = $readmemdres['stat'];
|
||||
}
|
||||
$Readmemd = str_replace('<!--ReadmemdContent-->', $readmemdcontent, $tmp[0]);
|
||||
$html .= $Readmemd . $tmp[1];
|
||||
while (strpos($html, '<!--ReadmemdStart-->')) {
|
||||
$html = str_replace('<!--ReadmemdStart-->', '', $html);
|
||||
$html = str_replace('<!--ReadmemdEnd-->', '', $html);
|
||||
}
|
||||
} else {
|
||||
$html .= $tmp[1];
|
||||
$tmp[1] = 'a';
|
||||
|
@ -2906,12 +2952,21 @@ function render_list($path = '', $files = [])
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$tmp = splitfirst($html, '<!--FootomfStart-->');
|
||||
$html = $tmp[0];
|
||||
$tmp = splitfirst($tmp[1], '<!--FootomfEnd-->');
|
||||
if (isset($files['list']['foot.omf'])) {
|
||||
$Footomf = str_replace('<!--FootomfContent-->', get_content(path_format($path . '/' . $files['list']['foot.omf']['name']))['content']['body'], $tmp[0]);
|
||||
} elseif (getConfig('globalFootOmfUrl')) {
|
||||
if (!$footomfcontent = getcache('FootomfContent')) {
|
||||
$footres = curl('GET', getConfig('globalFootOmfUrl'), '', [], 0, 1);
|
||||
if ($footres['stat']==200) {
|
||||
$footomfcontent = $footres['body'];
|
||||
savecache('FootomfContent', $footomfcontent);
|
||||
} else $footomfcontent = $footres['stat'];
|
||||
}
|
||||
$Footomf = str_replace('<!--FootomfContent-->', $footomfcontent, $tmp[0]);
|
||||
}
|
||||
$html .= $Footomf . $tmp[1];
|
||||
|
||||
|
@ -2919,7 +2974,7 @@ function render_list($path = '', $files = [])
|
|||
$tmp = splitfirst($html, '<!--MdRequireStart-->');
|
||||
$html = $tmp[0];
|
||||
$tmp = splitfirst($tmp[1], '<!--MdRequireEnd-->');
|
||||
if (isset($files['list']['head.md'])||isset($files['list']['readme.md'])) {
|
||||
if (isset($files['list']['head.md'])||isset($files['list']['readme.md'])||getConfig('globalHeadMdUrl')||getConfig('globalReadmeMdUrl')) {
|
||||
$html .= $tmp[0] . $tmp[1];
|
||||
} else $html .= $tmp[1];
|
||||
|
||||
|
|
Loading…
Reference in New Issue