diff --git a/LICENSE b/LICENSE index 261eeb9..29f81d8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,201 +1,201 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Plugin.php b/Plugin.php new file mode 100644 index 0000000..d783321 --- /dev/null +++ b/Plugin.php @@ -0,0 +1,236 @@ +header_2000 = array('AdminMD_Plugin', 'renderHeader'); + Typecho_Plugin::factory('admin/footer.php')->end_2000 = array('AdminMD_Plugin', 'renderFooter'); + if(file_exists("var/Widget/Menu.php")){ + //挂载menu.php + rename("var/Widget/Menu.php", "var/Widget/Menu.php.bak"); + copy("usr/plugins/AdminMD/var/Widget/Menu.php", "var/Widget/Menu.php"); + } + + + $admin_files = self::readdir($plugin_path.'/admin/'); + self::setFileMap($admin_files); + + foreach ($admin_files as $tmp_file){ + $tmp_file_path = "usr/plugins/AdminMD/admin/".$tmp_file; + $target_file_path = "admin/".$tmp_file; + $target_file_bak = "admin/".$tmp_file.".bak"; + + if(file_exists($target_file_path)){ + //挂载 + rename($target_file_path, $target_file_bak); + copy($tmp_file_path, $target_file_path); + } + } + + } + + /** + * 禁用插件方法,如果禁用失败,直接抛出异常 + * + * @static + * @access public + * @return void + * @throws Typecho_Plugin_Exception + */ + public static function deactivate() + { + //还原Menu.php + if(file_exists("var/Widget/Menu.php.bak")){ + unlink("var/Widget/Menu.php"); + rename("var/Widget/Menu.php.bak", "var/Widget/Menu.php"); + } + $plugin_path = dirname(__FILE__); + + $admin_files = self::readdir($plugin_path.'/admin/'); + + foreach ($admin_files as $tmp_file){ + $target_file_path = "admin/".$tmp_file; + $target_file_bak = "admin/".$tmp_file.".bak"; + + if(file_exists($target_file_bak)){ + unlink($target_file_path); + rename($target_file_bak, $target_file_path); + } + } + } + + /** + * 获取插件配置面板 + * + * @access public + * @param Typecho_Widget_Helper_Form $form 配置面板 + * @return void + */ + public static function config(Typecho_Widget_Helper_Form $form) + { + + ?> + + pluginUrl . '/AdminMD/'; + $zz1 = '
Green
'; + $zz2 = '
BlueSkyAndMountains
'; + $zz3 = '
Default
'; + $bgfengge = new Typecho_Widget_Helper_Form_Element_Radio( + 'bgfengge', array( + 'Green' => _t('
' . $zz1 . '
'), + 'BlueSkyAndMountains' => _t('
' . $zz2 . '
'), + 'Default' => _t('
' . $zz3 . '
'), + ), 'Green', _t('登陆/注册页面样式'), _t('')); + $bgfengge->setAttribute('id', 'yangshi'); + $form->addInput($bgfengge); + + $bgUrl = new Typecho_Widget_Helper_Form_Element_Text('bgUrl', NULL, NULL, _t('自定义背景图'), _t('选中上方的基础样式后,可以在这里填写图片地址自定义背景图')); + $form->addInput($bgUrl); + + $diycss = new Typecho_Widget_Helper_Form_Element_Textarea('diycss', NULL, NULL, '自定义样式', _t('上边的样式选择【Default】,然后在这里自己写css美化注册/登录页面;注意:该功能与【自定义背景图】功能冲突,使用该功能时如果想设置背景图请写css里面。')); + $form->addInput($diycss); + + } + + /** + * 个人用户的配置面板 + * + * @access public + * @param Typecho_Widget_Helper_Form $form + * @return void + */ + public static function personalConfig(Typecho_Widget_Helper_Form $form) + { + } + + /** + * + * 函数名:readdir($dir) + * 作用:读取目录所有的文件名 + * 参数:$dir 目录地址 + * 返回值:文件名数组 + * + * */ + public static function readdir($dir) { + $handle=opendir($dir); + $i=0; + while(!!$file = readdir($handle)) { + if (($file!=".")and($file!="..")) { + $list[$i]=$file; + $i=$i+1; + } + } + closedir($handle); + return $list; + } + + /** + * 插件实现方法 + * + * @access public + * @return string + */ + public static function renderHeader($hed) + { + $options = Helper::options(); + + $url = $options->pluginUrl . '/AdminMD/'; + list($prefixVersion, $suffixVersion) = explode('/', $options->version); + + if (!Typecho_Widget::widget('Widget_User')->hasLogin()) { + $skin = Typecho_Widget::widget('Widget_Options')->plugin('AdminMD')->bgfengge; + $diycss = Typecho_Widget::widget('Widget_Options')->plugin('AdminMD')->diycss; + if ($skin == 'kongbai') { + $hed = $hed . ''; + } else { + if ($skin == 'heike') { + $hed = $hed . ''; + } else { + $bgUrl = Typecho_Widget::widget('Widget_Options')->plugin('AdminMD')->bgUrl; + $zidingyi = ""; + if ($bgUrl) { + $zidingyi = ""; + } + $hed = $hed . '' . $zidingyi; + } + } + + echo $hed; + }else{ + /* 添加 Material Design style */ + $hed = $hed . ''; + $hed = $hed.''; + $hed = $hed.''; + $hed = $hed.''; + $hed = $hed.''; + $hed = $hed.''; + } + + return $hed; + } + + public static function renderFooter() + { + $options = Helper::options(); + + $url = $options->pluginUrl . '/AdminMD/'; + list($prefixVersion, $suffixVersion) = explode('/', $options->version); + if (!Typecho_Widget::widget('Widget_User')->hasLogin()) { + $url = Helper::options()->pluginUrl . '/AdminMD/'; + $skin = Typecho_Widget::widget('Widget_Options')->plugin('AdminMD')->bgfengge; + $ft = ''; + if ($skin == 'heike') { + $ft = ''; + } + if ($skin == 'lv') { + $ft = ''; + } + echo $ft; + }else{ + echo ''; + } + + } + + +} diff --git a/README.md b/README.md index b7ad51f..6ed6851 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,63 @@ # AdminMD -#### 介绍 +## 介绍 为Typecho博客程序专门美化的后台,框架主要采用MDUI -#### 更新日志: +## 更新日志: -1.修复部分Bug +1.由覆盖式模板改为插件式后台模板,一定程度上增强了兼容性 -2.网站概要页修改 +2.新增了自定义后台登录页面一键自定义 -3.MDUI核心版本升级为1.0.1 +3.修复了部分已知Bug -4.去除非必要部分 +4.新增了部分未知Bug(理论上是完美移植为插件版) -#### 编程语言 +## 编程语言 PHP -#### 安装教程 +## 安装教程 -覆盖安装admin目录 +导入到Typecho程序 usr/plugins/ 目录中,并解压 -切记 一定要备份 +解压后文件夹名称必须为AdminMD -#### 使用须知 +## 使用须知 -1.目前版本,部分内容不会根据网站所配置的内容进行变量 +1.当前版本中仍存在部分不影响使用的未知Bug,一旦发现请务必反馈 -2.目前版本,无法兼容几乎所有的后台外观增强插件 +2.后台登录页面的背景图可以在插件设置中进行更改 -3.后台登录页面的背景图需要到login.php里手动更改 在第18行即可看到URL +3.由于 Typecho 程序默认使用的 Gravatar 官方的头像线路已被 GWF 屏蔽,因此会导致使用本主题时使后台完全加载缓慢。 -#### 下载渠道 +#### 解决 使用须知->3 问题的方法 + +解决方法 + +修改 Typecho 程序源代码 + +需要修改文件地址:网站根目录 ``/var/Typecho/Common.php``第 937 行 + +修改前: + +``` +$url = $isSecure ? 'https://secure.gravatar.com' : 'http://www.gravatar.com'; +``` +修改后: +``` +$url = $isSecure ? 'https://sdn.geekzu.org' : 'http://www.gravatar.com'; +``` + +其中 ``https://sdn.geekzu.org`` 可以替换为别的 Gravatar 国内代理地址 + +## 下载渠道 1.Gitte [https://gitee.com/Magnetokuwan/AdminMD](https://gitee.com/Magnetokuwan/AdminMD) 适合国内(由GitHub同步至此) 2.GitHub [https://github.com/ouyangyanhuo/AdminMD](https://github.com/ouyangyanhuo/AdminMD) 适合国外(主仓库) -#### 使用截图 +## 使用截图 ![登录](https://cdn.jsdelivr.net/gh/fyhgay/CDNS@latest/2021/01/08/3af177c1328c3d1fc3da5ff26602feee.png "登录") -![后台首页](https://cdn.jsdelivr.net/gh/fyhgay/CDNS@latest/2021/01/08/b20a84a2ee83e7ffc11a0a9647526959.png "后台首页") -![文章撰写](https://cdn.jsdelivr.net/gh/fyhgay/CDNS@latest/2021/01/08/b9d05b9232a840955576d480193d2cbe.png "文章撰写") \ No newline at end of file +![后台首页](https://cdn.jsdelivr.net/gh/fyhgay/CDNS@latest/2021/07/15/748ba291663f8cb917662b703825cb4d.png "后台首页") +![文章撰写](https://cdn.jsdelivr.net/gh/fyhgay/CDNS@latest/2021/07/15/34c412ed6388b9ca1d72d65c89ce1f41.png "文章撰写") +![数据备份](https://cdn.jsdelivr.net/gh/fyhgay/CDNS@latest/2021/07/15/ff54bddcfd504694acaa493d67ee8eda.png "数据备份") \ No newline at end of file diff --git a/TUi.php b/TUi.php deleted file mode 100644 index cb07cc9..0000000 --- a/TUi.php +++ /dev/null @@ -1,128 +0,0 @@ - -
- - - -
-
- - - menu - - title, $options->title); ?> - -
- - - - mail, 220, 'X', 'mm', $request->isSecure()) . '" alt="' . $user->screenName . '" width="40" class="mdui-img-circle"/>'; ?> - - - - - - - - - - more_vert - - - -
-
-
-
- - home -
首页
-
- -
-
- settings -
主控制台
- keyboard_arrow_down -
- -
- -
-
- border_color -
内容撰写
- keyboard_arrow_down -
- -
- -
-
- inbox -
内容管理
- keyboard_arrow_down -
- -
- -
-
- settings_applications -
更多设置
- keyboard_arrow_down -
- -
-
-
\ No newline at end of file diff --git a/backup.php b/admin/backup.php similarity index 87% rename from backup.php rename to admin/backup.php index 9d767b4..dbff9d7 100644 --- a/backup.php +++ b/admin/backup.php @@ -2,15 +2,12 @@ include 'common.php'; include 'header.php'; include 'menu.php'; -include 'TUi.php'; $actionUrl = $security->getTokenUrl( Typecho_Router::url('do', array('action' => 'backup', 'widget' => 'Backup'), Typecho_Common::url('index.php', $options->rootUrl))); $backupFiles = Typecho_Widget::widget('Widget_Backup')->listFiles(); ?> - -
@@ -25,7 +22,7 @@
  • -

    +

    @@ -44,7 +41,7 @@
    • - +
    @@ -66,7 +63,7 @@
    • - +
    diff --git a/category.php b/admin/category.php similarity index 96% rename from category.php rename to admin/category.php index 070a247..778f87c 100644 --- a/category.php +++ b/admin/category.php @@ -2,10 +2,7 @@ include 'common.php'; include 'header.php'; include 'menu.php'; -include 'TUi.php'; ?> - -
    @@ -21,7 +18,6 @@
    - - - - + + + + t.attr('target', '_blank'); + }); + } + }); + })(); + \ No newline at end of file diff --git a/admin/common.php b/admin/common.php new file mode 100644 index 0000000..06a6d62 --- /dev/null +++ b/admin/common.php @@ -0,0 +1,58 @@ +begin(); + +Typecho_Widget::widget('Widget_Options')->to($options); +Typecho_Widget::widget('Widget_User')->to($user); +Typecho_Widget::widget('Widget_Security')->to($security); +Typecho_Widget::widget('Widget_Menu')->to($menu); + +/** 初始化上下文 */ +$request = $options->request; +$response = $options->response; + +/** 检测是否是第一次登录 */ +$currentMenu = $menu->getCurrentMenu(); +list($prefixVersion, $suffixVersion) = explode('/', $options->version); +$params = parse_url($currentMenu[2]); +$adminFile = basename($params['path']); + +if (!$user->logged && !Typecho_Cookie::get('__typecho_first_run') && !empty($currentMenu)) { + + if ('welcome.php' != $adminFile) { + $response->redirect(Typecho_Common::url('welcome.php', $options->adminUrl)); + } else { + Typecho_Cookie::set('__typecho_first_run', 1); + } + +} else { + + /** 检测版本是否升级 */ + if ($user->pass('administrator', true) && !empty($currentMenu)) { + $mustUpgrade = (!defined('Typecho_Common::VERSION') || version_compare(str_replace('/', '.', Typecho_Common::VERSION), + str_replace('/', '.', $options->version), '>')); + + if ($mustUpgrade && 'upgrade.php' != $adminFile && 'backup.php' != $adminFile) { + $response->redirect(Typecho_Common::url('upgrade.php', $options->adminUrl)); + } else if (!$mustUpgrade && 'upgrade.php' == $adminFile) { + $response->redirect($options->adminUrl); + } else if (!$mustUpgrade && 'welcome.php' == $adminFile && $user->logged) { + $response->redirect($options->adminUrl); + } + } + +} diff --git a/copyright.php b/admin/copyright.php similarity index 99% rename from copyright.php rename to admin/copyright.php index 5fb7e1c..ff46c45 100644 --- a/copyright.php +++ b/admin/copyright.php @@ -1,7 +1,7 @@ - -