'Pacific/Kwajalein',
'-11'=>'Pacific/Samoa',
'-10'=>'Pacific/Honolulu',
'-9'=>'America/Anchorage',
'-8'=>'America/Los_Angeles',
'-7'=>'America/Denver',
'-6'=>'America/Mexico_City',
'-5'=>'America/New_York',
'-4'=>'America/Caracas',
'-3.5'=>'America/St_Johns',
'-3'=>'America/Argentina/Buenos_Aires',
'-2'=>'America/Noronha',
'-1'=>'Atlantic/Azores',
'0'=>'UTC',
'1'=>'Europe/Paris',
'2'=>'Europe/Helsinki',
'3'=>'Europe/Moscow',
'3.5'=>'Asia/Tehran',
'4'=>'Asia/Baku',
'4.5'=>'Asia/Kabul',
'5'=>'Asia/Karachi',
'5.5'=>'Asia/Calcutta', //Asia/Colombo
'6'=>'Asia/Dhaka',
'6.5'=>'Asia/Rangoon',
'7'=>'Asia/Bangkok',
'8'=>'Asia/Shanghai',
'9'=>'Asia/Tokyo',
'9.5'=>'Australia/Darwin',
'10'=>'Pacific/Guam',
'11'=>'Asia/Magadan',
'12'=>'Asia/Kamchatka'
);
function main($path)
{
global $exts;
global $constStr;
$_SERVER['php_starttime'] = microtime(true);
$path = path_format($path);
if (in_array($_SERVER['firstacceptlanguage'], array_keys($constStr['languages']))) {
$constStr['language'] = $_SERVER['firstacceptlanguage'];
} else {
$prelang = splitfirst($_SERVER['firstacceptlanguage'], '-')[0];
foreach ( array_keys($constStr['languages']) as $lang) {
if ($prelang == splitfirst($lang, '-')[0]) {
$constStr['language'] = $lang;
break;
}
}
}
if (isset($_COOKIE['language'])&&$_COOKIE['language']!='') $constStr['language'] = $_COOKIE['language'];
//if (!$constStr['language']) $constStr['language'] = getConfig('language');
/*echo 'firstacceptlanguage:'.$_SERVER['firstacceptlanguage'].'
'.'lan:'.$constStr['language'];*/
if ($constStr['language']=='') $constStr['language'] = 'en-us';
$_SERVER['language'] = $constStr['language'];
$_SERVER['timezone'] = getConfig('timezone');
if (isset($_COOKIE['timezone'])&&$_COOKIE['timezone']!='') $_SERVER['timezone'] = $_COOKIE['timezone'];
if ($_SERVER['timezone']=='') $_SERVER['timezone'] = 0;
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
if (getConfig('admin')=='') 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 (getConfig('admin')!='') {
if ($_POST['password1']==getConfig('admin')) {
return adminform('admin',md5($_POST['password1']),$url);
} else return adminform();
} else {
return output('', 302, [ 'Location' => $url ]);
}
}
if (getConfig('admin')!='')
if ( isset($_COOKIE['admin'])&&$_COOKIE['admin']==md5(getConfig('admin')) ) {
$_SERVER['admin']=1;
$_SERVER['needUpdate'] = needUpdate();
} else {
$_SERVER['admin']=0;
}
if (isset($_GET['setup']))
if ($_SERVER['admin']) {
// setup Environments. 设置,对环境变量操作
return EnvOpt($_SERVER['needUpdate']);
} else {
$url = path_format($_SERVER['PHP_SELF'] . '/');
return output('', 302, [ 'Location' => $url ]);
}
$_SERVER['base_disk_path'] = $_SERVER['base_path'];
$disktags = explode("|",getConfig('disktag'));
// echo 'count$disk:'.count($disktags);
if (count($disktags)>1) {
if ($path=='/'||$path=='') return output('', 302, [ 'Location' => path_format($_SERVER['base_path'].'/'.$disktags[0].'/') ]);
$_SERVER['disktag'] = splitfirst( substr(path_format($path), 1), '/' )[0];
//$pos = strpos($path, '/');
//if ($pos>1) $_SERVER['disktag'] = substr($path, 0, $pos);
if (!in_array($_SERVER['disktag'], $disktags)) {
$tmp = path_format($_SERVER['base_path'].'/'.$disktags[0].'/'.$path);
return output('Please visit '.$tmp.'.', 302, [ 'Location' => $tmp ]);
//return message('Please visit from Home Page.', 'Error', 404);
}
$path = substr($path, strlen('/'.$_SERVER['disktag']));
if ($_SERVER['disktag']!='') $_SERVER['base_disk_path'] = path_format($_SERVER['base_disk_path']. '/' . $_SERVER['disktag'] . '/');
} else $_SERVER['disktag'] = $disktags[0];
// echo 'main.disktag:'.$_SERVER['disktag'].',path:'.$path.'
//';
$_SERVER['list_path'] = getListpath($_SERVER['HTTP_HOST']);
if ($_SERVER['list_path']=='') $_SERVER['list_path'] = '/';
$_SERVER['is_guestup_path'] = is_guestup_path($path);
$_SERVER['ajax']=0;
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) if ($_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest') $_SERVER['ajax']=1;
config_oauth();
if ($_SERVER['admin']) if (isset($_GET['AddDisk'])||isset($_GET['authorization_code'])) return get_refresh_token();
$refresh_token = getConfig('refresh_token');
//if (!$refresh_token) return get_refresh_token();
if (!$refresh_token) {
return render_list();
} else {
if (!($_SERVER['access_token'] = getcache('access_token'))) {
get_access_token($refresh_token);
}
if ($_SERVER['ajax']) {
if ($_GET['action']=='del_upload_cache') {
// del '.tmp' without login. 无需登录即可删除.tmp后缀文件
error_log('del.tmp:GET,'.json_encode($_GET,JSON_PRETTY_PRINT));
$tmp = splitlast($_GET['filename'], '/');
if ($tmp[1]!='') {
$filename = $tmp[0] . '/.' . $_GET['filelastModified'] . '_' . $_GET['filesize'] . '_' . $tmp[1] . '.tmp';
} else {
$filename = '.' . $_GET['filelastModified'] . '_' . $_GET['filesize'] . '_' . $_GET['filename'] . '.tmp';
}
$filename = path_format( path_format($_SERVER['list_path'] . path_format($path)) . '/' . spurlencode($filename, '/') );
$tmp = MSAPI('DELETE', $filename, '', $_SERVER['access_token']);
$path1 = path_format($_SERVER['list_path'] . path_format($path));
if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
savecache('path_' . $path1, json_decode('{}',true), 1);
return output($tmp['body'],$tmp['stat']);
}
if ($_GET['action']=='uploaded_rename') {
// rename .scfupload file without login.
// 无需登录即可重命名.scfupload后缀文件,filemd5为用户提交,可被构造,问题不大,以后处理
$oldname = spurlencode($_GET['filename']);
$pos = strrpos($oldname, '.');
if ($pos>0) $ext = strtolower(substr($oldname, $pos));
$oldname = path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . $oldname . '.scfupload' );
$data = '{"name":"' . $_GET['filemd5'] . $ext . '"}';
//echo $oldname .'
'. $data;
$tmp = MSAPI('PATCH',$oldname,$data,$_SERVER['access_token']);
if ($tmp['stat']==409) {
MSAPI('DELETE',$oldname,'',$_SERVER['access_token']);
$tmpbody = json_decode($tmp['body'], true);
$tmpbody['name'] = $_GET['filemd5'] . $ext;
$tmp['body'] = json_encode($tmpbody);
}
$path1 = path_format($_SERVER['list_path'] . path_format($path));
if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
savecache('path_' . $path1, json_decode('{}',true), 1);
return output($tmp['body'],$tmp['stat']);
}
if ($_GET['action']=='upbigfile') return bigfileupload($path);
}
if ($_SERVER['admin']) {
$tmp = adminoperate($path);
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, json_decode('{}',true), 1);
return $tmp;
}
} else {
if ($_SERVER['ajax']) return output(getconstStr('RefreshtoLogin'),401);
}
$_SERVER['ishidden'] = passhidden($path);
if (isset($_GET['thumbnails'])) {
if ($_SERVER['ishidden']<4) {
if (in_array(strtolower(substr($path, strrpos($path, '.') + 1)), $exts['img'])) {
return get_thumbnails_url($path);
} else return output(json_encode($exts['img']),400);
} else return output('',401);
}
$files = list_files($path);
//echo json_encode(array_keys($files['children']), JSON_PRETTY_PRINT);
if (isset($_GET['random'])&&$_GET['random']!=='') {
if ($_SERVER['ishidden']<4) {
$tmp = [];
foreach (array_keys($files['children']) as $filename) {
if (strtolower(splitlast($filename,'.')[1])==strtolower($_GET['random'])) $tmp[$filename] = $files['children'][$filename][$_SERVER['DownurlStrName']];
}
$tmp = array_values($tmp);
if (count($tmp)>0) {
if (isset($_GET['url'])) return output($tmp[rand(0,count($tmp)-1)], 200);
return output('', 302, [ 'Location' => $tmp[rand(0,count($tmp)-1)] ]);
} else return output('',404);
} else return output('',401);
}
if (isset($files['file']) && !isset($_GET['preview'])) {
// is file && not preview mode
if ( $_SERVER['ishidden']<4 || (!!getConfig('downloadencrypt')&&$files['name']!=getConfig('passfile')) ) return output('', 302, [ 'Location' => $files[$_SERVER['DownurlStrName']] ]);
}
if ( isset($files['folder']) || isset($files['file']) ) {
return render_list($path, $files);
} else {
if (!isset($files['error'])) {
$files['error']['message'] = json_encode($files, JSON_PRETTY_PRINT);
$files['error']['code'] = 'unknownError';
$files['error']['stat'] = 500;
}
return message(''.getconstStr('Back').getconstStr('Home').'
' . $files['error']['message'] . '
' . json_encode($ispassfile, JSON_PRETTY_PRINT) . ''; if (isset($ispassfile['file'])) { $arr = curl_request($ispassfile[$_SERVER['DownurlStrName']]); if ($arr['stat']==200) { $passwordf=explode("\n",$arr['body']); $password=$passwordf[0]; if ($password!='') $password=md5($password); savecache('path_' . $path1 . '/?password', $password); return $password; } else { //return md5('DefaultP@sswordWhenNetworkError'); return md5( md5(time()).rand(1000,9999) ); } } else { savecache('path_' . $path1 . '/?password', 'null'); if ($path !== '' ) { $path = substr($path,0,strrpos($path,'/')); return gethiddenpass($path,$passfile); } else { return ''; } } } elseif ($password==='null') { if ($path !== '' ) { $path = substr($path,0,strrpos($path,'/')); return gethiddenpass($path,$passfile); } else { return ''; } } else return $password; // return md5('DefaultP@sswordWhenNetworkError'); } function get_timezone($timezone = '8') { global $timezones; if ($timezone=='') $timezone = '8'; return $timezones[$timezone]; } function message($message, $title = 'Message', $statusCode = 200) { return output('
' . $message . '
', $statusCode); } function needUpdate() { $current_ver = file_get_contents(__DIR__ . '/version'); $current_ver = substr($current_ver, strpos($current_ver, '.')+1); $current_ver = explode(urldecode('%0A'),$current_ver)[0]; $current_ver = explode(urldecode('%0D'),$current_ver)[0]; //$github_version = file_get_contents('https://raw.githubusercontent.com/qkqpttgf/OneManager-php/master/version'); $tmp = curl_request('https://raw.githubusercontent.com/qkqpttgf/OneManager-php/master/version'); if ($tmp['stat']==0) return 0; $github_version = $tmp['body']; $github_ver = substr($github_version, strpos($github_version, '.')+1); $github_ver = explode(urldecode('%0A'),$github_ver)[0]; $github_ver = explode(urldecode('%0D'),$github_ver)[0]; if ($current_ver != $github_ver) { $_SERVER['github_version'] = $github_version; return 1; } return 0; } function output($body, $statusCode = 200, $headers = ['Content-Type' => 'text/html'], $isBase64Encoded = false) { return [ 'isBase64Encoded' => $isBase64Encoded, 'statusCode' => $statusCode, 'headers' => $headers, 'body' => $body ]; } function passhidden($path) { $path = str_replace('+','%2B',$path); $path = str_replace('&','&', path_format(urldecode($path))); if (getConfig('passfile') != '') { $path = spurlencode($path,'/'); if (substr($path,-1)=='/') $path=substr($path,0,-1); $hiddenpass=gethiddenpass($path,getConfig('passfile')); if ($hiddenpass != '') { return comppass($hiddenpass); } else { return 1; } } else { return 0; } return 4; } function size_format($byte) { $i = 0; while (abs($byte) >= 1024) { $byte = $byte / 1024; $i++; if ($i == 3) break; } $units = array('B', 'KB', 'MB', 'GB', 'TB'); $ret = round($byte, 2); return ($ret . ' ' . $units[$i]); } function time_format($ISO) { $ISO = str_replace('T', ' ', $ISO); $ISO = str_replace('Z', ' ', $ISO); //return $ISO; return date('Y-m-d H:i:s',strtotime($ISO . " UTC")); } function get_thumbnails_url($path = '/') { $path1 = path_format($path); $path = path_format($_SERVER['list_path'] . path_format($path)); if ($path!='/'&&substr($path,-1)=='/') $path=substr($path,0,-1); $thumb_url = getcache('thumb_'.$path); if ($thumb_url!='') return output($thumb_url); $url = $_SERVER['api_url']; if ($path !== '/') { $url .= ':' . $path; if (substr($url,-1)=='/') $url=substr($url,0,-1); } $url .= ':/thumbnails/0/medium'; $files = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true); if (isset($files['url'])) { savecache('thumb_'.$path, $files['url']); return output($files['url']); } return output('', 404); } function bigfileupload($path) { $path1 = path_format($_SERVER['list_path'] . path_format($path)); if (substr($path1,-1)=='/') $path1=substr($path1,0,-1); if ($_GET['upbigfilename']!=''&&$_GET['filesize']>0) { $tmp = splitlast($_GET['upbigfilename'], '/'); if ($tmp[1]!='') { $fileinfo['name'] = $tmp[1]; $fileinfo['path'] = $tmp[0]; } else { $fileinfo['name'] = $_GET['upbigfilename']; } $fileinfo['size'] = $_GET['filesize']; $fileinfo['lastModified'] = $_GET['lastModified']; $filename = spurlencode($_GET['upbigfilename'],'/'); $cachefilename = spurlencode( $fileinfo['path'] . '/.' . $fileinfo['lastModified'] . '_' . $fileinfo['size'] . '_' . $fileinfo['name'] . '.tmp', '/'); $getoldupinfo=fetch_files(path_format($path . '/' . $cachefilename)); //echo json_encode($getoldupinfo, JSON_PRETTY_PRINT); if (isset($getoldupinfo['file'])&&$getoldupinfo['size']<5120) { $getoldupinfo_j = curl_request($getoldupinfo[$_SERVER['DownurlStrName']]); $getoldupinfo = json_decode($getoldupinfo_j['body'], true); if ( json_decode( curl_request($getoldupinfo['uploadUrl'])['body'], true)['@odata.context']!='' ) return output($getoldupinfo_j['body'], $getoldupinfo_j['stat']); } if (!$_SERVER['admin']) $filename = spurlencode( $fileinfo['name'] ) . '.scfupload'; $response=MSAPI('createUploadSession',path_format($path1 . '/' . $filename),'{"item": { "@microsoft.graph.conflictBehavior": "fail" }}',$_SERVER['access_token']); $responsearry = json_decode($response['body'],true); if (isset($responsearry['error'])) return output($response['body'], $response['stat']); $fileinfo['uploadUrl'] = $responsearry['uploadUrl']; MSAPI('PUT', path_format($path1 . '/' . $cachefilename), json_encode($fileinfo, JSON_PRETTY_PRINT), $_SERVER['access_token'])['body']; return output($response['body'], $response['stat']); } return output('error', 400); } function adminform($name = '', $pass = '', $path = '') { $statusCode = 401; $html = '' . json_encode($arr, JSON_PRETTY_PRINT) . ''; if (isset($files['folder'])) { if ($files['folder']['childCount']>200) { // files num > 200 , then get nextlink $page = $_POST['pagenum']==''?1:$_POST['pagenum']; if ($page>1) $files=fetch_files_children($files, $path1, $page); $files['children'] = children_name($files['children']); /*$url = $_SERVER['api_url']; if ($path !== '/') { $url .= ':' . $path; if (substr($url,-1)=='/') $url=substr($url,0,-1); $url .= ':/children?$top=9999&$select=id,name,size,file,folder,parentReference,lastModifiedDateTime,'.$_SERVER['DownurlStrName']; } else { $url .= '/children?$top=9999&$select=id,name,size,file,folder,parentReference,lastModifiedDateTime,'.$_SERVER['DownurlStrName']; } $children = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true); $files['children'] = $children['value'];*/ } else { // files num < 200 , then cache //if (isset($files['children'])) { $files['children'] = children_name($files['children']); //} savecache('path_' . $path, $files); } } if (isset($files['file'])) { if (in_array(splitlast($files['name'],'.')[1], $exts['txt'])) { if (!(isset($files['content'])&&$files['content']['stat']==200)) { $content1 = curl_request($files[$_SERVER['DownurlStrName']]); $files['content'] = $content1; savecache('path_' . $path, $files); } } } if (isset($files['error'])) { $files['error']['stat'] = $arr['stat']; } } else { //error_log($arr['body']); $files = json_decode($arr['body'], true); if (isset($files['error'])) { $files['error']['stat'] = $arr['stat']; } else { $files['error']['stat'] = 503; $files['error']['code'] = 'unknownError'; $files['error']['message'] = 'unknownError'; } //$files = json_decode( '{"unknownError":{ "stat":'.$arr['stat'].',"message":"'.$arr['body'].'"}}', true); //error_log(json_encode($files, JSON_PRETTY_PRINT)); } } return $files; } function children_name($children) { $tmp = []; foreach ($children as $file) { $tmp[strtolower($file['name'])] = $file; } return $tmp; } function fetch_files_children($files, $path, $page) { $path1 = path_format($path); $path = path_format($_SERVER['list_path'] . path_format($path)); if ($path!='/'&&substr($path,-1)=='/') $path=substr($path,0,-1); $cachefilename = '.SCFcache_'.$_SERVER['function_name']; $maxpage = ceil($files['folder']['childCount']/200); if (!($files['children'] = getcache('files_' . $path . '_page_' . $page))) { // down cache file get jump info. 下载cache文件获取跳页链接 $cachefile = fetch_files(path_format($path1 . '/' .$cachefilename)); if ($cachefile['size']>0) { $pageinfo = curl_request($cachefile[$_SERVER['DownurlStrName']])['body']; $pageinfo = json_decode($pageinfo,true); for ($page4=1;$page4<$maxpage;$page4++) { savecache('nextlink_' . $path . '_page_' . $page4, $pageinfo['nextlink_' . $path . '_page_' . $page4]); $pageinfocache['nextlink_' . $path . '_page_' . $page4] = $pageinfo['nextlink_' . $path . '_page_' . $page4]; } } $pageinfochange=0; for ($page1=$page;$page1>=1;$page1--) { $page3=$page1-1; $url = getcache('nextlink_' . $path . '_page_' . $page3); if ($url == '') { if ($page1==1) { $url = $_SERVER['api_url']; if ($path !== '/') { $url .= ':' . $path; if (substr($url,-1)=='/') $url=substr($url,0,-1); $url .= ':/children?$select=id,name,size,file,folder,parentReference,lastModifiedDateTime,'.$_SERVER['DownurlStrName']; } else { $url .= '/children?$select=id,name,size,file,folder,parentReference,lastModifiedDateTime,'.$_SERVER['DownurlStrName']; } $children = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true); // echo $url . '
' . json_encode($children, JSON_PRETTY_PRINT) . ''; savecache('files_' . $path . '_page_' . $page1, $children['value']); $nextlink=getcache('nextlink_' . $path . '_page_' . $page1); if ($nextlink!=$children['@odata.nextLink']) { savecache('nextlink_' . $path . '_page_' . $page1, $children['@odata.nextLink']); $pageinfocache['nextlink_' . $path . '_page_' . $page1] = $children['@odata.nextLink']; $pageinfocache = clearbehindvalue($path,$page1,$maxpage,$pageinfocache); $pageinfochange = 1; } $url = $children['@odata.nextLink']; for ($page2=$page1+1;$page2<=$page;$page2++) { sleep(1); $children = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true); savecache('files_' . $path . '_page_' . $page2, $children['value']); $nextlink=getcache('nextlink_' . $path . '_page_' . $page2); if ($nextlink!=$children['@odata.nextLink']) { savecache('nextlink_' . $path . '_page_' . $page2, $children['@odata.nextLink']); $pageinfocache['nextlink_' . $path . '_page_' . $page2] = $children['@odata.nextLink']; $pageinfocache = clearbehindvalue($path,$page2,$maxpage,$pageinfocache); $pageinfochange = 1; } $url = $children['@odata.nextLink']; } //echo $url . '
' . json_encode($children, JSON_PRETTY_PRINT) . ''; $files['children'] = $children['value']; $files['folder']['page']=$page; $pageinfocache['filenum'] = $files['folder']['childCount']; $pageinfocache['dirsize'] = $files['size']; $pageinfocache['cachesize'] = $cachefile['size']; $pageinfocache['size'] = $files['size']-$cachefile['size']; if ($pageinfochange == 1) MSAPI('PUT', path_format($path.'/'.$cachefilename), json_encode($pageinfocache, JSON_PRETTY_PRINT), $_SERVER['access_token'])['body']; return $files; } } else { for ($page2=$page3+1;$page2<=$page;$page2++) { sleep(1); $children = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true); savecache('files_' . $path . '_page_' . $page2, $children['value'], 3300); $nextlink=getcache('nextlink_' . $path . '_page_' . $page2); if ($nextlink!=$children['@odata.nextLink']) { savecache('nextlink_' . $path . '_page_' . $page2, $children['@odata.nextLink'], 3300); $pageinfocache['nextlink_' . $path . '_page_' . $page2] = $children['@odata.nextLink']; $pageinfocache = clearbehindvalue($path,$page2,$maxpage,$pageinfocache); $pageinfochange = 1; } $url = $children['@odata.nextLink']; } //echo $url . '
' . json_encode($children, JSON_PRETTY_PRINT) . ''; $files['children'] = $children['value']; $files['folder']['page']=$page; $pageinfocache['filenum'] = $files['folder']['childCount']; $pageinfocache['dirsize'] = $files['size']; $pageinfocache['cachesize'] = $cachefile['size']; $pageinfocache['size'] = $files['size']-$cachefile['size']; if ($pageinfochange == 1) MSAPI('PUT', path_format($path.'/'.$cachefilename), json_encode($pageinfocache, JSON_PRETTY_PRINT), $_SERVER['access_token'])['body']; return $files; } } } else { $files['folder']['page']=$page; for ($page4=1;$page4<=$maxpage;$page4++) { if (!($url = getcache('nextlink_' . $path . '_page_' . $page4))) { if ($files['folder'][$path.'_'.$page4]!='') savecache('nextlink_' . $path . '_page_' . $page4, $files['folder'][$path.'_'.$page4]); } else { $files['folder'][$path.'_'.$page4] = $url; } } } return $files; } function get_refresh_token() { global $constStr; global $CommonEnv; $envs = ''; foreach ($CommonEnv as $env) $envs .= '\'' . $env . '\', '; $url = path_format($_SERVER['PHP_SELF'] . '/'); if (isset($_GET['authorization_code']) && isset($_GET['code'])) { $_SERVER['disktag'] = $_COOKIE['disktag']; config_oauth(); $tmp = curl_request($_SERVER['oauth_url'] . 'token', 'client_id=' . $_SERVER['client_id'] .'&client_secret=' . $_SERVER['client_secret'] . '&grant_type=authorization_code&requested_token_use=on_behalf_of&redirect_uri=' . $_SERVER['redirect_uri'] .'&code=' . $_GET['code']); if ($tmp['stat']==200) $ret = json_decode($tmp['body'], true); if (isset($ret['refresh_token'])) { $refresh_token = $ret['refresh_token']; $str = ' refresh_token :
' . json_encode(json_decode($tmp['body']), JSON_PRETTY_PRINT) . '', $tmp['stat']); //return message('
' . json_encode($ret, JSON_PRETTY_PRINT) . '', 500); } if (isset($_GET['install1'])) { $_SERVER['disktag'] = $_COOKIE['disktag']; config_oauth(); if (getConfig('Drive_ver')=='MS' || getConfig('Drive_ver')=='CN') { return message(' '.getconstStr('JumptoOffice').' ', getconstStr('Wait').' 1s', 201); } else { return message('Something error, retry after a few seconds.', 'retry', 201); } } if (isset($_GET['install0'])) { if ($_POST['disktag_add']!='') { if (in_array($_COOKIE['disktag'], $CommonEnv)) { return message('Do not input ' . $envs . '
'.json_encode($files, JSON_PRETTY_PRINT).'' . $html; $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } while (strpos($html, '')) { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } while (strpos($html, '')) { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } } if ($_SERVER['admin']) { $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } while (strpos($html, '')) { $html = str_replace('', '', $html); $html = str_replace('', '', $html); } while (strpos($html, '')) $html = str_replace('', getconstStr('Operate'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Create'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Encrypt'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('RefreshCache'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Setup'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Logout'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Rename'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Submit'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Delete'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Copy'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Move'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Folder'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('File'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Name'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Content'), $html); } else { $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } if (getConfig('adminloginpage')=='') { while (strpos($html, '')) $html = str_replace('', '', $html); while (strpos($html, '')) $html = str_replace('', '', $html); } else { $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } } while (strpos($html, '')) $html = str_replace('', '', $html); while (strpos($html, '')) $html = str_replace('', '', $html); } if ($_SERVER['is_guestup_path']&&!$_SERVER['admin']) { $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } while (strpos($html, '')) { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } while (strpos($html, '')) { $html = str_replace('', '', $html); $html = str_replace('', '', $html); } } if ($_SERVER['is_guestup_path']||( $_SERVER['admin']&&isset($files['folder'])&&$_SERVER['ishidden']<4 )) { while (strpos($html, '')) { $html = str_replace('', '', $html); $html = str_replace('', '', $html); } } else { $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } } if ($_SERVER['ishidden']==4) { $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } /*$tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; }*/ $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } while (strpos($html, '')) { $html = str_replace('', '', $html); $html = str_replace('', '', $html); } $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } } if (isset($files['children'])) { while (strpos($html, '')) { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } while (strpos($html, '')) { $html = str_replace('', '', $html); $html = str_replace('', '', $html); } $html = str_replace('', getconstStr('File'), $html); $html = str_replace('', getconstStr('ShowThumbnails'), $html); $html = str_replace('', getconstStr('CopyAllDownloadUrl'), $html); $html = str_replace('', getconstStr('EditTime'), $html); $html = str_replace('', getconstStr('Size'), $html); $filenum = 0; $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $FolderList = $tmp[0]; foreach ($files['children'] as $file) { if (isset($file['folder'])) { if ($_SERVER['admin'] or !isHideFile($file['name'])) { $filenum++; $FolderListStr = str_replace('', path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . encode_str_replace($file['name'])), $FolderList); $FolderListStr = str_replace('', str_replace('&','&', $file['name']), $FolderListStr); $FolderListStr = str_replace('', time_format($file['lastModifiedDateTime']), $FolderListStr); $FolderListStr = str_replace('', size_format($file['size']), $FolderListStr); while (strpos($FolderListStr, '')) $FolderListStr = str_replace('', $filenum, $FolderListStr); $html .= $FolderListStr; } } } $html .= $tmp[1]; $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $FolderList = $tmp[0]; foreach ($files['children'] as $file) { if (isset($file['file'])) { if ($_SERVER['admin'] or !isHideFile($file['name'])) { $filenum++; $ext = strtolower(substr($file['name'], strrpos($file['name'], '.') + 1)); $FolderListStr = str_replace('', path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . encode_str_replace($file['name'])), $FolderList); $FolderListStr = str_replace('', str_replace('&','&', $file['name']), $FolderListStr); //$FolderListStr = str_replace('', path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . str_replace('&','&', $file['name'])), $FolderListStr); $FolderListStr = str_replace('', time_format($file['lastModifiedDateTime']), $FolderListStr); $FolderListStr = str_replace('', size_format($file['size']), $FolderListStr); foreach ($IconValues as $key1 => $value1) { if (isset($exts[$key1])&&in_array($ext, $exts[$key1])) { $FolderListStr = str_replace('', $value1, $FolderListStr); } if ($ext==$key1) { $FolderListStr = str_replace('', $value1, $FolderListStr); } //error_log('file:'.$file['name'].':'.$key1); if (!strpos($FolderListStr, '')) break; } if (strpos($FolderListStr, '')) $FolderListStr = str_replace('', $IconValues['default'], $FolderListStr); while (strpos($FolderListStr, '')) $FolderListStr = str_replace('', $filenum, $FolderListStr); $html .= $FolderListStr; } } } $html .= $tmp[1]; while (strpos($html, '')) $html = str_replace('', $filenum, $html); if ($files['folder']['childCount']>200) { while (strpos($html, '')) $html = str_replace('', '', $html); while (strpos($html, '')) $html = str_replace('', '', $html); $pagenum = $files['folder']['page']; if ($pagenum=='') $pagenum = 1; $maxpage = ceil($files['folder']['childCount']/200); if ($pagenum!=1) { $html = str_replace('', '', $html); $html = str_replace('', '', $html); $html = str_replace('', getconstStr('PrePage'), $html); $html = str_replace('', $pagenum-1, $html); } else { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } //$html .= json_encode($files['folder']); if ($pagenum!=$maxpage) { $html = str_replace('', '', $html); $html = str_replace('', '', $html); $html = str_replace('', getconstStr('NextPage'), $html); $html = str_replace('', $pagenum+1, $html); } else { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $MorePageListNow = str_replace('', $pagenum, $tmp[0]); $html .= $tmp[1]; $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $MorePageList = $tmp[0]; for ($page=1;$page<=$maxpage;$page++) { if ($page == $pagenum) { $MorePageListStr = $MorePageListNow; } else { $MorePageListStr = str_replace('', $page, $MorePageList); $MorePageListStr = str_replace('', $page, $MorePageListStr); } $html .= $MorePageListStr; } $html .= $tmp[1]; } else { while (strpos($html, '')) { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } } } elseif (isset($files['file'])) { while (strpos($html, '')) { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } while (strpos($html, '')) { $html = str_replace('', '', $html); $html = str_replace('', '', $html); } $html = str_replace('', str_replace('%2523', '%23', str_replace('%26amp%3B','&',spurlencode(path_format($_SERVER['base_disk_path'] . '/' . $path), '/'))), $html); $html = str_replace('', path_format($_SERVER['base_disk_path'] . '/' . $path), $html); $html = str_replace('', getconstStr('Download'), $html); $ext = strtolower(substr($path, strrpos($path, '.') + 1)); if (in_array($ext, $exts['img'])) $ext = 'img'; elseif (in_array($ext, $exts['video'])) $ext = 'video'; elseif (in_array($ext, $exts['music'])) $ext = 'music'; //elseif (in_array($ext, $exts['pdf'])) $ext = 'pdf'; elseif ($ext=='pdf') $ext = 'pdf'; elseif (in_array($ext, $exts['office'])) $ext = 'office'; elseif (in_array($ext, $exts['txt'])) $ext = 'txt'; else $ext = 'Other'; $previewext = ['img', 'video', 'music', 'pdf', 'office', 'txt', 'Other']; $previewext = array_diff($previewext, [ $ext ]); foreach ($previewext as $ext1) { $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } } while (strpos($html, '')) { $html = str_replace('', '', $html); $html = str_replace('', '', $html); } //while (strpos($html, '')) $html = str_replace('', $files[$_SERVER['DownurlStrName']], $html); while (strpos($html, '')) $html = str_replace('', path_format($_SERVER['base_disk_path'] . '/' . $path), $html); while (strpos($html, '')) $html = str_replace('', path_format($_SERVER['base_disk_path'] . '/' . $path), $html); while (strpos($html, '')) $html = str_replace('', $files['name'], $html); $html = str_replace('', urlencode($files[$_SERVER['DownurlStrName']]), $html); $html = str_replace('', getconstStr('ClicktoEdit'), $html); $html = str_replace('', getconstStr('CancelEdit'), $html); $html = str_replace('', getconstStr('Save'), $html); while (strpos($html, '')) $html = str_replace('', htmlspecialchars(curl_request($files[$_SERVER['DownurlStrName']])['body']), $html); $html = str_replace('', getconstStr('FileNotSupport'), $html); //$html = str_replace('', getconstStr('File'), $html); } $html = str_replace('', $constStr['language'], $html); $title = $pretitle; if ($_SERVER['base_disk_path']!=$_SERVER['base_path']) { if (getConfig('diskname')!='') $diskname = getConfig('diskname'); else $diskname = $_SERVER['disktag']; $title .= ' - ' . $diskname; } $title .= ' - ' . $_SERVER['sitename']; $html = str_replace('', $title, $html); $keywords = $n_path; if ($p_path!='') $keywords .= ', ' . $p_path; if ($_SERVER['sitename']!='OneManager') $keywords .= ', ' . $_SERVER['sitename'] . ', OneManager'; else $keywords .= ', OneManager'; $html = str_replace('', $keywords, $html); if ($_GET['preview']) { $description = $n_path.', '.getconstStr('Preview');//'Preview of '. } elseif (isset($files['folder'])) { $description = $n_path.', '.getconstStr('List');//'List of '.$n_path.'. '; } //$description .= 'In '.$_SERVER['sitename']; $html = str_replace('', $description, $html); while (strpos($html, '')) $html = str_replace('', $_SERVER['base_disk_path'], $html); while (strpos($html, '')) $html = str_replace('', $_SERVER['base_path'], $html); while (strpos($html, '')) $html = str_replace('', str_replace('%23', '#', str_replace('&','&', $path)), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Home'), $html); $html = str_replace('', getConfig('customCss'), $html); $html = str_replace('', getConfig('customScript'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Login'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Close'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('InputPassword'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('InputPasswordUWant'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Submit'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Success'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('GetUploadLink'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('UpFileTooLarge'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('UploadStart'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('UploadStartAt'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('LastUpload'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('ThisTime'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Upload'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('AverageSpeed'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('CurrentSpeed'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Expect'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('UploadErrorUpAgain'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('EndAt'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('UploadComplete'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('CopyUrl'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('UploadFail23'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('GetFileNameFail'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('UploadFile'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('UploadFolder'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('FileSelected'), $html); while (strpos($html, '')) $html = str_replace('', (isset($_GET['preview'])?'?preview&':'?'), $html); $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); if (getConfig('background')) { $background = str_replace('', getConfig('background'), $tmp[0]); } $html .= $background . $tmp[1]; $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $SelectLanguage = $tmp[0]; foreach ($constStr['languages'] as $key1 => $value1) { $SelectLanguageStr = str_replace('', $key1, $SelectLanguage); $SelectLanguageStr = str_replace('', $value1, $SelectLanguageStr); $SelectLanguageStr = str_replace('', ($key1==$constStr['language']?'selected="selected"':''), $SelectLanguageStr); $html .= $SelectLanguageStr; } $html .= $tmp[1]; $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $NeedUpdateStr = $tmp[0]; if (isset($_SERVER['needUpdate'])&&$_SERVER['needUpdate']) $NeedUpdateStr = str_replace('', getconstStr('NeedUpdate'), $NeedUpdateStr); else $NeedUpdateStr =''; $html .= $NeedUpdateStr . $tmp[1]; $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); if ($path !== '/') { $current_url = $_SERVER['PHP_SELF']; while (substr($current_url, -1) === '/') { $current_url = substr($current_url, 0, -1); } if (strpos($current_url, '/') !== FALSE) { $parent_url = substr($current_url, 0, strrpos($current_url, '/')); } else { $parent_url = $current_url; } $BackArrow = str_replace('', $parent_url.'/', $tmp[0]); } $html .= $BackArrow . $tmp[1]; $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); if (!(isset($_SERVER['USER'])&&$_SERVER['USER']=='qcloud')) { $html .= str_replace('', getconstStr('OriginalPic'), $tmp[0]) . $tmp[1]; } else $html .= $tmp[1]; } $imgextstr = ''; foreach ($exts['img'] as $imgext) $imgextstr .= '\''.$imgext.'\', '; $html = str_replace('', $imgextstr, $html); $html = str_replace('', $_SERVER['sitename'], $html); $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $disktags = explode("|",getConfig('disktag')); if (count($disktags)>1) { $tmp1 = $tmp[1]; $tmp = splitfirst($tmp[0], ''); $MultiDiskArea = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $MultiDisks = $tmp[0]; foreach ($disktags as $disk) { $diskname = getConfig('diskname', $disk); if ($diskname=='') $diskname = $disk; $MultiDisksStr = str_replace('', path_format($_SERVER['base_path'].'/'.$disk.'/'), $MultiDisks); $MultiDisksStr = str_replace('', ($_SERVER['disktag']==$disk?' now':''), $MultiDisksStr); $MultiDisksStr = str_replace('', $diskname, $MultiDisksStr); $MultiDiskArea .= $MultiDisksStr; } $MultiDiskArea .= $tmp[1]; $tmp[1] = $tmp1; } $html .= $MultiDiskArea . $tmp[1]; $diskname = getConfig('diskname'); if ($diskname=='') $diskname = $_SERVER['disktag']; if (strlen($diskname)>10) $diskname = substr($diskname, 0, 7).'...'; while (strpos($html, '')) $html = str_replace('', $diskname, $html); $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); if (isset($files['children']['head.omf'])) { $headomf = str_replace('', fetch_files(spurlencode(path_format(urldecode($path) . '/head.omf'),'/'))['content']['body'], $tmp[0]); } $html .= $headomf . $tmp[1]; $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); if (isset($files['children']['head.md'])) { $headmd = str_replace('', fetch_files(spurlencode(path_format(urldecode($path) . '/head.md'),'/'))['content']['body'], $tmp[0]); $html .= $headmd . $tmp[1]; while (strpos($html, '')) { $html = str_replace('', '', $html); $html = str_replace('', '', $html); } } else { $html .= $tmp[1]; $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } } $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html_aft = $tmp[1]; if ($files) { $listarea = $tmp[0]; } $html .= $listarea . $html_aft; } $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); if (isset($files['children']['readme.md'])) { $Readmemd = str_replace('', fetch_files(spurlencode(path_format(urldecode($path) . '/readme.md'),'/'))['content']['body'], $tmp[0]); $html .= $Readmemd . $tmp[1]; while (strpos($html, '')) { $html = str_replace('', '', $html); $html = str_replace('', '', $html); } } else { $html .= $tmp[1]; $tmp[1] = 'a'; while ($tmp[1]!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } } $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); if (isset($files['children']['foot.omf'])) { $Footomf = str_replace('', fetch_files(spurlencode(path_format(urldecode($path) . '/foot.omf'),'/'))['content']['body'], $tmp[0]); } $html .= $Footomf . $tmp[1]; $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); if (isset($files['children']['head.md'])||isset($files['children']['readme.md'])) { $html .= $tmp[0] . $tmp[1]; } else $html .= $tmp[1]; if (getConfig('passfile')!='') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= str_replace('', getconstStr('Encrypt'), $tmp[0]) . $tmp[1]; $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } else { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= str_replace('', getconstStr('SetpassfileBfEncrypt'), $tmp[0]) . $tmp[1]; $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); if ($path != '/') { $html .= str_replace('', getconstStr('ParentDir'), $tmp[0]) . $tmp[1]; } else $html .= $tmp[1]; $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $MoveDirs = $tmp[0]; if (isset($files['children'])) { foreach ($files['children'] as $file) { if (isset($file['folder'])) { $MoveDirsStr = str_replace('', str_replace('&','&', $file['name']), $MoveDirs); $MoveDirsStr = str_replace('', str_replace('&','&', $file['name']), $MoveDirsStr); $html .= $MoveDirsStr; } } } $html .= $tmp[1]; $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); if (!isset($_COOKIE['timezone'])) $html .= str_replace('', $_SERVER['timezone'], $tmp[0]); $html .= $tmp[1]; while (strpos($html, '')) $html = str_replace('', $_SERVER['timezone'], $html); // 最后清除换行 while (strpos($html, "\r\n\r\n")) $html = str_replace("\r\n\r\n", "\r\n", $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); $html = str_replace('', date("Y-m-d H:i:s")." ".getconstStr('Week')[date("w")]." ".$_SERVER['REMOTE_ADDR'].' Runtime:'.$exetime.'s Mem:'.size_format(memory_get_usage()), $html); } $html = $authinfo . $html; if (isset($_SERVER['Set-Cookie'])) return output($html, $statusCode, [ 'Set-Cookie' => $_SERVER['Set-Cookie'], 'Content-Type' => 'text/html' ]); return output($html,$statusCode); }