Add files via upload
parent
6efbe394d2
commit
66a78a1685
130
conststr.php
130
conststr.php
|
@ -16,92 +16,64 @@ $constStr = [
|
|||
'ja' => '日本語',
|
||||
],
|
||||
'Week' => [
|
||||
0 => [
|
||||
'en-us' => 'Sunday',
|
||||
'zh-cn' => '星期日',
|
||||
'ja' => '日曜日',
|
||||
'en-us' => [
|
||||
0 => 'Sunday',
|
||||
1 => 'Monday',
|
||||
2 => 'Tuesday',
|
||||
3 => 'Wednesday',
|
||||
4 => 'Thursday',
|
||||
5 => 'Friday',
|
||||
6 => 'Saturday',
|
||||
],
|
||||
1 => [
|
||||
'en-us' => 'Monday',
|
||||
'zh-cn' => '星期一',
|
||||
'ja' => '月曜日',
|
||||
'zh-cn' => [
|
||||
0 => '星期日',
|
||||
1 => '星期一',
|
||||
2 => '星期二',
|
||||
3 => '星期三',
|
||||
4 => '星期四',
|
||||
5 => '星期五',
|
||||
6 => '星期六',
|
||||
],
|
||||
2 => [
|
||||
'en-us' => 'Tuesday',
|
||||
'zh-cn' => '星期二',
|
||||
'ja' => '火曜日',
|
||||
],
|
||||
3 => [
|
||||
'en-us' => 'Wednesday',
|
||||
'zh-cn' => '星期三',
|
||||
'ja' => '水曜日',
|
||||
],
|
||||
4 => [
|
||||
'en-us' => 'Thursday',
|
||||
'zh-cn' => '星期四',
|
||||
'ja' => '木曜日',
|
||||
],
|
||||
5 => [
|
||||
'en-us' => 'Friday',
|
||||
'zh-cn' => '星期五',
|
||||
'ja' => '金曜日',
|
||||
],
|
||||
6 => [
|
||||
'en-us' => 'Saturday',
|
||||
'zh-cn' => '星期六',
|
||||
'ja' => '土曜日',
|
||||
'ja' => [
|
||||
0 => '日曜日',
|
||||
1 => '月曜日',
|
||||
2 => '火曜日',
|
||||
3 => '水曜日',
|
||||
4 => '木曜日',
|
||||
5 => '金曜日',
|
||||
6 => '土曜日',
|
||||
],
|
||||
],
|
||||
'EnvironmentsDescription' => [
|
||||
'admin' => [
|
||||
'en-us' => 'The admin password, Login button will not show when empty',
|
||||
'zh-cn' => '管理密码,不添加时不显示登录页面且无法登录。',
|
||||
'ja' => 'パスワードを管理する、追加しない場合、ログインページは表示されず、ログインできません。',
|
||||
'en-us' => [
|
||||
'admin' => 'The admin password, Login button will not show when empty',
|
||||
'adminloginpage' => 'if set, the Login button will not display, and the login page no longer \'?admin\', it is \'?{this value}\'.',
|
||||
'domain_path' => 'more custom domain, format is a1.com:/dirto/path1|b2.com:/path2',
|
||||
'guestup_path' => 'Set guest upload dir, before set this, the files in this dir will show as normal.',
|
||||
'passfile' => 'The password of dir will save in this file.',
|
||||
'public_path' => 'Show this Onedrive dir when through the long url of API Gateway; public show files less than private.',
|
||||
'sitename' => 'sitename',
|
||||
'Onedrive_ver' => 'Onedrive version',
|
||||
],
|
||||
'adminloginpage' => [
|
||||
'en-us' => 'if set, the Login button will not display, and the login page no longer \'?admin\', it is \'?{this value}\'.',
|
||||
'zh-cn' => '如果设置,登录按钮及页面隐藏。管理登录的页面不再是\'?admin\',而是\'?此设置的值\'。',
|
||||
'ja' => '設定すると、ログインボタンとページが非表示になります。ログインを管理するためのページは\'?admin \'ではなく、\'?この設定の値\'。',
|
||||
'zh-cn' => [
|
||||
'admin' => '管理密码,不添加时不显示登录页面且无法登录。',
|
||||
'adminloginpage' => '如果设置,登录按钮及页面隐藏。管理登录的页面不再是\'?admin\',而是\'?此设置的值\'。',
|
||||
'domain_path' => '使用多个自定义域名时,指定每个域名看到的目录。格式为a1.com:/dirto/path1|b1.com:/path2,比private_path优先。',
|
||||
'guestup_path' => '设置游客上传路径(图床路径),不设置这个值时该目录内容会正常列文件出来,设置后只有上传界面,不显示其中文件(登录后显示)。',
|
||||
'passfile' => '自定义密码文件的名字,可以是\'pppppp\',也可以是\'aaaa.txt\'等等;列目录时不会显示,只有知道密码才能查看或下载此文件。密码是这个文件的内容,可以空格、可以中文;',
|
||||
'public_path' => '使用API长链接访问时,显示网盘文件的路径,不设置时默认为根目录;不能是private_path的上级(public看到的不能比private多,要么看到的就不一样)。',
|
||||
'sitename' => '网站的名称',
|
||||
'Onedrive_ver' => 'Onedrive版本',
|
||||
],
|
||||
'domain_path' => [
|
||||
'en-us' => 'more custom domain, format is a1.com:/dirto/path1|b2.com:/path2',
|
||||
'zh-cn' => '使用多个自定义域名时,指定每个域名看到的目录。格式为a1.com:/dirto/path1|b1.com:/path2,比private_path优先。',
|
||||
'ja' => '複数のカスタムドメイン名を使用する場合、各ドメイン名に表示されるディレクトリを指定します。形式はa1.com:/dirto/path1|b1.com:/path2で、private_pathよりも優先されます。',
|
||||
],
|
||||
'guestup_path' => [
|
||||
'en-us' => 'Set guest upload dir, before set this, the files in this dir will show as normal.',
|
||||
'zh-cn' => '设置游客上传路径(图床路径),不设置这个值时该目录内容会正常列文件出来,设置后只有上传界面,不显示其中文件(登录后显示)。',
|
||||
'ja' => 'マップベッドのパスを設定します。この値が設定されていない場合、ディレクトリの内容は通常ファイルにリストされ、設定後はアップロードインターフェイスのみが表示されます。',
|
||||
],
|
||||
'passfile' => [
|
||||
'en-us' => 'The password of dir will save in this file.',
|
||||
'zh-cn' => '自定义密码文件的名字,可以是\'pppppp\',也可以是\'aaaa.txt\'等等;列目录时不会显示,只有知道密码才能查看或下载此文件。密码是这个文件的内容,可以空格、可以中文;',
|
||||
'ja' => 'カスタムパスワードファイルの名前は、\'pppppp \'、\'aaaa.txt \'などの場合があります。ディレクトリをリストするときには表示されません。パスワードを知っている場合にのみ、このファイルを表示またはダウンロードできます。 パスワードはこのファイルの内容であり、スペースまたは漢字を使用できます。',
|
||||
],
|
||||
'private_path' => [
|
||||
'en-us' => 'Show this Onedrive dir when through custom domain, default is \'/\'.',
|
||||
'zh-cn' => '使用自定义域名访问时,显示网盘文件的路径,不设置时默认为根目录。',
|
||||
'ja' => 'カスタムドメイン名を使用してアクセスする場合、ネットワークディスクファイルのパスが表示されます設定されていない場合は、デフォルトでルートディレクトリになります。',
|
||||
],
|
||||
'public_path' => [
|
||||
'en-us' => 'Show this Onedrive dir when through the long url of API Gateway; public show files less than private.',
|
||||
'zh-cn' => '使用API长链接访问时,显示网盘文件的路径,不设置时默认为根目录;不能是private_path的上级(public看到的不能比private多,要么看到的就不一样)。',
|
||||
'ja' => 'APIのロングリンクアクセスを使用する場合、ネットワークディスクファイルのパスが表示されますが、設定されていない場合はデフォルトでルートディレクトリになり、private_pathの上位にはなりません(publicはprivate以上のものを見ることができません。それ以外は異なります。)。',
|
||||
],
|
||||
'sitename' => [
|
||||
'en-us' => 'sitename',
|
||||
'zh-cn' => '网站的名称',
|
||||
'ja' => 'ウェブサイト名',
|
||||
],
|
||||
'language' => [
|
||||
'en-us' => 'en-us',
|
||||
'zh-cn' => '中文',
|
||||
'ja' => '日本語',
|
||||
],
|
||||
'Onedrive_ver' => [
|
||||
'en-us' => 'Onedrive version',
|
||||
'zh-cn' => 'Onedrive版本',
|
||||
'ja' => 'Onedriveバージョン',
|
||||
'ja' => [
|
||||
'admin' => 'パスワードを管理する、追加しない場合、ログインページは表示されず、ログインできません。',
|
||||
'adminloginpage' => '設定すると、ログインボタンとページが非表示になります。ログインを管理するためのページは\'?admin \'ではなく、\'?この設定の値\'。',
|
||||
'domain_path' => '複数のカスタムドメイン名を使用する場合、各ドメイン名に表示されるディレクトリを指定します。形式はa1.com:/dirto/path1|b1.com:/path2で、private_pathよりも優先されます。',
|
||||
'guestup_path' => 'マップベッドのパスを設定します。この値が設定されていない場合、ディレクトリの内容は通常ファイルにリストされ、設定後はアップロードインターフェイスのみが表示されます。',
|
||||
'passfile' => 'カスタムパスワードファイルの名前は、\'pppppp \'、\'aaaa.txt \'などの場合があります。ディレクトリをリストするときには表示されません。パスワードを知っている場合にのみ、このファイルを表示またはダウンロードできます。 パスワードはこのファイルの内容であり、スペースまたは漢字を使用できます。',
|
||||
'public_path' => 'APIのロングリンクアクセスを使用する場合、ネットワークディスクファイルのパスが表示されますが、設定されていない場合はデフォルトでルートディレクトリになり、private_pathの上位にはなりません(publicはprivate以上のものを見ることができません。それ以外は異なります。)。',
|
||||
'sitename' => 'ウェブサイト名',
|
||||
'Onedrive_ver' => 'Onedriveバージョン',
|
||||
],
|
||||
],
|
||||
'SetSecretsFirst' => [
|
||||
|
|
|
@ -14,14 +14,21 @@ function savecache($key, $value, $exp = 3300)
|
|||
$cache->save($key, $value, $exp);
|
||||
}
|
||||
|
||||
function config_oauth()
|
||||
function getconstStr($str)
|
||||
{
|
||||
global $constStr;
|
||||
$constStr['language'] = $_COOKIE['language'];
|
||||
if ($constStr['language']=='') $constStr['language'] = getConfig('language');
|
||||
if ($constStr['language']=='') $constStr['language'] = 'en-us';
|
||||
if ($constStr[$str][$constStr['language']]!='') return $constStr[$str][$constStr['language']];
|
||||
return $constStr[$str]['en-us'];
|
||||
}
|
||||
|
||||
function config_oauth()
|
||||
{
|
||||
global $constStr;
|
||||
$_SERVER['sitename'] = getConfig('sitename');
|
||||
if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = $constStr['defaultSitename'][$constStr['language']];
|
||||
if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = getconstStr('defaultSitename');
|
||||
$_SERVER['redirect_uri'] = 'https://scfonedrive.github.io';
|
||||
|
||||
if (getConfig('Onedrive_ver')=='MS') {
|
||||
|
@ -311,3 +318,546 @@ function get_thumbnails_url($path = '/')
|
|||
if (isset($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['@microsoft.graph.downloadUrl']);
|
||||
$getoldupinfo = json_decode($getoldupinfo_j , true);
|
||||
if ( json_decode( curl_request($getoldupinfo['uploadUrl']), true)['@odata.context']!='' ) return output($getoldupinfo_j);
|
||||
}
|
||||
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 main($path)
|
||||
{
|
||||
global $exts;
|
||||
global $constStr;
|
||||
config_oauth();
|
||||
$_SERVER['list_path'] = getListpath($_SERVER['HTTP_HOST']);
|
||||
if ($_SERVER['list_path']=='') $_SERVER['list_path'] = '/';
|
||||
$_SERVER['is_guestup_path'] = is_guestup_path($path);
|
||||
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
|
||||
$_SERVER['ajax']=0;
|
||||
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) if ($_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest') $_SERVER['ajax']=1;
|
||||
|
||||
$refresh_token = getConfig('refresh_token');
|
||||
if (!$refresh_token) return get_refresh_token();
|
||||
|
||||
if (getConfig('adminloginpage')=='') {
|
||||
$adminloginpage = 'admin';
|
||||
} else {
|
||||
$adminloginpage = getConfig('adminloginpage');
|
||||
}
|
||||
if ($_GET[$adminloginpage]) {
|
||||
if ($_GET['preview']) {
|
||||
$url = $_SERVER['PHP_SELF'] . '?preview';
|
||||
} else {
|
||||
$url = path_format($_SERVER['PHP_SELF'] . '/');
|
||||
}
|
||||
if (getConfig('admin')!='') {
|
||||
if ($_POST['password1']==getConfig('admin')) {
|
||||
return adminform($_SERVER['function_name'].'admin',md5($_POST['password1']),$url);
|
||||
} else return adminform();
|
||||
} else {
|
||||
return output('', 302, [ 'Location' => $url ]);
|
||||
}
|
||||
}
|
||||
if (getConfig('admin')!='')
|
||||
if ( $_COOKIE['admin']==md5(getConfig('admin')) || $_POST['password1']==getConfig('admin') ) {
|
||||
$_SERVER['admin']=1;
|
||||
$_SERVER['needUpdate'] = needUpdate();
|
||||
} else {
|
||||
$_SERVER['admin']=0;
|
||||
}
|
||||
if ($_GET['setup'])
|
||||
if ($_SERVER['admin']) {
|
||||
// setup Environments. 设置,对环境变量操作
|
||||
return EnvOpt($_SERVER['function_name'], $_SERVER['needUpdate']);
|
||||
} else {
|
||||
$url = path_format($_SERVER['PHP_SELF'] . '/');
|
||||
return output('<script>alert(\''.getconstStr('SetSecretsFirst').'\');</script>', 302, [ 'Location' => $url ]);
|
||||
}
|
||||
$_SERVER['retry'] = 0;
|
||||
|
||||
if (!($_SERVER['access_token'] = getcache('access_token'))) {
|
||||
$ret = json_decode(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
|
||||
)['body'], true);
|
||||
if (!isset($ret['access_token'])) {
|
||||
error_log('failed to get access_token. response' . json_encode($ret));
|
||||
throw new Exception('failed to get access_token.');
|
||||
}
|
||||
$_SERVER['access_token'] = $ret['access_token'];
|
||||
savecache('access_token', $_SERVER['access_token']);
|
||||
}
|
||||
|
||||
if ($_SERVER['ajax']) {
|
||||
if ($_GET['action']=='del_upload_cache'&&substr($_GET['filename'],-4)=='.tmp') {
|
||||
// del '.tmp' without login. 无需登录即可删除.tmp后缀文件
|
||||
$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));
|
||||
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 .'<br>'. $data;
|
||||
$tmp = MSAPI('PATCH',$oldname,$data,$_SERVER['access_token']);
|
||||
if ($tmp['stat']==409) MSAPI('DELETE',$oldname,'',$_SERVER['access_token'])['body'];
|
||||
$path1 = path_format($_SERVER['list_path'] . path_format($path));
|
||||
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));
|
||||
savecache('path_' . $path1, json_decode('{}',true), 1);
|
||||
return $tmp;
|
||||
}
|
||||
} else {
|
||||
if ($_SERVER['ajax']) return output(getconstStr('RefleshtoLogin'),401);
|
||||
}
|
||||
$_SERVER['ishidden'] = passhidden($path);
|
||||
if ($_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);
|
||||
if (isset($files['file']) && !$_GET['preview']) {
|
||||
// is file && not preview mode
|
||||
if ($_SERVER['ishidden']<4) return output('', 302, [ 'Location' => $files['@microsoft.graph.downloadUrl'] ]);
|
||||
}
|
||||
if ( isset($files['folder']) || isset($files['file']) ) {
|
||||
return render_list($path, $files);
|
||||
} else {
|
||||
return message('<div style="margin:8px;">' . $files['error']['message'] . '</div><a href="javascript:history.back(-1)">'.getconstStr('Back').'</a>', $files['error']['code'], $files['error']['stat']);
|
||||
}
|
||||
}
|
||||
|
||||
function list_files($path)
|
||||
{
|
||||
$path = path_format($path);
|
||||
if ($_SERVER['is_guestup_path']&&!$_SERVER['admin']) {
|
||||
$files = json_decode('{"folder":{}}', true);
|
||||
} elseif ($_SERVER['ishidden']==4) {
|
||||
$files = json_decode('{"folder":{}}', true);
|
||||
} else {
|
||||
$files = fetch_files($path);
|
||||
}
|
||||
if ( isset($files['folder']) || isset($files['file']) || isset($files['error']) ) {
|
||||
return $files;
|
||||
} else {
|
||||
error_log( json_encode($files) . ' Network Error<br>' );
|
||||
$_SERVER['retry']++;
|
||||
if ($_SERVER['retry'] < 3) {
|
||||
return list_files($path);
|
||||
} else return $files;
|
||||
}
|
||||
}
|
||||
|
||||
function adminform($name = '', $pass = '', $path = '')
|
||||
{
|
||||
global $constStr;
|
||||
$statusCode = 401;
|
||||
$html = '<html><head><title>'.getconstStr('AdminLogin').'</title><meta charset=utf-8></head>';
|
||||
if ($name!=''&&$pass!='') {
|
||||
$html .= '<body>'.getconstStr('LoginSuccess').'</body></html>';
|
||||
$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 .= '
|
||||
<body>
|
||||
<div>
|
||||
<center><h4>'.getconstStr('InputPassword').'</h4>
|
||||
<form action="" method="post">
|
||||
<div>
|
||||
<input name="password1" type="password"/>
|
||||
<input type="submit" value="'.getconstStr('Login').'">
|
||||
</div>
|
||||
</form>
|
||||
</center>
|
||||
</div>
|
||||
';
|
||||
$html .= '</body></html>';
|
||||
return output($html,$statusCode);
|
||||
}
|
||||
|
||||
function adminoperate($path)
|
||||
{
|
||||
global $constStr;
|
||||
$path1 = path_format($_SERVER['list_path'] . path_format($path));
|
||||
if (substr($path1,-1)=='/') $path1=substr($path1,0,-1);
|
||||
$tmparr['statusCode'] = 0;
|
||||
if ($_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 ($_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 ($_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']);
|
||||
//savecache('path_' . $path1, json_decode('{}',true), 1);
|
||||
return output($result['body'], $result['stat']);
|
||||
}
|
||||
if ($_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'] . '/' );
|
||||
savecache('path_' . $path2, json_decode('{}',true), 1);
|
||||
return output($result['body'], $result['stat']);
|
||||
} else {
|
||||
return output('{"error":"Can not Move!"}', 403);
|
||||
}
|
||||
}
|
||||
if ($_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']. '<hr><a href="javascript:history.back(-1)">上一页</a>','Error',403);
|
||||
}
|
||||
if ($_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 ($_GET['RefreshCache']) {
|
||||
//savecache('path_' . $path1, json_decode('{}',true), 1);
|
||||
return output('<meta http-equiv="refresh" content="2;URL=./">'.getconstStr('RefreshCache'), 302);
|
||||
}
|
||||
return $tmparr;
|
||||
}
|
||||
|
||||
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_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 fetch_files($path = '/')
|
||||
{
|
||||
$path1 = path_format($path);
|
||||
$path = path_format($_SERVER['list_path'] . path_format($path));
|
||||
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
|
||||
$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)';
|
||||
$arr = curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']]);
|
||||
if ($arr['stat']<500) {
|
||||
$files = json_decode($arr['body'], true);
|
||||
// echo $path . '<br><pre>' . json_encode($files, JSON_PRETTY_PRINT) . '</pre>';
|
||||
if (isset($files['folder'])) {
|
||||
if ($files['folder']['childCount']>200) {
|
||||
// files num > 200 , then get nextlink
|
||||
$page = $_POST['pagenum']==''?1:$_POST['pagenum'];
|
||||
$files=fetch_files_children($files, $path, $page);
|
||||
} else {
|
||||
// files num < 200 , then cache
|
||||
savecache('path_' . $path, $files);
|
||||
}
|
||||
}
|
||||
if (isset($files['error'])) {
|
||||
$files['error']['stat'] = $arr['stat'];
|
||||
}
|
||||
} else {
|
||||
error_log($arr['body']);
|
||||
$files = json_decode( '{"unknownError":{ "stat":'.$arr['stat'].',"message":"'.$arr['body'].'"}}', true);
|
||||
}
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
|
||||
function fetch_files_children($files, $path, $page)
|
||||
{
|
||||
$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['@microsoft.graph.downloadUrl'])['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';
|
||||
} else {
|
||||
$url .= '/children?$select=name,size,file,folder,parentReference,lastModifiedDateTime';
|
||||
}
|
||||
$children = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true);
|
||||
// echo $url . '<br><pre>' . json_encode($children, JSON_PRETTY_PRINT) . '</pre>';
|
||||
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 . '<br><pre>' . json_encode($children, JSON_PRETTY_PRINT) . '</pre>';
|
||||
$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 . '<br><pre>' . json_encode($children, JSON_PRETTY_PRINT) . '</pre>';
|
||||
$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;
|
||||
|
||||
$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 = '<!--
|
||||
github : https://github.com/qkqpttgf/OneManager-php
|
||||
-->' . ob_get_clean();
|
||||
if ($_SERVER['Set-Cookie']!='') return output($html, $statusCode, [ 'Set-Cookie' => $_SERVER['Set-Cookie'], 'Content-Type' => 'text/html' ]);
|
||||
return output($html,$statusCode);
|
||||
}
|
||||
|
|
|
@ -13,17 +13,19 @@ function getpath()
|
|||
|
||||
function getGET()
|
||||
{
|
||||
$getstr = urldecode(substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'],'?')));
|
||||
while (substr($getstr, 0, 1) == '/' || substr($getstr, 0, 1) == '?') $getstr = substr($getstr, 1);
|
||||
$getstrarr = explode("&",$getstr);
|
||||
foreach ($getstrarr as $getvalues) {
|
||||
if ($getvalues != '') {
|
||||
$pos = strpos($getvalues, "=");
|
||||
$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 ($pos > 0) {
|
||||
$getarry[urldecode(substr($getvalues, 0, $pos))] = urldecode(substr($getvalues, $pos + 1));
|
||||
} else {
|
||||
$getarry[urldecode($getvalues)] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +69,7 @@ function get_refresh_token()
|
|||
savecache('access_token', $ret['access_token'], $ret['expires_in'] - 60);
|
||||
$str .= '
|
||||
<meta http-equiv="refresh" content="5;URL=' . $url . '">';
|
||||
return message($str, $constStr['WaitJumpIndex'][$constStr['language']]);
|
||||
return message($str, getconstStr('WaitJumpIndex'));
|
||||
}
|
||||
return message('<pre>' . $tmp['body'] . '</pre>', $tmp['stat']);
|
||||
//return message('<pre>' . json_encode($ret, JSON_PRETTY_PRINT) . '</pre>', 500);
|
||||
|
@ -75,7 +77,7 @@ function get_refresh_token()
|
|||
if ($_GET['install3']) {
|
||||
if (getConfig('Onedrive_ver')=='MS' || getConfig('Onedrive_ver')=='CN' || getConfig('Onedrive_ver')=='MSC') {
|
||||
return message('
|
||||
<a href="" id="a1">'.$constStr['JumptoOffice'][$constStr['language']].'</a>
|
||||
<a href="" id="a1">'.getconstStr('JumptoOffice').'</a>
|
||||
<script>
|
||||
url=location.protocol + "//" + location.host + "'.$url.'";
|
||||
url="'. $_SERVER['oauth_url'] .'authorize?scope='. $_SERVER['scope'] .'&response_type=code&client_id='. $_SERVER['client_id'] .'&redirect_uri='. $_SERVER['redirect_uri'] . '&state=' .'"+encodeURIComponent(url);
|
||||
|
@ -83,7 +85,7 @@ function get_refresh_token()
|
|||
//window.open(url,"_blank");
|
||||
location.href = url;
|
||||
</script>
|
||||
', $constStr['Wait'][$constStr['language']].' 1s', 201);
|
||||
', getconstStr('Wait').' 1s', 201);
|
||||
}
|
||||
}
|
||||
if ($_GET['install2']) {
|
||||
|
@ -95,12 +97,12 @@ function get_refresh_token()
|
|||
$tmp['client_secret'] = $_POST['client_secret'];
|
||||
}
|
||||
$response = setConfig($tmp);
|
||||
$title = $constStr['MayinEnv'][$constStr['language']];
|
||||
$html = $constStr['Wait'][$constStr['language']] . ' 3s<meta http-equiv="refresh" content="3;URL=' . $url . '?install3">';
|
||||
$title = getconstStr('MayinEnv');
|
||||
$html = getconstStr('Wait') . ' 3s<meta http-equiv="refresh" content="3;URL=' . $url . '?install3">';
|
||||
if (!$response) {
|
||||
$html = $response . '<br>
|
||||
Can not write config to file.<br>
|
||||
<button onclick="location.href = location.href;">'.$constStr['Reflesh'][$constStr['language']].'</button>';
|
||||
<button onclick="location.href = location.href;">'.getconstStr('Reflesh').'</button>';
|
||||
$title = 'Error';
|
||||
}
|
||||
return message($html, $title, 201);
|
||||
|
@ -112,7 +114,7 @@ Can not write config to file.<br>
|
|||
$tmp['language'] = $_POST['language'];
|
||||
$response = setConfig($tmp);
|
||||
if ($response) {
|
||||
if ($constStr['language']!='zh-cn') {
|
||||
if (getconstStr('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";
|
||||
|
@ -121,22 +123,22 @@ Can not write config to file.<br>
|
|||
$html = '
|
||||
<form action="?install2" method="post">
|
||||
Onedrive_Ver:<br>
|
||||
<label><input type="radio" name="Onedrive_ver" value="MS" checked>MS: '.$constStr['OndriveVerMS'][$constStr['language']].'</label><br>
|
||||
<label><input type="radio" name="Onedrive_ver" value="CN">CN: '.$constStr['OndriveVerCN'][$constStr['language']].'</label><br>
|
||||
<label><input type="radio" name="Onedrive_ver" value="MSC" onclick="document.getElementById(\'secret\').style.display=\'\';">MSC: '.$constStr['OndriveVerMSC'][$constStr['language']].'
|
||||
<label><input type="radio" name="Onedrive_ver" value="MS" checked>MS: '.getconstStr('OndriveVerMS').'</label><br>
|
||||
<label><input type="radio" name="Onedrive_ver" value="CN">CN: '.getconstStr('OndriveVerCN').'</label><br>
|
||||
<label><input type="radio" name="Onedrive_ver" value="MSC" onclick="document.getElementById(\'secret\').style.display=\'\';">MSC: '.getconstStr('OndriveVerMSC').'
|
||||
<div id="secret" style="display:none">
|
||||
<a href="'.$app_url.'" target="_blank">'.$constStr['GetSecretIDandKEY'][$constStr['language']].'</a><br>
|
||||
<a href="'.$app_url.'" target="_blank">'.getconstStr('GetSecretIDandKEY').'</a><br>
|
||||
client_secret:<input type="text" name="client_secret"><br>
|
||||
client_id(12345678-90ab-cdef-ghij-klmnopqrstuv):<input type="text" name="client_id"><br>
|
||||
</div>
|
||||
</label><br>
|
||||
<input type="submit" value="'.$constStr['Submit'][$constStr['language']].'">
|
||||
<input type="submit" value="'.getconstStr('Submit').'">
|
||||
</form>';
|
||||
$title = 'Install';
|
||||
} else {
|
||||
$html = $response . '<br>
|
||||
Can not write config to file.<br>
|
||||
<button onclick="location.href = location.href;">'.$constStr['Reflesh'][$constStr['language']].'</button>';
|
||||
<button onclick="location.href = location.href;">'.getconstStr('Reflesh').'</button>';
|
||||
$title = 'Error';
|
||||
}
|
||||
return message($html, $title, 201);
|
||||
|
@ -156,14 +158,14 @@ run Writeable.sh.';
|
|||
}
|
||||
$html .= '
|
||||
<form action="?install1" method="post" onsubmit="return adminnotnull(this);">
|
||||
<label>admin:<input name="admin" type="password" placeholder="' . $constStr['EnvironmentsDescription']['admin'][$constStr['language']] . '" size="' . strlen($constStr['EnvironmentsDescription']['admin'][$constStr['language']]) . '"></label><br>
|
||||
<label>admin:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription']['admin') . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>
|
||||
language:<br>';
|
||||
foreach ($constStr['languages'] as $key1 => $value1) {
|
||||
foreach (getconstStr('languages'] as $key1 => $value1) {
|
||||
$html .= '
|
||||
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
|
||||
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==getconstStr('language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
|
||||
}
|
||||
$html .= '<br>
|
||||
<input type="submit" value="'.$constStr['Submit'][$constStr['language']].'">
|
||||
<input type="submit" value="'.getconstStr('Submit').'">
|
||||
</form>
|
||||
<script>
|
||||
function changelanguage(str)
|
||||
|
@ -180,7 +182,7 @@ language:<br>';
|
|||
return true;
|
||||
}
|
||||
</script>';
|
||||
$title = $constStr['SelectLanguage'][$constStr['language']];
|
||||
$title = getconstStr('SelectLanguage');
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= 'refresh_token not exist, <a href="?install0">click to install.</a>';
|
||||
|
@ -267,3 +269,129 @@ function setConfig($arr)
|
|||
\';';
|
||||
return file_put_contents('config.php', $prestr . json_encode($envs, JSON_PRETTY_PRINT) . $aftstr);
|
||||
}
|
||||
|
||||
function EnvOpt($function_name, $needUpdate = 0)
|
||||
{
|
||||
global $constStr;
|
||||
$constEnv = [
|
||||
//'admin',
|
||||
'adminloginpage', 'domain_path', 'guestup_path', 'passfile',
|
||||
//'private_path',
|
||||
'public_path', 'sitename', 'language', 'theme'
|
||||
];
|
||||
asort($constEnv);
|
||||
$html = '<title>OneManager '.getconstStr('Setup').'</title>';
|
||||
/*if ($_POST['updateProgram']==getconstStr('updateProgram')) {
|
||||
$response = json_decode(updataProgram($function_name, $Region, $namespace), true)['Response'];
|
||||
if (isset($response['Error'])) {
|
||||
$html = $response['Error']['Code'] . '<br>
|
||||
' . $response['Error']['Message'] . '<br><br>
|
||||
function_name:' . $_SERVER['function_name'] . '<br>
|
||||
Region:' . $_SERVER['Region'] . '<br>
|
||||
namespace:' . $namespace . '<br>
|
||||
<button onclick="location.href = location.href;">'.getconstStr('Reflesh').'</button>';
|
||||
$title = 'Error';
|
||||
} else {
|
||||
$html .= getconstStr('UpdateSuccess') . '<br>
|
||||
<button onclick="location.href = location.href;">'.getconstStr('Reflesh').'</button>';
|
||||
$title = getconstStr('Setup');
|
||||
}
|
||||
return message($html, $title);
|
||||
}*/
|
||||
if ($_POST['submit1']) {
|
||||
foreach ($_POST as $k => $v) {
|
||||
if (in_array($k, $constEnv)) {
|
||||
//if (!(getConfig($k)==''&&$v==''))
|
||||
$tmp[$k] = $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 = setConfig($tmp);
|
||||
if (!$response) {
|
||||
$html = $response . '<br>
|
||||
<button onclick="location.href = location.href;">'.getconstStr('Reflesh').'</button>';
|
||||
$title = 'Error';
|
||||
} else {
|
||||
$html .= '<script>location.href=location.href</script>';
|
||||
}
|
||||
}
|
||||
if ($_GET['preview']) {
|
||||
$preurl = $_SERVER['PHP_SELF'] . '?preview';
|
||||
} else {
|
||||
$preurl = path_format($_SERVER['PHP_SELF'] . '/');
|
||||
}
|
||||
$html .= '
|
||||
<a href="'.$preurl.'">'.getconstStr('Back').'</a>
|
||||
<a href="https://github.com/qkqpttgf/OneManager-php">Github</a><br>';
|
||||
/*if ($needUpdate) {
|
||||
$html .= '<pre>' . $_SERVER['github_version'] . '</pre>
|
||||
<form action="" method="post">
|
||||
<input type="submit" name="updateProgram" value="'.getconstStr('updateProgram').'">
|
||||
</form>';
|
||||
} else {
|
||||
$html .= getconstStr('NotNeedUpdate');
|
||||
}*/
|
||||
$html .= '
|
||||
<form action="" method="post">
|
||||
<table border=1 width=100%>';
|
||||
foreach ($constEnv as $key) {
|
||||
if ($key=='language') {
|
||||
$html .= '
|
||||
<tr>
|
||||
<td><label>' . $key . '</label></td>
|
||||
<td width=100%>
|
||||
<select name="' . $key .'">';
|
||||
foreach (getconstStr('languages'] as $key1 => $value1) {
|
||||
$html .= '
|
||||
<option value="'.$key1.'" '.($key1==getConfig($key)?'selected="selected"':'').'>'.$value1.'</option>';
|
||||
}
|
||||
$html .= '
|
||||
</select>
|
||||
</td>
|
||||
</tr>';
|
||||
} elseif ($key=='theme') {
|
||||
$theme_arr = scandir('theme');
|
||||
$html .= '
|
||||
<tr>
|
||||
<td><label>' . $key . '</label></td>
|
||||
<td width=100%>
|
||||
<select name="' . $key .'">';
|
||||
foreach ($theme_arr as $v1) {
|
||||
if ($v1!='.' && $v1!='..') $html .= '
|
||||
<option value="'.$v1.'" '.($v1==getConfig($key)?'selected="selected"':'').'>'.$v1.'</option>';
|
||||
}
|
||||
$html .= '
|
||||
</select>
|
||||
</td>
|
||||
</tr>';
|
||||
} elseif ($key=='domain_path') {
|
||||
$tmp = getConfig($key);
|
||||
$domain_path = '';
|
||||
foreach ($tmp as $k1 => $v1) {
|
||||
$domain_path .= $k1 . ':' . $v1 . '|';
|
||||
}
|
||||
$domain_path = substr($domain_path, 0, -1);
|
||||
$html .= '
|
||||
<tr>
|
||||
<td><label>' . $key . '</label></td>
|
||||
<td width=100%><input type="text" name="' . $key .'" value="' . $domain_path . '" placeholder="' . getconstStr('EnvironmentsDescription')[$key] . '" style="width:100%"></td>
|
||||
</tr>';
|
||||
} else $html .= '
|
||||
<tr>
|
||||
<td><label>' . $key . '</label></td>
|
||||
<td width=100%><input type="text" name="' . $key .'" value="' . getConfig($key) . '" placeholder="' . getconstStr('EnvironmentsDescription')[$key] . '" style="width:100%"></td>
|
||||
</tr>';
|
||||
}
|
||||
$html .= '</table>
|
||||
<input type="submit" name="submit1" value="'.getconstStr('Setup').'">
|
||||
</form>';
|
||||
return message($html, getconstStr('Setup'));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,213 @@
|
|||
<?php
|
||||
|
||||
function printInput($event, $context)
|
||||
{
|
||||
if (strlen(json_encode($event['body']))>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));
|
||||
}
|
||||
}
|
||||
|
||||
function GetPathSetting($event, $context)
|
||||
{
|
||||
$_SERVER['function_name'] = $context['function_name'];
|
||||
$host_name = $event['headers']['host'];
|
||||
$serviceId = $event['requestContext']['serviceId'];
|
||||
$public_path = path_format(getenv('public_path'));
|
||||
$private_path = path_format(getenv('private_path'));
|
||||
$domain_path = getenv('domain_path');
|
||||
$tmp_path='';
|
||||
if ($domain_path!='') {
|
||||
$tmp = explode("|",$domain_path);
|
||||
foreach ($tmp as $multidomain_paths){
|
||||
$pos = strpos($multidomain_paths,":");
|
||||
$tmp_path = path_format(substr($multidomain_paths,$pos+1));
|
||||
if (substr($multidomain_paths,0,$pos)==$host_name) $private_path=$tmp_path;
|
||||
}
|
||||
}
|
||||
// public_path is not Parent Dir of private_path. public_path 不能是 private_path 的上级目录。
|
||||
if ($tmp_path!='') if ($public_path == substr($tmp_path,0,strlen($public_path))) $public_path=$tmp_path;
|
||||
if ($public_path == substr($private_path,0,strlen($public_path))) $public_path=$private_path;
|
||||
if ( $serviceId === substr($host_name,0,strlen($serviceId)) ) {
|
||||
$_SERVER['base_path'] = '/'.$event['requestContext']['stage'].'/'.$_SERVER['function_name'].'/';
|
||||
$_SERVER['list_path'] = $public_path;
|
||||
$_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['list_path'] = $private_path;
|
||||
$_SERVER['Region'] = getenv('Region');
|
||||
$path = substr($event['path'], strlen($event['requestContext']['path']));
|
||||
}
|
||||
if (substr($path,-1)=='/') $path=substr($path,0,-1);
|
||||
if (empty($_SERVER['list_path'])) {
|
||||
$_SERVER['list_path'] = '/';
|
||||
} else {
|
||||
$_SERVER['list_path'] = spurlencode($_SERVER['list_path'],'/') ;
|
||||
}
|
||||
$_SERVER['is_imgup_path'] = is_imgup_path($path);
|
||||
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
|
||||
$_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp'];
|
||||
$_SERVER['ajax']=0;
|
||||
if ($event['headers']['x-requested-with']=='XMLHttpRequest') {
|
||||
$_SERVER['ajax']=1;
|
||||
}
|
||||
/*
|
||||
$referer = $event['headers']['referer'];
|
||||
$tmpurl = substr($referer,strpos($referer,'//')+2);
|
||||
$refererhost = substr($tmpurl,0,strpos($tmpurl,'/'));
|
||||
if ($refererhost==$host_name) {
|
||||
// Guest only upload from this site. 仅游客上传用,referer不对就空值,无法上传
|
||||
$_SERVER['current_url'] = substr($referer,0,strpos($referer,'//')) . '//' . $host_name.$_SERVER['PHP_SELF'];
|
||||
} else {
|
||||
$_SERVER['current_url'] = '';
|
||||
}
|
||||
*/
|
||||
return $path;
|
||||
}
|
||||
|
||||
function get_refresh_token($function_name, $Region, $Namespace)
|
||||
{
|
||||
global $constStr;
|
||||
$url = path_format($_SERVER['PHP_SELF'] . '/');
|
||||
if ($_GET['authorization_code'] && isset($_GET['code'])) {
|
||||
$ret = json_decode(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']), true);
|
||||
if (isset($ret['refresh_token'])) {
|
||||
$tmptoken=$ret['refresh_token'];
|
||||
$str = '
|
||||
refresh_token :<br>';
|
||||
for ($i=1;strlen($tmptoken)>0;$i++) {
|
||||
$t['t' . $i] = substr($tmptoken,0,128);
|
||||
$str .= '
|
||||
t' . $i . ':<textarea readonly style="width: 95%">' . $t['t' . $i] . '</textarea><br><br>';
|
||||
$tmptoken=substr($tmptoken,128);
|
||||
}
|
||||
$str .= '
|
||||
Add t1-t'.--$i.' to environments.
|
||||
<script>
|
||||
var texta=document.getElementsByTagName(\'textarea\');
|
||||
for(i=0;i<texta.length;i++) {
|
||||
texta[i].style.height = texta[i].scrollHeight + \'px\';
|
||||
}
|
||||
document.cookie=\'language=; path=/\';
|
||||
</script>';
|
||||
if (getenv('SecretId')!='' && getenv('SecretKey')!='') {
|
||||
echo updataEnvironment($t, $function_name, $Region, $Namespace);
|
||||
$str .= '
|
||||
<meta http-equiv="refresh" content="5;URL=' . $url . '">';
|
||||
}
|
||||
return message($str, $constStr['WaitJumpIndex'][$constStr['language']]);
|
||||
}
|
||||
return message('<pre>' . json_encode($ret, JSON_PRETTY_PRINT) . '</pre>', 500);
|
||||
}
|
||||
if ($_GET['install2']) {
|
||||
if (getenv('Onedrive_ver')=='MS' || getenv('Onedrive_ver')=='CN' || getenv('Onedrive_ver')=='MSC') {
|
||||
return message('
|
||||
<a href="" id="a1">'.$constStr['JumptoOffice'][$constStr['language']].'</a>
|
||||
<script>
|
||||
url=location.protocol + "//" + location.host + "'.$url.'";
|
||||
url="'. $_SERVER['oauth_url'] .'authorize?scope='. $_SERVER['scope'] .'&response_type=code&client_id='. $_SERVER['client_id'] .'&redirect_uri='. $_SERVER['redirect_uri'] . '&state=' .'"+encodeURIComponent(url);
|
||||
document.getElementById(\'a1\').href=url;
|
||||
//window.open(url,"_blank");
|
||||
location.href = url;
|
||||
</script>
|
||||
', $constStr['Wait'][$constStr['language']].' 1s', 201);
|
||||
}
|
||||
}
|
||||
if ($_GET['install1']) {
|
||||
// echo $_POST['Onedrive_ver'];
|
||||
if ($_POST['Onedrive_ver']=='MS' || $_POST['Onedrive_ver']=='CN' || $_POST['Onedrive_ver']=='MSC') {
|
||||
$tmp['Onedrive_ver'] = $_POST['Onedrive_ver'];
|
||||
$tmp['language'] = $_COOKIE['language'];
|
||||
$tmp['client_id'] = $_POST['client_id'];
|
||||
$tmp['client_secret'] = equal_replace(base64_encode($_POST['client_secret']));
|
||||
$response = json_decode(updataEnvironment($tmp, $_SERVER['function_name'], $_SERVER['Region'], $Namespace), true)['Response'];
|
||||
sleep(2);
|
||||
$title = $constStr['MayinEnv'][$constStr['language']];
|
||||
$html = $constStr['Wait'][$constStr['language']] . ' 3s<meta http-equiv="refresh" content="3;URL=' . $url . '?install2">';
|
||||
if (isset($response['Error'])) {
|
||||
$html = $response['Error']['Code'] . '<br>
|
||||
' . $response['Error']['Message'] . '<br><br>
|
||||
function_name:' . $_SERVER['function_name'] . '<br>
|
||||
Region:' . $_SERVER['Region'] . '<br>
|
||||
namespace:' . $Namespace . '<br>
|
||||
<button onclick="location.href = location.href;">'.$constStr['Reflesh'][$constStr['language']].'</button>';
|
||||
$title = 'Error';
|
||||
}
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
}
|
||||
if ($_GET['install0']) {
|
||||
if (getenv('SecretId')=='' || getenv('SecretKey')=='') return message($constStr['SetSecretsFirst'][$constStr['language']].'<button onclick="location.href = location.href;">'.$constStr['Reflesh'][$constStr['language']].'</button><br>'.'(<a href="https://console.cloud.tencent.com/cam/capi" target="_blank">'.$constStr['Create'][$constStr['language']].' SecretId & SecretKey</a>)', 'Error', 500);
|
||||
$response = json_decode(SetConfig($_SERVER['function_name'], $_SERVER['Region'], $Namespace), true)['Response'];
|
||||
if (isset($response['Error'])) {
|
||||
$html = $response['Error']['Code'] . '<br>
|
||||
' . $response['Error']['Message'] . '<br><br>
|
||||
function_name:' . $_SERVER['function_name'] . '<br>
|
||||
Region:' . $_SERVER['Region'] . '<br>
|
||||
namespace:' . $Namespace . '<br>
|
||||
<button onclick="location.href = location.href;">'.$constStr['Reflesh'][$constStr['language']].'</button>';
|
||||
$title = 'Error';
|
||||
} else {
|
||||
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=one_scf&redirectUrl=".$_SERVER['redirect_uri']."&allowImplicitFlow=false&ru=".urlencode($ru);
|
||||
$app_url = "https://apps.dev.microsoft.com/?deepLink=".urlencode($deepLink);
|
||||
$html = '
|
||||
<form action="?install1" method="post">
|
||||
Onedrive_Ver:<br>
|
||||
<label><input type="radio" name="Onedrive_ver" value="MS" checked>MS: '.$constStr['OndriveVerMS'][$constStr['language']].'</label><br>
|
||||
<label><input type="radio" name="Onedrive_ver" value="CN">CN: '.$constStr['OndriveVerCN'][$constStr['language']].'</label><br>
|
||||
<label><input type="radio" name="Onedrive_ver" value="MSC" onclick="document.getElementById(\'secret\').style.display=\'\';">MSC: '.$constStr['OndriveVerMSC'][$constStr['language']].'
|
||||
<div id="secret" style="display:none">
|
||||
<a href="'.$app_url.'" target="_blank">'.$constStr['GetSecretIDandKEY'][$constStr['language']].'</a><br>
|
||||
client_secret:<input type="text" name="client_secret"><br>
|
||||
client_id(12345678-90ab-cdef-ghij-klmnopqrstuv):<input type="text" name="client_id"><br>
|
||||
</div>
|
||||
</label><br>
|
||||
<input type="submit" value="'.$constStr['Submit'][$constStr['language']].'">
|
||||
</form>';
|
||||
$title = 'Install';
|
||||
}
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '
|
||||
<form action="?install0" method="post">
|
||||
language:<br>';
|
||||
foreach ($constStr['languages'] as $key1 => $value1) {
|
||||
$html .= '
|
||||
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
|
||||
}
|
||||
$html .= '<br>
|
||||
<input type="submit" value="'.$constStr['Submit'][$constStr['language']].'">
|
||||
</form>
|
||||
<script>
|
||||
function changelanguage(str)
|
||||
{
|
||||
document.cookie=\'language=\'+str+\'; path=/\';
|
||||
location.href = location.href;
|
||||
}
|
||||
</script>';
|
||||
$title = $constStr['SelectLanguage'][$constStr['language']];
|
||||
return message($html, $title, 201);
|
||||
}
|
|
@ -0,0 +1,581 @@
|
|||
<?php
|
||||
|
||||
function getpath()
|
||||
{
|
||||
$_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/');
|
||||
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
||||
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
|
||||
else $path = $_SERVER['REQUEST_URI'];
|
||||
$path = path_format( substr($path, strlen($_SERVER['base_path'])) );
|
||||
return $path;
|
||||
//return spurlencode($path, '/');
|
||||
}
|
||||
|
||||
function getGET()
|
||||
{
|
||||
$getstr = urldecode(substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'],'?')));
|
||||
while (substr($getstr, 0, 1) == '/' || substr($getstr, 0, 1) == '?') $getstr = substr($getstr, 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 getcache($str)
|
||||
{
|
||||
$cache = null;
|
||||
$cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), '.Onedrive');
|
||||
return $cache->fetch($str);
|
||||
}
|
||||
|
||||
function savecache($key, $value, $exp = 3300)
|
||||
{
|
||||
$cache = null;
|
||||
$cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), '.Onedrive');
|
||||
$cache->save($key, $value, $exp);
|
||||
}
|
||||
|
||||
function config_oauth()
|
||||
{
|
||||
global $constStr;
|
||||
$constStr['language'] = $_COOKIE['language'];
|
||||
if ($constStr['language']=='') $constStr['language'] = getConfig('language');
|
||||
if ($constStr['language']=='') $constStr['language'] = 'en-us';
|
||||
$_SERVER['sitename'] = getConfig('sitename');
|
||||
if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = $constStr['defaultSitename'][$constStr['language']];
|
||||
$_SERVER['redirect_uri'] = 'https://scfonedrive.github.io';
|
||||
|
||||
if (getConfig('Onedrive_ver')=='MS') {
|
||||
// MS
|
||||
// https://portal.azure.com
|
||||
$_SERVER['client_id'] = '4da3e7f2-bf6d-467c-aaf0-578078f0bf7c';
|
||||
$_SERVER['client_secret'] = '7/+ykq2xkfx:.DWjacuIRojIaaWL0QI6';
|
||||
$_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('Onedrive_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('Onedrive_ver')=='MSC') {
|
||||
// MS Customer
|
||||
// https://portal.azure.com
|
||||
$_SERVER['client_id'] = getConfig('client_id');
|
||||
$_SERVER['client_secret'] = getConfig('client_secret');
|
||||
$_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';
|
||||
}
|
||||
|
||||
$_SERVER['client_secret'] = urlencode($_SERVER['client_secret']);
|
||||
$_SERVER['scope'] = urlencode($_SERVER['scope']);
|
||||
}
|
||||
|
||||
function getListpath($domain)
|
||||
{
|
||||
$domain_path = getConfig('domain_path');
|
||||
/*$tmp_path='';
|
||||
if ($domain_path!='') {
|
||||
$tmp = explode("|",$domain_path);
|
||||
foreach ($tmp as $multidomain_paths){
|
||||
$pos = strpos($multidomain_paths,":");
|
||||
$tmp_path = path_format(substr($multidomain_paths,$pos+1));
|
||||
if (substr($multidomain_paths,0,$pos)==$host_name) $private_path=$tmp_path;
|
||||
}
|
||||
}*/
|
||||
if (isset($domain_path[$domain])) return spurlencode($domain_path[$domain],'/');
|
||||
return spurlencode(getConfig('public_path'),'/');
|
||||
}
|
||||
|
||||
function path_format($path)
|
||||
{
|
||||
$path = '/' . $path;
|
||||
while (strpos($path, '//') !== FALSE) {
|
||||
$path = str_replace('//', '/', $path);
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
function spurlencode($str,$splite='')
|
||||
{
|
||||
$str = str_replace(' ', '%20',$str);
|
||||
$tmp='';
|
||||
if ($splite!='') {
|
||||
$tmparr=explode($splite,$str);
|
||||
for($x=0;$x<count($tmparr);$x++) {
|
||||
if ($tmparr[$x]!='') $tmp .= $splite . urlencode($tmparr[$x]);
|
||||
}
|
||||
} else {
|
||||
$tmp = urlencode($str);
|
||||
}
|
||||
$tmp = str_replace('%2520', '%20',$tmp);
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
function is_guestup_path($path)
|
||||
{
|
||||
if (path_format('/'.path_format(urldecode($_SERVER['list_path'].path_format($path))).'/')==path_format('/'.path_format(getConfig('guestup_path')).'/')&&getConfig('guestup_path')!='') return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
function curl_request($url, $data = false, $headers = [])
|
||||
{
|
||||
if (!isset($headers['Accept'])) $headers['Accept'] = '*/*';
|
||||
if (!isset($headers['Referer'])) $headers['Referer'] = $url;
|
||||
if (!isset($headers['Content-Type'])) $headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
$sendHeaders = array();
|
||||
foreach ($headers as $headerName => $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, 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);
|
||||
return $response;
|
||||
}
|
||||
|
||||
function clearbehindvalue($path,$page1,$maxpage,$pageinfocache)
|
||||
{
|
||||
for ($page=$page1+1;$page<$maxpage;$page++) {
|
||||
$pageinfocache['nextlink_' . $path . '_page_' . $page] = '';
|
||||
}
|
||||
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)
|
||||
{
|
||||
$ispassfile = fetch_files(spurlencode(path_format($path . '/' . $passfile),'/'));
|
||||
//echo $path . '<pre>' . json_encode($ispassfile, JSON_PRETTY_PRINT) . '</pre>';
|
||||
if (isset($ispassfile['file'])) {
|
||||
$arr = curl_request($ispassfile['@microsoft.graph.downloadUrl']);
|
||||
if ($arr['stat']==200) {
|
||||
$passwordf=explode("\n",$arr['body']);
|
||||
$password=$passwordf[0];
|
||||
$password=md5($password);
|
||||
return $password;
|
||||
} else {
|
||||
//return md5('DefaultP@sswordWhenNetworkError');
|
||||
return md5( md5(time()).rand(1000,9999) );
|
||||
}
|
||||
} else {
|
||||
if ($path !== '' ) {
|
||||
$path = substr($path,0,strrpos($path,'/'));
|
||||
return gethiddenpass($path,$passfile);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function get_refresh_token()
|
||||
{
|
||||
global $constStr;
|
||||
$url = path_format($_SERVER['PHP_SELF'] . '/');
|
||||
if ($_GET['authorization_code'] && isset($_GET['code'])) {
|
||||
$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'])) {
|
||||
$tmptoken = $ret['refresh_token'];
|
||||
$str = '
|
||||
refresh_token :<br>';
|
||||
/*for ($i=1;strlen($tmptoken)>0;$i++) {
|
||||
$t['t' . $i] = substr($tmptoken,0,128);
|
||||
$str .= '
|
||||
t' . $i . ':<textarea readonly style="width: 95%">' . $t['t' . $i] . '</textarea><br><br>';
|
||||
$tmptoken=substr($tmptoken,128);
|
||||
}
|
||||
$str .= '
|
||||
Add t1-t'.--$i.' to environments.*/
|
||||
$str .= '
|
||||
<textarea readonly style="width: 95%">' . $tmptoken . '</textarea><br><br>
|
||||
Adding refresh_token to Config.
|
||||
<script>
|
||||
var texta=document.getElementsByTagName(\'textarea\');
|
||||
for(i=0;i<texta.length;i++) {
|
||||
texta[i].style.height = texta[i].scrollHeight + \'px\';
|
||||
}
|
||||
document.cookie=\'language=; path=/\';
|
||||
</script>';
|
||||
setConfig([ 'refresh_token' => $tmptoken ]);
|
||||
savecache('access_token', $ret['access_token'], $ret['expires_in'] - 60);
|
||||
$str .= '
|
||||
<meta http-equiv="refresh" content="5;URL=' . $url . '">';
|
||||
return message($str, $constStr['WaitJumpIndex'][$constStr['language']]);
|
||||
}
|
||||
return message('<pre>' . $tmp['body'] . '</pre>', $tmp['stat']);
|
||||
//return message('<pre>' . json_encode($ret, JSON_PRETTY_PRINT) . '</pre>', 500);
|
||||
}
|
||||
if ($_GET['install3']) {
|
||||
if (getConfig('Onedrive_ver')=='MS' || getConfig('Onedrive_ver')=='CN' || getConfig('Onedrive_ver')=='MSC') {
|
||||
return message('
|
||||
<a href="" id="a1">'.$constStr['JumptoOffice'][$constStr['language']].'</a>
|
||||
<script>
|
||||
url=location.protocol + "//" + location.host + "'.$url.'";
|
||||
url="'. $_SERVER['oauth_url'] .'authorize?scope='. $_SERVER['scope'] .'&response_type=code&client_id='. $_SERVER['client_id'] .'&redirect_uri='. $_SERVER['redirect_uri'] . '&state=' .'"+encodeURIComponent(url);
|
||||
document.getElementById(\'a1\').href=url;
|
||||
//window.open(url,"_blank");
|
||||
location.href = url;
|
||||
</script>
|
||||
', $constStr['Wait'][$constStr['language']].' 1s', 201);
|
||||
}
|
||||
}
|
||||
if ($_GET['install2']) {
|
||||
// echo $_POST['Onedrive_ver'];
|
||||
if ($_POST['Onedrive_ver']=='MS' || $_POST['Onedrive_ver']=='CN' || $_POST['Onedrive_ver']=='MSC') {
|
||||
$tmp['Onedrive_ver'] = $_POST['Onedrive_ver'];
|
||||
if ($_POST['Onedrive_ver']=='MSC') {
|
||||
$tmp['client_id'] = $_POST['client_id'];
|
||||
$tmp['client_secret'] = $_POST['client_secret'];
|
||||
}
|
||||
$response = setConfig($tmp);
|
||||
$title = $constStr['MayinEnv'][$constStr['language']];
|
||||
$html = $constStr['Wait'][$constStr['language']] . ' 3s<meta http-equiv="refresh" content="3;URL=' . $url . '?install3">';
|
||||
if (!$response) {
|
||||
$html = $response . '<br>
|
||||
Can not write config to file.<br>
|
||||
<button onclick="location.href = location.href;">'.$constStr['Reflesh'][$constStr['language']].'</button>';
|
||||
$title = 'Error';
|
||||
}
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
}
|
||||
if ($_GET['install1']) {
|
||||
if ($_POST['admin']!='') {
|
||||
$tmp['admin'] = $_POST['admin'];
|
||||
$tmp['language'] = $_POST['language'];
|
||||
$response = setConfig($tmp);
|
||||
if ($response) {
|
||||
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 = '
|
||||
<form action="?install2" method="post">
|
||||
Onedrive_Ver:<br>
|
||||
<label><input type="radio" name="Onedrive_ver" value="MS" checked>MS: '.$constStr['OndriveVerMS'][$constStr['language']].'</label><br>
|
||||
<label><input type="radio" name="Onedrive_ver" value="CN">CN: '.$constStr['OndriveVerCN'][$constStr['language']].'</label><br>
|
||||
<label><input type="radio" name="Onedrive_ver" value="MSC" onclick="document.getElementById(\'secret\').style.display=\'\';">MSC: '.$constStr['OndriveVerMSC'][$constStr['language']].'
|
||||
<div id="secret" style="display:none">
|
||||
<a href="'.$app_url.'" target="_blank">'.$constStr['GetSecretIDandKEY'][$constStr['language']].'</a><br>
|
||||
client_secret:<input type="text" name="client_secret"><br>
|
||||
client_id(12345678-90ab-cdef-ghij-klmnopqrstuv):<input type="text" name="client_id"><br>
|
||||
</div>
|
||||
</label><br>
|
||||
<input type="submit" value="'.$constStr['Submit'][$constStr['language']].'">
|
||||
</form>';
|
||||
$title = 'Install';
|
||||
} else {
|
||||
$html = $response . '<br>
|
||||
Can not write config to file.<br>
|
||||
<button onclick="location.href = location.href;">'.$constStr['Reflesh'][$constStr['language']].'</button>';
|
||||
$title = 'Error';
|
||||
}
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
}
|
||||
if ($_GET['install0']) {
|
||||
if (!ConfigWriteable()) {
|
||||
$html .= 'Plase make sure the config.php is writeable.
|
||||
run Writeable.sh.';
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
if (!RewriteEngineOn()) {
|
||||
$html .= 'Plase make sure the RewriteEngine is On.';
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= '
|
||||
<form action="?install1" method="post" onsubmit="return adminnotnull(this);">
|
||||
<label>admin:<input name="admin" type="password" placeholder="' . $constStr['EnvironmentsDescription']['admin'][$constStr['language']] . '" size="' . strlen($constStr['EnvironmentsDescription']['admin'][$constStr['language']]) . '"></label><br>
|
||||
language:<br>';
|
||||
foreach ($constStr['languages'] as $key1 => $value1) {
|
||||
$html .= '
|
||||
<label><input type="radio" name="language" value="'.$key1.'" '.($key1==$constStr['language']?'checked':'').' onclick="changelanguage(\''.$key1.'\')">'.$value1.'</label><br>';
|
||||
}
|
||||
$html .= '<br>
|
||||
<input type="submit" value="'.$constStr['Submit'][$constStr['language']].'">
|
||||
</form>
|
||||
<script>
|
||||
function changelanguage(str)
|
||||
{
|
||||
document.cookie=\'language=\'+str+\'; path=/\';
|
||||
location.href = location.href;
|
||||
}
|
||||
function adminnotnull(t)
|
||||
{
|
||||
if (t.admin.value==\'\') {
|
||||
alert(\'input admin\');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
</script>';
|
||||
$title = $constStr['SelectLanguage'][$constStr['language']];
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
$html .= 'refresh_token not exist, <a href="?install0">click to install.</a>';
|
||||
$title = 'Error';
|
||||
return message($html, $title, 201);
|
||||
}
|
||||
|
||||
function ConfigWriteable()
|
||||
{
|
||||
$t = md5( md5(time()).rand(1000,9999) );
|
||||
setConfig([ 'tmp' => $t ]);
|
||||
$tmp = getConfig('tmp');
|
||||
setConfig([ 'tmp' => '' ]);
|
||||
if ($tmp == $t) 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'] . path_format($_SERVER['base_path'] . '/config.php');
|
||||
$tmp = curl_request($tmpurl);
|
||||
if ($tmp['stat']==201) return true; //when install return 201, after installed return 404 or 200;
|
||||
return false;
|
||||
}
|
||||
|
||||
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('<html><meta charset=utf-8><body><h1>' . $title . '</h1><p>' . $message . '</p></body></html>', $statusCode);
|
||||
}
|
||||
|
||||
function needUpdate()
|
||||
{
|
||||
if ($_SERVER['admin']) {
|
||||
$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') != '') {
|
||||
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 getConfig($str)
|
||||
{
|
||||
include 'config.php';
|
||||
//$s = file_get_contents('config.json');
|
||||
if ($configs!='') {
|
||||
$envs = json_decode($configs, true);
|
||||
if (isset($envs[$str])) return $envs[$str];
|
||||
}
|
||||
return '';
|
||||
/*
|
||||
if (!class_exists('mydbreader')) {
|
||||
class mydbreader extends SQLite3
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
$this->open( __DIR__ .'/.ht.db');
|
||||
}
|
||||
}
|
||||
}
|
||||
$db = new mydbreader();
|
||||
if(!$db){
|
||||
echo $db->lastErrorMsg();
|
||||
} else {
|
||||
//echo "Opened database successfully<br>\n";
|
||||
$id=rand(1,309);
|
||||
$sql="select * from config where id=".$str.";";
|
||||
$ret = $db->query($sql);
|
||||
if(!$ret){
|
||||
echo $db->lastErrorMsg();
|
||||
} else {
|
||||
$row = $ret->fetchArray(SQLITE3_ASSOC);
|
||||
$value1 = $row['value'];
|
||||
}
|
||||
$db->close();
|
||||
}
|
||||
return $value1;
|
||||
*/
|
||||
}
|
||||
|
||||
function array_value_isnot_null($arr)
|
||||
{
|
||||
return $arr!=='';
|
||||
}
|
||||
|
||||
function setConfig($arr)
|
||||
{
|
||||
include 'config.php';
|
||||
if ($configs!='') $envs = json_decode($configs, true);
|
||||
foreach ($arr as $k1 => $v1) {
|
||||
$envs[$k1] = $v1;
|
||||
}
|
||||
$envs = array_filter($envs, 'array_value_isnot_null');
|
||||
ksort($envs);
|
||||
//echo '<pre>'. json_encode($envs, JSON_PRETTY_PRINT).'</pre>';
|
||||
$prestr = '<?php $configs = \'
|
||||
';
|
||||
$aftstr = '
|
||||
\';';
|
||||
return file_put_contents('config.php', $prestr . json_encode($envs, JSON_PRETTY_PRINT) . $aftstr);
|
||||
}
|
||||
|
||||
function get_thumbnails_url($path = '/')
|
||||
{
|
||||
$path1 = path_format($path);
|
||||
$path = path_format($_SERVER['list_path'] . path_format($path));
|
||||
$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'])) return output($files['url']);
|
||||
return output('', 404);
|
||||
}
|
672
index.php
672
index.php
|
@ -3,13 +3,13 @@ include 'vendor/autoload.php';
|
|||
include 'conststr.php';
|
||||
include 'function/common.php';
|
||||
|
||||
//echo '<pre>'. json_encode($_SERVER, JSON_PRETTY_PRINT).'</pre>';
|
||||
if ($_SERVER['USER']==='qcloud') {
|
||||
include 'function/scf.php';
|
||||
} elseif ($_SERVER['HEROKU_APP_DIR']==='/app') {
|
||||
include 'function/heroku.php';
|
||||
} else {
|
||||
include 'function/normal.php';
|
||||
//echo '<pre>'. json_encode($_SERVER, JSON_PRETTY_PRINT).'</pre>';
|
||||
$path = getpath();
|
||||
//echo 'path:'. $path;
|
||||
$_GET = getGET();
|
||||
|
@ -26,10 +26,9 @@ if ($_SERVER['USER']==='qcloud') {
|
|||
|
||||
function main_handler($event, $context)
|
||||
{
|
||||
global $constStr;
|
||||
$event = json_decode(json_encode($event), true);
|
||||
$context = json_decode(json_encode($context), true);
|
||||
//printInput($event, $context);
|
||||
printInput($event, $context);
|
||||
unset($_POST);
|
||||
unset($_GET);
|
||||
unset($_COOKIE);
|
||||
|
@ -39,670 +38,3 @@ function main_handler($event, $context)
|
|||
$path = GetPathSetting($event, $context);
|
||||
return main($path);
|
||||
}
|
||||
|
||||
function main($path)
|
||||
{
|
||||
global $exts;
|
||||
global $constStr;
|
||||
config_oauth();
|
||||
$_SERVER['list_path'] = getListpath($_SERVER['HTTP_HOST']);
|
||||
if ($_SERVER['list_path']=='') $_SERVER['list_path'] = '/';
|
||||
$_SERVER['is_guestup_path'] = is_guestup_path($path);
|
||||
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
|
||||
$_SERVER['ajax']=0;
|
||||
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) if ($_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest') $_SERVER['ajax']=1;
|
||||
|
||||
$refresh_token = getConfig('refresh_token');
|
||||
if (!$refresh_token) return get_refresh_token();
|
||||
|
||||
if (getConfig('adminloginpage')=='') {
|
||||
$adminloginpage = 'admin';
|
||||
} else {
|
||||
$adminloginpage = getConfig('adminloginpage');
|
||||
}
|
||||
if ($_GET[$adminloginpage]) {
|
||||
if ($_GET['preview']) {
|
||||
$url = $_SERVER['PHP_SELF'] . '?preview';
|
||||
} else {
|
||||
$url = path_format($_SERVER['PHP_SELF'] . '/');
|
||||
}
|
||||
if (getConfig('admin')!='') {
|
||||
if ($_POST['password1']==getConfig('admin')) {
|
||||
return adminform($_SERVER['function_name'].'admin',md5($_POST['password1']),$url);
|
||||
} else return adminform();
|
||||
} else {
|
||||
return output('', 302, [ 'Location' => $url ]);
|
||||
}
|
||||
}
|
||||
if (getConfig('admin')!='')
|
||||
if ( $_COOKIE['admin']==md5(getConfig('admin')) || $_POST['password1']==getConfig('admin') ) {
|
||||
$_SERVER['admin']=1;
|
||||
$_SERVER['needUpdate'] = needUpdate();
|
||||
} else {
|
||||
$_SERVER['admin']=0;
|
||||
}
|
||||
if ($_GET['setup'])
|
||||
if ($_SERVER['admin']) {
|
||||
// setup Environments. 设置,对环境变量操作
|
||||
return EnvOpt($_SERVER['function_name'], $_SERVER['needUpdate']);
|
||||
} else {
|
||||
$url = path_format($_SERVER['PHP_SELF'] . '/');
|
||||
return output('<script>alert(\''.$constStr['SetSecretsFirst'][$constStr['language']].'\');</script>', 302, [ 'Location' => $url ]);
|
||||
}
|
||||
$_SERVER['retry'] = 0;
|
||||
|
||||
if (!($_SERVER['access_token'] = getcache('access_token'))) {
|
||||
$ret = json_decode(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
|
||||
)['body'], true);
|
||||
if (!isset($ret['access_token'])) {
|
||||
error_log('failed to get access_token. response' . json_encode($ret));
|
||||
throw new Exception('failed to get access_token.');
|
||||
}
|
||||
$_SERVER['access_token'] = $ret['access_token'];
|
||||
savecache('access_token', $_SERVER['access_token']);
|
||||
}
|
||||
|
||||
if ($_SERVER['ajax']) {
|
||||
if ($_GET['action']=='del_upload_cache'&&substr($_GET['filename'],-4)=='.tmp') {
|
||||
// del '.tmp' without login. 无需登录即可删除.tmp后缀文件
|
||||
$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));
|
||||
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 .'<br>'. $data;
|
||||
$tmp = MSAPI('PATCH',$oldname,$data,$_SERVER['access_token']);
|
||||
if ($tmp['stat']==409) MSAPI('DELETE',$oldname,'',$_SERVER['access_token'])['body'];
|
||||
$path1 = path_format($_SERVER['list_path'] . path_format($path));
|
||||
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));
|
||||
savecache('path_' . $path1, json_decode('{}',true), 1);
|
||||
return $tmp;
|
||||
}
|
||||
} else {
|
||||
if ($_SERVER['ajax']) return output($constStr['RefleshtoLogin'][$constStr['language']],401);
|
||||
}
|
||||
$_SERVER['ishidden'] = passhidden($path);
|
||||
if ($_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);
|
||||
if (isset($files['file']) && !$_GET['preview']) {
|
||||
// is file && not preview mode
|
||||
if ($_SERVER['ishidden']<4) return output('', 302, [ 'Location' => $files['@microsoft.graph.downloadUrl'] ]);
|
||||
}
|
||||
if ( isset($files['folder']) || isset($files['file']) ) {
|
||||
return render_list($path, $files);
|
||||
} else {
|
||||
return message('<div style="margin:8px;">' . $files['error']['message'] . '</div><a href="javascript:history.back(-1)">'.$constStr['Back'][$constStr['language']].'</a>', $files['error']['code'], $files['error']['stat']);
|
||||
}
|
||||
}
|
||||
|
||||
function list_files($path)
|
||||
{
|
||||
$path = path_format($path);
|
||||
if ($_SERVER['is_guestup_path']&&!$_SERVER['admin']) {
|
||||
$files = json_decode('{"folder":{}}', true);
|
||||
} elseif ($_SERVER['ishidden']==4) {
|
||||
$files = json_decode('{"folder":{}}', true);
|
||||
} else {
|
||||
$files = fetch_files($path);
|
||||
}
|
||||
if ( isset($files['folder']) || isset($files['file']) || isset($files['error']) ) {
|
||||
return $files;
|
||||
} else {
|
||||
error_log( json_encode($files) . ' Network Error<br>' );
|
||||
$_SERVER['retry']++;
|
||||
if ($_SERVER['retry'] < 3) {
|
||||
return list_files($path);
|
||||
} else return $files;
|
||||
}
|
||||
}
|
||||
|
||||
function adminform($name = '', $pass = '', $path = '')
|
||||
{
|
||||
global $constStr;
|
||||
$statusCode = 401;
|
||||
$html = '<html><head><title>'.$constStr['AdminLogin'][$constStr['language']].'</title><meta charset=utf-8></head>';
|
||||
if ($name!=''&&$pass!='') {
|
||||
$html .= '<body>'.$constStr['LoginSuccess'][$constStr['language']].'</body></html>';
|
||||
$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 .= '
|
||||
<body>
|
||||
<div>
|
||||
<center><h4>'.$constStr['InputPassword'][$constStr['language']].'</h4>
|
||||
<form action="" method="post">
|
||||
<div>
|
||||
<input name="password1" type="password"/>
|
||||
<input type="submit" value="'.$constStr['Login'][$constStr['language']].'">
|
||||
</div>
|
||||
</form>
|
||||
</center>
|
||||
</div>
|
||||
';
|
||||
$html .= '</body></html>';
|
||||
return output($html,$statusCode);
|
||||
}
|
||||
|
||||
function EnvOpt($function_name, $needUpdate = 0)
|
||||
{
|
||||
global $constStr;
|
||||
$constEnv = [
|
||||
//'admin',
|
||||
'adminloginpage', 'domain_path', 'guestup_path', 'passfile',
|
||||
//'private_path',
|
||||
'public_path', 'sitename', 'language', 'theme'
|
||||
];
|
||||
asort($constEnv);
|
||||
$html = '<title>OneManager '.$constStr['Setup'][$constStr['language']].'</title>';
|
||||
/*if ($_POST['updateProgram']==$constStr['updateProgram'][$constStr['language']]) {
|
||||
$response = json_decode(updataProgram($function_name, $Region, $namespace), true)['Response'];
|
||||
if (isset($response['Error'])) {
|
||||
$html = $response['Error']['Code'] . '<br>
|
||||
' . $response['Error']['Message'] . '<br><br>
|
||||
function_name:' . $_SERVER['function_name'] . '<br>
|
||||
Region:' . $_SERVER['Region'] . '<br>
|
||||
namespace:' . $namespace . '<br>
|
||||
<button onclick="location.href = location.href;">'.$constStr['Reflesh'][$constStr['language']].'</button>';
|
||||
$title = 'Error';
|
||||
} else {
|
||||
$html .= $constStr['UpdateSuccess'][$constStr['language']] . '<br>
|
||||
<button onclick="location.href = location.href;">'.$constStr['Reflesh'][$constStr['language']].'</button>';
|
||||
$title = $constStr['Setup'][$constStr['language']];
|
||||
}
|
||||
return message($html, $title);
|
||||
}*/
|
||||
if ($_POST['submit1']) {
|
||||
foreach ($_POST as $k => $v) {
|
||||
if (in_array($k, $constEnv)) {
|
||||
//if (!(getConfig($k)==''&&$v==''))
|
||||
$tmp[$k] = $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 = setConfig($tmp);
|
||||
if (!$response) {
|
||||
$html = $response . '<br>
|
||||
<button onclick="location.href = location.href;">'.$constStr['Reflesh'][$constStr['language']].'</button>';
|
||||
$title = 'Error';
|
||||
} else {
|
||||
$html .= '<script>location.href=location.href</script>';
|
||||
}
|
||||
}
|
||||
if ($_GET['preview']) {
|
||||
$preurl = $_SERVER['PHP_SELF'] . '?preview';
|
||||
} else {
|
||||
$preurl = path_format($_SERVER['PHP_SELF'] . '/');
|
||||
}
|
||||
$html .= '
|
||||
<a href="'.$preurl.'">'.$constStr['Back'][$constStr['language']].'</a>
|
||||
<a href="https://github.com/qkqpttgf/OneManager-php">Github</a><br>';
|
||||
/*if ($needUpdate) {
|
||||
$html .= '<pre>' . $_SERVER['github_version'] . '</pre>
|
||||
<form action="" method="post">
|
||||
<input type="submit" name="updateProgram" value="'.$constStr['updateProgram'][$constStr['language']].'">
|
||||
</form>';
|
||||
} else {
|
||||
$html .= $constStr['NotNeedUpdate'][$constStr['language']];
|
||||
}*/
|
||||
$html .= '
|
||||
<form action="" method="post">
|
||||
<table border=1 width=100%>';
|
||||
foreach ($constEnv as $key) {
|
||||
if ($key=='language') {
|
||||
$html .= '
|
||||
<tr>
|
||||
<td><label>' . $key . '</label></td>
|
||||
<td width=100%>
|
||||
<select name="' . $key .'">';
|
||||
foreach ($constStr['languages'] as $key1 => $value1) {
|
||||
$html .= '
|
||||
<option value="'.$key1.'" '.($key1==getConfig($key)?'selected="selected"':'').'>'.$value1.'</option>';
|
||||
}
|
||||
$html .= '
|
||||
</select>
|
||||
</td>
|
||||
</tr>';
|
||||
} elseif ($key=='theme') {
|
||||
$theme_arr = scandir('theme');
|
||||
$html .= '
|
||||
<tr>
|
||||
<td><label>' . $key . '</label></td>
|
||||
<td width=100%>
|
||||
<select name="' . $key .'">';
|
||||
foreach ($theme_arr as $v1) {
|
||||
if ($v1!='.' && $v1!='..') $html .= '
|
||||
<option value="'.$v1.'" '.($v1==getConfig($key)?'selected="selected"':'').'>'.$v1.'</option>';
|
||||
}
|
||||
$html .= '
|
||||
</select>
|
||||
</td>
|
||||
</tr>';
|
||||
} elseif ($key=='domain_path') {
|
||||
$tmp = getConfig($key);
|
||||
$domain_path = '';
|
||||
foreach ($tmp as $k1 => $v1) {
|
||||
$domain_path .= $k1 . ':' . $v1 . '|';
|
||||
}
|
||||
$domain_path = substr($domain_path, 0, -1);
|
||||
$html .= '
|
||||
<tr>
|
||||
<td><label>' . $key . '</label></td>
|
||||
<td width=100%><input type="text" name="' . $key .'" value="' . $domain_path . '" placeholder="' . $constStr['EnvironmentsDescription'][$key][$constStr['language']] . '" style="width:100%"></td>
|
||||
</tr>';
|
||||
} else $html .= '
|
||||
<tr>
|
||||
<td><label>' . $key . '</label></td>
|
||||
<td width=100%><input type="text" name="' . $key .'" value="' . getConfig($key) . '" placeholder="' . $constStr['EnvironmentsDescription'][$key][$constStr['language']] . '" style="width:100%"></td>
|
||||
</tr>';
|
||||
}
|
||||
$html .= '</table>
|
||||
<input type="submit" name="submit1" value="'.$constStr['Setup'][$constStr['language']].'">
|
||||
</form>';
|
||||
return message($html, $constStr['Setup'][$constStr['language']]);
|
||||
}
|
||||
|
||||
|
||||
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['@microsoft.graph.downloadUrl']);
|
||||
$getoldupinfo = json_decode($getoldupinfo_j , true);
|
||||
if ( json_decode( curl_request($getoldupinfo['uploadUrl']), true)['@odata.context']!='' ) return output($getoldupinfo_j);
|
||||
}
|
||||
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 adminoperate($path)
|
||||
{
|
||||
global $constStr;
|
||||
$path1 = path_format($_SERVER['list_path'] . path_format($path));
|
||||
if (substr($path1,-1)=='/') $path1=substr($path1,0,-1);
|
||||
$tmparr['statusCode'] = 0;
|
||||
if ($_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 ($_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 ($_GET['operate_action']==$constStr['encrypt'][$constStr['language']]) {
|
||||
// encrypt 加密
|
||||
if (getConfig('passfile')=='') return message($constStr['SetpassfileBfEncrypt'][$constStr['language']],'',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']);
|
||||
//savecache('path_' . $path1, json_decode('{}',true), 1);
|
||||
return output($result['body'], $result['stat']);
|
||||
}
|
||||
if ($_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'] . '/' );
|
||||
savecache('path_' . $path2, json_decode('{}',true), 1);
|
||||
return output($result['body'], $result['stat']);
|
||||
} else {
|
||||
return output('{"error":"Can not Move!"}', 403);
|
||||
}
|
||||
}
|
||||
if ($_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']. '<hr><a href="javascript:history.back(-1)">上一页</a>','Error',403);
|
||||
}
|
||||
if ($_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 ($_GET['RefreshCache']) {
|
||||
//savecache('path_' . $path1, json_decode('{}',true), 1);
|
||||
return output('<meta http-equiv="refresh" content="2;URL=./">'.$constStr['RefreshCache'][$constStr['language']], 302);
|
||||
}
|
||||
return $tmparr;
|
||||
}
|
||||
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_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 fetch_files($path = '/')
|
||||
{
|
||||
$path1 = path_format($path);
|
||||
$path = path_format($_SERVER['list_path'] . path_format($path));
|
||||
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
|
||||
$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)';
|
||||
$arr = curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']]);
|
||||
if ($arr['stat']<500) {
|
||||
$files = json_decode($arr['body'], true);
|
||||
// echo $path . '<br><pre>' . json_encode($files, JSON_PRETTY_PRINT) . '</pre>';
|
||||
if (isset($files['folder'])) {
|
||||
if ($files['folder']['childCount']>200) {
|
||||
// files num > 200 , then get nextlink
|
||||
$page = $_POST['pagenum']==''?1:$_POST['pagenum'];
|
||||
$files=fetch_files_children($files, $path, $page);
|
||||
} else {
|
||||
// files num < 200 , then cache
|
||||
savecache('path_' . $path, $files);
|
||||
}
|
||||
}
|
||||
if (isset($files['error'])) {
|
||||
$files['error']['stat'] = $arr['stat'];
|
||||
}
|
||||
} else {
|
||||
error_log($arr['body']);
|
||||
$files = json_decode( '{"unknownError":{ "stat":'.$arr['stat'].',"message":"'.$arr['body'].'"}}', true);
|
||||
}
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
function fetch_files_children($files, $path, $page)
|
||||
{
|
||||
$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['@microsoft.graph.downloadUrl'])['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';
|
||||
} else {
|
||||
$url .= '/children?$select=name,size,file,folder,parentReference,lastModifiedDateTime';
|
||||
}
|
||||
$children = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true);
|
||||
// echo $url . '<br><pre>' . json_encode($children, JSON_PRETTY_PRINT) . '</pre>';
|
||||
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 . '<br><pre>' . json_encode($children, JSON_PRETTY_PRINT) . '</pre>';
|
||||
$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 . '<br><pre>' . json_encode($children, JSON_PRETTY_PRINT) . '</pre>';
|
||||
$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;
|
||||
|
||||
$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 = $constStr['Home'][$constStr['language']];
|
||||
$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 = '<!--
|
||||
github : https://github.com/qkqpttgf/OneManager-php
|
||||
-->' . ob_get_clean();
|
||||
if ($_SERVER['Set-Cookie']!='') return output($html, $statusCode, [ 'Set-Cookie' => $_SERVER['Set-Cookie'], 'Content-Type' => 'text/html' ]);
|
||||
return output($html,$statusCode);
|
||||
}
|
||||
|
|
|
@ -55,31 +55,31 @@
|
|||
<?php
|
||||
if (getConfig('admin')!='') if (!$_SERVER['admin']) {
|
||||
if (getConfig('adminloginpage')=='') { ?>
|
||||
<a onclick="login();"><?php echo $constStr['Login'][$constStr['language']]; ?></a>
|
||||
<a onclick="login();"><?php echo getconstStr('Login'); ?></a>
|
||||
<?php }
|
||||
} else { ?>
|
||||
<li class="operate"><?php echo $constStr['Operate'][$constStr['language']]; ?><ul>
|
||||
<li class="operate"><?php echo getconstStr('Operate'); ?><ul>
|
||||
<?php if (isset($files['folder'])) { ?>
|
||||
<li><a onclick="showdiv(event,'create','');"><?php echo $constStr['Create'][$constStr['language']]; ?></a></li>
|
||||
<li><a onclick="showdiv(event,'encrypt','');"><?php echo $constStr['encrypt'][$constStr['language']]; ?></a></li>
|
||||
<li><a href="?RefreshCache"><?php echo $constStr['RefreshCache'][$constStr['language']]; ?></a></li>
|
||||
<li><a onclick="showdiv(event,'create','');"><?php echo getconstStr('Create'); ?></a></li>
|
||||
<li><a onclick="showdiv(event,'encrypt','');"><?php echo getconstStr('encrypt'); ?></a></li>
|
||||
<li><a href="?RefreshCache"><?php echo getconstStr('RefreshCache'); ?></a></li>
|
||||
<?php } ?>
|
||||
<li><a href="<?php echo $_GET['preview']?'?preview&':'?';?>setup"><?php echo $constStr['Setup'][$constStr['language']]; ?></a></li>
|
||||
<li><a onclick="logout()"><?php echo $constStr['Logout'][$constStr['language']]; ?></a></li>
|
||||
<li><a href="<?php echo $_GET['preview']?'?preview&':'?';?>setup"><?php echo getconstStr('Setup'); ?></a></li>
|
||||
<li><a onclick="logout()"><?php echo getconstStr('Logout'); ?></a></li>
|
||||
</ul></li>
|
||||
<?php
|
||||
} ?>
|
||||
<select class="changelanguage" name="language" onchange="changelanguage(this.options[this.options.selectedIndex].value)">
|
||||
<option value="">Language</option>
|
||||
<?php
|
||||
foreach ($constStr['languages'] as $key1 => $value1) { ?>
|
||||
foreach (getconstStr('languages'] as $key1 => $value1) { ?>
|
||||
<option value="<?php echo $key1; ?>" <?php echo $key1==$constStr['language']?'selected="selected"':'' ?>><?php echo $value1; ?></option>
|
||||
<?php
|
||||
} ?>
|
||||
</select>
|
||||
<?php
|
||||
if ($_SERVER['needUpdate']) { ?>
|
||||
<div style='position:absolute;'><font color='red'><?php echo $constStr['NeedUpdate'][$constStr['language']]; ?></font></div>
|
||||
<div style='position:absolute;'><font color='red'><?php echo getconstStr('NeedUpdate'); ?></font></div>
|
||||
<?php } ?>
|
||||
<h1 class="title">
|
||||
<a href="<?php echo $_SERVER['base_path']; ?>"><?php echo $_SERVER['sitename']; ?></a>
|
||||
|
@ -111,7 +111,7 @@
|
|||
<div id="upload_div" style="margin:10px">
|
||||
<center>
|
||||
<input id="upload_file" type="file" name="upload_filename">
|
||||
<input id="upload_submit" onclick="preup();" value="<?php echo $constStr['Upload'][$constStr['language']]; ?>" type="button">
|
||||
<input id="upload_submit" onclick="preup();" value="<?php echo getconstStr('Upload'); ?>" type="button">
|
||||
<center>
|
||||
</div>
|
||||
<?php } else {
|
||||
|
@ -125,7 +125,7 @@
|
|||
<div style="margin: 12px 4px 4px; text-align: center">
|
||||
<div style="margin: 24px">
|
||||
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><?php echo str_replace('%2523', '%23', str_replace('%26amp%3B','&',spurlencode(path_format($_SERVER['base_path'] . '/' . $path), '/'))); ?></textarea>
|
||||
<a href="<?php echo path_format($_SERVER['base_path'] . '/' . $path);//$files['@microsoft.graph.downloadUrl'] ?>"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon> <?php echo $constStr['Download'][$constStr['language']]; ?></a>
|
||||
<a href="<?php echo path_format($_SERVER['base_path'] . '/' . $path);//$files['@microsoft.graph.downloadUrl'] ?>"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon> <?php echo getconstStr('Download'); ?></a>
|
||||
</div>
|
||||
<div style="margin: 24px">
|
||||
<?php $ext = strtolower(substr($path, strrpos($path, '.') + 1));
|
||||
|
@ -156,8 +156,8 @@
|
|||
<div id="txt">
|
||||
<?php if ($_SERVER['admin']) { ?>
|
||||
<form id="txt-form" action="" method="POST">
|
||||
<a onclick="enableedit(this);" id="txt-editbutton"><?php echo $constStr['ClicktoEdit'][$constStr['language']]; ?></a>
|
||||
<a id="txt-save" style="display:none"><?php echo $constStr['Save'][$constStr['language']]; ?></a>
|
||||
<a onclick="enableedit(this);" id="txt-editbutton"><?php echo getconstStr('ClicktoEdit'); ?></a>
|
||||
<a id="txt-save" style="display:none"><?php echo getconstStr('Save'); ?></a>
|
||||
<?php } ?>
|
||||
<textarea id="txt-a" name="editfile" readonly style="width: 100%; margin-top: 2px;" <?php if ($_SERVER['admin']) echo 'onchange="document.getElementById(\'txt-save\').onclick=function(){document.getElementById(\'txt-form\').submit();}"';?> ><?php echo $txtstr;?></textarea>
|
||||
<?php if ($_SERVER['admin']) echo '</form>'; ?>
|
||||
|
@ -169,7 +169,7 @@
|
|||
</div>
|
||||
';
|
||||
} else {
|
||||
echo '<span>'.$constStr['FileNotSupport'][$constStr['language']].'</span>';
|
||||
echo '<span>'.getconstStr('FileNotSupport').'</span>';
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -179,9 +179,9 @@
|
|||
$readme = false; ?>
|
||||
<table class="list-table" id="list-table">
|
||||
<tr id="tr0">
|
||||
<th class="file" onclick="sortby('a');"><?php echo $constStr['File'][$constStr['language']]; ?> <button onclick="showthumbnails(this);"><?php echo $constStr['ShowThumbnails'][$constStr['language']]; ?></button></th>
|
||||
<th class="updated_at" width="25%" onclick="sortby('time');"><?php echo $constStr['EditTime'][$constStr['language']]; ?></th>
|
||||
<th class="size" width="15%" onclick="sortby('size');"><?php echo $constStr['Size'][$constStr['language']]; ?></th>
|
||||
<th class="file" onclick="sortby('a');"><?php echo getconstStr('File'); ?> <button onclick="showthumbnails(this);"><?php echo getconstStr('ShowThumbnails'); ?></button></th>
|
||||
<th class="updated_at" width="25%" onclick="sortby('time');"><?php echo getconstStr('EditTime'); ?></th>
|
||||
<th class="size" width="15%" onclick="sortby('size');"><?php echo getconstStr('Size'); ?></th>
|
||||
</tr>
|
||||
<!-- Dirs -->
|
||||
<?php //echo json_encode($files['children'], JSON_PRETTY_PRINT);
|
||||
|
@ -192,12 +192,12 @@
|
|||
<tr data-to id="tr<?php echo $filenum;?>">
|
||||
<td class="file">
|
||||
<?php if ($_SERVER['admin']) { ?>
|
||||
<li class="operate"><?php echo $constStr['Operate'][$constStr['language']]; ?>
|
||||
<li class="operate"><?php echo getconstStr('Operate'); ?>
|
||||
<ul>
|
||||
<li><a onclick="showdiv(event,'encrypt',<?php echo $filenum;?>);"><?php echo $constStr['encrypt'][$constStr['language']]; ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'rename',<?php echo $filenum;?>);"><?php echo $constStr['Rename'][$constStr['language']]; ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'move',<?php echo $filenum;?>);"><?php echo $constStr['Move'][$constStr['language']]; ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'delete',<?php echo $filenum;?>);"><?php echo $constStr['Delete'][$constStr['language']]; ?></a></li>
|
||||
<li><a onclick="showdiv(event,'encrypt',<?php echo $filenum;?>);"><?php echo getconstStr('encrypt'); ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'rename',<?php echo $filenum;?>);"><?php echo getconstStr('Rename'); ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'move',<?php echo $filenum;?>);"><?php echo getconstStr('Move'); ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'delete',<?php echo $filenum;?>);"><?php echo getconstStr('Delete'); ?></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
@ -223,11 +223,11 @@
|
|||
<tr data-to id="tr<?php echo $filenum;?>">
|
||||
<td class="file">
|
||||
<?php if ($_SERVER['admin']) { ?>
|
||||
<li class="operate"><?php echo $constStr['Operate'][$constStr['language']]; ?>
|
||||
<li class="operate"><?php echo getconstStr('Operate'); ?>
|
||||
<ul>
|
||||
<li><a onclick="showdiv(event, 'rename',<?php echo $filenum;?>);"><?php echo $constStr['Rename'][$constStr['language']]; ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'move',<?php echo $filenum;?>);"><?php echo $constStr['Move'][$constStr['language']]; ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'delete',<?php echo $filenum;?>);"><?php echo $constStr['Delete'][$constStr['language']]; ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'rename',<?php echo $filenum;?>);"><?php echo getconstStr('Rename'); ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'move',<?php echo $filenum;?>);"><?php echo getconstStr('Move'); ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'delete',<?php echo $filenum;?>);"><?php echo getconstStr('Delete'); ?></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php }
|
||||
|
@ -275,7 +275,7 @@
|
|||
if ($pagenum!=1) {
|
||||
$prepagenum = $pagenum-1;
|
||||
$prepagenext .= '
|
||||
<a onclick="nextpage('.$prepagenum.');">'.$constStr['PrePage'][$constStr['language']].'</a>';
|
||||
<a onclick="nextpage('.$prepagenum.');">'.getconstStr('PrePage').'</a>';
|
||||
}
|
||||
$prepagenext .= '
|
||||
</td>
|
||||
|
@ -296,7 +296,7 @@
|
|||
if ($pagenum!=$maxpage) {
|
||||
$nextpagenum = $pagenum+1;
|
||||
$prepagenext .= '
|
||||
<a onclick="nextpage('.$nextpagenum.');">'.$constStr['NextPage'][$constStr['language']].'</a>';
|
||||
<a onclick="nextpage('.$nextpagenum.');">'.getconstStr('NextPage').'</a>';
|
||||
}
|
||||
$prepagenext .= '
|
||||
</td>
|
||||
|
@ -309,7 +309,7 @@
|
|||
<div id="upload_div" style="margin:0 0 16px 0">
|
||||
<center>
|
||||
<input id="upload_file" type="file" name="upload_filename" multiple="multiple">
|
||||
<input id="upload_submit" onclick="preup();" value="<?php echo $constStr['Upload'][$constStr['language']]; ?>" type="button">
|
||||
<input id="upload_submit" onclick="preup();" value="<?php echo getconstStr('Upload'); ?>" type="button">
|
||||
</center>
|
||||
</div>
|
||||
<?php }
|
||||
|
@ -342,8 +342,8 @@
|
|||
<div style="padding:20px">
|
||||
<center>
|
||||
<form action="" method="post">
|
||||
<input name="password1" type="password" placeholder="'.$constStr['InputPassword'][$constStr['language']].'">
|
||||
<input type="submit" value="'.$constStr['Submit'][$constStr['language']].'">
|
||||
<input name="password1" type="password" placeholder="'.getconstStr('InputPassword').'">
|
||||
<input type="submit" value="'.getconstStr('Submit').'">
|
||||
</form>
|
||||
</center>
|
||||
</div>';
|
||||
|
@ -360,47 +360,47 @@
|
|||
<div>
|
||||
<div id="rename_div" class="operatediv" style="display:none">
|
||||
<div>
|
||||
<label id="rename_label"></label><br><br><a onclick="operatediv_close('rename')" class="operatediv_close"><?php echo $constStr['Close'][$constStr['language']]; ?></a>
|
||||
<label id="rename_label"></label><br><br><a onclick="operatediv_close('rename')" class="operatediv_close"><?php echo getconstStr('Close'); ?></a>
|
||||
<form id="rename_form" onsubmit="return submit_operate('rename');">
|
||||
<input id="rename_sid" name="rename_sid" type="hidden" value="">
|
||||
<input id="rename_hidden" name="rename_oldname" type="hidden" value="">
|
||||
<input id="rename_input" name="rename_newname" type="text" value="">
|
||||
<input name="operate_action" type="submit" value="<?php echo $constStr['Rename'][$constStr['language']]; ?>">
|
||||
<input name="operate_action" type="submit" value="<?php echo getconstStr('Rename'); ?>">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div id="delete_div" class="operatediv" style="display:none">
|
||||
<div>
|
||||
<br><a onclick="operatediv_close('delete')" class="operatediv_close"><?php echo $constStr['Close'][$constStr['language']]; ?></a>
|
||||
<br><a onclick="operatediv_close('delete')" class="operatediv_close"><?php echo getconstStr('Close'); ?></a>
|
||||
<label id="delete_label"></label>
|
||||
<form id="delete_form" onsubmit="return submit_operate('delete');">
|
||||
<label id="delete_input"><?php echo $constStr['Delete'][$constStr['language']]; ?>?</label>
|
||||
<label id="delete_input"><?php echo getconstStr('Delete'); ?>?</label>
|
||||
<input id="delete_sid" name="delete_sid" type="hidden" value="">
|
||||
<input id="delete_hidden" name="delete_name" type="hidden" value="">
|
||||
<input name="operate_action" type="submit" value="<?php echo $constStr['Submit'][$constStr['language']]; ?>">
|
||||
<input name="operate_action" type="submit" value="<?php echo getconstStr('Submit'); ?>">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div id="encrypt_div" class="operatediv" style="display:none">
|
||||
<div>
|
||||
<label id="encrypt_label"></label><br><br><a onclick="operatediv_close('encrypt')" class="operatediv_close"><?php echo $constStr['Close'][$constStr['language']]; ?></a>
|
||||
<label id="encrypt_label"></label><br><br><a onclick="operatediv_close('encrypt')" class="operatediv_close"><?php echo getconstStr('Close'); ?></a>
|
||||
<form id="encrypt_form" onsubmit="return submit_operate('encrypt');">
|
||||
<input id="encrypt_sid" name="encrypt_sid" type="hidden" value="">
|
||||
<input id="encrypt_hidden" name="encrypt_folder" type="hidden" value="">
|
||||
<input id="encrypt_input" name="encrypt_newpass" type="text" value="" placeholder="<?php echo $constStr['InputPasswordUWant'][$constStr['language']]; ?>">
|
||||
<?php if (getConfig('passfile')!='') {?><input name="operate_action" type="submit" value="<?php echo $constStr['encrypt'][$constStr['language']]; ?>"><?php } else { ?><br><label><?php echo $constStr['SetpassfileBfEncrypt'][$constStr['language']]; ?></label><?php } ?>
|
||||
<input id="encrypt_input" name="encrypt_newpass" type="text" value="" placeholder="<?php echo getconstStr('InputPasswordUWant'); ?>">
|
||||
<?php if (getConfig('passfile')!='') {?><input name="operate_action" type="submit" value="<?php echo getconstStr('encrypt'); ?>"><?php } else { ?><br><label><?php echo getconstStr('SetpassfileBfEncrypt'); ?></label><?php } ?>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div id="move_div" class="operatediv" style="display:none">
|
||||
<div>
|
||||
<label id="move_label"></label><br><br><a onclick="operatediv_close('move')" class="operatediv_close"><?php echo $constStr['Close'][$constStr['language']]; ?></a>
|
||||
<label id="move_label"></label><br><br><a onclick="operatediv_close('move')" class="operatediv_close"><?php echo getconstStr('Close'); ?></a>
|
||||
<form id="move_form" onsubmit="return submit_operate('move');">
|
||||
<input id="move_sid" name="move_sid" type="hidden" value="">
|
||||
<input id="move_hidden" name="move_name" type="hidden" value="">
|
||||
<select id="move_input" name="move_folder">
|
||||
<?php if ($path != '/') { ?>
|
||||
<option value="/../"><?php echo $constStr['ParentDir'][$constStr['language']]; ?></option>
|
||||
<option value="/../"><?php echo getconstStr('ParentDir'); ?></option>
|
||||
<?php }
|
||||
if (isset($files['children'])) foreach ($files['children'] as $file) {
|
||||
if (isset($file['folder'])) { ?>
|
||||
|
@ -408,13 +408,13 @@
|
|||
<?php }
|
||||
} ?>
|
||||
</select>
|
||||
<input name="operate_action" type="submit" value="<?php echo $constStr['Move'][$constStr['language']]; ?>">
|
||||
<input name="operate_action" type="submit" value="<?php echo getconstStr('Move'); ?>">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div id="create_div" class="operatediv" style="display:none">
|
||||
<div>
|
||||
<a onclick="operatediv_close('create')" class="operatediv_close"><?php echo $constStr['Close'][$constStr['language']]; ?></a>
|
||||
<a onclick="operatediv_close('create')" class="operatediv_close"><?php echo getconstStr('Close'); ?></a>
|
||||
<form id="create_form" onsubmit="return submit_operate('create');">
|
||||
<input id="create_sid" name="create_sid" type="hidden" value="">
|
||||
<input id="create_hidden" type="hidden" value="">
|
||||
|
@ -426,21 +426,21 @@
|
|||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<label><input id="create_type_folder" name="create_type" type="radio" value="folder" onclick="document.getElementById('create_text_div').style.display='none';"><?php echo $constStr['Folder'][$constStr['language']]; ?></label>
|
||||
<label><input id="create_type_file" name="create_type" type="radio" value="file" onclick="document.getElementById('create_text_div').style.display='';" checked><?php echo $constStr['File'][$constStr['language']]; ?></label>
|
||||
<label><input id="create_type_folder" name="create_type" type="radio" value="folder" onclick="document.getElementById('create_text_div').style.display='none';"><?php echo getconstStr('Folder'); ?></label>
|
||||
<label><input id="create_type_file" name="create_type" type="radio" value="file" onclick="document.getElementById('create_text_div').style.display='';" checked><?php echo getconstStr('File'); ?></label>
|
||||
<td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo $constStr['Name'][$constStr['language']]; ?>:</td>
|
||||
<td><?php echo getconstStr('Name'); ?>:</td>
|
||||
<td><input id="create_input" name="create_name" type="text" value=""></td>
|
||||
</tr>
|
||||
<tr id="create_text_div">
|
||||
<td><?php echo $constStr['Content'][$constStr['language']]; ?>:</td>
|
||||
<td><?php echo getconstStr('Content'); ?>:</td>
|
||||
<td><textarea id="create_text" name="create_text" rows="6" cols="40"></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td><input name="operate_action" type="submit" value="<?php echo $constStr['Create'][$constStr['language']]; ?>"></td>
|
||||
<td><input name="operate_action" type="submit" value="<?php echo getconstStr('Create'); ?>"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
@ -452,18 +452,18 @@
|
|||
if (getConfig('admin')!='') if (getConfig('adminloginpage')=='') { ?>
|
||||
<div id="login_div" class="operatediv" style="display:none">
|
||||
<div style="margin:50px">
|
||||
<a onclick="operatediv_close('login')" class="operatediv_close"><?php echo $constStr['Close'][$constStr['language']]; ?></a>
|
||||
<a onclick="operatediv_close('login')" class="operatediv_close"><?php echo getconstStr('Close'); ?></a>
|
||||
<center>
|
||||
<form action="<?php echo $_GET['preview']?'?preview&':'?';?>admin" method="post">
|
||||
<input id="login_input" name="password1" type="password" placeholder="<?php echo $constStr['InputPassword'][$constStr['language']]; ?>">
|
||||
<input type="submit" value="<?php echo $constStr['Login'][$constStr['language']]; ?>">
|
||||
<input id="login_input" name="password1" type="password" placeholder="<?php echo getconstStr('InputPassword'); ?>">
|
||||
<input type="submit" value="<?php echo getconstStr('Login'); ?>">
|
||||
</form>
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
} ?>
|
||||
<font color="#f7f7f9"><?php echo date("Y-m-d H:i:s")." ".$constStr['Week'][date("w")][$constStr['language']]." ".$_SERVER['REMOTE_ADDR'];?></font>
|
||||
<font color="#f7f7f9"><?php echo date("Y-m-d H:i:s")." ".getconstStr('Week')[date("w")]." ".$_SERVER['REMOTE_ADDR'];?></font>
|
||||
</body>
|
||||
|
||||
<link rel="stylesheet" href="//unpkg.zhimg.com/github-markdown-css@3.0.1/github-markdown.css">
|
||||
|
@ -759,9 +759,9 @@
|
|||
var td2=document.createElement('td');
|
||||
tr1.appendChild(td2);
|
||||
td2.setAttribute('id','upfile_td2_'+timea+'_'+i);
|
||||
td2.innerHTML='<?php echo $constStr['GetUploadLink'][$constStr['language']]; ?> ...';
|
||||
td2.innerHTML='<?php echo getconstStr('GetUploadLink'); ?> ...';
|
||||
if (file.size>100*1024*1024*1024) {
|
||||
td2.innerHTML='<font color="red"><?php echo $constStr['UpFileTooLarge'][$constStr['language']]; ?></font>';
|
||||
td2.innerHTML='<font color="red"><?php echo getconstStr('UpFileTooLarge'); ?></font>';
|
||||
uploadbuttonshow();
|
||||
return;
|
||||
}
|
||||
|
@ -778,7 +778,7 @@
|
|||
td2.innerHTML='<font color="red">'+xhr1.responseText+'</font><br>';
|
||||
uploadbuttonshow();
|
||||
} else {
|
||||
td2.innerHTML='<?php echo $constStr['UploadStart'][$constStr['language']]; ?> ...';
|
||||
td2.innerHTML='<?php echo getconstStr('UploadStart'); ?> ...';
|
||||
binupfile(file,html['uploadUrl'],timea+'_'+i);
|
||||
}
|
||||
}
|
||||
|
@ -832,9 +832,9 @@
|
|||
asize = newstartsize;
|
||||
<?php } ?>
|
||||
if (newstartsize==0) {
|
||||
StartStr='<?php echo $constStr['UploadStartAt'][$constStr['language']]; ?>:' +StartTime.toLocaleString()+'<br>' ;
|
||||
StartStr='<?php echo getconstStr('UploadStartAt'); ?>:' +StartTime.toLocaleString()+'<br>' ;
|
||||
} else {
|
||||
StartStr='<?php echo $constStr['LastUpload'][$constStr['language']]; ?>'+size_format(newstartsize)+ '<br><?php echo $constStr['ThisTime'][$constStr['language']].$constStr['UploadStartAt'][$constStr['language']]; ?>:' +StartTime.toLocaleString()+'<br>' ;
|
||||
StartStr='<?php echo getconstStr('LastUpload'); ?>'+size_format(newstartsize)+ '<br><?php echo getconstStr('ThisTime').getconstStr('UploadStartAt'); ?>:' +StartTime.toLocaleString()+'<br>' ;
|
||||
}
|
||||
var chunksize=5*1024*1024; // chunk size, max 60M. 每小块上传大小,最大60M,微软建议10M
|
||||
if (totalsize>200*1024*1024) chunksize=10*1024*1024;
|
||||
|
@ -867,7 +867,7 @@
|
|||
var tmptime = new Date();
|
||||
var tmpspeed = e.loaded*1000/(tmptime.getTime()-C_starttime.getTime());
|
||||
var remaintime = (totalsize-asize-e.loaded)/tmpspeed;
|
||||
label.innerHTML=StartStr+'<?php echo $constStr['Upload'][$constStr['language']]; ?> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + ((asize+e.loaded)*100/totalsize).toFixed(2) + '% <?php echo $constStr['AverageSpeed'][$constStr['language']]; ?>:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><?php echo $constStr['CurrentSpeed'][$constStr['language']]; ?> '+size_format(tmpspeed)+'/s <?php echo $constStr['Expect'][$constStr['language']]; ?> '+remaintime.toFixed(1)+'s';
|
||||
label.innerHTML=StartStr+'<?php echo getconstStr('Upload'); ?> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + ((asize+e.loaded)*100/totalsize).toFixed(2) + '% <?php echo getconstStr('AverageSpeed'); ?>:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><?php echo getconstStr('CurrentSpeed'); ?> '+size_format(tmpspeed)+'/s <?php echo getconstStr('Expect'); ?> '+remaintime.toFixed(1)+'s';
|
||||
}
|
||||
}
|
||||
var C_starttime = new Date();
|
||||
|
@ -895,7 +895,7 @@
|
|||
if (xhr4.status==200) filename = JSON.parse(xhr4.responseText)['name'];
|
||||
if (xhr4.status==409) filename = filemd5 + file.name.substr(file.name.indexOf('.'));
|
||||
if (filename=='') {
|
||||
alert('<?php echo $constStr['UploadErrorUpAgain'][$constStr['language']]; ?>');
|
||||
alert('<?php echo getconstStr('UploadErrorUpAgain'); ?>');
|
||||
uploadbuttonshow();
|
||||
return;
|
||||
}
|
||||
|
@ -907,13 +907,13 @@
|
|||
}
|
||||
<?php } ?>
|
||||
EndTime=new Date();
|
||||
MiddleStr = '<?php echo $constStr['EndAt'][$constStr['language']]; ?>:'+EndTime.toLocaleString()+'<br>';
|
||||
MiddleStr = '<?php echo getconstStr('EndAt'); ?>:'+EndTime.toLocaleString()+'<br>';
|
||||
if (newstartsize==0) {
|
||||
MiddleStr += '<?php echo $constStr['AverageSpeed'][$constStr['language']]; ?>:'+size_format(totalsize*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
|
||||
MiddleStr += '<?php echo getconstStr('AverageSpeed'); ?>:'+size_format(totalsize*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
|
||||
} else {
|
||||
MiddleStr += '<?php echo $constStr['ThisTime'][$constStr['language']].$constStr['AverageSpeed'][$constStr['language']]; ?>:'+size_format((totalsize-newstartsize)*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
|
||||
MiddleStr += '<?php echo getconstStr('ThisTime').getconstStr('AverageSpeed'); ?>:'+size_format((totalsize-newstartsize)*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
|
||||
}
|
||||
document.getElementById('upfile_td1_'+tdnum).innerHTML='<font color="green"><?php if (!$_SERVER['admin']) { ?>'+filemd5+'<br><?php } ?>'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'<br><?php echo $constStr['UploadComplete'][$constStr['language']]; ?></font>';
|
||||
document.getElementById('upfile_td1_'+tdnum).innerHTML='<font color="green"><?php if (!$_SERVER['admin']) { ?>'+filemd5+'<br><?php } ?>'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'<br><?php echo getconstStr('UploadComplete'); ?></font>';
|
||||
label.innerHTML=StartStr+MiddleStr;
|
||||
uploadbuttonshow();
|
||||
<?php if ($_SERVER['admin']) { ?>
|
||||
|
@ -933,7 +933,7 @@
|
|||
}
|
||||
} else {
|
||||
if (window.location.pathname.indexOf('%23')>0||file.name.indexOf('%23')>0) {
|
||||
label.innerHTML='<font color="red"><?php echo $constStr['UploadFail23'][$constStr['language']]; ?></font>';
|
||||
label.innerHTML='<font color="red"><?php echo getconstStr('UploadFail23'); ?></font>';
|
||||
} else {
|
||||
label.innerHTML='<font color="red">'+xhr2.responseText+'</font>';
|
||||
}
|
||||
|
@ -951,7 +951,7 @@
|
|||
function enableedit(obj) {
|
||||
document.getElementById('txt-a').readOnly=!document.getElementById('txt-a').readOnly;
|
||||
//document.getElementById('txt-editbutton').innerHTML=(document.getElementById('txt-editbutton').innerHTML=='取消编辑')?'点击后编辑':'取消编辑';
|
||||
obj.innerHTML=(obj.innerHTML=='<?php echo $constStr['CancelEdit'][$constStr['language']]; ?>')?'<?php echo $constStr['ClicktoEdit'][$constStr['language']]; ?>':'<?php echo $constStr['CancelEdit'][$constStr['language']]; ?>';
|
||||
obj.innerHTML=(obj.innerHTML=='<?php echo getconstStr('CancelEdit'); ?>')?'<?php echo getconstStr('ClicktoEdit'); ?>':'<?php echo getconstStr('CancelEdit'); ?>';
|
||||
document.getElementById('txt-save').style.display=document.getElementById('txt-save').style.display==''?'none':'';
|
||||
}
|
||||
<?php if (!$_GET['preview']) {?>
|
||||
|
@ -970,7 +970,7 @@
|
|||
if (str=='') {
|
||||
str=document.getElementById('file_a'+num).getElementsByTagName("img")[0].alt;
|
||||
if (str=='') {
|
||||
alert('<?php echo $constStr['GetFileNameFail'][$constStr['language']]; ?>');
|
||||
alert('<?php echo getconstStr('GetFileNameFail'); ?>');
|
||||
operatediv_close(action);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue