Revision | b6b4d3b9d76034585438e1f7f865a53923f4ed4c (tree) |
---|---|
Time | 2022-01-24 01:59:57 |
Author | hai-fun <haifun129@gmai...> |
Commiter | hai-fun |
v1.2, author: sonots
@@ -0,0 +1,63 @@ | ||
1 | +<?php | |
2 | +/** | |
3 | + * Markdon Syntax | |
4 | + * | |
5 | + * @author sonots | |
6 | + * @license http://www.gnu.org/licenses/gpl.html GPL v2 | |
7 | + * @link http://lsx.sourceforge.jp/?Plugin%2Fmarkdown.inc.php | |
8 | + * @version $Id: markdown.inc.php,v 1.2 2007-02-24 16:28:39Z sonots $ | |
9 | + * @package plugin | |
10 | + */ | |
11 | + | |
12 | +function plugin_markdown_convert() | |
13 | +{ | |
14 | + if (defined('PLUGIN_DIR') && file_exists(PLUGIN_DIR . 'markdown.php')) { | |
15 | + $markdown = PLUGIN_DIR . 'markdown.php'; | |
16 | + } elseif (defined('EXT_PLUGIN_DIR') && file_exists(EXT_PLUGIN_DIR . 'markdown.php')) { | |
17 | + $markdown = EXT_PLUGIN_DIR . 'markdown.php'; | |
18 | + } else { | |
19 | + return "markdown(): markdown.php does not exist under " . PLUGIN_DIR . ' or ' . EXT_PLUGIN_DIR; | |
20 | + } | |
21 | + | |
22 | + $args = func_get_args(); | |
23 | + $body = array_pop($args); | |
24 | + $noskin = in_array("noskin", $args); | |
25 | + global $vars; | |
26 | + if (! (PKWK_READONLY > 0 or is_freeze($vars['page']) or plugin_markdown_is_edit_auth($vars['page']))) { | |
27 | + $body = htmlspecialchars($body); | |
28 | + } | |
29 | + require_once($markdown); | |
30 | + $body = Markdown($body); | |
31 | + | |
32 | + if ($noskin) { | |
33 | + pkwk_common_headers(); | |
34 | + print $body; | |
35 | + exit; | |
36 | + } | |
37 | + return $body; | |
38 | +} | |
39 | + | |
40 | +function plugin_markdown_is_edit_auth($page, $user = '') | |
41 | +{ | |
42 | + global $edit_auth, $edit_auth_pages, $auth_method_type; | |
43 | + if (! $edit_auth) { | |
44 | + return FALSE; | |
45 | + } | |
46 | + // Checked by: | |
47 | + $target_str = ''; | |
48 | + if ($auth_method_type == 'pagename') { | |
49 | + $target_str = $page; // Page name | |
50 | + } else if ($auth_method_type == 'contents') { | |
51 | + $target_str = join('', get_source($page)); // Its contents | |
52 | + } | |
53 | + | |
54 | + foreach($edit_auth_pages as $regexp => $users) { | |
55 | + if (preg_match($regexp, $target_str)) { | |
56 | + if ($user == '' || in_array($user, explode(',', $users))) { | |
57 | + return TRUE; | |
58 | + } | |
59 | + } | |
60 | + } | |
61 | + return FALSE; | |
62 | +} | |
63 | +?> |