diff --git a/common.php b/common.php
new file mode 100644
index 0000000..7f3bb59
--- /dev/null
+++ b/common.php
@@ -0,0 +1,1664 @@
+ $url ]);
+ }
+ }
+ if (getConfig('admin')!='')
+ if ( (isset($_COOKIE['admin'])&&$_COOKIE['admin']==md5(getConfig('admin'))) || (isset($_POST['password1'])&&$_POST['password1']==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'] = $path;
+ $pos = strpos($path, '/');
+ if ($pos>1) $_SERVER['disktag'] = substr($path, 0, $pos);
+ if (!in_array($_SERVER['disktag'], $disktags)) 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'&&substr($_GET['filename'],-4)=='.tmp') {
+ // del '.tmp' without login. 无需登录即可删除.tmp后缀文件
+ error_log('del.tmp:GET,'.json_encode($_GET,JSON_PRETTY_PRINT));
+ $tmp = MSAPI('DELETE',path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . spurlencode($_GET['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'] . '
'.getconstStr('Back').'', $files['error']['code'], $files['error']['stat']);
+ }
+ }
+}
+
+function get_access_token($refresh_token)
+{
+ if (getConfig('Drive_ver')=='shareurl') {
+
+//if (!$files) $files['body'] = $arr['body'];
+ //$files['returnhead'] = $arr['returnhead'];
+ //$files['cookie'] = $arr['returnhead']['Set-Cookie'];
+//return $files;
+
+ /*$files['get'] = curl_request(
+ "https://mfedu-my.sharepoint.com/personal/ysun_ac_stu_office_gy/_api/web/GetListUsingPath(DecodedUrl=@a1)/RenderListDataAsStream?@a1='%2Fpersonal%2Fysun_ac_stu_office_gy%2FDocuments'&RootFolder=%2Fpersonal%2Fysun_ac_stu_office_gy%2FDocuments%2F&TryNewExperienceSingle=TRUE",
+ '{"parameters":{"__metadata":{"type":"SP.RenderListDataParameters"},"RenderOptions":136967,"AllowMultipleValueFilterForTaxonomyFields":true,"AddRequiredFields":true}}',
+ ['Accept' => 'application/json;odata=verbose', 'Content-Type' => 'application/json;odata=verbose', 'origin' => 'https://mfedu-my.sharepoint.com', 'Cookie' => $arr['returnhead']['Set-Cookie']],
+ 1);
+ $files['get']['body'] = json_decode($files['get']['body'], true);
+ $_SERVER['access_token'] = splitlast($files['get']['body']['ListSchema']['.driveAccessToken'],'=')[1];
+ $_SERVER['api_url'] = $files['get']['body']['ListSchema']['.driveUrl'].'/root';
+
+ $files = json_decode( curl_request( $_SERVER['api_url'].'?expand=children(select=name,size,file,folder,parentReference,lastModifiedDateTime,@microsoft.graph.downloadUrl,@content.downloadUrl)', false, ['Authorization' => 'Bearer ' . $_SERVER['access_token'], 'Accept' => 'application/json'] )['body'], true);
+ $files['children']['a']['file'] = $_SERVER['api_url'];
+ $files['children']['a']['name'] = $_SERVER['api_url'];
+*/
+ $shareurl = getConfig('shareurl');
+ //$url = 'https://mfedu-my.sharepoint.com/:f:/g/personal/ysun_ac_stu_office_gy/EpDIBOaYyExHjfu-PJA46icB40X0FKVwmn_9UDJsRvu3Ug?e=XyRZxP';
+ //$url = 'https://2d2-my.sharepoint.com/:f:/g/personal/ysun_host_ac_cn/Ehy8pjSQSoZOtLDs4ZKPiGUBYFt26CjEwG6bw7W5vleNNQ?e=DLZcWF';
+ $tmp1 = splitlast($shareurl, '/')[0];
+ $account = splitlast($tmp1, '/')[1];
+ $tmp1 = splitlast($shareurl, ':')[0];
+ $domain = splitlast($tmp1, '/')[0];
+ if (!isset($_SERVER['sharecookie'])||$_SERVER['sharecookie']=='') $_SERVER['sharecookie'] = curl_request($shareurl,false, [],1)['returnhead']['Set-Cookie'];
+ $response = curl_request(
+ $domain . "/personal/" . $account . "/_api/web/GetListUsingPath(DecodedUrl=@a1)/RenderListDataAsStream?@a1='" . urlencode("/personal/" . $account . "/Documents") . "'&RootFolder=" . urlencode("/personal/" . $account . "/Documents/") . "&TryNewExperienceSingle=TRUE",
+ '{"parameters":{"__metadata":{"type":"SP.RenderListDataParameters"},"RenderOptions":136967,"AllowMultipleValueFilterForTaxonomyFields":true,"AddRequiredFields":true}}',
+ [ 'Accept' => 'application/json;odata=verbose', 'Content-Type' => 'application/json;odata=verbose', 'origin' => $domain, 'Cookie' => $_SERVER['sharecookie'] ]
+ );
+ if ($response['stat']==200) $ret = json_decode($response['body'], true);
+ $_SERVER['access_token'] = splitlast($ret['ListSchema']['.driveAccessToken'],'=')[1];
+ $_SERVER['api_url'] = $ret['ListSchema']['.driveUrl'].'/root';
+ if (!$_SERVER['access_token']) {
+ error_log($domain . "/personal/" . $account . "/_api/web/GetListUsingPath(DecodedUrl=@a1)/RenderListDataAsStream?@a1='" . urlencode("/personal/" . $account . "/Documents") . "'&RootFolder=" . urlencode("/personal/" . $account . "/Documents/") . "&TryNewExperienceSingle=TRUE");
+ error_log('failed to get access_token. response' . json_encode($ret));
+ throw new Exception($response['stat'].', failed to get access_token.'.$response['body']);
+ }
+ error_log('Get access token:'.json_encode($ret, JSON_PRETTY_PRINT));
+ savecache('access_token', $_SERVER['access_token']);
+ if (getConfig('sharecookie')==''||getConfig('shareapiurl')=='') setConfig([ 'sharecookie' => $_SERVER['sharecookie'], 'shareapiurl' => $_SERVER['api_url'] ]);
+ } else {
+ $response = curl_request( $_SERVER['oauth_url'] . 'token', 'client_id='. $_SERVER['client_id'] .'&client_secret='. $_SERVER['client_secret'] .'&grant_type=refresh_token&requested_token_use=on_behalf_of&refresh_token=' . $refresh_token );
+ if ($response['stat']==200) $ret = json_decode($response['body'], true);
+ if (!isset($ret['access_token'])) {
+ error_log($_SERVER['oauth_url'] . 'token'.'?client_id='. $_SERVER['client_id'] .'&client_secret='. $_SERVER['client_secret'] .'&grant_type=refresh_token&requested_token_use=on_behalf_of&refresh_token=' . $refresh_token);
+ error_log('failed to get access_token. response' . json_encode($ret));
+ throw new Exception($response['stat'].', failed to get access_token.'.$response['body']);
+ }
+ error_log('Get access token:'.json_encode($ret, JSON_PRETTY_PRINT));
+ $_SERVER['access_token'] = $ret['access_token'];
+ savecache('access_token', $_SERVER['access_token'], $ret['expires_in'] - 300);
+ if (time()>getConfig('token_expires')) setConfig([ 'refresh_token' => $ret['refresh_token'], 'token_expires' => time()+7*24*60*60 ]);
+ }
+}
+
+function list_files($path)
+{
+ $path = path_format($path);
+ if ($_SERVER['is_guestup_path']&&!$_SERVER['admin']) {
+ $files = json_decode('{"folder":{}}', true);
+ } elseif (!getConfig('downloadencrypt')) {
+ if ($_SERVER['ishidden']==4) $files = json_decode('{"folder":{}}', true);
+ else $files = fetch_files($path);
+ } else {
+ $files = fetch_files($path);
+ }
+ return $files;
+}
+
+function isHideFile($name)
+{
+ $FunctionalityFile = [
+ 'head.md',
+ 'readme.md',
+ 'favicon.ico',
+ ];
+
+ if ($name == getConfig('passfile')) return true;
+ if (substr($name,0,1) == '.') return true;
+ if (getConfig('hideFunctionalityFile')) if (in_array(strtolower($name), $FunctionalityFile)) return true;
+ return false;
+}
+
+function getcache($str)
+{
+ //$cache = null;
+ $cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']);
+ return $cache->fetch($str);
+}
+
+function savecache($key, $value, $exp = 1800)
+{
+ //$cache = null;
+ $cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']);
+ $cache->save($key, $value, $exp);
+}
+
+function getconstStr($str)
+{
+ global $constStr;
+ if ($constStr[$str][$constStr['language']]!='') return $constStr[$str][$constStr['language']];
+ return $constStr[$str]['en-us'];
+}
+
+function config_oauth()
+{
+ $_SERVER['sitename'] = getConfig('sitename');
+ if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = getconstStr('defaultSitename');
+ $_SERVER['redirect_uri'] = 'https://scfonedrive.github.io';
+ if (getConfig('Drive_ver')=='shareurl') {
+ $_SERVER['api_url'] = getConfig('shareapiurl');
+ $_SERVER['sharecookie'] = getConfig('sharecookie');
+ $_SERVER['DownurlStrName'] = '@content.downloadUrl';
+ return 0;
+ }
+ if (getConfig('Drive_ver')=='MS') {
+ // MS
+ // https://portal.azure.com
+ //$_SERVER['client_id'] = '4da3e7f2-bf6d-467c-aaf0-578078f0bf7c';
+ //$_SERVER['client_secret'] = '7/+ykq2xkfx:.DWjacuIRojIaaWL0QI6';
+ $_SERVER['client_id'] = '734ef928-d74c-4555-8d1b-d942fa0a1a41';
+ $_SERVER['client_secret'] = ':EK[e0/4vQ@mQgma8LmnWb6j4_C1CSIW';
+ $_SERVER['oauth_url'] = 'https://login.microsoftonline.com/common/oauth2/v2.0/';
+ $_SERVER['api_url'] = 'https://graph.microsoft.com/v1.0/me/drive/root';
+ $_SERVER['scope'] = 'https://graph.microsoft.com/Files.ReadWrite.All offline_access';
+ if (getConfig('usesharepoint')=='on') $_SERVER['api_url'] = 'https://graph.microsoft.com/v1.0/sites/' . getConfig('siteid') . '/drive/root';
+ }
+ if (getConfig('Drive_ver')=='CN') {
+ // CN
+ // https://portal.azure.cn
+ $_SERVER['client_id'] = '04c3ca0b-8d07-4773-85ad-98b037d25631';
+ $_SERVER['client_secret'] = 'h8@B7kFVOmj0+8HKBWeNTgl@pU/z4yLB';
+ $_SERVER['oauth_url'] = 'https://login.partner.microsoftonline.cn/common/oauth2/v2.0/';
+ $_SERVER['api_url'] = 'https://microsoftgraph.chinacloudapi.cn/v1.0/me/drive/root';
+ $_SERVER['scope'] = 'https://microsoftgraph.chinacloudapi.cn/Files.ReadWrite.All offline_access';
+ if (getConfig('usesharepoint')=='on') $_SERVER['api_url'] = 'https://microsoftgraph.chinacloudapi.cn/v1.0/sites/' . getConfig('siteid') . '/drive/root';
+ }
+
+ if (getConfig('Drive_custom')=='on') {
+ // Customer
+ $_SERVER['client_id'] = getConfig('client_id');
+ $_SERVER['client_secret'] = getConfig('client_secret');
+ }
+ $_SERVER['client_secret'] = urlencode($_SERVER['client_secret']);
+ $_SERVER['scope'] = urlencode($_SERVER['scope']);
+ $_SERVER['DownurlStrName'] = '@microsoft.graph.downloadUrl';
+}
+
+function get_siteid($access_token)
+{
+ if (getConfig('Drive_ver')=='MS') $url = 'https://graph.microsoft.com/v1.0/sites/root:/sites/'.getConfig('sharepointname');
+ if (getConfig('Drive_ver')=='CN') $url = 'https://microsoftgraph.chinacloudapi.cn/v1.0/sites/root:/sites/'.getConfig('sharepointname');
+ $i=0;
+ $response = [];
+ while ($url!=''&&$response['stat']!=200&&$i<4) {
+ $response = curl_request($url, false, ['Authorization' => 'Bearer ' . $access_token]);
+ $i++;
+ //echo 'https://graph.microsoft.com/v1.0/sites/root:/sites/'.getConfig('sharepointname').$response['stat'].$response['body'].'
+ //';
+ }
+ if ($response['stat']!=200) {
+ error_log('failed to get siteid. response' . json_encode($response));
+ throw new Exception($response['stat'].', failed to get siteid.'.$response['body']);
+ }
+ return json_decode($response['body'],true)['id'];
+}
+
+function getListpath($domain)
+{
+ $domain_path1 = getConfig('domain_path');
+ $public_path = getConfig('public_path');
+ $tmp_path='';
+ if ($domain_path1!='') {
+ $tmp = explode("|",$domain_path1);
+ foreach ($tmp as $multidomain_paths){
+ $pos = strpos($multidomain_paths,":");
+ if ($pos>0) {
+ $domain1 = substr($multidomain_paths,0,$pos);
+ $tmp_path = path_format(substr($multidomain_paths,$pos+1));
+ $domain_path[$domain1] = $tmp_path;
+ if ($public_path=='') $public_path = $tmp_path;
+ //if (substr($multidomain_paths,0,$pos)==$host_name) $private_path=$tmp_path;
+ }
+ }
+ }
+ if (isset($domain_path[$domain])) return spurlencode($domain_path[$domain],'/');
+ return spurlencode($public_path,'/');
+}
+
+function path_format($path)
+{
+ $path = '/' . $path;
+ while (strpos($path, '//') !== FALSE) {
+ $path = str_replace('//', '/', $path);
+ }
+ return $path;
+}
+
+function spurlencode($str,$split='')
+{
+ $str = str_replace(' ', '%20',$str);
+ $tmp='';
+ if ($split!='') {
+ $tmparr=explode($split,$str);
+ for($x=0;$x $headerVal) {
+ $sendHeaders[] = $headerName . ': ' . $headerVal;
+ }
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ if ($data !== false) {
+ curl_setopt($ch, CURLOPT_POST, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+ }
+ curl_setopt($ch, CURLOPT_TIMEOUT, 5);
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_HEADER, $returnheader);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $sendHeaders);
+ //$response['body'] = curl_exec($ch);
+ if ($returnheader) {
+ list($returnhead, $response['body']) = explode("\r\n\r\n", curl_exec($ch));
+ foreach (explode("\r\n", $returnhead) as $head) {
+ $tmp = explode(': ', $head);
+ $heads[$tmp[0]] = $tmp[1];
+ }
+ $response['returnhead'] = $heads;
+ } else {
+ $response['body'] = curl_exec($ch);
+ }
+ $response['stat'] = curl_getinfo($ch,CURLINFO_HTTP_CODE);
+ curl_close($ch);
+ return $response;
+}
+
+function clearbehindvalue($path,$page1,$maxpage,$pageinfocache)
+{
+ for ($page=$page1+1;$page<$maxpage;$page++) {
+ $pageinfocache['nextlink_' . $path . '_page_' . $page] = '';
+ }
+ $pageinfocache = array_filter($pageinfocache, 'array_value_isnot_null');
+ return $pageinfocache;
+}
+
+function comppass($pass)
+{
+ if ($_POST['password1'] !== '') if (md5($_POST['password1']) === $pass ) {
+ date_default_timezone_set('UTC');
+ $_SERVER['Set-Cookie'] = 'password='.$pass.'; expires='.date(DATE_COOKIE,strtotime('+1hour'));
+ date_default_timezone_set(get_timezone($_COOKIE['timezone']));
+ return 2;
+ }
+ if ($_COOKIE['password'] !== '') if ($_COOKIE['password'] === $pass ) return 3;
+ return 4;
+}
+
+function encode_str_replace($str)
+{
+ $str = str_replace('&','&',$str);
+ $str = str_replace('+','%2B',$str);
+ $str = str_replace('#','%23',$str);
+ return $str;
+}
+
+function gethiddenpass($path,$passfile)
+{
+ $path1 = path_format($_SERVER['list_path'] . path_format($path));
+ if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
+ $password=getcache('path_' . $path1 . '/?password');
+ if ($password=='') {
+ $ispassfile = fetch_files(path_format($path . '/' . urlencode($passfile)));
+ //echo $path . '' . 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')
+{
+ $timezones = array(
+ '-12'=>'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'
+ );
+ if ($timezone=='') $timezone = '8';
+ return $timezones[$timezone];
+}
+
+function message($message, $title = 'Message', $statusCode = 200)
+{
+ return output('
+
+
+
+
+
+ ' . $title . '
+
+
+' . $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');
+ $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) {
+ $fileinfo['name'] = $_GET['upbigfilename'];
+ $fileinfo['size'] = $_GET['filesize'];
+ $fileinfo['lastModified'] = $_GET['lastModified'];
+ $filename = spurlencode( $fileinfo['name'] );
+ $cachefilename = '.' . $fileinfo['lastModified'] . '_' . $fileinfo['size'] . '_' . $filename . '.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 = ''.getconstStr('AdminLogin').'';
+ if ($name!=''&&$pass!='') {
+ $html .= ''.getconstStr('LoginSuccess').'';
+ $statusCode = 302;
+ date_default_timezone_set('UTC');
+ $header = [
+ 'Set-Cookie' => $name.'='.$pass.'; path=/; expires='.date(DATE_COOKIE,strtotime('+1hour')),
+ 'Location' => $path,
+ 'Content-Type' => 'text/html'
+ ];
+ return output($html,$statusCode,$header);
+ }
+ $html .= '
+
+
+
'.getconstStr('InputPassword').'
+
+
+
+';
+ $html .= '';
+ return output($html,$statusCode);
+}
+
+function adminoperate($path)
+{
+ $path1 = path_format($_SERVER['list_path'] . path_format($path));
+ if (substr($path1,-1)=='/') $path1=substr($path1,0,-1);
+ $tmparr['statusCode'] = 0;
+ if (isset($_GET['rename_newname'])&&$_GET['rename_newname']!=$_GET['rename_oldname'] && $_GET['rename_newname']!='') {
+ // rename 重命名
+ $oldname = spurlencode($_GET['rename_oldname']);
+ $oldname = path_format($path1 . '/' . $oldname);
+ $data = '{"name":"' . $_GET['rename_newname'] . '"}';
+ //echo $oldname;
+ $result = MSAPI('PATCH',$oldname,$data,$_SERVER['access_token']);
+ //savecache('path_' . $path1, json_decode('{}',true), 1);
+ return output($result['body'], $result['stat']);
+ }
+ if (isset($_GET['delete_name'])) {
+ // delete 删除
+ $filename = spurlencode($_GET['delete_name']);
+ $filename = path_format($path1 . '/' . $filename);
+ //echo $filename;
+ $result = MSAPI('DELETE', $filename, '', $_SERVER['access_token']);
+ //savecache('path_' . $path1, json_decode('{}',true), 1);
+ return output($result['body'], $result['stat']);
+ }
+ if (isset($_GET['operate_action'])&&$_GET['operate_action']==getconstStr('encrypt')) {
+ // encrypt 加密
+ if (getConfig('passfile')=='') return message(getconstStr('SetpassfileBfEncrypt'),'',403);
+ if ($_GET['encrypt_folder']=='/') $_GET['encrypt_folder']=='';
+ $foldername = spurlencode($_GET['encrypt_folder']);
+ $filename = path_format($path1 . '/' . $foldername . '/' . getConfig('passfile'));
+ //echo $foldername;
+ $result = MSAPI('PUT', $filename, $_GET['encrypt_newpass'], $_SERVER['access_token']);
+ $path1 = path_format($path1 . '/' . $foldername );
+ if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
+ savecache('path_' . $path1 . '/?password', '', 1);
+ return output($result['body'], $result['stat']);
+ }
+ if (isset($_GET['move_folder'])) {
+ // move 移动
+ $moveable = 1;
+ if ($path == '/' && $_GET['move_folder'] == '/../') $moveable=0;
+ if ($_GET['move_folder'] == $_GET['move_name']) $moveable=0;
+ if ($moveable) {
+ $filename = spurlencode($_GET['move_name']);
+ $filename = path_format($path1 . '/' . $filename);
+ $foldername = path_format('/'.urldecode($path1).'/'.$_GET['move_folder']);
+ $data = '{"parentReference":{"path": "/drive/root:'.$foldername.'"}}';
+ $result = MSAPI('PATCH', $filename, $data, $_SERVER['access_token']);
+ //savecache('path_' . $path1, json_decode('{}',true), 1);
+ if ($_GET['move_folder'] == '/../') $path2 = path_format( substr($path1, 0, strrpos($path1, '/')) . '/' );
+ else $path2 = path_format( $path1 . '/' . $_GET['move_folder'] . '/' );
+ if ($path2!='/'&&substr($path2,-1)=='/') $path2=substr($path2,0,-1);
+ savecache('path_' . $path2, json_decode('{}',true), 1);
+ return output($result['body'], $result['stat']);
+ } else {
+ return output('{"error":"'.getconstStr('CannotMove').'"}', 403);
+ }
+ }
+ if (isset($_GET['copy_name'])) {
+ // copy 复制
+ $filename = spurlencode($_GET['copy_name']);
+ $filename = path_format($path1 . '/' . $filename);
+ $namearr = splitlast($_GET['copy_name'], '.');
+ if ($namearr[0]!='') {
+ $newname = $namearr[0] . ' (' . getconstStr('Copy') . ')';
+ if ($namearr[1]!='') $newname .= '.' . $namearr[1];
+ } else {
+ $newname = '.' . $namearr[1] . ' (' . getconstStr('Copy') . ')';
+ }
+ //$newname = spurlencode($newname);
+ //$foldername = path_format('/'.urldecode($path1).'/./');
+ //$data = '{"parentReference":{"path": "/drive/root:'.$foldername.'"}}';
+ $data = '{ "name": "' . $newname . '" }';
+ $result = MSAPI('copy', $filename, $data, $_SERVER['access_token']);
+ $num = 0;
+ while ($result['stat']==409 && json_decode($result['body'], true)['error']['code']=='nameAlreadyExists') {
+ $num++;
+ if ($namearr[0]!='') {
+ $newname = $namearr[0] . ' (' . getconstStr('Copy') . ' ' . $num . ')';
+ if ($namearr[1]!='') $newname .= '.' . $namearr[1];
+ } else {
+ $newname = '.' . $namearr[1] . ' ('.getconstStr('Copy'). ' ' . $num .')';
+ }
+ //$newname = spurlencode($newname);
+ $data = '{ "name": "' . $newname . '" }';
+ $result = MSAPI('copy', $filename, $data, $_SERVER['access_token']);
+ }
+ //echo $result['stat'].$result['body'];
+ //savecache('path_' . $path1, json_decode('{}',true), 1);
+ //if ($_GET['move_folder'] == '/../') $path2 = path_format( substr($path1, 0, strrpos($path1, '/')) . '/' );
+ //else $path2 = path_format( $path1 . '/' . $_GET['move_folder'] . '/' );
+ //savecache('path_' . $path2, json_decode('{}',true), 1);
+ return output($result['body'], $result['stat']);
+ }
+ if (isset($_POST['editfile'])) {
+ // edit 编辑
+ $data = $_POST['editfile'];
+ /*TXT一般不会超过4M,不用二段上传
+ $filename = $path1 . ':/createUploadSession';
+ $response=MSAPI('POST',$filename,'{"item": { "@microsoft.graph.conflictBehavior": "replace" }}',$_SERVER['access_token']);
+ $uploadurl=json_decode($response,true)['uploadUrl'];
+ echo MSAPI('PUT',$uploadurl,$data,$_SERVER['access_token']);*/
+ $result = MSAPI('PUT', $path1, $data, $_SERVER['access_token'])['body'];
+ //echo $result;
+ $resultarry = json_decode($result,true);
+ if (isset($resultarry['error'])) return message($resultarry['error']['message']. '
'.getconstStr('Back').'','Error',403);
+ }
+ if (isset($_GET['create_name'])) {
+ // create 新建
+ if ($_GET['create_type']=='file') {
+ $filename = spurlencode($_GET['create_name']);
+ $filename = path_format($path1 . '/' . $filename);
+ $result = MSAPI('PUT', $filename, $_GET['create_text'], $_SERVER['access_token']);
+ }
+ if ($_GET['create_type']=='folder') {
+ $data = '{ "name": "' . $_GET['create_name'] . '", "folder": { }, "@microsoft.graph.conflictBehavior": "rename" }';
+ $result = MSAPI('children', $path1, $data, $_SERVER['access_token']);
+ }
+ //savecache('path_' . $path1, json_decode('{}',true), 1);
+ return output($result['body'], $result['stat']);
+ }
+ if (isset($_GET['RefreshCache'])) {
+ $path1 = path_format($_SERVER['list_path'] . path_format($path));
+ if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
+ savecache('path_' . $path1 . '/?password', '', 1);
+ return message('', getconstStr('RefreshCache'), 302);
+ }
+ return $tmparr;
+}
+
+function splitlast($str, $split)
+{
+ $pos = strrpos($str, $split);
+ if ($pos===false) {
+ $tmp[0] = $str;
+ $tmp[1] = '';
+ } elseif ($pos>0) {
+ $tmp[0] = substr($str, 0, $pos);
+ $tmp[1] = substr($str, $pos+1);
+ } else {
+ $tmp[0] = '';
+ $tmp[1] = substr($str, 1);
+ }
+ return $tmp;
+}
+
+function MSAPI($method, $path, $data = '', $access_token)
+{
+ if (substr($path,0,7) == 'http://' or substr($path,0,8) == 'https://') {
+ $url=$path;
+ $lenth=strlen($data);
+ $headers['Content-Length'] = $lenth;
+ $lenth--;
+ $headers['Content-Range'] = 'bytes 0-' . $lenth . '/' . $headers['Content-Length'];
+ } else {
+ $url = $_SERVER['api_url'];
+ if ($path=='' or $path=='/') {
+ $url .= '/';
+ } else {
+ $url .= ':' . $path;
+ if (substr($url,-1)=='/') $url=substr($url,0,-1);
+ }
+ if ($method=='PUT') {
+ if ($path=='' or $path=='/') {
+ $url .= 'content';
+ } else {
+ $url .= ':/content';
+ }
+ $headers['Content-Type'] = 'text/plain';
+ } elseif ($method=='PATCH') {
+ $headers['Content-Type'] = 'application/json';
+ } elseif ($method=='POST') {
+ $headers['Content-Type'] = 'application/json';
+ } elseif ($method=='DELETE') {
+ $headers['Content-Type'] = 'application/json';
+ } else {
+ if ($path=='' or $path=='/') {
+ $url .= $method;
+ } else {
+ $url .= ':/' . $method;
+ }
+ $method='POST';
+ $headers['Content-Type'] = 'application/json';
+ }
+ }
+ $headers['Authorization'] = 'Bearer ' . $access_token;
+ if (!isset($headers['Accept'])) $headers['Accept'] = '*/*';
+ //if (!isset($headers['Referer'])) $headers['Referer'] = $url;*
+ $sendHeaders = array();
+ foreach ($headers as $headerName => $headerVal) {
+ $sendHeaders[] = $headerName . ': ' . $headerVal;
+ }
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST,$method);
+ curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 5);
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+ //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $sendHeaders);
+ $response['body'] = curl_exec($ch);
+ $response['stat'] = curl_getinfo($ch,CURLINFO_HTTP_CODE);
+ //$response['Location'] = curl_getinfo($ch);
+ curl_close($ch);
+ error_log($response['stat'].'
+'.$response['body'].'
+');
+ return $response;
+}
+
+function fetch_files($path = '/')
+{
+ global $exts;
+ $path1 = path_format($path);
+ $path = path_format($_SERVER['list_path'] . path_format($path));
+ if ($path!='/'&&substr($path,-1)=='/') $path=substr($path,0,-1);
+ if (!($files = getcache('path_' . $path))) {
+ // 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, '/');
+ $parentpath = $pos[0];
+ if ($parentpath=='') $parentpath = '/';
+ $filename = $pos[1];
+ if ($parentfiles = getcache('path_' . $parentpath)) {
+ if (isset($parentfiles['children'][$filename][$_SERVER['DownurlStrName']])) {
+ if (in_array(splitlast($filename,'.')[1], $exts['txt'])) {
+ if (!(isset($parentfiles['children'][$filename]['content'])&&$parentfiles['children'][$filename]['content']['stat']==200)) {
+ $content1 = curl_request($parentfiles['children'][$filename][$_SERVER['DownurlStrName']]);
+ $parentfiles['children'][$filename]['content'] = $content1;
+ savecache('path_' . $parentpath, $parentfiles);
+ }
+ }
+ return $parentfiles['children'][$filename];
+ }
+ }
+
+ $url = $_SERVER['api_url'];
+ if ($path !== '/') {
+ $url .= ':' . $path;
+ if (substr($url,-1)=='/') $url=substr($url,0,-1);
+ }
+ $url .= '?expand=children(select=name,size,file,folder,parentReference,lastModifiedDateTime,'.$_SERVER['DownurlStrName'].')';
+ $retry = 0;
+ $arr = [];
+ while ($retry<3&&!$arr['stat']) {
+ $arr = curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']],1);
+ $retry++;
+ }
+ if ($arr['stat']<500) {
+ $files = json_decode($arr['body'], true);
+ //echo $path . '
' . 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']);
+ } else {
+ // files num < 200 , then cache
+ //if (isset($files['children'])) {
+ $files['children'] = children_name($files['children']);
+ //}
+ 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=name,size,file,folder,parentReference,lastModifiedDateTime,'.$_SERVER['DownurlStrName'];
+ } else {
+ $url .= '/children?$select=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 render_list($path = '', $files = '')
+{
+ global $exts;
+ global $constStr;
+
+ if (isset($files['children']['index.html']) && !$_SERVER['admin']) {
+ $htmlcontent = fetch_files(spurlencode(path_format($path . '/index.html'),'/'))['content'];
+ return output($htmlcontent['body'], $htmlcontent['stat']);
+ }
+ $path = str_replace('%20','%2520',$path);
+ $path = str_replace('+','%2B',$path);
+ $path = str_replace('&','&',path_format(urldecode($path))) ;
+ $path = str_replace('%20',' ',$path);
+ $path = str_replace('#','%23',$path);
+ $p_path='';
+ if ($path !== '/') {
+ if (isset($files['file'])) {
+ $pretitle = str_replace('&','&', $files['name']);
+ $n_path=$pretitle;
+ } else {
+ $pretitle = substr($path,-1)=='/'?substr($path,0,-1):$path;
+ $n_path=substr($pretitle,strrpos($pretitle,'/')+1);
+ $pretitle = substr($pretitle,1);
+ }
+ if (strrpos($path,'/')!=0) {
+ $p_path=substr($path,0,strrpos($path,'/'));
+ $p_path=substr($p_path,strrpos($p_path,'/')+1);
+ }
+ } else {
+ $pretitle = getconstStr('Home');
+ $n_path=$pretitle;
+ }
+ $n_path=str_replace('&','&',$n_path);
+ $p_path=str_replace('&','&',$p_path);
+ $pretitle = str_replace('%23','#',$pretitle);
+ $statusCode=200;
+ date_default_timezone_set(get_timezone($_COOKIE['timezone']));
+ @ob_start();
+
+ $theme = getConfig('theme');
+ if ( $theme=='' || !file_exists('theme/'.$theme) ) $theme = 'classic.php';
+ include 'theme/'.$theme;
+
+ $html = '' . ob_get_clean();
+ //if (isset($htmlpage['statusCode'])) return $htmlpage;
+ if (isset($_SERVER['Set-Cookie'])) return output($html, $statusCode, [ 'Set-Cookie' => $_SERVER['Set-Cookie'], 'Content-Type' => 'text/html' ]);
+ return output($html,$statusCode);
+}
+
+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 :
';
+ $str .= '
+
+ '.getconstStr('SavingToken').'
+ ';
+ $tmptoken['refresh_token'] = $refresh_token;
+ $tmptoken['token_expires'] = time()+7*24*60*60;
+ if (getConfig('usesharepoint')=='on') $tmptoken['siteid'] = get_siteid($ret['access_token']);
+ setConfig($tmptoken, $_COOKIE['disktag']);
+ savecache('access_token', $ret['access_token'], $ret['expires_in'] - 60);
+ //WaitSCFStat();
+ $str .= '
+ ';
+ return message($str, getconstStr('WaitJumpIndex'));
+ }
+ return message('' . 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, try 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 . '
', 'Error', 201);
+ }
+ $_SERVER['disktag'] = $_COOKIE['disktag'];
+ $tmp['disktag_add'] = $_POST['disktag_add'];
+ $tmp['diskname'] = $_POST['diskname'];
+ $tmp['Drive_ver'] = $_POST['Drive_ver'];
+ if ($_POST['Drive_ver']=='shareurl') {
+ $tmp['shareurl'] = $_POST['shareurl'];
+ $tmp['refresh_token'] = 1;
+ } else {
+ if ($_POST['Drive_custom']=='on') {
+ $tmp['Drive_custom'] = $_POST['Drive_custom'];
+ $tmp['client_id'] = $_POST['client_id'];
+ $tmp['client_secret'] = $_POST['client_secret'];
+ }
+ if ($_POST['usesharepoint']=='on') {
+ $tmp['usesharepoint'] = $_POST['usesharepoint'];
+ $tmp['sharepointname'] = $_POST['sharepointname'];
+ }
+ }
+ $response = setConfigResponse( setConfig($tmp, $_COOKIE['disktag']) );
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ } else {
+ $title = getconstStr('MayinEnv');
+ $html = getconstStr('Wait') . ' 3s';
+ if ($_POST['Drive_ver']=='shareurl') $html = getconstStr('Wait') . ' 3s';
+ }
+ return message($html, $title, 201);
+ }
+ }
+
+ if ($constStr['language']!='zh-cn') {
+ $linklang='en-us';
+ } else $linklang='zh-cn';
+ $ru = "https://developer.microsoft.com/".$linklang."/graph/quick-start?appID=_appId_&appName=_appName_&redirectUrl=".$_SERVER['redirect_uri']."&platform=option-php";
+ $deepLink = "/quickstart/graphIO?publicClientSupport=false&appName=OneManager&redirectUrl=".$_SERVER['redirect_uri']."&allowImplicitFlow=false&ru=".urlencode($ru);
+ $app_url = "https://apps.dev.microsoft.com/?deepLink=".urlencode($deepLink);
+ $html = '
+
+ ';
+ $title = 'Bind Disk';
+ return message($html, $title, 201);
+}
+
+function EnvOpt($needUpdate = 0)
+{
+ global $constStr;
+ global $ShowedCommonEnv;
+ global $ShowedInnerEnv;
+ asort($ShowedCommonEnv);
+ asort($ShowedInnerEnv);
+ $html = 'OneManager '.getconstStr('Setup').'';
+ if (isset($_POST['updateProgram'])&&$_POST['updateProgram']==getconstStr('updateProgram')) {
+ $response = OnekeyUpate($_POST['auth'], $_POST['project'], $_POST['branch']);
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ } else {
+ //WaitSCFStat();
+ $html .= getconstStr('UpdateSuccess') . '
+';
+ $title = getconstStr('Setup');
+ }
+ return message($html, $title);
+ }
+ if (isset($_POST['submit1'])) {
+ $_SERVER['disk_oprating'] = '';
+ foreach ($_POST as $k => $v) {
+ if (in_array($k, $ShowedCommonEnv)||in_array($k, $ShowedInnerEnv)||$k=='disktag_del' || $k=='disktag_add') {
+ $tmp[$k] = $v;
+ }
+ if ($k == 'disk') $_SERVER['disk_oprating'] = $v;
+ }
+ /*if ($tmp['domain_path']!='') {
+ $tmp1 = explode("|",$tmp['domain_path']);
+ $tmparr = [];
+ foreach ($tmp1 as $multidomain_paths){
+ $pos = strpos($multidomain_paths,":");
+ if ($pos>0) $tmparr[substr($multidomain_paths, 0, $pos)] = path_format(substr($multidomain_paths, $pos+1));
+ }
+ $tmp['domain_path'] = $tmparr;
+ }*/
+ $response = setConfigResponse( setConfig($tmp, $_SERVER['disk_oprating']) );
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ } else {
+ //WaitSCFStat();
+ //sleep(3);
+ $html .= getconstStr('Success') . '!
+';
+ $title = getconstStr('Setup');
+ }
+ return message($html, $title);
+ }
+ if (isset($_GET['preview'])) {
+ $preurl = $_SERVER['PHP_SELF'] . '?preview';
+ } else {
+ $preurl = path_format($_SERVER['PHP_SELF'] . '/');
+ }
+ $html .= '
+'.getconstStr('Back').' '.getconstStr('Back').getconstStr('Home').'
+Github
';
+
+ $html .= '
+
';
+ foreach (explode("|",getConfig('disktag')) as $disktag) {
+ if ($disktag!='') {
+ $html .= '
+
+ ';
+ if (getConfig('refresh_token', $disktag)!='') {
+ $html .= '
+ ';
+ }
+ $html .= '
+
';
+ }
+ }
+ $html .= '
+'.getconstStr('AddDisk').'
';
+ if (!((isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud')||(isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app'))) {
+ $html .= '
+In VPS can not update by a click!
';
+ } else {
+ $html .= '
+
+
+';
+ }
+ if ($needUpdate) {
+ $html .= '
+ ' . str_replace("\r", '
',$_SERVER['github_version']) . '
+
';
+ } else {
+ $html .= getconstStr('NotNeedUpdate');
+ }
+ return message($html, getconstStr('Setup'));
+}
diff --git a/index.php b/index.php
index ff1cac9..efc0ac1 100644
--- a/index.php
+++ b/index.php
@@ -1,13 +1,13 @@
'. json_encode($_SERVER, JSON_PRETTY_PRINT).'';
if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
- include 'function/scf.php';
+ include 'platform/scf.php';
} elseif (isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app') {
- include 'function/heroku.php';
+ include 'platform/heroku.php';
$path = getpath();
//echo 'path:'. $path;
$_GET = getGET();
@@ -20,7 +20,7 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
http_response_code($re['statusCode']);
echo $re['body'];
} else {
- include 'function/normal.php';
+ include 'platform/normal.php';
$path = getpath();
//echo 'path:'. $path;
$_GET = getGET();
diff --git a/platform/heroku.php b/platform/heroku.php
new file mode 100644
index 0000000..36d3f77
--- /dev/null
+++ b/platform/heroku.php
@@ -0,0 +1,252 @@
+0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
+ else $path = $_SERVER['REQUEST_URI'];
+ $path = path_format( substr($path, strlen($_SERVER['base_path'])) );
+ return substr($path, 1);
+ //return spurlencode($path, '/');
+}
+
+function getGET()
+{
+ $p = strpos($_SERVER['REQUEST_URI'],'?');
+ if ($p>0) {
+ $getstr = substr($_SERVER['REQUEST_URI'], $p+1);
+ $getstrarr = explode("&",$getstr);
+ foreach ($getstrarr as $getvalues) {
+ if ($getvalues != '') {
+ $pos = strpos($getvalues, "=");
+ //echo $pos;
+ if ($pos > 0) {
+ $getarry[urldecode(substr($getvalues, 0, $pos))] = urldecode(substr($getvalues, $pos + 1));
+ } else {
+ $getarry[urldecode($getvalues)] = true;
+ }
+ }
+ }
+ }
+ if (isset($getarry)) {
+ return $getarry;
+ } else {
+ return [];
+ }
+}
+
+function getConfig($str, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ if (in_array($str, $InnerEnv)) {
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ $env = json_decode(getenv($disktag), true);
+ if (isset($env[$str])) {
+ if (in_array($str, $Base64Env)) return equal_replace($env[$str],1);
+ else return $env[$str];
+ }
+ } else {
+ if (in_array($str, $Base64Env)) return equal_replace(getenv($str),1);
+ else return getenv($str);
+ }
+ return '';
+}
+
+function setConfig($arr, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ $disktags = explode("|",getConfig('disktag'));
+ $diskconfig = json_decode(getenv($disktag), true);
+ $tmp = [];
+ $indisk = 0;
+ $oparetdisk = 0;
+ foreach ($arr as $k => $v) {
+ if (in_array($k, $InnerEnv)) {
+ if (in_array($k, $Base64Env)) $diskconfig[$k] = equal_replace($v);
+ else $diskconfig[$k] = $v;
+ $indisk = 1;
+ } elseif ($k=='disktag_add') {
+ array_push($disktags, $v);
+ $oparetdisk = 1;
+ } elseif ($k=='disktag_del') {
+ $disktags = array_diff($disktags, [ $v ]);
+ $tmp[$v] = '';
+ $oparetdisk = 1;
+ } else {
+ if (in_array($k, $Base64Env)) $tmp[$k] = equal_replace($v);
+ else $tmp[$k] = $v;
+ }
+ }
+ if ($indisk) {
+ $diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
+ ksort($diskconfig);
+ $tmp[$disktag] = json_encode($diskconfig);
+ }
+ if ($oparetdisk) {
+ $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'] = '';
+ }
+ foreach ($tmp as $key => $val) if ($val=='') $tmp[$key]=null;
+// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
+//';
+ return setHerokuConfig($tmp, getConfig('function_name'), getConfig('APIKey'));
+}
+
+function install()
+{
+ global $constStr;
+ if ($_GET['install1']) {
+ if ($_POST['admin']!='') {
+ $tmp['admin'] = $_POST['admin'];
+ $tmp['language'] = $_POST['language'];
+ $APIKey = getConfig('APIKey');
+ if ($APIKey=='') {
+ $APIKey = $_POST['APIKey'];
+ $tmp['APIKey'] = $APIKey;
+ }
+ $function_name = getConfig('function_name');
+ if ($function_name=='') {
+ $tmp1 = substr($_SERVER['HTTP_HOST'], 0, strrpos($_SERVER['HTTP_HOST'], '.'));
+ $maindomain = substr($tmp1, strrpos($tmp1, '.')+1);
+ if ($maindomain=='herokuapp') $function_name = substr($tmp1, 0, strrpos($tmp1, '.'));
+ else $function_name = 'visit from xxxx.herokuapp.com';
+ $tmp['function_name'] = $function_name;
+ }
+ $response = json_decode(setHerokuConfig($tmp, $function_name, $APIKey)['body'], true);
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ } else {
+ return output('Jump', 302);
+ }
+ return message($html, $title, 201);
+ }
+ }
+ if ($_GET['install0']) {
+ $html .= '
+
+ ';
+ $title = getconstStr('SelectLanguage');
+ return message($html, $title, 201);
+ }
+ $html .= ''.getconstStr('ClickInstall').', '.getconstStr('LogintoBind');
+ $title = 'Error';
+ return message($html, $title, 201);
+}
+
+function HerokuAPI($method, $url, $data = '', $apikey)
+{
+ if ($method=='PATCH'||$method=='POST') {
+ $headers['Content-Type'] = 'application/json';
+ }
+ $headers['Authorization'] = 'Bearer ' . $apikey;
+ $headers['Accept'] = 'application/vnd.heroku+json; version=3';
+ //if (!isset($headers['Accept'])) $headers['Accept'] = '*/*';
+ //if (!isset($headers['Referer'])) $headers['Referer'] = $url;
+ $sendHeaders = array();
+ foreach ($headers as $headerName => $headerVal) {
+ $sendHeaders[] = $headerName . ': ' . $headerVal;
+ }
+ error_log($method . $url . $data . $apikey);
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST,$method);
+ curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 5);
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $sendHeaders);
+ $response['body'] = curl_exec($ch);
+ $response['stat'] = curl_getinfo($ch,CURLINFO_HTTP_CODE);
+ curl_close($ch);
+ error_log($response['stat'].'
+'.$response['body'].'
+');
+ return $response;
+}
+
+function getHerokuConfig($function_name, $apikey)
+{
+ return HerokuAPI('GET', 'https://api.heroku.com/apps/' . $function_name . '/config-vars', '', $apikey);
+}
+
+function setHerokuConfig($env, $function_name, $apikey)
+{
+ $data = json_encode($env);
+ return HerokuAPI('PATCH', 'https://api.heroku.com/apps/' . $function_name . '/config-vars', $data, $apikey);
+}
+
+function updateHerokuapp($function_name, $apikey, $source)
+{
+ $tmp['source_blob']['url'] = $source;
+ $data = json_encode($tmp);
+ return HerokuAPI('POST', 'https://api.heroku.com/apps/' . $function_name . '/builds', $data, $apikey);
+}
+
+function api_error($response)
+{
+ return isset($response['id'])&&isset($response['message']);
+}
+
+function api_error_msg($response)
+{
+ return $response['id'] . '
+' . $response['message'] . '
+function_name:' . $_SERVER['function_name'] . '
+';
+}
+
+function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
+{
+ //'https://github.com/qkqpttgf/OneManager-php/tarball/master/';
+ $source = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . $branch . '/';
+ return json_decode(updateHerokuapp(getConfig('function_name'), getConfig('APIKey'), $source)['body'], true);
+}
+
+function setConfigResponse($response)
+{
+ return json_decode( $response['body'], true );
+}
diff --git a/platform/normal.php b/platform/normal.php
new file mode 100644
index 0000000..1e4e0d7
--- /dev/null
+++ b/platform/normal.php
@@ -0,0 +1,254 @@
+0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
+ else $path = $_SERVER['REQUEST_URI'];
+ $path = path_format( substr($path, strlen($_SERVER['base_path'])) );
+ return substr($path, 1);
+ //return spurlencode($path, '/');
+}
+
+function getGET()
+{
+ $p = strpos($_SERVER['REQUEST_URI'],'?');
+ if ($p>0) {
+ $getstr = substr($_SERVER['REQUEST_URI'], $p+1);
+ $getstrarr = explode("&",$getstr);
+ foreach ($getstrarr as $getvalues) {
+ if ($getvalues != '') {
+ $pos = strpos($getvalues, "=");
+ //echo $pos;
+ if ($pos > 0) {
+ $getarry[urldecode(substr($getvalues, 0, $pos))] = urldecode(substr($getvalues, $pos + 1));
+ } else {
+ $getarry[urldecode($getvalues)] = true;
+ }
+ }
+ }
+ }
+ if (isset($getarry)) {
+ return $getarry;
+ } else {
+ return [];
+ }
+}
+
+function getConfig($str, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ //include 'config.php';
+ $s = file_get_contents('config.php');
+ $configs = substr($s, 18, -2);
+ if ($configs!='') {
+ $envs = json_decode($configs, true);
+ if (in_array($str, $InnerEnv)) {
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ if (isset($envs[$disktag][$str])) {
+ if (in_array($str, $Base64Env)) return equal_replace($envs[$disktag][$str],1);
+ else return $envs[$disktag][$str];
+ }
+ } else {
+ if (isset($envs[$str])) {
+ if (in_array($str, $Base64Env)) return equal_replace($envs[$str],1);
+ else return $envs[$str];
+ }
+ }
+ }
+ return '';
+}
+
+function setConfig($arr, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ //include 'config.php';
+ $s = file_get_contents('config.php');
+ $configs = substr($s, 18, -2);
+ if ($configs!='') $envs = json_decode($configs, true);
+ $disktags = explode("|",getConfig('disktag'));
+ //$indisk = 0;
+ $operatedisk = 0;
+ foreach ($arr as $k => $v) {
+ if (in_array($k, $InnerEnv)) {
+ if (in_array($k, $Base64Env)) $envs[$disktag][$k] = equal_replace($v);
+ else $envs[$disktag][$k] = $v;
+ /*$diskconfig[$k] = $v;
+ $indisk = 1;*/
+ } elseif ($k=='disktag_add') {
+ array_push($disktags, $v);
+ $operatedisk = 1;
+ } elseif ($k=='disktag_del') {
+ $disktags = array_diff($disktags, [ $v ]);
+ $envs[$v] = '';
+ $operatedisk = 1;
+ } else {
+ if (in_array($k, $Base64Env)) $envs[$k] = equal_replace($v);
+ else $envs[$k] = $v;
+ }
+ }
+ /*if ($indisk) {
+ $diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
+ ksort($diskconfig);
+ $tmp[$disktag] = json_encode($diskconfig);
+ }*/
+ if ($operatedisk) {
+ $disktags = array_unique($disktags);
+ foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
+ if ($disktag_s!='') $envs['disktag'] = substr($disktag_s, 0, -1);
+ else $envs['disktag'] = '';
+ }
+ $envs = array_filter($envs, 'array_value_isnot_null');
+ ksort($envs);
+ //echo ''. json_encode($envs, JSON_PRETTY_PRINT).'
';
+ $prestr = 'document.cookie=\'language=; path=/\';', 302);
+ }
+ }
+ }
+ if ($_GET['install1']) {
+ if (!ConfigWriteable()) {
+ $html .= getconstStr('MakesuerWriteable');
+ $title = 'Error';
+ return message($html, $title, 201);
+ }
+ /*if (!RewriteEngineOn()) {
+ $html .= getconstStr('MakesuerRewriteOn');
+ $title = 'Error';
+ return message($html, $title, 201);
+ }*/
+ $html .= '
+
+
+
+ ';
+ $title = getconstStr('SetAdminPassword');
+ return message($html, $title, 201);
+ }
+ if ($_GET['install0']) {
+ $html .= '
+
+ ';
+ $title = getconstStr('SelectLanguage');
+ return message($html, $title, 201);
+ }
+ $html .= ''.getconstStr('ClickInstall').', '.getconstStr('LogintoBind');
+ $title = 'Error';
+ return message($html, $title, 201);
+}
+
+function ConfigWriteable()
+{
+ $t = md5( md5(time()).rand(1000,9999) );
+ $r = setConfig([ 'tmp' => $t ]);
+ $tmp = getConfig('tmp');
+ setConfig([ 'tmp' => '' ]);
+ if ($tmp == $t) return true;
+ if ($r) return true;
+ return false;
+}
+
+function RewriteEngineOn()
+{
+ $http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
+ $tmpurl = $http_type . $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'];
+ $tmpurl .= path_format($_SERVER['base_path'] . '/config.php');
+ $tmp = curl_request($tmpurl);
+ if ($tmp['stat']==200) return false;
+ if ($tmp['stat']==201) return true; //when install return 201, after installed return 404 or 200;
+ return false;
+}
+
+function api_error($response)
+{
+ return !$response;
+}
+
+function api_error_msg($response)
+{
+ return $response . '
+Can not write config to file.
+';
+}
+
+function OnekeyUpate()
+{
+ return json_decode(updateHerokuapp(getConfig('function_name'), getConfig('APIKey'))['body'], true);
+}
+
+function setConfigResponse($response)
+{
+ return $response;
+}
diff --git a/platform/scf.php b/platform/scf.php
new file mode 100644
index 0000000..f01e57a
--- /dev/null
+++ b/platform/scf.php
@@ -0,0 +1,421 @@
+500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
+ echo urldecode(json_encode($event, JSON_PRETTY_PRINT)) . '
+
+' . urldecode(json_encode($context, JSON_PRETTY_PRINT)) . '
+
+';
+}
+
+function GetGlobalVariable($event)
+{
+ $_GET = $event['queryString'];
+ $postbody = explode("&",$event['body']);
+ foreach ($postbody as $postvalues) {
+ $pos = strpos($postvalues,"=");
+ $_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
+ }
+ $cookiebody = explode("; ",$event['headers']['cookie']);
+ foreach ($cookiebody as $cookievalues) {
+ $pos = strpos($cookievalues,"=");
+ $_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
+ }
+ $_SERVER['USER'] = 'qcloud';
+}
+
+function GetPathSetting($event, $context)
+{
+ $_SERVER['function_name'] = $context['function_name'];
+ $_SERVER['namespace'] = $context['namespace'];
+ $host_name = $event['headers']['host'];
+ $_SERVER['HTTP_HOST'] = $host_name;
+ $serviceId = $event['requestContext']['serviceId'];
+ if ( $serviceId === substr($host_name,0,strlen($serviceId)) ) {
+ $_SERVER['base_path'] = '/'.$event['requestContext']['stage'].'/'.$_SERVER['function_name'].'/';
+ $_SERVER['Region'] = getenv('Region');
+ if ($_SERVER['Region'] == '') {
+ $_SERVER['Region'] = substr($host_name, strpos($host_name, '.')+1);
+ $_SERVER['Region'] = substr($_SERVER['Region'], 0, strpos($_SERVER['Region'], '.'));
+ }
+ $path = substr($event['path'], strlen('/'.$_SERVER['function_name'].'/'));
+ } else {
+ $_SERVER['base_path'] = $event['requestContext']['path'];
+ $_SERVER['Region'] = getenv('Region');
+ $path = substr($event['path'], strlen($event['requestContext']['path']));
+ }
+ if (substr($path,-1)=='/') $path=substr($path,0,-1);
+ $_SERVER['is_guestup_path'] = is_guestup_path($path);
+ $_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
+ $_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp'];
+ $_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
+ return $path;
+}
+
+function getConfig($str, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ if (in_array($str, $InnerEnv)) {
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ $env = json_decode(getenv($disktag), true);
+ if (isset($env[$str])) {
+ if (in_array($str, $Base64Env)) return equal_replace($env[$str],1);
+ else return $env[$str];
+ }
+ } else {
+ if (in_array($str, $Base64Env)) return equal_replace(getenv($str),1);
+ else return getenv($str);
+ }
+ return '';
+}
+
+function setConfig($arr, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ $disktags = explode("|",getConfig('disktag'));
+ $diskconfig = json_decode(getenv($disktag), true);
+ $tmp = [];
+ $indisk = 0;
+ $oparetdisk = 0;
+ foreach ($arr as $k => $v) {
+ if (in_array($k, $InnerEnv)) {
+ if (in_array($k, $Base64Env)) $diskconfig[$k] = equal_replace($v);
+ else $diskconfig[$k] = $v;
+ $indisk = 1;
+ } elseif ($k=='disktag_add') {
+ array_push($disktags, $v);
+ $oparetdisk = 1;
+ } elseif ($k=='disktag_del') {
+ $disktags = array_diff($disktags, [ $v ]);
+ $tmp[$v] = '';
+ $oparetdisk = 1;
+ } else {
+ if (in_array($k, $Base64Env)) $tmp[$k] = equal_replace($v);
+ else $tmp[$k] = $v;
+ }
+ }
+ if ($indisk) {
+ $diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
+ ksort($diskconfig);
+ $tmp[$disktag] = json_encode($diskconfig);
+ }
+ if ($oparetdisk) {
+ $disktags = array_unique($disktags);
+ foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
+ if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
+ else $tmp['disktag'] = '';
+ }
+// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
+//';
+ $response = updateEnvironment($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'));
+ WaitSCFStat();
+ return $response;
+}
+
+function WaitSCFStat()
+{
+ $trynum = 0;
+ while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']!='Active' ) echo '
+'.++$trynum;
+}
+
+function install()
+{
+ global $constStr;
+ if ($_GET['install2']) {
+ $tmp['admin'] = $_POST['admin'];
+ setConfig($tmp);
+ if (needUpdate()) {
+ OnekeyUpate();
+ //updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey);
+ return message('update to github version, reinstall.', 'Program updating', 201);
+ }
+ return output('Jump', 302);
+ }
+ if ($_GET['install1']) {
+ //if ($_POST['admin']!='') {
+ $tmp['language'] = $_POST['language'];
+ $tmp['Region'] = $_POST['Region'];
+ $SecretId = getConfig('SecretId');
+ if ($SecretId=='') {
+ $SecretId = $_POST['SecretId'];
+ $tmp['SecretId'] = $SecretId;
+ }
+ $SecretKey = getConfig('SecretKey');
+ if ($SecretKey=='') {
+ $SecretKey = $_POST['SecretKey'];
+ $tmp['SecretKey'] = $SecretKey;
+ }
+ $response = json_decode(SetbaseConfig($tmp, $_SERVER['function_name'], $_POST['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response'];
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ return message($html, $title, 201);
+ } else {
+ $html .= '
+
+ ';
+ $title = getconstStr('SetAdminPassword');
+ return message($html, $title, 201);
+ }
+ //}
+ }
+ if ($_GET['install0']) {
+ $html .= '
+
+ ';
+ $title = getconstStr('SelectLanguage');
+ return message($html, $title, 201);
+ }
+ $html .= ''.getconstStr('ClickInstall').', '.getconstStr('LogintoBind');
+ $title = 'Error';
+ return message($html, $title, 201);
+}
+
+function post2url($url, $data)
+{
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_POST, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 5);
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+ $response = curl_exec($ch);
+ curl_close($ch);
+ //echo $response;
+ return $response;
+}
+
+function ReorganizeDate($arr)
+{
+ $str = '';
+ ksort($arr);
+ foreach ($arr as $k1 => $v1) {
+ $str .= '&' . $k1 . '=' . $v1;
+ }
+ $str = substr($str, 1); // remove first '&'. 去掉第一个&
+ return $str;
+}
+
+function getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey)
+{
+ //$meth = 'GET';
+ $meth = 'POST';
+ $host = 'scf.tencentcloudapi.com';
+ $tmpdata['Action'] = 'GetFunction';
+ $tmpdata['FunctionName'] = $function_name;
+ $tmpdata['Namespace'] = $Namespace;
+ $tmpdata['Nonce'] = time();
+ $tmpdata['Region'] = $Region;
+ $tmpdata['SecretId'] = $SecretId;
+ $tmpdata['Timestamp'] = time();
+ $tmpdata['Token'] = '';
+ $tmpdata['Version'] = '2018-04-16';
+ $data = ReorganizeDate($tmpdata);
+ $signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
+ //echo urlencode($signStr);
+ //return file_get_contents('https://'.$url.'&Signature='.urlencode($signStr));
+ return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
+}
+
+function updateEnvironment($Envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey)
+{
+ //print_r($Envs);
+ WaitSCFStat();
+ //json_decode($a,true)['Response']['Environment']['Variables'][0]['Key']
+ $tmp = json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Environment']['Variables'];
+ foreach ($tmp as $tmp1) {
+ $tmp_env[$tmp1['Key']] = $tmp1['Value'];
+ }
+ foreach ($Envs as $key1 => $value1) {
+ $tmp_env[$key1] = $value1;
+ }
+ $tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
+ $tmp_env['Region'] = $Region;
+ ksort($tmp_env);
+
+ $i = 0;
+ foreach ($tmp_env as $key1 => $value1) {
+ $tmpdata['Environment.Variables.'.$i.'.Key'] = $key1;
+ $tmpdata['Environment.Variables.'.$i.'.Value'] = $value1;
+ $i++;
+ }
+ $meth = 'POST';
+ $host = 'scf.tencentcloudapi.com';
+ $tmpdata['Action'] = 'UpdateFunctionConfiguration';
+ $tmpdata['FunctionName'] = $function_name;
+ $tmpdata['Namespace'] = $Namespace;
+ $tmpdata['Nonce'] = time();
+ $tmpdata['Region'] = $Region;
+ $tmpdata['SecretId'] = $SecretId;
+ $tmpdata['Timestamp'] = time();
+ $tmpdata['Token'] = '';
+ $tmpdata['Version'] = '2018-04-16';
+ $data = ReorganizeDate($tmpdata);
+ $signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
+ //echo urlencode($signStr);
+ return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
+}
+
+function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey)
+{
+ echo json_encode($Envs,JSON_PRETTY_PRINT);
+ /*$trynum = 0;
+ while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
+'.++$trynum;*/
+ //json_decode($a,true)['Response']['Environment']['Variables'][0]['Key']
+ $tmp = json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Environment']['Variables'];
+ foreach ($tmp as $tmp1) {
+ $tmp_env[$tmp1['Key']] = $tmp1['Value'];
+ }
+ foreach ($Envs as $key1 => $value1) {
+ $tmp_env[$key1] = $value1;
+ }
+ $tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
+ $tmp_env['Region'] = $Region;
+ ksort($tmp_env);
+
+ $i = 0;
+ foreach ($tmp_env as $key1 => $value1) {
+ $tmpdata['Environment.Variables.'.$i.'.Key'] = $key1;
+ $tmpdata['Environment.Variables.'.$i.'.Value'] = $value1;
+ $i++;
+ }
+ $meth = 'POST';
+ $host = 'scf.tencentcloudapi.com';
+ $tmpdata['Action'] = 'UpdateFunctionConfiguration';
+ $tmpdata['FunctionName'] = $function_name;
+ $tmpdata['Namespace'] = $Namespace;
+ $tmpdata['Nonce'] = time();
+ $tmpdata['Region'] = $Region;
+ $tmpdata['SecretId'] = $SecretId;
+ $tmpdata['Timestamp'] = time();
+ $tmpdata['Token'] = '';
+ $tmpdata['Version'] = '2018-04-16';
+ $tmpdata['Description'] = 'Onedrive index and manager in SCF.';
+ $tmpdata['MemorySize'] = 64;
+ $tmpdata['Timeout'] = 30;
+ $data = ReorganizeDate($tmpdata);
+ echo $data;
+ $signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
+ //echo urlencode($signStr);
+ return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
+}
+
+function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKey, $source = '')
+{
+ WaitSCFStat();
+ $meth = 'POST';
+ $host = 'scf.tencentcloudapi.com';
+ $tmpdata['Action'] = 'UpdateFunctionCode';
+ $tmpdata['Code.GitUrl'] = $source;
+ $tmpdata['CodeSource'] = 'Git';
+ $tmpdata['FunctionName'] = $function_name;
+ $tmpdata['Handler'] = 'index.main_handler';
+ $tmpdata['Namespace'] = $Namespace;
+ $tmpdata['Nonce'] = time();
+ $tmpdata['Region'] = $Region;
+ $tmpdata['SecretId'] = $SecretId;
+ $tmpdata['Timestamp'] = time();
+ $tmpdata['Token'] = '';
+ $tmpdata['Version'] = '2018-04-16';
+ $data = ReorganizeDate($tmpdata);
+ $signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
+ //echo urlencode($signStr);
+ return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
+}
+
+function api_error($response)
+{
+ return isset($response['Error']);
+}
+
+function api_error_msg($response)
+{
+ return $response['Error']['Code'] . '
+' . $response['Error']['Message'] . '
+function_name:' . $_SERVER['function_name'] . '
+Region:' . $_SERVER['Region'] . '
+namespace:' . $_SERVER['namespace'] . '
+';
+}
+
+function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
+{
+ //'https://github.com/qkqpttgf/OneManager-php/tree/v2-MultiDisk';
+ $source = 'https://github.com/' . $auth . '/' . $project . '/tree/' . $branch;
+ return json_decode(updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'), $source), true)['Response'];
+}
+
+function setConfigResponse($response)
+{
+ return json_decode( $response, true )['Response'];
+}
diff --git a/theme/classic.php b/theme/classic.php
index 56df397..c93a081 100644
--- a/theme/classic.php
+++ b/theme/classic.php
@@ -166,33 +166,33 @@
';
}*/ else {
@@ -705,7 +705,8 @@
tmptextarea.select();
tmptextarea.setSelectionRange(0, tmptextarea.value.length);
document.execCommand("copy");
- alert(tmptextarea.innerHTML+'');
+ //alert(tmptextarea.innerHTML);
+ alert('Success');
}
var sort=0;
function sortby(string) {
diff --git a/theme/purenice.php b/theme/purenice.php
index d94f99f..f1e8bc1 100644
--- a/theme/purenice.php
+++ b/theme/purenice.php
@@ -25,34 +25,38 @@
.list-wrapper{width:80%;margin:0 auto;position:relative;}
.list-container{position:relative;}
.list-header-container{position:relative;width:100%;}
- .list-header-container a.back-link{float:left;color:#ffffff;display:block;margin:10px;height:40px;width:40px;background:#613EEA;line-height:40px;text-decoration:none;text-align:center;border-radius:20px;box-shadow: 0px 4px 12px rgba(97, 62, 234, 0.5);}
+ .list-header-container a.back-link{position:absolute;float:left;color:#ffffff;display:inline-block;margin:10px;height:40px;width:40px;background:#613EEA;line-height:40px;text-decoration:none;text-align:center;border-radius:20px;box-shadow: 0px 4px 12px rgba(97, 62, 234, 0.5);}
.list-header-container a.back-link ion-icon{font-size:20px;}
.list-header-container a.back-link:hover{color:white}
.list-container,.list-header-container,.list-wrapper,a.back-link:hover,body{color:#24292e}
- .table-header{display:block;float:left;margin:10px 0;height:40px;line-height:40px;text-align:left;font-weight:400;color:#A0A4B0;word-break: break-all;word-wrap: break-word;}
+ .table-header{display:block;float:left;margin:10px 0 0 60px;height:40px;line-height:40px;text-align:left;font-weight:400;color:#A0A4B0;word-break: break-all;word-wrap: break-word;}
.fix{height:60px;}
.list-body-container{position:relative;left:0;overflow-x:hidden;overflow-y:auto;box-sizing:border-box;}
.more-disk{border-bottom:1px solid #E8E9EC;height:40px;white-space:nowrap;overflow:auto;}
.more-disk a{display:block;float:left;width:20%;height:38px;text-align:center;font-weight: bold;font-size: 18px;line-height:38px;color:#A6AAB4; }
.more-disk a:hover, .more-disk a[now]{ color: #3B414B;border-bottom:2px solid #FF7D00;}
.list-table{width:100%;border-spacing:0;margin-bottom:20px;}
- .list-table tr{display:block;margin:10px 20px;height:60px;background:#ffffff;box-shadow: 0px 4px 26px rgba(0, 0, 0, 0.06);border-radius: 6px;}
+ .list-table tr{display:block;margin:10px 20px;width:96%;float:left;background:#ffffff;box-shadow: 0px 4px 26px rgba(0, 0, 0, 0.06);border-radius: 6px;}
.list-table tr[data-to]:hover{background:#10C971;color:white;}
.list-table tr[data-to]:hover a{color:white}
- .list-table tr:first-child{background:#F9FAFB;box-shadow:none;}
- .list-table td,.list-table th{display:block;float:left;height:60px;line-height:60px;text-align:left;}
+ .list-table td,.list-table th{display:block;float:left;line-height:60px;text-align:left;}
.list-table td button,.list-table th button{cursor:pointer;color:#ffffff;height:30px;background:#FF7D00;padding:0 20px;border-width:0;border-radius:6px;box-shadow: 0px 4px 12px rgba(255, 125, 0, 0.5);}
.list-table td.file,.list-table th.file{width:60%;color:#171D33;padding-left:20px;}
+ .list-table td.file ion-icon{float:left;margin-top:22px;margin-right:5px;}
+ .list-table td.file:hover>ion-icon,.list-table td.file:hover .operate>ion-icon{color:#fff;}
+ .list-table td.file a[name="filelist"]{float:left;}
+ .list-table td.file a[name="filelist"] img{border-radius:6px;margin-top:20px;}
.list-table td.updated_at,.list-table th.updated_at{width:25%;}
.list-table td.size,.list-table th.size{width:10%;}
.list-table .size,.list-table .updated_at{text-align:right}
.mask{position:absolute;left:0px;top:0px;width:100%;background-color:#000;filter:alpha(opacity=50);opacity:0.5;z-index:2;}
- .operate{display:inline-table;margin:0;margin-right:5px;list-style:none}
+ .operate{display:inline-table;margin:0;margin-right:5px;list-style:none;float:left;}
.operate ul{position:absolute;display:none;background:#fffaaa;border:0;border-radius:5px;margin:0;padding:0 7px;color:#205D67;z-index:1;box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);}
.operate:hover ul{position:absolute;display:inline-table;}
.operate ul li{list-style:none;display:block;line-height:40px;}
.list-table tr[data-to]:hover .operate ul li a{color:black}
+ .list-table tr[data-to]:hover .operate ul li a ion-icon{margin-top:12px;}
.operatediv{position:absolute;background-color:#ffffff;z-index:2;border-radius:10px;background-color:#F9FAFB;}
.loginstyle{width:250px;height:124px;}
@@ -71,10 +75,12 @@
.size, .updated_at{display:none}
}
.update_notice{position:absolute;color:#A6AAB4;left:10%;margin-top:10px;}
- .upload_style{height:60px;margin:20px 20px;background:#ffffff;box-shadow: 0px 4px 26px rgba(0, 0, 0, 0.06);border-radius: 6px;}
- .upload_style .file{position: relative;float:left;width:100px;height:60px;;display: inline-block;background: #FF7D00;border-radius: 6px;overflow: hidden;color: #fff;text-decoration: none;text-align:center;line-height: 60px;font-size:14px;pointer-events: none;}
- .upload_style input[type="file"]{color:#A6AAB4;float:left;height:38px;margin-left:-100px;outline:none;font-size:14px;padding:22px 0 0 38px;}
- .upload_style input[type="button"]{display:block;color:#fff;float:right;height:60px;width:160px;outline:none;font-size:16px;background:#613EEA;border-radius:6px;}
+ .upload_style{height:60px;width:96%;margin:20px;background:#ffffff;box-shadow: 0px 4px 26px rgba(0, 0, 0, 0.06);border-radius: 6px;}
+ /* .upload_style .file{position: relative;float:left;width:100px;height:60px;;display: block;background: #FF7D00;border-radius: 6px;overflow: hidden;color: #fff;text-decoration: none;text-align:center;line-height: 60px;font-size:14px;pointer-events: none;} */
+ .upload_style input[type="file"]{display:block;color:#A6AAB4;float:left;height:38px;margin:20px 0 0 20px;outline:none;font-size:14px;text-align:center;}
+ .upload_style input[type="button"]{display:block;color:#fff;float:right;height:60px;width:160px;outline:none;font-size:16px;background:#613EEA;border-radius:6px;border:0;}
+ .upload_style .list-table tr td{line-height:30px;margin:10px 20px;}
+ .upload_style .list-table tr td button{margin-left:10px;}
@@ -174,8 +180,7 @@
$DPvideo = false;
if ($_SERVER['is_guestup_path']&&!$_SERVER['admin']) { ?>
@@ -868,7 +872,7 @@
tr1.setAttribute('data-to',1);
var td1=document.createElement('td');
tr1.appendChild(td1);
- td1.setAttribute('style','width:30%');
+ td1.setAttribute('class','uplist');
td1.setAttribute('id','upfile_td1_'+timea+'_'+i);
td1.innerHTML=file.name+'
'+size_format(file.size);
var td2=document.createElement('td');