Jony/core/factory.php

76 lines
3.7 KiB
PHP
Raw Normal View History

2021-01-28 11:30:39 +00:00
<?php
2021-04-28 09:20:27 +00:00
2021-02-16 12:26:00 +00:00
/* 加强评论拦截功能 */
Typecho_Plugin::factory('Widget_Feedback')->comment = array('Intercept', 'message');
class Intercept
{
public static function message($comment)
{
2021-04-19 09:01:09 +00:00
/* 用户输入内容画图模式 */
2021-03-16 02:55:03 +00:00
if (preg_match('/\{!\{(.*)\}!\}/', $comment['text'], $matches)) {
/* 如果判断是否有双引号,如果有双引号,则禁止评论 */
if (strpos($matches[1], '"') !== false || _checkXSS($matches[1])) {
$comment['status'] = 'waiting';
2021-02-16 12:26:00 +00:00
}
2021-04-19 09:01:09 +00:00
/* 普通评论 */
2021-03-16 02:55:03 +00:00
} else {
2021-04-19 09:01:09 +00:00
/* 判断用户输入是否大于字符 */
if (Helper::options()->JTextLimit && strlen($comment['text']) > Helper::options()->JTextLimit) {
$comment['status'] = 'waiting';
} else {
/* 判断评论内容是否包含敏感词 */
if (Helper::options()->JSensitiveWords) {
if (_checkSensitiveWords(Helper::options()->JSensitiveWords, $comment['text'])) {
$comment['status'] = 'waiting';
}
2021-03-16 02:55:03 +00:00
}
2021-04-19 09:01:09 +00:00
/* 判断评论是否至少包含一个中文 */
if (Helper::options()->JLimitOneChinese === "on") {
if (preg_match("/[\x{4e00}-\x{9fa5}]/u", $comment['text']) == 0) {
$comment['status'] = 'waiting';
}
2021-03-16 02:55:03 +00:00
}
2021-02-16 12:26:00 +00:00
}
}
2021-03-16 02:55:03 +00:00
Typecho_Cookie::delete('__typecho_remember_text');
2021-02-16 12:26:00 +00:00
return $comment;
}
}
2021-03-14 11:20:25 +00:00
/* 加强后台编辑器功能 */
2021-03-16 13:44:38 +00:00
if (Helper::options()->JEditor !== 'off') {
Typecho_Plugin::factory('admin/write-post.php')->richEditor = array('Editor', 'Edit');
Typecho_Plugin::factory('admin/write-page.php')->richEditor = array('Editor', 'Edit');
}
2021-03-14 11:20:25 +00:00
class Editor
{
public static function Edit()
2021-03-25 09:05:46 +00:00
{
?>
2021-04-21 14:48:18 +00:00
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.css">
2021-03-28 07:40:48 +00:00
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-tomorrow.min.css">
2021-04-16 09:09:40 +00:00
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css">
2021-05-06 06:43:19 +00:00
<link rel="stylesheet" href="<?php Helper::options()->themeUrl('typecho/write/css/joe.write.min.css?v=20210506') ?>">
2021-03-28 05:34:27 +00:00
<script>
window.JoeConfig = {
uploadAPI: '<?php Helper::security()->index('/action/upload'); ?>',
emojiAPI: '<?php Helper::options()->themeUrl('typecho/write/json/emoji.json') ?>',
2021-04-01 06:46:20 +00:00
expressionAPI: '<?php Helper::options()->themeUrl('typecho/write/json/expression.json') ?>',
2021-03-28 05:34:27 +00:00
characterAPI: '<?php Helper::options()->themeUrl('typecho/write/json/character.json') ?>',
2021-04-01 05:58:02 +00:00
playerAPI: '<?php Helper::options()->JCustomPlayer ? Helper::options()->JCustomPlayer() : Helper::options()->themeUrl('library/player.php?url=') ?>',
2021-04-01 08:46:21 +00:00
autoSave: <?php Helper::options()->autoSave(); ?>,
2021-04-22 02:45:37 +00:00
themeURL: '<?php Helper::options()->themeUrl(); ?>',
canPreview: false
2021-03-28 05:34:27 +00:00
}
</script>
2021-05-07 09:58:57 +00:00
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script>
2021-04-21 14:48:18 +00:00
<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.js"></script>
2021-04-01 01:47:50 +00:00
<script src="https://cdn.jsdelivr.net/npm/typecho-joe-next@6.2.4/plugin/prism/prism.min.js"></script>
2021-04-26 08:15:51 +00:00
<script src="<?php Helper::options()->themeUrl('typecho/write/js/joe.parse.min.js') ?>"></script>
2021-05-07 09:58:57 +00:00
<script src="<?php Helper::options()->themeUrl('typecho/write/js/joe.write.chunk.js?v=20210507') ?>"></script>
<script src="<?php Helper::options()->themeUrl('assets/js/joe.short.min.js') ?>"></script>
2021-03-14 11:20:25 +00:00
<?php
}
}