diff --git a/Plugin.php b/Plugin.php index ca0d054..15f04f7 100644 --- a/Plugin.php +++ b/Plugin.php @@ -55,8 +55,29 @@ class AliOssForTypecho_Plugin implements Typecho_Plugin_Interface */ public static function config(Typecho_Widget_Helper_Form $form) { - $upload_dir = $localPath = Typecho_Common::url(defined('__TYPECHO_UPLOAD_DIR__') ? __TYPECHO_UPLOAD_DIR__ : self::UPLOAD_DIR, - defined('__TYPECHO_UPLOAD_ROOT_DIR__') ? __TYPECHO_UPLOAD_ROOT_DIR__ : __TYPECHO_ROOT_DIR__); + $upload_root = Typecho_Common::url(defined('__TYPECHO_UPLOAD_DIR__') ? __TYPECHO_UPLOAD_DIR__ : self::UPLOAD_DIR, + defined('__TYPECHO_UPLOAD_ROOT_DIR__') ? __TYPECHO_UPLOAD_ROOT_DIR__ : __TYPECHO_ROOT_DIR__); + + $log_name = $upload_root . self::LOG_SUFFIX . 'error.log'; + + if (is_writable($upload_root) && is_writable($upload_root . self::LOG_SUFFIX) && is_writable($log_name)) { + $log_content = '恭喜!暂无错误日志产生,请继续保持维护,加油~'; + $log_color = '#009900'; + if (file_exists($log_name)) { + $handle = fopen($log_name, "r"); + $content = fread($handle, filesize($log_name)); + if ($content) { + $log_content = $content; + $log_color = '#dd0000'; + } + fclose($handle); + } + } else { + $log_content = '!!!注意!!! +当前网站上传目录无写入权限,无法记录日志! +请给路径 '.$upload_root.' 赋予写入权限'; + $log_color = '#f00000'; + } $des = new Typecho_Widget_Helper_Form_Element_Text('des', NULL, '', _t('插件使用说明'), '
'.$upload_dir.'
'.$upload_root.'
以下是本插件产生的错误日志,请定期查看并处理:
+