diff --git a/.htaccess b/.htaccess index 7444332..c548b41 100644 --- a/.htaccess +++ b/.htaccess @@ -1,2 +1,15 @@ +# apache +# LoadModule rewrite_module modules/mod_rewrite.so +# AllowOverride All RewriteEngine On RewriteRule ^(.*) index.php?/$1 [L] + +#----------------------------------- +# nginx +# rewrite ^(.*) /index.php?/$1 last; +# +# caddy +# rewrite { +# to index.php?/$1 +# } +#----------------------------------- diff --git a/conststr.php b/conststr.php index b57666e..c4f5df8 100644 --- a/conststr.php +++ b/conststr.php @@ -3,7 +3,7 @@ $exts['img'] = ['ico', 'bmp', 'gif', 'jpg', 'jpeg', 'jpe', 'jfif', 'tif', 'tiff', 'png', 'heic', 'webp']; $exts['music'] = ['mp3', 'wma', 'flac', 'wav', 'ogg']; $exts['office'] = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']; -$exts['txt'] = ['txt', 'bat', 'sh', 'php', 'asp', 'js', 'json', 'html', 'c', 'md']; +$exts['txt'] = ['txt', 'bat', 'sh', 'php', 'asp', 'js', 'json', 'html', 'c', 'md', 'py']; $exts['video'] = ['mp4', 'webm', 'mkv', 'mov', 'flv', 'blv', 'avi', 'wmv', 'm3u8']; $exts['zip'] = ['zip', 'rar', '7z', 'gz', 'tar']; @@ -13,6 +13,7 @@ $constStr = [ 'zh-cn' => '中文', 'ja' => '日本語', 'ko-kr' => '한국어', + 'fa' => 'فارسی', ], 'Week' => [ 'en-us' => [ @@ -51,6 +52,15 @@ $constStr = [ 5 => '금요일', 6 => '토요일', ], + 'fa' => [ + 0 => 'یکشنبه', + 1 => 'دوشنبه', + 2 => 'سه شنبه', + 3 => 'چهارشنبه', + 4 => 'پنج شنبه', + 5 => 'جمعه', + 6 => 'شنبه', + ], ], 'EnvironmentsDescription' => [ 'en-us' => [ @@ -59,8 +69,10 @@ $constStr = [ 'domain_path' => 'more custom domain, format is a1.com:/dirto/path1|b2.com:/path2', 'diskname' => 'The disk name you want show.', 'disktag' => 'A tag used in store config and url.', - 'background' => 'Set an url as background photo, or put a \'background.jpg\' at showed path.', + 'downloadencrypt' => '0 or 1. if 1, the files in encrypt folder can be downloaded without password', + 'background' => 'Set an url as background photo.', 'guestup_path' => 'Set guest upload dir, before set this, the files in this dir will show as normal.', + 'hideFunctionalityFile' => '0 or 1. if 1, some file will not show in list to guest, like readme.md', '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', @@ -72,8 +84,10 @@ $constStr = [ 'domain_path' => '使用多个自定义域名时,指定每个域名看到的目录。格式为a1.com:/dirto/path1|b1.com:/path2,比private_path优先。', 'diskname' => '这个盘你想显示什么名称。', 'disktag' => '一个标签,用于保存配置,多盘时会显示在url中。', - 'background' => '设置一个url作为背景,或者在你显示的目录放一个background.jpg文件。', + 'downloadencrypt' => '0 或 1。如果 1, 那加密目录内的文件可以不需要密码就能下载。', + 'background' => '设置一个url作为背景。', 'guestup_path' => '设置游客上传路径(图床路径),不设置这个值时该目录内容会正常列文件出来,设置后只有上传界面,不显示其中文件(登录后显示)。', + 'hideFunctionalityFile' => '0 或 1。如果 1, 某些文件不列表给游客看,但它的功能正常,比如readme.md', 'passfile' => '自定义密码文件的名字,可以是\'pppppp\',也可以是\'aaaa.txt\'等等;列目录时不会显示,只有知道密码才能查看或下载此文件。密码是这个文件的内容,可以空格、可以中文;', 'public_path' => '使用API长链接访问时,显示网盘文件的路径,不设置时默认为根目录;不能是private_path的上级(public看到的不能比private多,要么看到的就不一样)。', 'sitename' => '网站的名称', @@ -85,6 +99,7 @@ $constStr = [ 'domain_path' => '複数のカスタムドメイン名を使用する場合、各ドメイン名に表示されるディレクトリを指定します。形式はa1.com:/dirto/path1|b1.com:/path2で、private_pathよりも優先されます。', 'diskname' => '', 'disktag' => '', + 'downloadencrypt' => '', 'background' => '', 'guestup_path' => 'マップベッドのパスを設定します。この値が設定されていない場合、ディレクトリの内容は通常ファイルにリストされ、設定後はアップロードインターフェイスのみが表示されます。', 'passfile' => 'カスタムパスワードファイルの名前は、\'pppppp \'、\'aaaa.txt \'などの場合があります。ディレクトリをリストするときには表示されません。パスワードを知っている場合にのみ、このファイルを表示またはダウンロードできます。 パスワードはこのファイルの内容であり、スペースまたは漢字を使用できます。', @@ -98,498 +113,617 @@ $constStr = [ 'domain_path' => '여러 개의 사용자 정의 도메인 이름을 사용하는 경우 각 도메인 이름에 표시되는 디렉토리를 지정하십시오. 형식은 a1.com:/dirto/path1|b1.com:/path2이며 private_path보다 우선합니다.', 'diskname' => '이 디스크에 어떤 이름을 표시 하시겠습니까?', 'disktag' => '레이블은 구성을 저장하는 데 사용되며 디스크가 여러 개인 경우 URL에 표시됩니다.', - 'background' => 'URL을 배경으로 설정하거나 표시하는 디렉토리에 background.jpg 파일을 넣으십시오.', + 'downloadencrypt' => '', + 'background' => 'URL을 배경으로 설정하거나 표시하는.', 'guestup_path' => '방문자의 업로드 경로 (맵 베드 경로)를 설정합니다.이 값을 설정하지 않으면 디렉토리의 내용이 파일로 표시되고 설정 후에는 업로드 인터페이스 만 표시되고 파일은 표시되지 않습니다 (로그인 후 표시).', 'passfile' => '사용자 정의 비밀번호 파일의 이름은 \'pppppp\' \'aaaa.txt \'등이 될 수 있으며 디렉토리가 나열되어 있으면 표시되지 않으며 비밀번호를 알고있는 경우에만이 파일을 보거나 다운로드 할 수 있습니다. 암호는이 파일의 내용이며 공백이거나 한국어 일 수 있습니다.', 'public_path' => 'API 긴 링크 액세스를 사용하는 경우 네트워크 디스크 파일의 경로가 표시됩니다. 설정되지 않은 경우 기본적으로 루트 디렉토리로 설정됩니다.', 'sitename' => '웹 사이트 이름', 'Onedrive_ver' => 'Onedrive 버전', ], + 'fa' => [ + 'admin' => 'رمز عبور ادمین، در صورت خالی بودن دکمه لاگین به نمایش در نمی‌آید', + 'adminloginpage' => 'در صورت تنظیم ، دکمه ورود نمایش داده نمی شود و صفحه ورود دیگر \?admin\ نیست بلکه \?{مقدار ورودی شما}\ است.', + 'domain_path' => 'تنظیم دامنه سفارشی، به صورت a1.com:/dirto/path1|b2.com:/path2', + 'diskname' => 'نام دیسک که می‌خواهید نشان دهید.', + 'disktag' => 'تگی که در ذخیره پیکربندی و نشانی اینترنتی استفاده می‌شود.', + 'downloadencrypt' => '', + 'background' => 'تنظیم عکس پشت زمینه به صورت url یا قرار دادن بک گراند به صورت دستی در مسیر نشان داده شده.', + 'guestup_path' => 'قبل از تنظیم این گزینه ، فایل آپلود guest را تنظیم کنید ، پرونده های موجود در این حالت به صورت عادی نشان داده می شوند.', + 'passfile' => 'رمز عبور dir در این فایل ذخیره می شود.', + 'public_path' => 'این مسیر Onedrive را هنگامی که از طریق آدرس طولانی API Gateway استفاده می کنید ، نشان دهید. فایل های نمایش عمومی کمتر از خصوصی.', + 'sitename' => 'نام سایت', + 'Onedrive_ver' => 'ورژن Onedrive', + ], ], 'SetSecretsFirst' => [ 'en-us' => 'Set API in Config first! or reinstall.', 'zh-cn' => '先在环境变量设置API!或重装。', 'ja' => '最初に環境変数にAPIを設定してください!', 'ko-kr' => '먼저 환경 변수에서 API를 설정하십시오! 또는 다시 설치하십시오.', + 'fa' => 'ابتدا API را در پیکربندی تنظیم کنید! یا دوباره نصب کنید.', ], - 'RefleshtoLogin' => [ - 'en-us' => 'Reflesh and login.', + 'RefreshtoLogin' => [ + 'en-us' => 'Refresh and login.', 'zh-cn' => '请刷新页面后重新登录', 'ja' => 'ページを更新して、再度ログインしてください', 'ko-kr' => '페이지를 새로 고침 하시고 다시 로그인하십시오', + 'fa' => 'رفرش و لاگین.', ], 'AdminLogin' => [ 'en-us' => 'Admin Login', 'zh-cn' => '管理登录', 'ja' => 'ログインを管理する', 'ko-kr' => '로그인 관리', + 'fa' => 'ورود ادمین', ], 'LoginSuccess' => [ 'en-us' => 'Login Success!', 'zh-cn' => '登录成功,正在跳转', 'ja' => 'ログイン成功、ジャンプ', 'ko-kr' => '로그인 성공, 점프', + 'fa' => 'ورود با موفقیت انجام شد!', ], 'InputPassword' => [ 'en-us' => 'Input Password', 'zh-cn' => '输入密码', 'ja' => 'パスワードを入力してください', 'ko-kr' => '비밀번호 입력', + 'fa' => 'رمز عبور را وارد کنید', ], 'Login' => [ 'en-us' => 'Login', 'zh-cn' => '登录', 'ja' => 'サインイン', 'ko-kr' => '로그인', + 'fa' => 'ورود', ], 'encrypt' => [ 'en-us' => 'Encrypt', 'zh-cn' => '加密', 'ja' => '暗号化', 'ko-kr' => '암호화', + 'fa' => 'رمزگذاری', ], 'SetpassfileBfEncrypt' => [ 'en-us' => 'Set \'passfile\' in Environments before encrypt', 'zh-cn' => '先在环境变量设置passfile才能加密', 'ja' => '最初に暗号化する環境変数にパスファイルを設定します', 'ko-kr' => '암호화하기 전에 환경 변수에 패스 파일을 설정하십시오', + 'fa' => 'قبل از رمزگذاری \ "pass file \" را در محیط تنظیم کنید', ], 'updateProgram' => [ 'en-us' => 'Update Program', 'zh-cn' => '一键更新', 'ja' => 'ワンクリック更新', 'ko-kr' => '원 클릭 업데이트', + 'fa' => 'برنامه را به روز کنید', ], 'UpdateSuccess' => [ 'en-us' => 'Program update Success!', 'zh-cn' => '程序升级成功!', 'ja' => 'プログラムのアップグレードに成功しました!', 'ko-kr' => '프로그램 업그레이드 성공!', + 'fa' => 'موفقیت به روز رسانی برنامه!', ], 'Setup' => [ 'en-us' => 'Setup', 'zh-cn' => '设置', 'ja' => '設定する', 'ko-kr' => '설정', + 'fa' => 'نصب', ], 'Back' => [ 'en-us' => 'Back', 'zh-cn' => '返回', 'ja' => 'back', 'ko-kr' => '돌아 가기', + 'fa' => 'بازگشت', ], 'NotNeedUpdate' => [ 'en-us' => 'Not Need Update', 'zh-cn' => '不需要更新', 'ja' => '更新不要', 'ko-kr' => '업데이트가 필요하지 않습니다', + 'fa' => 'آپدیت لازم نیست', ], 'PlatformConfig' => [ 'en-us' => 'Platform Config', 'zh-cn' => '平台变量', 'ja' => 'プラットフォーム変数', 'ko-kr' => '플랫폼 변수', + 'fa' => 'پیکربندی پلتفرم', ], 'DelDisk' => [ 'en-us' => 'Del This Disk', 'zh-cn' => '删除此盘', 'ja' => 'このディスクを削除', 'ko-kr' => '이 디스크를 삭제', + 'fa' => 'پاک کردن این دیسک', ], 'AddDisk' => [ 'en-us' => 'Add Onedrive Disk', 'zh-cn' => '添加Onedrive盘', 'ja' => 'Onedriveを追加', 'ko-kr' => 'Onedrive 추가', + 'fa' => 'اضافه کردن دیسک Onedrive', ], 'Home' => [ 'en-us' => 'Home', 'zh-cn' => '首页', 'ja' => 'ホーム', 'ko-kr' => '홈', + 'fa' => 'خانه', ], 'NeedUpdate' => [ 'en-us' => 'Program can update
Click setup in Operate at top.', 'zh-cn' => '可以升级程序
在上方管理菜单中
进入设置页面升级', 'ja' => 'プログラムをアップグレードできます
上記の管理メニューで
アップグレードする設定ページに入ります', 'ko-kr' => '프로그램을 업그레이드 할 수 있습니다.
위의 관리 메뉴에서
업그레이드 할 설정 페이지를 입력하십시오.', + 'fa' => 'برنامه می تواند آپدیت شود
روی گزینه نصب در بالای صفحه کلیک کنید.', ], 'Operate' => [ 'en-us' => 'Operate', 'zh-cn' => '管理', 'ja' => '管理', 'ko-kr' => '관리', + 'fa' => 'مدیریت', ], 'Logout' => [ 'en-us' => 'Logout', 'zh-cn' => '登出', 'ja' => 'ログアウトする', 'ko-kr' => '로그 아웃', + 'fa' => 'خروج', ], 'Create' => [ 'en-us' => 'Create', 'zh-cn' => '新建', 'ja' => '新しい', 'ko-kr' => '새로운', + 'fa' => 'ایجاد کردن', ], 'Download' => [ 'en-us' => 'download', 'zh-cn' => '下载', 'ja' => 'ダウンロードする', 'ko-kr' => '다운로드', + 'fa' => 'دانلود', ], 'ClicktoEdit' => [ 'en-us' => 'Click to edit', 'zh-cn' => '点击后编辑', 'ja' => 'クリック後に編集', 'ko-kr' => '클릭 후 편집', + 'fa' => 'برای ویرایش کلیک کنید', ], 'Save' => [ 'en-us' => 'Save', 'zh-cn' => '保存', 'ja' => '保存する', 'ko-kr' => '저장', + 'fa' => 'ذخیره', ], 'FileNotSupport' => [ 'en-us' => 'File not support preview.', 'zh-cn' => '文件格式不支持预览', 'ja' => 'ファイル形式はプレビューをサポートしていません', 'ko-kr' => '파일 형식은 미리보기를 지원하지 않습니다', + 'fa' => 'پیش نمایش برای این فایل پشتیبانی نمی شود.', ], 'File' => [ 'en-us' => 'File', 'zh-cn' => '文件', 'ja' => 'ファイル', 'ko-kr' => '파일', + 'fa' => 'فایل', ], 'ShowThumbnails' => [ 'en-us' => 'Thumbnails', 'zh-cn' => '图片缩略', 'ja' => '画像のサムネイル', 'ko-kr' => '사진 섬네일', + 'fa' => 'تصویر بندانگشتی', + ], + 'CopyAllDownloadUrl' => [ + 'en-us' => 'CopyAllDownloadUrl', + 'zh-cn' => '复制所有下载链接', + 'ja' => 'すべてのダウンロードリンクをコピー', + 'ko-kr' => '모든 다운로드 링크 복사', + 'fa' => 'کپی از تمام لینک ها', ], 'EditTime' => [ 'en-us' => 'EditTime', 'zh-cn' => '修改时间', 'ja' => '変更時間', 'ko-kr' => '수정 시간', + 'fa' => 'زمان ویرایش', ], 'Size' => [ 'en-us' => 'Size', 'zh-cn' => '大小', 'ja' => 'サイズ ', 'ko-kr' => '사이즈', + 'fa' => 'سایز', ], 'Rename' => [ 'en-us' => 'Rename', 'zh-cn' => '重命名', 'ja' => '名前を変更', 'ko-kr' => '이름 바꾸기', + 'fa' => 'تغییر نام', ], 'Move' => [ 'en-us' => 'Move', 'zh-cn' => '移动', 'ja' => '移動する', 'ko-kr' => '이동', + 'fa' => 'انتقال', ], 'Copy' => [ 'en-us' => 'Copy', 'zh-cn' => '复制', 'ja' => 'コピー', 'ko-kr' => '복사', + 'fa' => 'کپی', ], 'CannotMove' => [ 'en-us' => 'Can not Move!', 'zh-cn' => '不能移动!', 'ja' => '動かない!', 'ko-kr' => '움직일 수 없어!', + 'fa' => 'نمی‌تواند منتقل شود!', ], 'Delete' => [ 'en-us' => 'Delete', 'zh-cn' => '删除', 'ja' => '削除する', 'ko-kr' => '삭제', + 'fa' => 'حذف کردن', ], 'PrePage' => [ 'en-us' => 'PrePage', 'zh-cn' => '上一页', 'ja' => '前へ', 'ko-kr' => '이전', + 'fa' => 'صفحه قبل', ], 'NextPage' => [ 'en-us' => 'NextPage', 'zh-cn' => '下一页', 'ja' => '次のページ', 'ko-kr' => '다음 페이지', + 'fa' => 'صفحه بعد', ], 'Upload' => [ 'en-us' => 'Upload', 'zh-cn' => '上传', 'ja' => 'アップロードする', 'ko-kr' => '업로드', + 'fa' => 'آپلود', ], 'FileSelected' => [ 'en-us' => 'Select File', 'zh-cn' => '选择文件', 'ja' => 'ファイルを選択', 'ko-kr' => '파일 선택', + 'fa' => 'انتخاب فایل', ], 'NoFileSelected' => [ 'en-us' => 'Not Select File', 'zh-cn' => '没有选择文件', 'ja' => 'ファイルが選択されていません', 'ko-kr' => '선택된 파일이 없습니다', + 'fa' => 'فایل را انتخاب نکنید', ], 'Submit' => [ 'en-us' => 'Submit', 'zh-cn' => '确认', 'ja' => '確認する', 'ko-kr' => '확인', + 'fa' => 'ارسال', ], 'Close' => [ 'en-us' => 'Close', 'zh-cn' => '关闭', 'ja' => '閉じる', 'ko-kr' => '닫기', + 'fa' => 'بستن', ], 'InputPasswordUWant' => [ 'en-us' => 'Input Password you Want', 'zh-cn' => '输入想要设置的密码', 'ja' => '設定するパスワードを入力してください', 'ko-kr' => '설정하려는 비밀번호를 입력하십시오', + 'fa' => 'پسورد خود را وارد کنید', ], 'ParentDir' => [ 'en-us' => 'Parent Dir', 'zh-cn' => '上一级目录', 'ja' => '親ディレクトリ', 'ko-kr' => '부모 디렉토리', + 'fa' => 'مسیر', ], 'Folder' => [ 'en-us' => 'Folder', 'zh-cn' => '文件夹', 'ja' => 'フォルダー', 'ko-kr' => '폴더', + 'fa' => 'پوشه', ], 'Name' => [ 'en-us' => 'Name', 'zh-cn' => '名称', 'ja' => '名前', 'ko-kr' => '이름', + 'fa' => 'نام', ], 'Content' => [ 'en-us' => 'Content', 'zh-cn' => '内容', 'ja' => '内容', 'ko-kr' => '내용', + 'fa' => 'محتوا', ], 'CancelEdit' => [ 'en-us' => 'Cancel Edit', 'zh-cn' => '取消编辑', 'ja' => '編集をキャンセル', 'ko-kr' => '편집 취소', + 'fa' => 'لغو ویرایش', ], 'GetFileNameFail' => [ 'en-us' => 'Fail to Get File Name!', 'zh-cn' => '获取文件名失败!', 'ja' => 'ファイル名を取得できませんでした!', 'ko-kr' => '파일 이름을 가져 오지 못했습니다!', + 'fa' => 'نام فایل به دست نیامد!', ], 'GetUploadLink' => [ 'en-us' => 'Get Upload Link', 'zh-cn' => '获取上传链接', 'ja' => 'アップロードリンクを取得', 'ko-kr' => '업로드 링크 받기', + 'fa' => 'دریافت لینک آپلود', ], 'UpFileTooLarge' => [ 'en-us' => 'The File is too Large!', 'zh-cn' => '文件过大,终止上传。', 'ja' => '超えると、アップロードは終了します。', 'ko-kr' => '파일이 너무 커서 업로드가 종료되었습니다.', + 'fa' => 'فایل خیلی بزرگ است!', ], 'UploadStart' => [ 'en-us' => 'Upload Start', 'zh-cn' => '开始上传', 'ja' => 'アップロードを開始', 'ko-kr' => '업로드 시작', + 'fa' => 'شروع آپلود', ], 'UploadStartAt' => [ 'en-us' => 'Start At', 'zh-cn' => '开始于', 'ja' => 'で開始', 'ko-kr' => '에서 시작', + 'fa' => 'شروع از', ], 'ThisTime' => [ 'en-us' => 'This Time', 'zh-cn' => '本次', 'ja' => '今回は', 'ko-kr' => '이번에는', + 'fa' => 'این زمان', ], 'LastUpload' => [ 'en-us' => 'Last time Upload', 'zh-cn' => '上次上传', 'ja' => '上回は', 'ko-kr' => '마지막 업로드', + 'fa' => 'آخرین زمان آپلود', ], 'AverageSpeed' => [ 'en-us' => 'AverageSpeed', 'zh-cn' => '平均速度', 'ja' => '平均速度', 'ko-kr' => '평균 속도', + 'fa' => 'میانگین سرعت', ], 'CurrentSpeed' => [ 'en-us' => 'CurrentSpeed', 'zh-cn' => '即时速度', 'ja' => 'インスタントスピード', 'ko-kr' => '즉각적인 속도', + 'fa' => 'سرعت فعلی', ], 'Expect' => [ 'en-us' => 'Expect', 'zh-cn' => '预计还要', 'ja' => '期待される', 'ko-kr' => '예상', + 'fa' => 'انتظار', ], 'EndAt' => [ 'en-us' => 'End At', 'zh-cn' => '结束于', 'ja' => 'で終了', 'ko-kr' => '에 끝남', + 'fa' => 'پایان از', ], 'UploadErrorUpAgain' => [ 'en-us' => 'Maybe error, do upload again.', 'zh-cn' => '可能出错,重新上传。', 'ja' => '間違っている可能性があります。もう一度アップロードしてください。', 'ko-kr' => '잘못되었을 수 있습니다. 다시 업로드하십시오.', + 'fa' => 'خطا، دوباره آپلود کنید', ], 'UploadComplete' => [ 'en-us' => 'Upload Complete', 'zh-cn' => '上传完成', 'ja' => 'アップロード完了', 'ko-kr' => '업로드 완료', + 'fa' => 'آپلود با موفقیت انجام شد', ], 'UploadFail23' => [ 'en-us' => 'Upload Fail, contain #.', 'zh-cn' => '目录或文件名含有#,上传失败。', 'ja' => 'ディレクトリまたはファイル名に#が含まれています。アップロードに失敗しました。', 'ko-kr' => '디렉토리 또는 파일 이름에 #이 포함되어 있습니다. 업로드하지 못했습니다.', + 'fa' => 'بارگذاری ناموفق، حاوی #.', ], 'defaultSitename' => [ 'en-us' => 'OneManager', - 'zh-cn' => 'OneManager', - 'ja' => 'OneManager', - 'ko-kr' => 'OneManager', ], 'SavingToken' => [ 'en-us' => 'Saving refresh_token!', 'zh-cn' => '正在保存 refresh_token!', 'ja' => 'refresh_tokenを保存しています!', 'ko-kr' => 'refresh_token 저장 중!', + 'fa' => 'در حال ذخیره refresh_token!', ], 'MayinEnv' => [ 'en-us' => 'The \'Onedrive_ver\' may in Config', 'zh-cn' => 'Onedrive_ver应该已经写入', 'ja' => 'Onedrive_verは環境変数に書き込まれている必要があります', 'ko-kr' => 'Onedrive_verが書き込まれている必要があります', + 'fa' => 'The \'Onedrive_ver\' may in Config', ], 'Wait' => [ 'en-us' => 'Wait', 'zh-cn' => '稍等', 'ja' => 'ちょっと待って', 'ko-kr' => '잠깐만', + 'fa' => 'منتظر بمانید', ], 'WaitJumpIndex' => [ 'en-us' => 'Wait 5s jump to Home page', 'zh-cn' => '等5s跳到首页', 'ja' => '5秒待ってホームページにジャンプします', 'ko-kr' => '5 초 동안 홈페이지로 이동', + 'fa' => '۵ دقیقه صبر کنید تا به صفحه نخست برگردید', ], 'JumptoOffice' => [ 'en-us' => 'Login Office and Get a refresh_token', 'zh-cn' => '跳转到Office,登录获取refresh_token', 'ja' => 'Officeにジャンプしてログインし、refresh_tokenを取得します', 'ko-kr' => '사무실로 이동하여 로그인하여 refresh_token을 받으십시오.', + 'fa' => 'وارد Office شوید و یک refresh_token دریافت کنید', ], 'OnedriveDiskTag' => [ 'en-us' => 'Onedrive Disk Tag', 'zh-cn' => 'Onedrive 标签', 'ja' => 'Onedriveタグ', 'ko-kr' => 'Onedrive 태그', + 'fa' => 'برچسب دیسک Onedrive', ], 'OnedriveDiskName' => [ 'en-us' => 'Onedrive Showed Name', 'zh-cn' => 'Onedrive 显示名称', 'ja' => 'Onedrive表示名', 'ko-kr' => 'Onedrive 표시 이름', + 'fa' => 'نام نشان داده شده Onedrive', ], - 'OndriveVerMS' => [ - 'en-us' => 'default(Onedrive, Onedrive for business)', - 'zh-cn' => '默认(支持商业版与个人版)', - 'ja' => 'デフォルト(商用版および個人版をサポート)', - 'ko-kr' => '기본 (상업용 및 개인용 버전 지원)', + 'DriveVerMS' => [ + 'en-us' => 'Onedrive, Onedrive for business', + 'zh-cn' => '国际版(商业版与个人版)', ], - 'OndriveVerCN' => [ + 'DriveVerCN' => [ 'en-us' => 'Onedrive in China', 'zh-cn' => '世纪互联版', 'ja' => '中国のOnedrive', 'ko-kr' => '중국 Onedrive', + 'fa' => 'Onedrive در چین', ], - 'OndriveVerMSC' =>[ - 'en-us' => 'default but use customer app id & secret', - 'zh-cn' => '国际版,自己申请应用ID与机密', - 'ja' => '国際版、アプリケーションIDとシークレットを自分で申請する', - 'ko-kr' => '국제 버전, 응용 프로그램 ID 및 비밀 신청', + 'CustomIdSecret' => [ + 'en-us' => 'Use custom client id & secret', + 'zh-cn' => '自己申请应用ID与机密', + 'ja' => 'アプリケーションIDとシークレットを自分で申請する', + 'ko-kr' => '응용 프로그램 ID 및 비밀 신청', + 'fa' => 'به طور پیش فرض اما از شناسه برنامه و سکرت استفاده کنید', ], - 'GetSecretIDandKEY' =>[ - 'en-us' => 'Get customer app id & secret', + 'GetSecretIDandKEY' => [ + 'en-us' => 'Get custom client id & secret', 'zh-cn' => '申请应用ID与机密', 'ja' => 'アプリケーションIDとシークレット', + 'fa' => 'دریافت شناسه برنامه و سکرت', ], - 'TagFormatAlert' =>[ + 'UseSharepointInstead' => [ + 'en-us' => 'Use space in Sharepoint website instead of Onedrive', + 'zh-cn' => '使用Sharepoint网站的空间,不使用Onedrive', + ], + 'GetSharepointName' => [ + 'en-us' => 'Login office.com and click the SharePoint, create a website or find an exist website, input the name below', + 'zh-cn' => '登录office.com,点击Sharepoint,创建一个网站或使用原有网站,然后将它的名字填在下方', + ], + 'InputSharepointName' => [ + 'en-us' => 'Input the name of Sharepoint website', + 'zh-cn' => '输入Sharepoint网站的名称', + ], + 'TagFormatAlert' => [ 'en-us' => 'Tag must start with a letter, end with a letter or digit and can only contain lowercase letters, digits, and dashes, at least 2 letters!', 'zh-cn' => '标签只能以字母开头,以字母或数字结尾,至少2位', 'ja' => 'タグは、文字で始まり、文字または数字で終わる必要があります。少なくとも2つ', 'ko-kr' => '태그는 문자로 시작하고 문자 또는 숫자로 끝나야합니다 (2 이상).', + 'fa' => 'برچسب باید با یک حرف شروع شود، با یک حرف یا رقم پایان یابد و تنها می‌تواند حاوی حروف کوچک، ارقام و خط فاصله، حداقل ۲ حرف باشد!', ], - 'ClickInstall' =>[ + 'ClickInstall' => [ 'en-us' => 'Click to install the project', 'zh-cn' => '点击开始安装程序', 'ja' => 'クリックしてインストールプロセスを開始します', 'ko-kr' => '설치 과정을 시작하려면 클릭', + 'fa' => 'برای نصب پروژه کلیک کنید', ], - 'LogintoBind' =>[ + 'LogintoBind' => [ 'en-us' => 'then login and bind your onedrive in setup', 'zh-cn' => '然后登录后在设置中绑定你的onedrive。', 'ja' => '次に、ログインして、設定でonedriveをバインドします。', 'ko-kr' => '그런 다음 로그인하여 onedrive를 설정에 바인딩하십시오.', + 'fa' => 'پس از آن وارد سیستم شوید و تنظیمات خود را در onedrive متصل کنید', ], - 'MakesuerWriteable' =>[ + 'MakesuerWriteable' => [ 'en-us' => 'Plase make sure the config.php is writeable. run writeable.sh.', 'zh-cn' => '确认config.php可写。', 'ja' => 'config.phpが書き込み可能であることを確認してください。', 'ko-kr' => 'config.php가 쓰기 가능한지 확인하십시오.', + 'fa' => 'اطمینان حاصل کنید که config.php قابل نوشتن است. writeable.sh را اجرا کنید.', ], - 'MakesuerRewriteOn' =>[ + 'MakesuerRewriteOn' => [ 'en-us' => 'Plase make sure the RewriteEngine is On.', 'zh-cn' => '确认重写(伪静态)功能启用。', 'ja' => '書き換え(擬似静的)機能が有効になっていることを確認します。', 'ko-kr' => '다시 쓰기 (의사 정적) 기능이 활성화되어 있는지 확인하십시오.', + 'fa' => 'لطفاً مطمئن شوید که RewriteEngine روشن است.', ], - - 'Reflesh' => [ - 'en-us' => 'Reflesh', + 'CopyUrl' => [ + 'en-us' => 'Copy URL', + 'zh-cn' => '复制链接', + ], + 'Success' => [ + 'en-us' => 'Success', + 'zh-cn' => '成功', + ], + 'SetAdminPassword' => [ + 'en-us' => 'Set Admin Password', + 'zh-cn' => '设置管理密码', + ], + 'Refresh' => [ + 'en-us' => 'Refresh', 'zh-cn' => '刷新', 'ja' => 'リフレッシュ', 'ko-kr' => '새로 고침', + 'fa' => 'رفرش', ], 'SelectLanguage' => [ 'en-us' => 'Select Language', 'zh-cn' => '选择语言', 'ja' => '言語を選択してください', 'ko-kr' => '언어를 선택하십시오', + 'fa' => 'زبان را انتخاب کنید', ], 'RefreshCache' => [ 'en-us' => 'RefreshCache', 'zh-cn' => '刷新缓存', 'ja' => 'キャッシュを再構築', 'ko-kr' => '캐시 플러시', + 'fa' => 'رفرش cache', ], ]; diff --git a/function/common.php b/function/common.php index 150b2a9..18fdf8a 100644 --- a/function/common.php +++ b/function/common.php @@ -1,5 +1,36 @@ fetch($str); } -function savecache($key, $value, $exp = 3300) +function savecache($key, $value, $exp = 1800) { - $cache = null; + //$cache = null; $cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']); $cache->save($key, $value, $exp); } @@ -82,17 +139,19 @@ function config_oauth() $_SERVER['sitename'] = getConfig('sitename'); if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = getconstStr('defaultSitename'); $_SERVER['redirect_uri'] = 'https://scfonedrive.github.io'; - - if (getConfig('Onedrive_ver')=='MS') { + if (getConfig('Drive_ver')=='MS') { // MS // https://portal.azure.com - $_SERVER['client_id'] = '4da3e7f2-bf6d-467c-aaf0-578078f0bf7c'; - $_SERVER['client_secret'] = '7/+ykq2xkfx:.DWjacuIRojIaaWL0QI6'; + //$_SERVER['client_id'] = '4da3e7f2-bf6d-467c-aaf0-578078f0bf7c'; + //$_SERVER['client_secret'] = '7/+ykq2xkfx:.DWjacuIRojIaaWL0QI6'; + $_SERVER['client_id'] = '734ef928-d74c-4555-8d1b-d942fa0a1a41'; + $_SERVER['client_secret'] = ':EK[e0/4vQ@mQgma8LmnWb6j4_C1CSIW'; $_SERVER['oauth_url'] = 'https://login.microsoftonline.com/common/oauth2/v2.0/'; $_SERVER['api_url'] = 'https://graph.microsoft.com/v1.0/me/drive/root'; $_SERVER['scope'] = 'https://graph.microsoft.com/Files.ReadWrite.All offline_access'; + if (getConfig('usesharepoint')=='on') $_SERVER['api_url'] = 'https://graph.microsoft.com/v1.0/sites/' . getConfig('siteid') . '/drive/root'; } - if (getConfig('Onedrive_ver')=='CN') { + if (getConfig('Drive_ver')=='CN') { // CN // https://portal.azure.cn $_SERVER['client_id'] = '04c3ca0b-8d07-4773-85ad-98b037d25631'; @@ -100,22 +159,37 @@ function config_oauth() $_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'] = base64_decode(equal_replace(getConfig('client_secret'),1)); - //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'; + if (getConfig('usesharepoint')=='on') $_SERVER['api_url'] = 'https://microsoftgraph.chinacloudapi.cn/v1.0/sites/' . getConfig('siteid') . '/drive/root'; } + if (getConfig('Drive_custom')=='on') { + // Customer + $_SERVER['client_id'] = getConfig('client_id'); + $_SERVER['client_secret'] = getConfig('client_secret'); + } $_SERVER['client_secret'] = urlencode($_SERVER['client_secret']); $_SERVER['scope'] = urlencode($_SERVER['scope']); } +function get_siteid($access_token) +{ + if (getConfig('Drive_ver')=='MS') $url = 'https://graph.microsoft.com/v1.0/sites/root:/sites/'.getConfig('sharepointname'); + if (getConfig('Drive_ver')=='CN') $url = 'https://microsoftgraph.chinacloudapi.cn/v1.0/sites/root:/sites/'.getConfig('sharepointname'); + $i=0; + $response = []; + while ($url!=''&&$response['stat']!=200&&$i<4) { + $response = curl_request($url, false, ['Authorization' => 'Bearer ' . $access_token]); + $i++; + //echo 'https://graph.microsoft.com/v1.0/sites/root:/sites/'.getConfig('sharepointname').$response['stat'].$response['body'].' + //'; + } + if ($response['stat']!=200) { + error_log('failed to get siteid. response' . json_encode($response)); + throw new Exception($response['stat'].', failed to get siteid.'.$response['body']); + } + return json_decode($response['body'],true)['id']; +} + function getListpath($domain) { $domain_path1 = getConfig('domain_path'); @@ -167,7 +241,9 @@ function equal_replace($str, $add = false) { if ($add) { while(strlen($str)%4) $str .= '='; + $str = urldecode(base64_decode($str)); } else { + $str = base64_encode(urlencode($str)); while(substr($str,-1)=='=') $str=substr($str,0,-1); } return $str; @@ -184,7 +260,7 @@ function array_value_isnot_null($arr) return $arr!==''; } -function curl_request($url, $data = false, $headers = []) +function curl_request($url, $data = false, $headers = [], $returnheader = 0) { if (!isset($headers['Accept'])) $headers['Accept'] = '*/*'; //if (!isset($headers['Referer'])) $headers['Referer'] = $url; @@ -202,14 +278,23 @@ function curl_request($url, $data = false, $headers = []) 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_HEADER, $returnheader); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, $sendHeaders); - $response['body'] = curl_exec($ch); + //$response['body'] = curl_exec($ch); + if ($returnheader) { + list($returnhead, $response['body']) = explode("\r\n\r\n", curl_exec($ch)); + foreach (explode("\r\n", $returnhead) as $head) { + $tmp = explode(': ', $head); + $heads[$tmp[0]] = $tmp[1]; + } + $response['returnhead'] = $heads; + } else { + $response['body'] = curl_exec($ch); + } $response['stat'] = curl_getinfo($ch,CURLINFO_HTTP_CODE); curl_close($ch); - if ($response['stat']==0) return curl_request($url, $data, $headers); return $response; } @@ -244,31 +329,33 @@ function encode_str_replace($str) function gethiddenpass($path,$passfile) { - $password=getcache('path_' . $path . '/?password'); + $path1 = path_format($_SERVER['list_path'] . path_format($path)); + if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1); + $password=getcache('path_' . $path1 . '/?password'); if ($password=='') { - $ispassfile = fetch_files(spurlencode(path_format($path . '/' . $passfile),'/')); - //echo $path . '
' . json_encode($ispassfile, JSON_PRETTY_PRINT) . '
'; - 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); - savecache($path . '/password', $password); - return $password; + $ispassfile = fetch_files(path_format($path . '/' . urlencode($passfile))); + //echo $path . '
' . json_encode($ispassfile, JSON_PRETTY_PRINT) . '
'; + if (isset($ispassfile['file'])) { + $arr = curl_request($ispassfile['@microsoft.graph.downloadUrl']); + if ($arr['stat']==200) { + $passwordf=explode("\n",$arr['body']); + $password=$passwordf[0]; + if ($password!='') $password=md5($password); + savecache('path_' . $path1 . '/?password', $password); + return $password; + } else { + //return md5('DefaultP@sswordWhenNetworkError'); + return md5( md5(time()).rand(1000,9999) ); + } } else { - //return md5('DefaultP@sswordWhenNetworkError'); - return md5( md5(time()).rand(1000,9999) ); + savecache('path_' . $path1 . '/?password', 'null'); + if ($path !== '' ) { + $path = substr($path,0,strrpos($path,'/')); + return gethiddenpass($path,$passfile); + } else { + return ''; + } } - } else { - savecache($path . '/password', 'null'); - if ($path !== '' ) { - $path = substr($path,0,strrpos($path,'/')); - return gethiddenpass($path,$passfile); - } else { - return ''; - } - } } elseif ($password==='null') { if ($path !== '' ) { $path = substr($path,0,strrpos($path,'/')); @@ -322,15 +409,20 @@ function get_timezone($timezone = '8') function message($message, $title = 'Message', $statusCode = 200) { return output(' + +

' . $title . '

+ ' . $message . ' +

-', $statusCode); + +', $statusCode); } function needUpdate() @@ -365,6 +457,7 @@ function passhidden($path) $path = str_replace('+','%2B',$path); $path = str_replace('&','&', path_format(urldecode($path))); if (getConfig('passfile') != '') { + $path = spurlencode($path,'/'); if (substr($path,-1)=='/') $path=substr($path,0,-1); $hiddenpass=gethiddenpass($path,getConfig('passfile')); if ($hiddenpass != '') { @@ -403,7 +496,8 @@ function get_thumbnails_url($path = '/') { $path1 = path_format($path); $path = path_format($_SERVER['list_path'] . path_format($path)); - $thumb_url = getcache($path); + if ($path!='/'&&substr($path,-1)=='/') $path=substr($path,0,-1); + $thumb_url = getcache('thumb_'.$path); if ($thumb_url!='') return output($thumb_url); $url = $_SERVER['api_url']; if ($path !== '/') { @@ -413,7 +507,7 @@ function get_thumbnails_url($path = '/') $url .= ':/thumbnails/0/medium'; $files = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true); if (isset($files['url'])) { - savecache($path, $files['url']); + savecache('thumb_'.$path, $files['url']); return output($files['url']); } return output('', 404); @@ -453,36 +547,20 @@ function main($path) global $constStr; //echo 'main.enterpath:'.$path.' //'; - $constStr['language'] = $_COOKIE['language']; - if ($constStr['language']=='') $constStr['language'] = getConfig('language'); + if (isset($_COOKIE['language'])) $constStr['language'] = $_COOKIE['language']; + if (!$constStr['language']) $constStr['language'] = getConfig('language'); if ($constStr['language']=='') $constStr['language'] = 'en-us'; + $_SERVER['language'] = $constStr['language']; $_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path); - $_SERVER['base_disk_path'] = $_SERVER['base_path']; - $disktags = explode("|",getConfig('disktag')); -// echo 'count$disk:'.count($disktags); - if (count($disktags)>1) { - if ($path=='/'||$path=='') return output('', 302, [ 'Location' => path_format($_SERVER['PHP_SELF'].'/'.$disktags[0]) ]); - $_SERVER['disktag'] = $path; - $pos = strpos($path, '/'); - if ($pos>1) $_SERVER['disktag'] = substr($path, 0, $pos); - $path = substr($path, strlen('/'.$_SERVER['disktag'])); - if ($_SERVER['disktag']!='') $_SERVER['base_disk_path'] = path_format($_SERVER['base_disk_path']. '/' . $_SERVER['disktag'] . '/'); - } else $_SERVER['disktag'] = $disktags[0]; -// echo 'main.disktag:'.$_SERVER['disktag'].',path:'.$path.' -//'; - $_SERVER['list_path'] = getListpath($_SERVER['HTTP_HOST']); - if ($_SERVER['list_path']=='') $_SERVER['list_path'] = '/'; - $_SERVER['is_guestup_path'] = is_guestup_path($path); - $_SERVER['ajax']=0; - if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) if ($_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest') $_SERVER['ajax']=1; + if (getConfig('admin')=='') return install(); if (getConfig('adminloginpage')=='') { $adminloginpage = 'admin'; } else { $adminloginpage = getConfig('adminloginpage'); } - if ($_GET[$adminloginpage]) { - if ($_GET['preview']) { + if (isset($_GET[$adminloginpage])) { + if (isset($_GET['preview'])) { $url = $_SERVER['PHP_SELF'] . '?preview'; } else { $url = path_format($_SERVER['PHP_SELF'] . '/'); @@ -496,96 +574,144 @@ function main($path) } } if (getConfig('admin')!='') - if ( $_COOKIE['admin']==md5(getConfig('admin')) || $_POST['password1']==getConfig('admin') ) { + if ( (isset($_COOKIE['admin'])&&$_COOKIE['admin']==md5(getConfig('admin'))) || (isset($_POST['password1'])&&$_POST['password1']==getConfig('admin')) ) { $_SERVER['admin']=1; $_SERVER['needUpdate'] = needUpdate(); } else { $_SERVER['admin']=0; } - if ($_GET['setup']) + if (isset($_GET['setup'])) if ($_SERVER['admin']) { // setup Environments. 设置,对环境变量操作 - return EnvOpt($_SERVER['function_name'], $_SERVER['needUpdate']); + return EnvOpt($_SERVER['needUpdate']); } else { $url = path_format($_SERVER['PHP_SELF'] . '/'); return output('', 302, [ 'Location' => $url ]); } - - if (getConfig('admin')=='') return install(); + + $_SERVER['base_disk_path'] = $_SERVER['base_path']; + $disktags = explode("|",getConfig('disktag')); +// echo 'count$disk:'.count($disktags); + if (count($disktags)>1) { + if ($path=='/'||$path=='') return output('', 302, [ 'Location' => path_format($_SERVER['base_path'].'/'.$disktags[0].'/') ]); + $_SERVER['disktag'] = $path; + $pos = strpos($path, '/'); + if ($pos>1) $_SERVER['disktag'] = substr($path, 0, $pos); + if (!in_array($_SERVER['disktag'], $disktags)) return message('Please visit from Home Page.', 'Error', 404); + $path = substr($path, strlen('/'.$_SERVER['disktag'])); + if ($_SERVER['disktag']!='') $_SERVER['base_disk_path'] = path_format($_SERVER['base_disk_path']. '/' . $_SERVER['disktag'] . '/'); + } else $_SERVER['disktag'] = $disktags[0]; +// echo 'main.disktag:'.$_SERVER['disktag'].',path:'.$path.' +//'; + $_SERVER['list_path'] = getListpath($_SERVER['HTTP_HOST']); + if ($_SERVER['list_path']=='') $_SERVER['list_path'] = '/'; + $_SERVER['is_guestup_path'] = is_guestup_path($path); + $_SERVER['ajax']=0; + if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) if ($_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest') $_SERVER['ajax']=1; + config_oauth(); - if ($_SERVER['admin']) if ($_GET['AddDisk']||$_GET['authorization_code']) return get_refresh_token(); + if ($_SERVER['admin']) if (isset($_GET['AddDisk'])||isset($_GET['authorization_code'])) return get_refresh_token(); $refresh_token = getConfig('refresh_token'); //if (!$refresh_token) return get_refresh_token(); if (!$refresh_token) { return render_list(); } else { - if (!($_SERVER['access_token'] = getcache('access_token'))) { - $response = curl_request( $_SERVER['oauth_url'] . 'token', 'client_id='. $_SERVER['client_id'] .'&client_secret='. $_SERVER['client_secret'] .'&grant_type=refresh_token&requested_token_use=on_behalf_of&refresh_token=' . $refresh_token ); - if ($response['stat']==200) $ret = json_decode($response['body'], true); - if (!isset($ret['access_token'])) { - error_log('failed to get access_token. response' . json_encode($ret)); - throw new Exception($response['stat'].', failed to get access_token.'.$response['body']); + if (!($_SERVER['access_token'] = getcache('access_token'))) { + $response = curl_request( $_SERVER['oauth_url'] . 'token', 'client_id='. $_SERVER['client_id'] .'&client_secret='. $_SERVER['client_secret'] .'&grant_type=refresh_token&requested_token_use=on_behalf_of&refresh_token=' . $refresh_token ); + if ($response['stat']==200) $ret = json_decode($response['body'], true); + if (!isset($ret['access_token'])) { + error_log($_SERVER['oauth_url'] . 'token'.'?client_id='. $_SERVER['client_id'] .'&client_secret='. $_SERVER['client_secret'] .'&grant_type=refresh_token&requested_token_use=on_behalf_of&refresh_token=' . $refresh_token); + error_log('failed to get access_token. response' . json_encode($ret)); + throw new Exception($response['stat'].', failed to get access_token.'.$response['body']); + } + error_log('Get access token:'.json_encode($ret, JSON_PRETTY_PRINT)); + $_SERVER['access_token'] = $ret['access_token']; + savecache('access_token', $_SERVER['access_token'], $ret['expires_in'] - 300); + if (time()>getConfig('token_expires')) setConfig([ 'refresh_token' => $ret['refresh_token'], 'token_expires' => time()+7*24*60*60 ]); } - error_log('Get access token:'.json_encode($ret, JSON_PRETTY_PRINT)); - $_SERVER['access_token'] = $ret['access_token']; - savecache('access_token', $_SERVER['access_token'], $ret['expires_in'] - 300); - if (time()>getConfig('token_expires')) setConfig([ 'refresh_token' => $ret['refresh_token'], 'token_expires' => time()+30*24*60*60 ]); - } - $_SERVER['retry'] = 0; - 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 ($_SERVER['ajax']) { + if ($_GET['action']=='del_upload_cache'&&substr($_GET['filename'],-4)=='.tmp') { + // del '.tmp' without login. 无需登录即可删除.tmp后缀文件 + error_log('del.tmp:GET,'.json_encode($_GET,JSON_PRETTY_PRINT)); + $tmp = MSAPI('DELETE',path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . spurlencode($_GET['filename']) ),'',$_SERVER['access_token']); + $path1 = path_format($_SERVER['list_path'] . path_format($path)); + if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1); + savecache('path_' . $path1, json_decode('{}',true), 1); + return output($tmp['body'],$tmp['stat']); + } + if ($_GET['action']=='uploaded_rename') { + // rename .scfupload file without login. + // 无需登录即可重命名.scfupload后缀文件,filemd5为用户提交,可被构造,问题不大,以后处理 + $oldname = spurlencode($_GET['filename']); + $pos = strrpos($oldname, '.'); + if ($pos>0) $ext = strtolower(substr($oldname, $pos)); + $oldname = path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . $oldname . '.scfupload' ); + $data = '{"name":"' . $_GET['filemd5'] . $ext . '"}'; + //echo $oldname .'
'. $data; + $tmp = MSAPI('PATCH',$oldname,$data,$_SERVER['access_token']); + if ($tmp['stat']==409) { + MSAPI('DELETE',$oldname,'',$_SERVER['access_token']); + $tmpbody = json_decode($tmp['body'], true); + $tmpbody['name'] = $_GET['filemd5'] . $ext; + $tmp['body'] = json_encode($tmpbody); + } + $path1 = path_format($_SERVER['list_path'] . path_format($path)); + if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1); + savecache('path_' . $path1, json_decode('{}',true), 1); + return output($tmp['body'],$tmp['stat']); + } + if ($_GET['action']=='upbigfile') return bigfileupload($path); } - if ($_GET['action']=='uploaded_rename') { - // rename .scfupload file without login. - // 无需登录即可重命名.scfupload后缀文件,filemd5为用户提交,可被构造,问题不大,以后处理 - $oldname = spurlencode($_GET['filename']); - $pos = strrpos($oldname, '.'); - if ($pos>0) $ext = strtolower(substr($oldname, $pos)); - $oldname = path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . $oldname . '.scfupload' ); - $data = '{"name":"' . $_GET['filemd5'] . $ext . '"}'; - //echo $oldname .'
'. $data; - $tmp = MSAPI('PATCH',$oldname,$data,$_SERVER['access_token']); - if ($tmp['stat']==409) MSAPI('DELETE',$oldname,'',$_SERVER['access_token'])['body']; - $path1 = path_format($_SERVER['list_path'] . path_format($path)); - savecache('path_' . $path1, json_decode('{}',true), 1); - return output($tmp['body'],$tmp['stat']); + if ($_SERVER['admin']) { + $tmp = adminoperate($path); + if ($tmp['statusCode'] > 0) { + $path1 = path_format($_SERVER['list_path'] . path_format($path)); + if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1); + savecache('path_' . $path1, json_decode('{}',true), 1); + return $tmp; + } + } else { + if ($_SERVER['ajax']) return output(getconstStr('RefreshtoLogin'),401); } - 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; + $_SERVER['ishidden'] = passhidden($path); + if (isset($_GET['thumbnails'])) { + if ($_SERVER['ishidden']<4) { + if (in_array(strtolower(substr($path, strrpos($path, '.') + 1)), $exts['img'])) { + return get_thumbnails_url($path); + } else return output(json_encode($exts['img']),400); + } else return output('',401); + } + + $files = list_files($path); + //echo json_encode(array_keys($files['children']), JSON_PRETTY_PRINT); + if (isset($_GET['random'])&&$_GET['random']!=='') { + if ($_SERVER['ishidden']<4) { + $tmp = []; + foreach (array_keys($files['children']) as $filename) { + if (strtolower(splitlast($filename,'.')[1])==strtolower($_GET['random'])) $tmp[$filename] = $files['children'][$filename]['@microsoft.graph.downloadUrl']; + } + $tmp = array_values($tmp); + if (count($tmp)>0) { + if (isset($_GET['url'])) return output($tmp[rand(0,count($tmp)-1)], 200); + return output('', 302, [ 'Location' => $tmp[rand(0,count($tmp)-1)] ]); + } else return output('',404); + } else return output('',401); + } + if (isset($files['file']) && !isset($_GET['preview'])) { + // is file && not preview mode + if ( $_SERVER['ishidden']<4 || (!!getConfig('downloadencrypt')&&$files['name']!=getConfig('passfile')) ) return output('', 302, [ 'Location' => $files['@microsoft.graph.downloadUrl'] ]); + } + if ( isset($files['folder']) || isset($files['file']) ) { + return render_list($path, $files); + } else { + if (!isset($files['error'])) { + $files['error']['message'] = json_encode($files, JSON_PRETTY_PRINT); + $files['error']['code'] = 'unknownError'; + $files['error']['stat'] = 500; + } + return message(''.getconstStr('Back').getconstStr('Home').'
' . $files['error']['message'] . '
'.getconstStr('Back').'', $files['error']['code'], $files['error']['stat']); } - } 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(''.getconstStr('Back').getconstStr('Home').'
' . $files['error']['message'] . '
'.getconstStr('Back').'', $files['error']['code'], $files['error']['stat']); - } } } @@ -594,20 +720,13 @@ 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); + } elseif (!getConfig('downloadencrypt')) { + if ($_SERVER['ishidden']==4) $files = json_decode('{"folder":{}}', true); + else $files = fetch_files($path); } 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
' ); - $_SERVER['retry']++; - if ($_SERVER['retry'] < 3) { - return list_files($path); - } else return $files; - } + return $files; } function adminform($name = '', $pass = '', $path = '') @@ -647,7 +766,7 @@ function adminoperate($path) $path1 = path_format($_SERVER['list_path'] . path_format($path)); if (substr($path1,-1)=='/') $path1=substr($path1,0,-1); $tmparr['statusCode'] = 0; - if ($_GET['rename_newname']!=$_GET['rename_oldname'] && $_GET['rename_newname']!='') { + if (isset($_GET['rename_newname'])&&$_GET['rename_newname']!=$_GET['rename_oldname'] && $_GET['rename_newname']!='') { // rename 重命名 $oldname = spurlencode($_GET['rename_oldname']); $oldname = path_format($path1 . '/' . $oldname); @@ -657,7 +776,7 @@ function adminoperate($path) //savecache('path_' . $path1, json_decode('{}',true), 1); return output($result['body'], $result['stat']); } - if ($_GET['delete_name']!='') { + if (isset($_GET['delete_name'])) { // delete 删除 $filename = spurlencode($_GET['delete_name']); $filename = path_format($path1 . '/' . $filename); @@ -666,7 +785,7 @@ function adminoperate($path) //savecache('path_' . $path1, json_decode('{}',true), 1); return output($result['body'], $result['stat']); } - if ($_GET['operate_action']==getconstStr('encrypt')) { + if (isset($_GET['operate_action'])&&$_GET['operate_action']==getconstStr('encrypt')) { // encrypt 加密 if (getConfig('passfile')=='') return message(getconstStr('SetpassfileBfEncrypt'),'',403); if ($_GET['encrypt_folder']=='/') $_GET['encrypt_folder']==''; @@ -674,10 +793,12 @@ function adminoperate($path) $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); + $path1 = path_format($path1 . '/' . $foldername ); + if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1); + savecache('path_' . $path1 . '/?password', '', 1); return output($result['body'], $result['stat']); } - if ($_GET['move_folder']!='') { + if (isset($_GET['move_folder'])) { // move 移动 $moveable = 1; if ($path == '/' && $_GET['move_folder'] == '/../') $moveable=0; @@ -691,13 +812,14 @@ function adminoperate($path) //savecache('path_' . $path1, json_decode('{}',true), 1); if ($_GET['move_folder'] == '/../') $path2 = path_format( substr($path1, 0, strrpos($path1, '/')) . '/' ); else $path2 = path_format( $path1 . '/' . $_GET['move_folder'] . '/' ); + if ($path2!='/'&&substr($path2,-1)=='/') $path2=substr($path2,0,-1); savecache('path_' . $path2, json_decode('{}',true), 1); return output($result['body'], $result['stat']); } else { return output('{"error":"'.getconstStr('CannotMove').'"}', 403); } } - if ($_GET['copy_name']!='') { + if (isset($_GET['copy_name'])) { // copy 复制 $filename = spurlencode($_GET['copy_name']); $filename = path_format($path1 . '/' . $filename); @@ -731,9 +853,9 @@ function adminoperate($path) //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'].json_encode($result['Location']), $result['stat']); + return output($result['body'], $result['stat']); } - if ($_POST['editfile']!='') { + if (isset($_POST['editfile'])) { // edit 编辑 $data = $_POST['editfile']; /*TXT一般不会超过4M,不用二段上传 @@ -746,7 +868,7 @@ function adminoperate($path) $resultarry = json_decode($result,true); if (isset($resultarry['error'])) return message($resultarry['error']['message']. '
'.getconstStr('Back').'','Error',403); } - if ($_GET['create_name']!='') { + if (isset($_GET['create_name'])) { // create 新建 if ($_GET['create_type']=='file') { $filename = spurlencode($_GET['create_name']); @@ -760,9 +882,10 @@ function adminoperate($path) //savecache('path_' . $path1, json_decode('{}',true), 1); return output($result['body'], $result['stat']); } - if ($_GET['RefreshCache']) { - //savecache('path_' . $path1, json_decode('{}',true), 1); - savecache('path_' . $path . '/?password', '', 1); + if (isset($_GET['RefreshCache'])) { + $path1 = path_format($_SERVER['list_path'] . path_format($path)); + if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1); + savecache('path_' . $path1 . '/?password', '', 1); return message('', getconstStr('RefreshCache'), 302); } return $tmparr; @@ -779,7 +902,7 @@ function splitlast($str, $split) $tmp[1] = substr($str, $pos+1); } else { $tmp[0] = ''; - $tmp[1] = $str; + $tmp[1] = substr($str, 1); } return $tmp; } @@ -854,39 +977,57 @@ function MSAPI($method, $path, $data = '', $access_token) function fetch_files($path = '/') { + global $exts; $path1 = path_format($path); $path = path_format($_SERVER['list_path'] . path_format($path)); + if ($path!='/'&&substr($path,-1)=='/') $path=substr($path,0,-1); if (!($files = getcache('path_' . $path))) { // https://docs.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0 // https://docs.microsoft.com/zh-cn/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=http // https://developer.microsoft.com/zh-cn/graph/graph-explorer - $pos = strrpos($path, '/'); - if ($pos>1) { - $parentpath = substr($path, 0, $pos); - $filename = substr($path, $pos+1); - if ($parentfiles = getcache('path_' . $parentpath)) - foreach ($parentfiles['children'] as $file) - if ($file['name']==$filename) - if (isset($file['@microsoft.graph.downloadUrl'])) - return $file; + $pos = splitlast($path, '/'); + $parentpath = $pos[0]; + if ($parentpath=='') $parentpath = '/'; + $filename = $pos[1]; + if ($parentfiles = getcache('path_' . $parentpath)) { + if (isset($parentfiles['children'][$filename]['@microsoft.graph.downloadUrl'])) { + if (in_array(splitlast($filename,'.')[1], $exts['txt'])) { + if (!(isset($parentfiles['children'][$filename]['content'])&&$parentfiles['children'][$filename]['content']['stat']==200)) { + $content1 = curl_request($parentfiles['children'][$filename]['@microsoft.graph.downloadUrl']); + $parentfiles['children'][$filename]['content'] = $content1; + savecache('path_' . $parentpath, $parentfiles); + } + } + return $parentfiles['children'][$filename]; + } } + $url = $_SERVER['api_url']; if ($path !== '/') { $url .= ':' . $path; if (substr($url,-1)=='/') $url=substr($url,0,-1); } $url .= '?expand=children(select=name,size,file,folder,parentReference,lastModifiedDateTime,@microsoft.graph.downloadUrl)'; - $arr = curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']]); + $retry = 0; + $arr = []; + while ($retry<3&&!$arr['stat']) { + $arr = curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']]); + $retry++; + } if ($arr['stat']<500) { $files = json_decode($arr['body'], true); // echo $path . '
' . json_encode($files, JSON_PRETTY_PRINT) . '
'; if (isset($files['folder'])) { if ($files['folder']['childCount']>200) { - // files num > 200 , then get nextlink + // files num > 200 , then get nextlink $page = $_POST['pagenum']==''?1:$_POST['pagenum']; - $files=fetch_files_children($files, $path1, $page); + if ($page>1) $files=fetch_files_children($files, $path1, $page); + $files['children'] = children_name($files['children']); } else { // files num < 200 , then cache + //if (isset($files['children'])) { + $files['children'] = children_name($files['children']); + //} savecache('path_' . $path, $files); } } @@ -894,17 +1035,37 @@ function fetch_files($path = '/') $files['error']['stat'] = $arr['stat']; } } else { - error_log($arr['body']); - $files = json_decode( '{"unknownError":{ "stat":'.$arr['stat'].',"message":"'.$arr['body'].'"}}', true); + //error_log($arr['body']); + $files = json_decode($arr['body'], true); + if (isset($files['error'])) { + $files['error']['stat'] = $arr['stat']; + } else { + $files['error']['stat'] = 503; + $files['error']['code'] = 'unknownError'; + $files['error']['message'] = 'unknownError'; + } + //$files = json_decode( '{"unknownError":{ "stat":'.$arr['stat'].',"message":"'.$arr['body'].'"}}', true); + //error_log(json_encode($files, JSON_PRETTY_PRINT)); } } + return $files; } +function children_name($children) +{ + $tmp = []; + foreach ($children as $file) { + $tmp[strtolower($file['name'])] = $file; + } + return $tmp; +} + function fetch_files_children($files, $path, $page) { $path1 = path_format($path); $path = path_format($_SERVER['list_path'] . path_format($path)); + if ($path!='/'&&substr($path,-1)=='/') $path=substr($path,0,-1); $cachefilename = '.SCFcache_'.$_SERVER['function_name']; $maxpage = ceil($files['folder']['childCount']/200); if (!($files['children'] = getcache('files_' . $path . '_page_' . $page))) { @@ -928,9 +1089,9 @@ function fetch_files_children($files, $path, $page) if ($path !== '/') { $url .= ':' . $path; if (substr($url,-1)=='/') $url=substr($url,0,-1); - $url .= ':/children?$select=name,size,file,folder,parentReference,lastModifiedDateTime'; + $url .= ':/children?$select=name,size,file,folder,parentReference,lastModifiedDateTime,@microsoft.graph.downloadUrl'; } else { - $url .= '/children?$select=name,size,file,folder,parentReference,lastModifiedDateTime'; + $url .= '/children?$select=name,size,file,folder,parentReference,lastModifiedDateTime,@microsoft.graph.downloadUrl'; } $children = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true); // echo $url . '
' . json_encode($children, JSON_PRETTY_PRINT) . '
'; @@ -1009,6 +1170,10 @@ function render_list($path = '', $files = '') global $exts; global $constStr; + if (isset($files['children']['index.html']) && !$_SERVER['admin']) { + $htmlcontent = fetch_files(spurlencode(path_format($path . '/index.html'),'/'))['content']; + return output($htmlcontent['body'], $htmlcontent['stat']); + } $path = str_replace('%20','%2520',$path); $path = str_replace('+','%2B',$path); $path = str_replace('&','&',path_format(urldecode($path))) ; @@ -1041,12 +1206,343 @@ function render_list($path = '', $files = '') $theme = getConfig('theme'); if ( $theme=='' || !file_exists('theme/'.$theme) ) $theme = 'classic.php'; - $htmlpage = include 'theme/'.$theme; + include 'theme/'.$theme; $html = '' . ob_get_clean(); - if (isset($htmlpage['statusCode'])) return $htmlpage; - if ($_SERVER['Set-Cookie']!='') return output($html, $statusCode, [ 'Set-Cookie' => $_SERVER['Set-Cookie'], 'Content-Type' => 'text/html' ]); + //if (isset($htmlpage['statusCode'])) return $htmlpage; + if (isset($_SERVER['Set-Cookie'])) return output($html, $statusCode, [ 'Set-Cookie' => $_SERVER['Set-Cookie'], 'Content-Type' => 'text/html' ]); return output($html,$statusCode); } + +function get_refresh_token() +{ + global $constStr; + global $CommonEnv; + $envs = ''; + foreach ($CommonEnv as $env) $envs .= '\'' . $env . '\', '; + $url = path_format($_SERVER['PHP_SELF'] . '/'); + if (isset($_GET['authorization_code']) && isset($_GET['code'])) { + $_SERVER['disktag'] = $_COOKIE['disktag']; + config_oauth(); + $tmp = curl_request($_SERVER['oauth_url'] . 'token', 'client_id=' . $_SERVER['client_id'] .'&client_secret=' . $_SERVER['client_secret'] . '&grant_type=authorization_code&requested_token_use=on_behalf_of&redirect_uri=' . $_SERVER['redirect_uri'] .'&code=' . $_GET['code']); + if ($tmp['stat']==200) $ret = json_decode($tmp['body'], true); + if (isset($ret['refresh_token'])) { + $refresh_token = $ret['refresh_token']; + $str = ' + refresh_token :
'; + $str .= ' +

+ '.getconstStr('SavingToken').' + '; + $tmptoken['refresh_token'] = $refresh_token; + $tmptoken['token_expires'] = time()+7*24*60*60; + if (getConfig('usesharepoint')=='on') $tmptoken['siteid'] = get_siteid($ret['access_token']); + setConfig($tmptoken, $_COOKIE['disktag']); + savecache('access_token', $ret['access_token'], $ret['expires_in'] - 60); + //WaitSCFStat(); + $str .= ' + '; + return message($str, getconstStr('WaitJumpIndex')); + } + return message('
' . json_encode(json_decode($tmp['body']), JSON_PRETTY_PRINT) . '
', $tmp['stat']); + //return message('
' . json_encode($ret, JSON_PRETTY_PRINT) . '
', 500); + } + if (isset($_GET['install1'])) { + $_SERVER['disktag'] = $_COOKIE['disktag']; + config_oauth(); + if (getConfig('Drive_ver')=='MS' || getConfig('Drive_ver')=='CN') { + return message(' + '.getconstStr('JumptoOffice').' + + ', getconstStr('Wait').' 1s', 201); + } else { + return message('something error, try after a few seconds.', 'retry', 201); + } + } + if (isset($_GET['install0'])) { + if ($_POST['disktag_add']!='' && ($_POST['Drive_ver']=='MS' || $_POST['Drive_ver']=='CN')) { + if (in_array($_COOKIE['disktag'], $CommonEnv)) { + return message('Do not input ' . $envs . '
', 'Error', 201); + } + $_SERVER['disktag'] = $_COOKIE['disktag']; + $tmp['disktag_add'] = $_POST['disktag_add']; + $tmp['diskname'] = $_POST['diskname']; + $tmp['Drive_ver'] = $_POST['Drive_ver']; + if ($_POST['Drive_custom']=='on') { + $tmp['Drive_custom'] = $_POST['Drive_custom']; + $tmp['client_id'] = $_POST['client_id']; + $tmp['client_secret'] = $_POST['client_secret']; + } + if ($_POST['usesharepoint']=='on') { + $tmp['usesharepoint'] = $_POST['usesharepoint']; + $tmp['sharepointname'] = $_POST['sharepointname']; + } + $response = setConfigResponse( setConfig($tmp, $_COOKIE['disktag']) ); + if (api_error($response)) { + $html = api_error_msg($response); + $title = 'Error'; + } else { + $title = getconstStr('MayinEnv'); + $html = getconstStr('Wait') . ' 3s'; + } + return message($html, $title, 201); + } + } + + if ($constStr['language']!='zh-cn') { + $linklang='en-us'; + } else $linklang='zh-cn'; + $ru = "https://developer.microsoft.com/".$linklang."/graph/quick-start?appID=_appId_&appName=_appName_&redirectUrl=".$_SERVER['redirect_uri']."&platform=option-php"; + $deepLink = "/quickstart/graphIO?publicClientSupport=false&appName=OneManager&redirectUrl=".$_SERVER['redirect_uri']."&allowImplicitFlow=false&ru=".urlencode($ru); + $app_url = "https://apps.dev.microsoft.com/?deepLink=".urlencode($deepLink); + $html = ' +
+
+ '.getconstStr('OnedriveDiskTag').': ('.getConfig('disktag').')
+ '.getconstStr('OnedriveDiskName').':
+
+
+
+ +
+
+
+ + +
+
+
+ +
+
+ +
+
+ '; + $title = 'Bind Onedrive'; + return message($html, $title, 201); +} + +function EnvOpt($needUpdate = 0) +{ + global $constStr; + global $ShowedCommonEnv; + global $ShowedInnerEnv; + asort($ShowedCommonEnv); + asort($ShowedInnerEnv); + $html = 'OneManager '.getconstStr('Setup').''; + if (isset($_POST['updateProgram'])&&$_POST['updateProgram']==getconstStr('updateProgram')) { + $response = OnekeyUpate(); + if (api_error($response)) { + $html = api_error_msg($response); + $title = 'Error'; + } else { + //WaitSCFStat(); + $html .= getconstStr('UpdateSuccess') . '
+'; + $title = getconstStr('Setup'); + } + return message($html, $title); + } + if (isset($_POST['submit1'])) { + $_SERVER['disk_oprating'] = ''; + foreach ($_POST as $k => $v) { + if (in_array($k, $ShowedCommonEnv)||in_array($k, $ShowedInnerEnv)||$k=='disktag_del' || $k=='disktag_add') { + $tmp[$k] = $v; + } + if ($k == 'disk') $_SERVER['disk_oprating'] = $v; + } + /*if ($tmp['domain_path']!='') { + $tmp1 = explode("|",$tmp['domain_path']); + $tmparr = []; + foreach ($tmp1 as $multidomain_paths){ + $pos = strpos($multidomain_paths,":"); + if ($pos>0) $tmparr[substr($multidomain_paths, 0, $pos)] = path_format(substr($multidomain_paths, $pos+1)); + } + $tmp['domain_path'] = $tmparr; + }*/ + $response = setConfigResponse( setConfig($tmp, $_SERVER['disk_oprating']) ); + if (api_error($response)) { + $html = api_error_msg($response); + $title = 'Error'; + } else { + //WaitSCFStat(); + //sleep(3); + $html .= getconstStr('Success') . '!
+'; + $title = getconstStr('Setup'); + } + return message($html, $title); + } + if (isset($_GET['preview'])) { + $preurl = $_SERVER['PHP_SELF'] . '?preview'; + } else { + $preurl = path_format($_SERVER['PHP_SELF'] . '/'); + } + $html .= ' +'.getconstStr('Back').'   '.getconstStr('Back').getconstStr('Home').'
+Github
'; + if (!((isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud')||(isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app'))) { + $html .= ' +In VPS can not update by a click!
'; + } else { + $html .= ' +
+'; + if ($needUpdate) { + $html .= '
' . $_SERVER['github_version'] . '
'; + } else { + $html .= getconstStr('NotNeedUpdate'); + } + $html .= ' + +
'; + } + $html .= ' + + + + + '; + foreach ($ShowedCommonEnv as $key) { + if ($key=='language') { + $html .= ' + + + + '; + } elseif ($key=='theme') { + $theme_arr = scandir('theme'); + $html .= ' + + + + '; + } /*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 .= ' + + + + '; + }*/ else $html .= ' + + + + '; + } + $html .= ' + + +
'.getconstStr('PlatformConfig').'
+ +
+ +

'; + foreach (explode("|",getConfig('disktag')) as $disktag) { + if ($disktag!='') { + $html .= ' + + + + + + '; + if (getConfig('refresh_token', $disktag)!='') { + $html .= ' + + '; + foreach ($ShowedInnerEnv as $key) { + $html .= ' + + + + '; + } + $html .= ' + + '; + } + $html .= ' +
'.$disktag.': + + +

'; + } + } + $html .= ' +'.getconstStr('AddDisk').''; + return message($html, getconstStr('Setup')); +} diff --git a/function/heroku.php b/function/heroku.php index 653805a..4aa8e42 100644 --- a/function/heroku.php +++ b/function/heroku.php @@ -40,16 +40,25 @@ function getGET() function getConfig($str, $disktag = '') { global $InnerEnv; - if ($disktag=='') $disktag = $_SERVER['disktag']; + global $Base64Env; if (in_array($str, $InnerEnv)) { - return json_decode(getenv($disktag), true)[$str]; + if ($disktag=='') $disktag = $_SERVER['disktag']; + $env = json_decode(getenv($disktag), true); + if (isset($env[$str])) { + if (in_array($str, $Base64Env)) return equal_replace($env[$str],1); + else return $env[$str]; + } + } else { + if (in_array($str, $Base64Env)) return equal_replace(getenv($str),1); + else return getenv($str); } - return getenv($str); + return ''; } function setConfig($arr, $disktag = '') { global $InnerEnv; + global $Base64Env; if ($disktag=='') $disktag = $_SERVER['disktag']; $disktags = explode("|",getConfig('disktag')); $diskconfig = json_decode(getenv($disktag), true); @@ -58,7 +67,8 @@ function setConfig($arr, $disktag = '') $oparetdisk = 0; foreach ($arr as $k => $v) { if (in_array($k, $InnerEnv)) { - $diskconfig[$k] = $v; + if (in_array($k, $Base64Env)) $diskconfig[$k] = equal_replace($v); + else $diskconfig[$k] = $v; $indisk = 1; } elseif ($k=='disktag_add') { array_push($disktags, $v); @@ -68,7 +78,8 @@ function setConfig($arr, $disktag = '') $tmp[$v] = ''; $oparetdisk = 1; } else { - $tmp[$k] = $v; + if (in_array($k, $Base64Env)) $tmp[$k] = equal_replace($v); + else $tmp[$k] = $v; } } if ($indisk) { @@ -82,146 +93,12 @@ function setConfig($arr, $disktag = '') if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1); else $tmp['disktag'] = ''; } + foreach ($tmp as $key => $val) if ($val=='') $tmp[$key]=null; // echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).' //'; return setHerokuConfig($tmp, getConfig('function_name'), getConfig('APIKey')); } -function get_refresh_token() -{ - global $constStr; - global $CommonEnv; - foreach ($CommonEnv as $env) $envs .= '\'' . $env . '\', '; - $url = path_format($_SERVER['PHP_SELF'] . '/'); - if ($_GET['authorization_code'] && isset($_GET['code'])) { - $_SERVER['disktag'] = $_COOKIE['disktag']; - config_oauth(); - $tmp = curl_request($_SERVER['oauth_url'] . 'token', 'client_id=' . $_SERVER['client_id'] .'&client_secret=' . $_SERVER['client_secret'] . '&grant_type=authorization_code&requested_token_use=on_behalf_of&redirect_uri=' . $_SERVER['redirect_uri'] .'&code=' . $_GET['code']); - if ($tmp['stat']==200) $ret = json_decode($tmp['body'], true); - if (isset($ret['refresh_token'])) { - $tmptoken = $ret['refresh_token']; - $str = ' - refresh_token :
'; - /*for ($i=1;strlen($tmptoken)>0;$i++) { - $t['t' . $i] = substr($tmptoken,0,128); - $str .= ' - t' . $i . ':

'; - $tmptoken=substr($tmptoken,128); - } - $str .= ' - Add t1-t'.--$i.' to environments.*/ - $str .= ' -

- '.getconstStr('SavingToken').' - '; - setConfig([ 'refresh_token' => $tmptoken, 'token_expires' => time()+30*24*60*60 ], $_COOKIE['disktag']); - savecache('access_token', $ret['access_token'], $ret['expires_in'] - 60); - $str .= ' - '; - return message($str, getconstStr('WaitJumpIndex')); - } - return message('
' . $tmp['body'] . '
', $tmp['stat']); - //return message('
' . json_encode($ret, JSON_PRETTY_PRINT) . '
', 500); - } - if ($_GET['install1']) { - $_SERVER['disk_oprating'] = $_COOKIE['disktag']; - $_SERVER['disktag'] = $_COOKIE['disktag']; - config_oauth(); - if (getConfig('Onedrive_ver')=='MS' || getConfig('Onedrive_ver')=='CN' || getConfig('Onedrive_ver')=='MSC') { - return message(' - '.getconstStr('JumptoOffice').' - - ', getconstStr('Wait').' 1s', 201); - } - } - if ($_GET['install0']) { - if ($_POST['disktag_add']!='' && ($_POST['Onedrive_ver']=='MS' || $_POST['Onedrive_ver']=='CN' || $_POST['Onedrive_ver']=='MSC')) { - if (in_array($_COOKIE['disktag'], $CommonEnv)) { - return message('Do not input ' . $envs . '
', 'Error', 201); - } - $_SERVER['disktag'] = $_COOKIE['disktag']; - $tmp['disktag_add'] = $_POST['disktag_add']; - $tmp['diskname'] = $_POST['diskname']; - $tmp['Onedrive_ver'] = $_POST['Onedrive_ver']; - if ($_POST['Onedrive_ver']=='MSC') { - $tmp['client_id'] = $_POST['client_id']; - $tmp['client_secret'] = equal_replace(base64_encode($_POST['client_secret'])); - //$_POST['client_secret']; - } - $response = json_decode( setConfig($tmp, $_COOKIE['disktag']), true )['Response']; - $title = getconstStr('MayinEnv'); - $html = getconstStr('Wait') . ' 3s'; - if (isset($response['id'])&&isset($response['message'])) { - $html = $response['id'] . '
-' . $response['message'] . '

-function_name:' . $_SERVER['function_name'] . '
-'; - $title = 'Error'; - } - return message($html, $title, 201); - } - } - - if ($constStr['language']!='zh-cn') { - $linklang='en-us'; - } else $linklang='zh-cn'; - $ru = "https://developer.microsoft.com/".$linklang."/graph/quick-start?appID=_appId_&appName=_appName_&redirectUrl=".$_SERVER['redirect_uri']."&platform=option-php"; - $deepLink = "/quickstart/graphIO?publicClientSupport=false&appName=OneManager&redirectUrl=".$_SERVER['redirect_uri']."&allowImplicitFlow=false&ru=".urlencode($ru); - $app_url = "https://apps.dev.microsoft.com/?deepLink=".urlencode($deepLink); - $html = ' -
- '.getconstStr('OnedriveDiskTag').':
- '.getconstStr('OnedriveDiskName').':
- Onedrive_Ver:
-
-
-
- -
- '; - $title = 'Bind Onedrive'; - return message($html, $title, 201); -} - function install() { global $constStr; @@ -243,11 +120,8 @@ function install() $tmp['function_name'] = $function_name; } $response = json_decode(setHerokuConfig($tmp, $function_name, $APIKey)['body'], true); - if (isset($response['id'])&&isset($response['message'])) { - $html = $response['id'] . '
-' . $response['message'] . '

-function_name:' . $_SERVER['function_name'] . '
-'; + if (api_error($response)) { + $html = api_error_msg($response); $title = 'Error'; } else { return output('Jump', 302); @@ -352,173 +226,25 @@ function updateHerokuapp($function_name, $apikey) return HerokuAPI('POST', 'https://api.heroku.com/apps/' . $function_name . '/builds', $data, $apikey); } -function EnvOpt($function_name, $needUpdate = 0) +function api_error($response) { - global $constStr; - global $ShowedCommonEnv; - global $ShowedInnerEnv; - asort($ShowedCommonEnv); - asort($ShowedInnerEnv); - $html = 'OneManager '.getconstStr('Setup').''; - if ($_POST['updateProgram']==getconstStr('updateProgram')) { - $response = json_decode(updateHerokuapp(getConfig('function_name'), getConfig('APIKey'))['body'], true); - if (isset($response['id'])&&isset($response['message'])) { - $html = $response['id'] . '
-' . $response['message'] . '

-function_name:' . $_SERVER['function_name'] . '
-'; - $title = 'Error'; - } else { - $html .= getconstStr('UpdateSuccess') . '
-'; - $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; - } - } - $_SERVER['disk_oprating'] = ''; - foreach ($_POST as $k => $v) { - if (in_array($k, $ShowedCommonEnv)) { - if (!(getConfig($k)==''&&$v=='')) $tmp[$k] = $v; - } - if (in_array($k, $ShowedInnerEnv)||$k=='disktag_del' || $k=='disktag_add') { - $tmp[$k] = $v; - } - if ($k == 'disk') $_SERVER['disk_oprating'] = $v; - } - /*if ($tmp['domain_path']!='') { - $tmp1 = explode("|",$tmp['domain_path']); - $tmparr = []; - foreach ($tmp1 as $multidomain_paths){ - $pos = strpos($multidomain_paths,":"); - if ($pos>0) $tmparr[substr($multidomain_paths, 0, $pos)] = path_format(substr($multidomain_paths, $pos+1)); - } - $tmp['domain_path'] = $tmparr; - }*/ - $response = json_decode(setConfig($tmp, $_SERVER['disk_oprating'])['body'], true); - if (isset($response['id'])&&isset($response['message'])) { - $html = $response['id'] . '
-' . $response['message'] . '

-function_name:' . $_SERVER['function_name'] . '
-'; - $title = 'Error'; - } else { - $html .= ''; - } - } - if ($_GET['preview']) { - $preurl = $_SERVER['PHP_SELF'] . '?preview'; - } else { - $preurl = path_format($_SERVER['PHP_SELF'] . '/'); - } - $html .= ' -'.getconstStr('Back').'   '.getconstStr('Back').getconstStr('Home').'
-Github
-
-'; - if ($needUpdate) { - $html .= '
' . $_SERVER['github_version'] . '
'; - } else { - $html .= getconstStr('NotNeedUpdate'); - } - $html .= ' - -
- - - - - '; - foreach ($ShowedCommonEnv as $key) { - if ($key=='language') { - $html .= ' - - - - '; - } elseif ($key=='theme') { - $theme_arr = scandir('theme'); - $html .= ' - - - - '; - } /*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 .= ' - - - - '; - }*/ else $html .= ' - - - - '; - } - $html .= ' - - -
'.getconstStr('PlatformConfig').'
- -
- -

'; - foreach (explode("|",getConfig('disktag')) as $disktag) { - if ($disktag!='') { - $html .= ' - - - - - - '; - if (getConfig('refresh_token', $disktag)!='') { - $html .= ' - - '; - foreach ($ShowedInnerEnv as $key) { - $html .= ' - - - - '; - } - $html .= ' - - '; - } - $html .= ' -
'.$disktag.': - - -

'; - } - } - $html .= ' -'.getconstStr('AddDisk').''; - return message($html, getconstStr('Setup')); + return isset($response['id'])&&isset($response['message']); +} + +function api_error_msg($response) +{ + return $response['id'] . '
+' . $response['message'] . '

+function_name:' . $_SERVER['function_name'] . '
+'; +} + +function OnekeyUpate() +{ + return json_decode(updateHerokuapp(getConfig('function_name'), getConfig('APIKey'))['body'], true); +} + +function setConfigResponse($response) +{ + return json_decode( $response['body'], true ); } diff --git a/function/normal.php b/function/normal.php index 7821695..68a9afb 100644 --- a/function/normal.php +++ b/function/normal.php @@ -39,15 +39,24 @@ function getGET() function getConfig($str, $disktag = '') { global $InnerEnv; + global $Base64Env; //include 'config.php'; - if ($disktag=='') $disktag = $_SERVER['disktag']; $s = file_get_contents('config.php'); $configs = substr($s, 18, -2); if ($configs!='') { $envs = json_decode($configs, true); if (in_array($str, $InnerEnv)) { - if (isset($envs[$disktag][$str])) return $envs[$disktag][$str]; - } else if (isset($envs[$str])) return $envs[$str]; + if ($disktag=='') $disktag = $_SERVER['disktag']; + if (isset($envs[$disktag][$str])) { + if (in_array($str, $Base64Env)) return equal_replace($envs[$disktag][$str],1); + else return $envs[$disktag][$str]; + } + } else { + if (isset($envs[$str])) { + if (in_array($str, $Base64Env)) return equal_replace($envs[$str],1); + else return $envs[$str]; + } + } } return ''; } @@ -55,6 +64,7 @@ function getConfig($str, $disktag = '') function setConfig($arr, $disktag = '') { global $InnerEnv; + global $Base64Env; if ($disktag=='') $disktag = $_SERVER['disktag']; //include 'config.php'; $s = file_get_contents('config.php'); @@ -65,7 +75,8 @@ function setConfig($arr, $disktag = '') $operatedisk = 0; foreach ($arr as $k => $v) { if (in_array($k, $InnerEnv)) { - $envs[$disktag][$k] = $v; + if (in_array($k, $Base64Env)) $envs[$disktag][$k] = equal_replace($v); + else $envs[$disktag][$k] = $v; /*$diskconfig[$k] = $v; $indisk = 1;*/ } elseif ($k=='disktag_add') { @@ -76,7 +87,8 @@ function setConfig($arr, $disktag = '') $envs[$v] = ''; $operatedisk = 1; } else { - $envs[$k] = $v; + if (in_array($k, $Base64Env)) $envs[$k] = equal_replace($v); + else $envs[$k] = $v; } } /*if ($indisk) { @@ -100,180 +112,86 @@ function setConfig($arr, $disktag = '') return file_put_contents('config.php', $prestr . json_encode($envs, JSON_PRETTY_PRINT) . $aftstr); } -function get_refresh_token() -{ - global $constStr; - global $CommonEnv; - foreach ($CommonEnv as $env) $envs .= '\'' . $env . '\', '; - $url = path_format($_SERVER['PHP_SELF'] . '/'); - if ($_GET['authorization_code'] && isset($_GET['code'])) { - $_SERVER['disktag'] = $_COOKIE['disktag']; - config_oauth(); - $tmp = curl_request($_SERVER['oauth_url'] . 'token', 'client_id=' . $_SERVER['client_id'] .'&client_secret=' . $_SERVER['client_secret'] . '&grant_type=authorization_code&requested_token_use=on_behalf_of&redirect_uri=' . $_SERVER['redirect_uri'] .'&code=' . $_GET['code']); - if ($tmp['stat']==200) $ret = json_decode($tmp['body'], true); - if (isset($ret['refresh_token'])) { - $tmptoken = $ret['refresh_token']; - $str = ' - refresh_token :
'; - /*for ($i=1;strlen($tmptoken)>0;$i++) { - $t['t' . $i] = substr($tmptoken,0,128); - $str .= ' - t' . $i . ':

'; - $tmptoken=substr($tmptoken,128); - } - $str .= ' - Add t1-t'.--$i.' to environments.*/ - $str .= ' -

- '.getconstStr('SavingToken').' - '; - setConfig([ 'refresh_token' => $tmptoken, 'token_expires' => time()+30*24*60*60 ], $_COOKIE['disktag']); - savecache('access_token', $ret['access_token'], $ret['expires_in'] - 60); - $str .= ' - '; - return message($str, getconstStr('WaitJumpIndex')); - } - return message('
' . $tmp['body'] . '
', $tmp['stat']); - //return message('
' . json_encode($ret, JSON_PRETTY_PRINT) . '
', 500); - } - if ($_GET['install1']) { - $_SERVER['disk_oprating'] = $_COOKIE['disktag']; - $_SERVER['disktag'] = $_COOKIE['disktag']; - config_oauth(); - if (getConfig('Onedrive_ver')=='MS' || getConfig('Onedrive_ver')=='CN' || getConfig('Onedrive_ver')=='MSC') { - return message(' - '.getconstStr('JumptoOffice').' - - ', getconstStr('Wait').' 1s', 201); - } - } - if ($_GET['install0']) { - if ($_POST['disktag_add']!='' && ($_POST['Onedrive_ver']=='MS' || $_POST['Onedrive_ver']=='CN' || $_POST['Onedrive_ver']=='MSC')) { - if (in_array($_COOKIE['disktag'], $CommonEnv)) { - return message('Do not input ' . $envs . '
', 'Error', 201); - } - $_SERVER['disktag'] = $_COOKIE['disktag']; - $tmp['disktag_add'] = $_POST['disktag_add']; - $tmp['diskname'] = $_POST['diskname']; - $tmp['Onedrive_ver'] = $_POST['Onedrive_ver']; - if ($_POST['Onedrive_ver']=='MSC') { - $tmp['client_id'] = $_POST['client_id']; - $tmp['client_secret'] = equal_replace(base64_encode($_POST['client_secret'])); - //$_POST['client_secret']; - } - $response = setConfig($tmp, $_COOKIE['disktag']); - $title = getconstStr('MayinEnv'); - $html = getconstStr('Wait') . ' 3s'; - if (!$response) { - $html = $response . '
-Can not write config to file.
-'; - $title = 'Error'; - } - return message($html, $title, 201); - } - } - - if ($constStr['language']!='zh-cn') { - $linklang='en-us'; - } else $linklang='zh-cn'; - $ru = "https://developer.microsoft.com/".$linklang."/graph/quick-start?appID=_appId_&appName=_appName_&redirectUrl=".$_SERVER['redirect_uri']."&platform=option-php"; - $deepLink = "/quickstart/graphIO?publicClientSupport=false&appName=OneManager&redirectUrl=".$_SERVER['redirect_uri']."&allowImplicitFlow=false&ru=".urlencode($ru); - $app_url = "https://apps.dev.microsoft.com/?deepLink=".urlencode($deepLink); - $html = ' -
- '.getconstStr('OnedriveDiskTag').':
- '.getconstStr('OnedriveDiskName').':
- Onedrive_Ver:
-
-
-
- -
- '; - $title = 'Bind Onedrive'; - return message($html, $title, 201); -} - function install() { global $constStr; - if ($_GET['install1']) { + if ($_GET['install2']) { if ($_POST['admin']!='') { $tmp['admin'] = $_POST['admin']; - $tmp['language'] = $_POST['language']; + $tmp['language'] = $_COOKIE['language']; $response = setConfig($tmp); - if (!$response) { - $html = $response . '
-Can not write config to file.
-'; + if (api_error($response)) { + $html = api_error_msg($response); $title = 'Error'; return message($html, $title, 201); } else { - return output('Jump', 302); + return output('Jump', 302); } } } - if ($_GET['install0']) { + if ($_GET['install1']) { if (!ConfigWriteable()) { $html .= getconstStr('MakesuerWriteable'); $title = 'Error'; return message($html, $title, 201); } - if (!RewriteEngineOn()) { + /*if (!RewriteEngineOn()) { $html .= getconstStr('MakesuerRewriteOn'); $title = 'Error'; return message($html, $title, 201); + }*/ + $html .= ' + + '; + $title = getconstStr('SetAdminPassword'); + return message($html, $title, 201); + } + if ($_GET['install0']) { $html .= ' -
+ language:
'; foreach ($constStr['languages'] as $key1 => $value1) { $html .= '
'; } $html .= ' -
'; - $html .= '
'; $title = getconstStr('SelectLanguage'); return message($html, $title, 201); @@ -302,10 +212,11 @@ language:
'; function ConfigWriteable() { $t = md5( md5(time()).rand(1000,9999) ); - setConfig([ 'tmp' => $t ]); + $r = setConfig([ 'tmp' => $t ]); $tmp = getConfig('tmp'); setConfig([ 'tmp' => '' ]); if ($tmp == $t) return true; + if ($r) return true; return false; } @@ -320,164 +231,24 @@ function RewriteEngineOn() return false; } -function EnvOpt($function_name, $needUpdate = 0) +function api_error($response) { - global $constStr; - global $ShowedCommonEnv; - global $ShowedInnerEnv; - asort($ShowedCommonEnv); - asort($ShowedInnerEnv); - $html = 'OneManager '.getconstStr('Setup').''; - /*if ($_POST['updateProgram']==getconstStr('updateProgram')) { - $response = json_decode(updataProgram($function_name, $Region, $namespace), true)['Response']; - if (isset($response['Error'])) { - $html = $response['Error']['Code'] . '
-' . $response['Error']['Message'] . '

-function_name:' . $_SERVER['function_name'] . '
-Region:' . $_SERVER['Region'] . '
-namespace:' . $namespace . '
-'; - $title = 'Error'; - } else { - $html .= getconstStr('UpdateSuccess') . '
-'; - $title = getconstStr('Setup'); - } - return message($html, $title); - }*/ - if ($_POST['submit1']) { - $_SERVER['disk_oprating'] = ''; - foreach ($_POST as $k => $v) { - if (in_array($k, $ShowedCommonEnv)||in_array($k, $ShowedInnerEnv)||$k=='disktag_del' || $k=='disktag_add') { - $tmp[$k] = $v; - } - if ($k == 'disk') $_SERVER['disk_oprating'] = $v; - } - /*if ($tmp['domain_path']!='') { - $tmp1 = explode("|",$tmp['domain_path']); - $tmparr = []; - foreach ($tmp1 as $multidomain_paths){ - $pos = strpos($multidomain_paths,":"); - if ($pos>0) $tmparr[substr($multidomain_paths, 0, $pos)] = path_format(substr($multidomain_paths, $pos+1)); - } - $tmp['domain_path'] = $tmparr; - }*/ - $response = setConfig($tmp, $_SERVER['disk_oprating']); - if (!$response) { - $html = $response . '
-'; - $title = 'Error'; - } else { - $html .= ''; - } - } - if ($_GET['preview']) { - $preurl = $_SERVER['PHP_SELF'] . '?preview'; - } else { - $preurl = path_format($_SERVER['PHP_SELF'] . '/'); - } - $html .= ' -'.getconstStr('Back').'   '.getconstStr('Back').getconstStr('Home').'
-Github
'; - /*if ($needUpdate) { - $html .= '
' . $_SERVER['github_version'] . '
-
- -
'; - } else { - $html .= getconstStr('NotNeedUpdate'); - }*/ - $html .= 'Can not update by a click!
- - - - - '; - foreach ($ShowedCommonEnv as $key) { - if ($key=='language') { - $html .= ' - - - - '; - } elseif ($key=='theme') { - $theme_arr = scandir('theme'); - $html .= ' - - - - '; - } /*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 .= ' - - - - '; - }*/ else $html .= ' - - - - '; - } - $html .= ' - - -
'.getconstStr('PlatformConfig').'
- -
- -

'; - foreach (explode("|",getConfig('disktag')) as $disktag) { - if ($disktag!='') { - $html .= ' - - - - - - '; - if (getConfig('refresh_token', $disktag)!='') { - $html .= ' - - '; - foreach ($ShowedInnerEnv as $key) { - $html .= ' - - - - '; - } - $html .= ' - - '; - } - $html .= ' -
'.$disktag.': - - -

'; - } - } - $html .= ' -'.getconstStr('AddDisk').''; - return message($html, getconstStr('Setup')); + return !$response; +} + +function api_error_msg($response) +{ + return $response . '
+Can not write config to file.
+'; +} + +function OnekeyUpate() +{ + return json_decode(updateHerokuapp(getConfig('function_name'), getConfig('APIKey'))['body'], true); +} + +function setConfigResponse($response) +{ + return $response; } diff --git a/function/scf.php b/function/scf.php index 01cd9b9..957ee34 100644 --- a/function/scf.php +++ b/function/scf.php @@ -35,8 +35,11 @@ function GetPathSetting($event, $context) $serviceId = $event['requestContext']['serviceId']; if ( $serviceId === substr($host_name,0,strlen($serviceId)) ) { $_SERVER['base_path'] = '/'.$event['requestContext']['stage'].'/'.$_SERVER['function_name'].'/'; - $_SERVER['Region'] = substr($host_name, strpos($host_name, '.')+1); - $_SERVER['Region'] = substr($_SERVER['Region'], 0, strpos($_SERVER['Region'], '.')); + $_SERVER['Region'] = getenv('Region'); + if ($_SERVER['Region'] == '') { + $_SERVER['Region'] = substr($host_name, strpos($host_name, '.')+1); + $_SERVER['Region'] = substr($_SERVER['Region'], 0, strpos($_SERVER['Region'], '.')); + } $path = substr($event['path'], strlen('/'.$_SERVER['function_name'].'/')); } else { $_SERVER['base_path'] = $event['requestContext']['path']; @@ -54,16 +57,25 @@ function GetPathSetting($event, $context) function getConfig($str, $disktag = '') { global $InnerEnv; - if ($disktag=='') $disktag = $_SERVER['disktag']; + global $Base64Env; if (in_array($str, $InnerEnv)) { - return json_decode(getenv($disktag), true)[$str]; + if ($disktag=='') $disktag = $_SERVER['disktag']; + $env = json_decode(getenv($disktag), true); + if (isset($env[$str])) { + if (in_array($str, $Base64Env)) return equal_replace($env[$str],1); + else return $env[$str]; + } + } else { + if (in_array($str, $Base64Env)) return equal_replace(getenv($str),1); + else return getenv($str); } - return getenv($str); + return ''; } function setConfig($arr, $disktag = '') { global $InnerEnv; + global $Base64Env; if ($disktag=='') $disktag = $_SERVER['disktag']; $disktags = explode("|",getConfig('disktag')); $diskconfig = json_decode(getenv($disktag), true); @@ -72,7 +84,8 @@ function setConfig($arr, $disktag = '') $oparetdisk = 0; foreach ($arr as $k => $v) { if (in_array($k, $InnerEnv)) { - $diskconfig[$k] = $v; + if (in_array($k, $Base64Env)) $diskconfig[$k] = equal_replace($v); + else $diskconfig[$k] = $v; $indisk = 1; } elseif ($k=='disktag_add') { array_push($disktags, $v); @@ -82,7 +95,8 @@ function setConfig($arr, $disktag = '') $tmp[$v] = ''; $oparetdisk = 1; } else { - $tmp[$k] = $v; + if (in_array($k, $Base64Env)) $tmp[$k] = equal_replace($v); + else $tmp[$k] = $v; } } if ($indisk) { @@ -98,7 +112,9 @@ function setConfig($arr, $disktag = '') } // echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).' //'; - return updateEnvironment($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')); + $response = updateEnvironment($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')); + WaitSCFStat(); + return $response; } function WaitSCFStat() @@ -108,151 +124,22 @@ function WaitSCFStat() '.++$trynum; } -function get_refresh_token() -{ - global $constStr; - global $CommonEnv; - foreach ($CommonEnv as $env) $envs .= '\'' . $env . '\', '; - $url = path_format($_SERVER['PHP_SELF'] . '/'); - if ($_GET['authorization_code'] && isset($_GET['code'])) { - $_SERVER['disktag'] = $_COOKIE['disktag']; - config_oauth(); - $tmp = curl_request($_SERVER['oauth_url'] . 'token', 'client_id=' . $_SERVER['client_id'] .'&client_secret=' . $_SERVER['client_secret'] . '&grant_type=authorization_code&requested_token_use=on_behalf_of&redirect_uri=' . $_SERVER['redirect_uri'] .'&code=' . $_GET['code']); - if ($tmp['stat']==200) $ret = json_decode($tmp['body'], true); - if (isset($ret['refresh_token'])) { - $tmptoken = $ret['refresh_token']; - $str = ' - refresh_token :
'; - /*for ($i=1;strlen($tmptoken)>0;$i++) { - $t['t' . $i] = substr($tmptoken,0,128); - $str .= ' - t' . $i . ':

'; - $tmptoken=substr($tmptoken,128); - } - $str .= ' - Add t1-t'.--$i.' to environments.*/ - $str .= ' -

- '.getconstStr('SavingToken').' - '; - setConfig([ 'refresh_token' => $tmptoken, 'token_expires' => time()+30*24*60*60 ], $_COOKIE['disktag']); - savecache('access_token', $ret['access_token'], $ret['expires_in'] - 60); - WaitSCFStat(); - $str .= ' - '; - return message($str, getconstStr('WaitJumpIndex')); - } - return message('
' . json_encode(json_decode($tmp['body']), JSON_PRETTY_PRINT) . '
', $tmp['stat']); - //return message('
' . json_encode($ret, JSON_PRETTY_PRINT) . '
', 500); - } - if ($_GET['install1']) { - $_SERVER['disk_oprating'] = $_COOKIE['disktag']; - $_SERVER['disktag'] = $_COOKIE['disktag']; - config_oauth(); - if (getConfig('Onedrive_ver')=='MS' || getConfig('Onedrive_ver')=='CN' || getConfig('Onedrive_ver')=='MSC') { - return message(' - '.getconstStr('JumptoOffice').' - - ', getconstStr('Wait').' 1s', 201); - } - } - if ($_GET['install0']) { - if ($_POST['disktag_add']!='' && ($_POST['Onedrive_ver']=='MS' || $_POST['Onedrive_ver']=='CN' || $_POST['Onedrive_ver']=='MSC')) { - if (in_array($_COOKIE['disktag'], $CommonEnv)) { - return message('Do not input ' . $envs . '
', 'Error', 201); - } - $_SERVER['disktag'] = $_COOKIE['disktag']; - $tmp['disktag_add'] = $_POST['disktag_add']; - $tmp['diskname'] = $_POST['diskname']; - $tmp['Onedrive_ver'] = $_POST['Onedrive_ver']; - if ($_POST['Onedrive_ver']=='MSC') { - $tmp['client_id'] = $_POST['client_id']; - $tmp['client_secret'] = equal_replace(base64_encode($_POST['client_secret'])); - //$_POST['client_secret']; - } - $response = json_decode( setConfig($tmp, $_COOKIE['disktag']), true )['Response']; - $title = getconstStr('MayinEnv'); - $html = getconstStr('Wait') . ' 3s'; - if (isset($response['Error'])) { - $html = $response['Error']['Code'] . '
-' . $response['Error']['Message'] . '

-function_name:' . $_SERVER['function_name'] . '
-Region:' . $_SERVER['Region'] . '
-namespace:' . $_SERVER['namespace'] . '
-'; - $title = 'Error'; - } - return message($html, $title, 201); - } - } - - if ($constStr['language']!='zh-cn') { - $linklang='en-us'; - } else $linklang='zh-cn'; - $ru = "https://developer.microsoft.com/".$linklang."/graph/quick-start?appID=_appId_&appName=_appName_&redirectUrl=".$_SERVER['redirect_uri']."&platform=option-php"; - $deepLink = "/quickstart/graphIO?publicClientSupport=false&appName=OneManager&redirectUrl=".$_SERVER['redirect_uri']."&allowImplicitFlow=false&ru=".urlencode($ru); - $app_url = "https://apps.dev.microsoft.com/?deepLink=".urlencode($deepLink); - $html = ' -
- '.getconstStr('OnedriveDiskTag').':
- '.getconstStr('OnedriveDiskName').':
- Onedrive_Ver:
-
-
-
- -
- '; - $title = 'Bind Onedrive'; - return message($html, $title, 201); -} - function install() { global $constStr; + if ($_GET['install2']) { + $tmp['admin'] = $_POST['admin']; + setConfig($tmp); + if (needUpdate()) { + updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey); + return message('update to github version, reinstall.', 'Program updating', 201); + } + return output('Jump', 302); + } if ($_GET['install1']) { - if ($_POST['admin']!='') { - $tmp['admin'] = $_POST['admin']; + //if ($_POST['admin']!='') { $tmp['language'] = $_POST['language']; + $tmp['Region'] = $_POST['Region']; $SecretId = getConfig('SecretId'); if ($SecretId=='') { $SecretId = $_POST['SecretId']; @@ -263,28 +150,31 @@ function install() $SecretKey = $_POST['SecretKey']; $tmp['SecretKey'] = $SecretKey; } - $response = json_decode(SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response']; - if (isset($response['Error'])) { - $html = $response['Error']['Code'] . '
-' . $response['Error']['Message'] . '

-function_name:' . $_SERVER['function_name'] . '
-Region:' . $_SERVER['Region'] . '
-namespace:' . $_SERVER['namespace'] . '
-'; + $response = json_decode(SetbaseConfig($tmp, $_SERVER['function_name'], $_POST['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response']; + if (api_error($response)) { + $html = api_error_msg($response); $title = 'Error'; + return message($html, $title, 201); } else { - $trynum = 0; - while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo ' -'.++$trynum; - //$response = json_decode( updateEnvironment($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response']; - if (needUpdate()) { - updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey); - return message('update to github version, reinstall.', 'Program updating', 201); - } - return output('Jump', 302); + $html .= ' +
+
+ +
+ '; + $title = getconstStr('SetAdminPassword'); + return message($html, $title, 201); + } + //} } if ($_GET['install0']) { $html .= ' @@ -299,8 +189,21 @@ language:
';

'; $html .= ' -
'; - $html .= ' + (腾讯几个月了还不做出来,只能先弄选择了)
'; - $title = getconstStr('Setup'); - } - return message($html, $title); - } - if ($_GET['preview']) { - $preurl = $_SERVER['PHP_SELF'] . '?preview'; - } else { - $preurl = path_format($_SERVER['PHP_SELF'] . '/'); - } - $html .= ' -'.getconstStr('Back').'   '.getconstStr('Back').getconstStr('Home').'
-Github
-
-'; - if ($needUpdate) { - $html .= '
' . $_SERVER['github_version'] . '
'; - } else { - $html .= getconstStr('NotNeedUpdate'); - } - $html .= ' - -
- - - - - '; - foreach ($ShowedCommonEnv as $key) { - if ($key=='language') { - $html .= ' - - - - '; - } elseif ($key=='theme') { - $theme_arr = scandir('theme'); - $html .= ' - - - - '; - } /*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 .= ' - - - - '; - }*/ else $html .= ' - - - - '; - } - $html .= ' - - -
'.getconstStr('PlatformConfig').'
- -
- -

'; - foreach (explode("|",getConfig('disktag')) as $disktag) { - if ($disktag!='') { - $html .= ' - - - - - - '; - if (getConfig('refresh_token', $disktag)!='') { - $html .= ' - - '; - foreach ($ShowedInnerEnv as $key) { - $html .= ' - - - - '; - } - $html .= ' - - '; - } - $html .= ' -
'.$disktag.': - - -

'; - } - } - $html .= ' -'.getconstStr('AddDisk').''; - return message($html, getconstStr('Setup')); +'; +} + +function OnekeyUpate() +{ + return json_decode(updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')), true)['Response']; +} + +function setConfigResponse($response) +{ + return json_decode( $response, true )['Response']; } diff --git a/index.php b/index.php index c53a035..ff1cac9 100644 --- a/index.php +++ b/index.php @@ -4,9 +4,9 @@ include 'conststr.php'; include 'function/common.php'; //echo '
'. json_encode($_SERVER, JSON_PRETTY_PRINT).'
'; -if ($_SERVER['USER']==='qcloud') { +if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') { include 'function/scf.php'; -} elseif ($_SERVER['HEROKU_APP_DIR']==='/app') { +} elseif (isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app') { include 'function/heroku.php'; $path = getpath(); //echo 'path:'. $path; diff --git a/readme.md b/readme.md index 6de9882..ca4f48a 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ -QQ Group: 943919989 -Telegram Group: https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw +Install program first, then add onedrive in setup after login. +先安装程序,登录后在设置中添加onedrive。 # Deploy to heroku Official: https://heroku.com @@ -13,20 +13,21 @@ How to Install: 1.Start web service on your server (httpd or other), make sure you can visit it. 启动web服务器,确保你能访问到。 2.Make the rewrite works, the rule is in .htaccess file, make sure any query redirect to index.php. - 开启伪静态(重写)功能,规则在.htaccess文件中,ngnix自行转换,我们的目的是不管访问什么都让index.php来处理。 + 开启伪静态(重写)功能,规则在.htaccess文件中,ngnix从里面复制,我们的目的是不管访问什么都让index.php来处理。 3.Upload code. 上传好代码。 4.Change the file config.php can be read&write (666 is suggested). 让代码中的config.php文件程序可读写,推荐chmod 666 config.php。 5.View the website in chrome or other. 在浏览器中访问。 - 6.Follow the guide, bind your onedrive. - 根据引导,绑定你的OneDrive。 # Deploy to SCF Official: https://cloud.tencent.com/product/scf -How to Install: https://service-pgxgvop2-1258064400.ap-hongkong.apigateway.myqcloud.com/test/abcdef/%E6%97%A0%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%87%BD%E6%95%B0SCF%E6%90%AD%E5%BB%BAOneDrive.mp4?preview +~~How to Install: https://service-pgxgvop2-1258064400.ap-hongkong.apigateway.myqcloud.com/test/abcdef/%E6%97%A0%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%87%BD%E6%95%B0SCF%E6%90%AD%E5%BB%BAOneDrive.mp4?preview~~ + +先手动在环境变量添加Region,ap-hongkong或ap-guangzhou之类,具体看 https://cloud.tencent.com/document/api/583/17238 最底下,然后再安装。 +添加网盘时,SCF反应不过来,会添加失败,请不要删除,再添加一次相同的就可以了。 DEMO: https://service-pgxgvop2-1258064400.ap-hongkong.apigateway.myqcloud.com/test/abcdef/ @@ -39,8 +40,8 @@ The XXX_path in setting is the path in Onedrive, not in url, program will find t 设置中的 XXX_path 是Onedrive里面的路径,并不是你url里面的,程序会去你Onedrive里面找这个路径。 LOGO ICON: put your 'favicon.ico' in the path you showed, make sure xxxxx.com/favicon.ico can be visited. 网站图标:将favicon.ico文件放在你要展示的目录中,确保 xxxxx.com/favicon.ico 可以访问到。 -Program will show content of 'readme.md' under file list. -可以在文件列表下面显示readme.md文件的内容。 +Program will show content of 'readme.md' & 'head.md'. +可以在文件列表显示head.md跟readme.md文件的内容。 guest up path, is a folder that the guest can upload files, but can not be list (exclude admin). 游客上传目录(也叫图床目录),是指定一个目录,让游客可以上传文件,不限格式,不限大小。这个目录里面的内容不列清单(除非管理登录)。 If there is 'index.html' file, program will only show the content of 'index.html', not list the files. @@ -48,3 +49,5 @@ If there is 'index.html' file, program will only show the content of 'index.html Click 'EditTime' or 'Size', the list will sort by time or size, Click 'File' can resume sort. 点击“时间”、“大小”,可以排序显示,点“文件”恢复原样。 +QQ Group: 943919989 +Telegram Group: https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw diff --git a/theme/classic.php b/theme/classic.php index 23e50ba..ff720fb 100644 --- a/theme/classic.php +++ b/theme/classic.php @@ -2,7 +2,7 @@ - <?php echo $pretitle;?> - <?php echo $_SERVER['sitename'];?> + <?php echo $pretitle; if ($_SERVER['base_disk_path']!=$_SERVER['base_path']) { if (getConfig('diskname')!='') $diskname = getConfig('diskname'); else $diskname = $_SERVER['disktag']; echo ' - ' . $diskname; } ?> - <?php echo $_SERVER['sitename'];?> @@ -10,7 +10,7 @@ @@ -69,7 +70,7 @@
  • -
  • +
  • + if (isset($_SERVER['needUpdate'])&&$_SERVER['needUpdate']) { ?>

    @@ -100,14 +101,28 @@ '.$diskname.'  '; + echo ' '.$diskname.' +'; } ?> + if ($files) { + if (isset($files['children']['head.md'])) { ?> +
    +
    +
    +
    + +
    +
    +
    +
    +
    @@ -131,6 +146,8 @@
    @@ -153,8 +170,6 @@
    document.getElementById(\'url\').offsetWidth) this.style.width=\'100%\';" /> '; @@ -200,12 +215,12 @@
    + if (isset($_POST['filenum'])) $filenum = $_POST['filenum']; + if (!isset($filenum) and isset($files['folder']['page'])) $filenum = ($files['folder']['page']-1)*200; + else $filenum = 0; ?> - + @@ -240,13 +255,7 @@ foreach ($files['children'] as $file) { // Files if (isset($file['file'])) { - if ($_SERVER['admin'] or (substr($file['name'],0,1) !== '.' and $file['name'] !== getConfig('passfile') ) ) { - if (strtolower($file['name']) === 'head.md') $head = $file; - if (strtolower($file['name']) === 'readme.md') $readme = $file; - if (strtolower($file['name']) === 'index.html' && !$_SERVER['admin']) { - $html = curl_request(fetch_files(spurlencode(path_format($path . '/' .$file['name']),'/'))['@microsoft.graph.downloadUrl'])['body']; - return output($html,200); - } + if ($_SERVER['admin'] or !isHideFile($file['name'])) { $filenum++; ?> @@ -347,25 +356,7 @@ echo 'Unknown path or file.'; echo json_encode($files, JSON_PRETTY_PRINT); } - if ($head) { - echo ' - - - -
    -
    -
    -
    - - -
    -'; - } - if ($readme) { + if (isset($files['children']['readme.md'])) { echo '
    @@ -374,11 +365,8 @@
    -
    - +
    '; @@ -404,7 +392,7 @@ + if (!isset($_GET['preview'])) { ?>
           
    @@ -283,7 +292,7 @@ - +
    - - - - - - - - - - - - -'; - foreach ($files['children'] as $file) { - // Files - if (isset($file['file'])) { - if ($_SERVER['admin'] or (substr($file['name'],0,1) !== '.' and $file['name'] !== getConfig('passfile') ) ) { - if (strtolower($file['name']) === 'head.md') $head = $file; - if (strtolower($file['name']) === 'readme.md') $readme = $file; - if (strtolower($file['name']) === 'index.html' && !$_SERVER['admin']) { - $html = curl_request(fetch_files(spurlencode(path_format($path . '/' .$file['name']),'/'))['@microsoft.graph.downloadUrl'])['body']; - return output($html,200); - } - $filenum++; ?> - - - - - - -
       
    - -
  • -
      -
    • -
    • -
    • -
    • -
    • -
    -
  •     - - - -
    - -
  • -
      -
    • -
    • -
    • -
    • -
    -
  •     - - - - - - - - - - - - - - - - - - - - - - - -
    -200) { - $pagenum = $files['folder']['page']; - $maxpage = ceil($files['folder']['childCount']/200); - $prepagenext = ' - - - - - - - - -
    '; - if ($pagenum!=1) { - $prepagenum = $pagenum-1; - $prepagenext .= ' - '.getconstStr('PrePage').''; - } - $prepagenext .= ' - '; - for ($page=1;$page<=$maxpage;$page++) { - if ($page == $pagenum) { - $prepagenext .= ' - ' . $page . ' '; - } else { - $prepagenext .= ' - ' . $page . ' '; - } - } - $prepagenext = substr($prepagenext,0,-1); - $prepagenext .= ' - '; - if ($pagenum!=$maxpage) { - $nextpagenum = $pagenum+1; - $prepagenext .= ' - '.getconstStr('NextPage').''; - } - $prepagenext .= ' -
    - '; - echo $prepagenext; - } - if ($_SERVER['admin']) { ?> -
    -
    - - -
    -
    - -
    -
    -
    -
    -
    -
    - - -
    -'; - } - if ($readme) { - echo ' -
    -
    -
    -
    -
    -
    -
    - -
    - -
    -
    -'; - } - } - } else { - echo ' -
    -
    -
    - - -
    -
    -
    '; - $statusCode = 401; - } - } ?> -
    -
    -
    - - - -
    - - - - - - -
    - - - -
    - - - - -
    - - - - - - - - - - \ No newline at end of file + + + + + <?php echo $pretitle;?> - <?php echo $_SERVER['sitename'];?> + + + + + + + + + + +
    + + + +
    • + +
    • +
    • +
    • + +
    • +
    • +
  • + +   + +
    + +
    + +

    + +

    +1) { ?> +
    +
    +
    +
    +'.$diskname.' +'; + } ?> +
    +
    +
    +
    + +
    +
    +
    + + + + + +

    +
    +
    + +
    +
    + + +
    +
    +' . $files['error']['message'] . '
    '; + $statusCode=404; + } else { + if (isset($files['file'])) { +?> +
    +
    + +   +
    +
    +document.getElementById(\'url\').offsetWidth) this.style.width=\'100%\';" /> +'; + } elseif (in_array($ext, $exts['video'])) { + //echo ''; + $DPvideo=$files['@microsoft.graph.downloadUrl']; + echo '
    +'; + } elseif (in_array($ext, $exts['music'])) { + echo ' +'; + } elseif (in_array($ext, ['pdf'])) { + /*echo ' + +';*/ + $pdfurl = $files['@microsoft.graph.downloadUrl']; + echo '
    +'; + } elseif (in_array($ext, $exts['office'])) { + echo ' +'; + } elseif (in_array($ext, $exts['txt'])) { + $txtstr = htmlspecialchars(curl_request($files['@microsoft.graph.downloadUrl'])['body']); +?> +
    + +
    + +     + + + +'; ?> +
    + + +
    +'; + }*/ else { + echo ''.getconstStr('FileNotSupport').''; + } ?> +
    +
    + + + + + + + + + + + + + + +'; + foreach ($files['children'] as $file) { + // Files + if (isset($file['file'])) { + if ($_SERVER['admin'] or (substr($file['name'],0,1) !== '.' and $file['name'] !== getConfig('passfile') ) ) { + if (strtolower($file['name']) === 'head.md') $head = $file; + if (strtolower($file['name']) === 'readme.md') $readme = $file; + if (strtolower($file['name']) === 'index.html' && !$_SERVER['admin']) { + $html = curl_request(fetch_files(spurlencode(path_format($path . '/' .$file['name']),'/'))['@microsoft.graph.downloadUrl'])['body']; + return output($html,200); + } + $filenum++; ?> + + + + + + +
       
    + +
  • +
      +
    • +
    • +
    • +
    • +
    • +
    +
  • + + + +
    + +
  • +
      +
    • +
    • +
    • +
    • +
    +
  • + + + + + + + + + + + + + + + + + + + + + + + +
    +200) { + $pagenum = $files['folder']['page']; + $maxpage = ceil($files['folder']['childCount']/200); + $prepagenext = ' + + + + + + + + +
    '; + if ($pagenum!=1) { + $prepagenum = $pagenum-1; + $prepagenext .= ' + '.getconstStr('PrePage').''; + } + $prepagenext .= ' + '; + for ($page=1;$page<=$maxpage;$page++) { + if ($page == $pagenum) { + $prepagenext .= ' + ' . $page . ' '; + } else { + $prepagenext .= ' + ' . $page . ' '; + } + } + $prepagenext = substr($prepagenext,0,-1); + $prepagenext .= ' + '; + if ($pagenum!=$maxpage) { + $nextpagenum = $pagenum+1; + $prepagenext .= ' + '.getconstStr('NextPage').''; + } + $prepagenext .= ' +
    + '; + echo $prepagenext; + } + if ($_SERVER['admin']) { ?> +
    +
    + + +
    +
    + +
    + +
    +
    +
    +
    + + +
    +'; + } + if ($readme) { + echo ' +
    +
    +
    +
    +
    +
    +
    + +
    + +
    +
    +'; + } + } + } else { + echo ' +
    +
    +
    + + +
    +
    +
    '; + $statusCode = 401; + } + } ?> +
    +
    +
    + + + +
    + + + + + + +
    + + + +
    + + + + +
    + + + + + + + + + + diff --git a/theme/onemoe.php b/theme/onemoe.php new file mode 100644 index 0000000..ea738b0 --- /dev/null +++ b/theme/onemoe.php @@ -0,0 +1,1198 @@ + + + + + <?php echo $pretitle; if ($_SERVER['base_disk_path']!=$_SERVER['base_path']) echo ' - ' . getConfig('diskname');?> - <?php echo $_SERVER['sitename'];?> + + + + + + + + + + + + +
    + + + +
    • + +
    • +
    • +
    • + +
    • +
    • +
  • + +   + +
    + +
    + +

    + +

    +1) { ?> +
    +
    +
    +
    +'.$diskname.' +'; + } ?> +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    + + + + + +

    +
    +
    + +
    +
    + + +
    +
    +' . $files['error']['message'] . '
    '; + $statusCode=404; + } else { + if (isset($files['file'])) { +?> +
    +
    + +   +
    +
    +document.getElementById(\'url\').offsetWidth) this.style.width=\'100%\';" /> +'; + } elseif (in_array($ext, $exts['video'])) { + //echo ''; + $DPvideo=$files['@microsoft.graph.downloadUrl']; + echo '
    +'; + } elseif (in_array($ext, $exts['music'])) { + echo ' +'; + } elseif (in_array($ext, ['pdf'])) { + /*echo ' + +';*/ + $pdfurl = $files['@microsoft.graph.downloadUrl']; + echo '
    +'; + } elseif (in_array($ext, $exts['office'])) { + echo ' +'; + } elseif (in_array($ext, $exts['txt'])) { + $txtstr = htmlspecialchars(curl_request($files['@microsoft.graph.downloadUrl'])['body']); +?> +
    + +
    + +     + + + +'; ?> +
    + + +
    +'; + }*/ else { + echo ''.getconstStr('FileNotSupport').''; + } ?> +
    +
    + + + + + + + + + + + + + + +'; + foreach ($files['children'] as $file) { + // Files + if (isset($file['file'])) { + if ($_SERVER['admin'] or !isHideFile($file['name'])) { + $filenum++; ?> + + + + + + +
        
    + +
  • +
      +
    • +
    • +
    • +
    • +
    • +
    +
  • + + + +
    + +
  • +
      +
    • +
    • +
    • +
    • +
    +
  • + + + + + + + + + + + + + + + + + + + + + + + +
    +200) { + $pagenum = $files['folder']['page']; + $maxpage = ceil($files['folder']['childCount']/200); + $prepagenext = ' + + + + + + + + +
    '; + if ($pagenum!=1) { + $prepagenum = $pagenum-1; + $prepagenext .= ' + '.getconstStr('PrePage').''; + } + $prepagenext .= ' + '; + for ($page=1;$page<=$maxpage;$page++) { + if ($page == $pagenum) { + $prepagenext .= ' + ' . $page . ' '; + } else { + $prepagenext .= ' + ' . $page . ' '; + } + } + $prepagenext = substr($prepagenext,0,-1); + $prepagenext .= ' + '; + if ($pagenum!=$maxpage) { + $nextpagenum = $pagenum+1; + $prepagenext .= ' + '.getconstStr('NextPage').''; + } + $prepagenext .= ' +
    + '; + echo $prepagenext; + } + if ($_SERVER['admin']) { ?> +
    +
    + + +
    +
    + +
    + +
    +
    +
    +
    +
    + +
    +
    +'; + } + } + } else { + echo ' +
    +
    +
    + + +
    +
    +
    '; + $statusCode = 401; + } + } ?> +
    +
    +
    + + + +
    + + + + + + +
    + + + +
    + + + + + + + + + + diff --git a/theme/ruoli_violet.php b/theme/ruoli_violet.php new file mode 100644 index 0000000..ce71dfc --- /dev/null +++ b/theme/ruoli_violet.php @@ -0,0 +1,1259 @@ + + + + + <?php echo $pretitle;?> - <?php echo $_SERVER['sitename'];?> + + + + + + + + + + +
    + + + +
    • + +
    • +
    • +
    • + +
    • +
    • +
  • + + +
    + +
    + +

    + +

    +1) { ?> +
    +
    +
    +
    +=strlen(path_format($_SERVER['base_path'].'/'.$disk))){ + if(substr($_SERVER['REQUEST_URI'],0,strlen(path_format($_SERVER['base_path'].'/'.$disk)))===path_format($_SERVER['base_path'].'/'.$disk)) + echo ''.$diskname.''; + else + echo ''.$diskname.''; + } + else + echo ''.$diskname.''; + + } ?> +
    +
    +
    +
    + +
    +
    +
    + + + + + +

    +
    +
    + +
    +
    + + +
    +
    +' . $files['error']['message'] . '
    '; + $statusCode=404; + } else { + if (isset($files['file'])) { +?> +
    +
    + +   +
    +
    +document.getElementById(\'url\').offsetWidth) this.style.width=\'100%\';" /> +'; + } elseif (in_array($ext, $exts['video'])) { + //echo ''; + $DPvideo=$files['@microsoft.graph.downloadUrl']; + echo '
    +'; + } elseif (in_array($ext, $exts['music'])) { + echo ' +'; + } elseif (in_array($ext, ['pdf'])) { + /*echo ' + +';*/ + $pdfurl = $files['@microsoft.graph.downloadUrl']; + echo '
    +'; + } elseif (in_array($ext, $exts['office'])) { + echo ' +'; + } elseif (in_array($ext, $exts['txt'])) { + $txtstr = htmlspecialchars(curl_request($files['@microsoft.graph.downloadUrl'])['body']); +?> +
    + +
    + +     + + + +'; ?> +
    + + +
    +'; + }*/ else { + echo ''.getconstStr('FileNotSupport').''; + } ?> +
    +
    + + + + + + + + + + + + + + +'; + foreach ($files['children'] as $file) { + // Files + if (isset($file['file'])) { + if ($_SERVER['admin'] or (substr($file['name'],0,1) !== '.' and $file['name'] !== getConfig('passfile') ) ) { + if (strtolower($file['name']) === 'head.md') $head = $file; + if (strtolower($file['name']) === 'readme.md') $readme = $file; + if (strtolower($file['name']) === 'index.html' && !$_SERVER['admin']) { + $html = curl_request(fetch_files(spurlencode(path_format($path . '/' .$file['name']),'/'))['@microsoft.graph.downloadUrl'])['body']; + return output($html,200); + } + $filenum++; ?> + + + + + + + +
       
    + +
  • +
      +
    • +
    • +
    • +
    • +
    • +
    +
  • + + + +
    + +
  • +
      +
    • +
    • +
    • +
    • +
    +
  • + + + + + + + + + + + + + + + + + + + + + + +
    +200) { + $pagenum = $files['folder']['page']; + $maxpage = ceil($files['folder']['childCount']/200); + $prepagenext = ' + + + + + + + + +
    '; + if ($pagenum!=1) { + $prepagenum = $pagenum-1; + $prepagenext .= ' + '.getconstStr('PrePage').''; + } + $prepagenext .= ' + '; + for ($page=1;$page<=$maxpage;$page++) { + if ($page == $pagenum) { + $prepagenext .= ' + ' . $page . ' '; + } else { + $prepagenext .= ' + ' . $page . ' '; + } + } + $prepagenext = substr($prepagenext,0,-1); + $prepagenext .= ' + '; + if ($pagenum!=$maxpage) { + $nextpagenum = $pagenum+1; + $prepagenext .= ' + '.getconstStr('NextPage').''; + } + $prepagenext .= ' +
    + '; + echo $prepagenext; + } + if ($_SERVER['admin']) { ?> +
    +
    + + +
    +
    + +
    + +
    +
    +
    +
    + + +
    +'; + } + if ($readme) { + echo ' +
    +
    +
    +
    +
    +
    +
    + +
    + +
    +
    +'; + } + } + } else { + echo ' +
    +
    +
    + + +
    +
    +
    '; + $statusCode = 401; + } + } ?> +
    +
    +
    + + + +
    + + + + + + +
    + + + +
    +
    Powred by 逸笙 | Theme by 若离
    + + + + + + + + + + diff --git a/update.sh b/update.sh new file mode 100644 index 0000000..cb2c7ff --- /dev/null +++ b/update.sh @@ -0,0 +1,16 @@ +#!bash + +gitsource='https://github.com/qkqpttgf/OneManager-php' + +OneManagerPath=`cd $(dirname $0);pwd -P` +cd ${OneManagerPath} + +git clone ${gitsource} +\mv -b config.php OneManager-php/ +\mv -b OneManager-php/* ./ +\mv -b OneManager-php/.[^.]* ./ +rm -rf *~ +rm -rf .[^.]*~ +rm -rf OneManager-php +chmod 666 config.php + diff --git a/version b/version index a813a8f..9bfcb61 100644 --- a/version +++ b/version @@ -1,7 +1,25 @@ +20200326-0001.16 +You can add sharepoint site drive as a disk, you must reinstall after update. +可以将sharepoint网站添加成一个盘,由于结构改变,升级后只能重装。 + +20200321-1830.15 +本次更新后,'index.html'功能在其它主题会导致bug。 +文本类文件将缓存;添加hideFunctionalityFile开关;在添加网盘时会显示已经在用的标签。 +after this update, then 'index.html' function will bug in other theme. +cache text file content;add hideFunctionalityFile;list exist disktags when AddDisk。 +20200311-2150.14 +Add a switch, can download a known file or not, while the folder is encrypted. +Hide time and size in mobile. +Now, you can get a random 'jpg' from a folder when you type '?random=jpg' after the folder. +增加一个开关,在目录加密后能否下载其中的某个文件。 +在手机上浏览时,隐藏修改时间跟大小。 +加入一个功能,现在可以在某个目录后面加上'?random=jpg'来得到本目录里面的一张随机jpg。 +20200229-1300.13 +In SCF, some config can input Special symbols now, like ?&= 。 +在SCF中,某些配置可以输入特殊符号了,像background可以用?&=之类的了。 20200225-1310.12 Can update by one click any time. fix bugs: special tag, reupload. 可以不管版本直接一键更新(覆盖)了。修复可以使用特殊onedrive标签的bug,修复断网续传的问题。 - 20200222-2130.11 you can set background now. fix bug: 2nd disk upload. 可以设置背景图片了。第2个盘上传后链接不对。