From 890b239d7eb2a1aca2b3ce81d8efdd0665d30310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=94=E8=90=BD?= <45323514+BigCoke233@users.noreply.github.com> Date: Sat, 6 Apr 2019 15:00:31 +0800 Subject: =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- post/post-content.php | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 post/post-content.php (limited to 'post/post-content.php') diff --git a/post/post-content.php b/post/post-content.php new file mode 100644 index 0000000..a1fdd24 --- /dev/null +++ b/post/post-content.php @@ -0,0 +1,70 @@ +content; + + $content = preg_replace('//s','',$content); + $content = preg_replace('/
/s','
',$content);
+	$content = preg_replace('//s','${4}',$content); 
+	
+	//短代码(无参数)
+	$reg = '/\[scode\](.*?)\[\/scode\]/s';
+    $rp = '
${1}
'; + $content = preg_replace($reg,$rp,$content); + + //短代码(有参数) + $reg = '/\[scode.*?type="(.*?)"\](.*?)\[\/scode\]/s'; + $rp = '
${2}
'; + $content = preg_replace($reg,$rp,$content); + + //font文字排版 + //无参数时,自动解析为红色 + $reg = '/\[font\](.*?)\[\/font\]/s'; + $rg = '${1}'; + $content = preg_replace($reg,$rp,$content); + + //解析只有color参数的font + $reg = '/\[font color="(.*?)"\](.*?)\[\/font\]/s'; + $rp = '${2}'; + $content = preg_replace($reg,$rp,$content); + + //解析只有bg参数的font + $reg = '/\[font bg="(.*?)"\](.*?)\[\/font\]/s'; + $rp = '${2}'; + $content = preg_replace($reg,$rp,$content); + + //解析只有size参数的font + $reg = '/\[font size="(.*?)"\](.*?)\[\/font\]/s'; + $rp = '${2}'; + $content = preg_replace($reg,$rp,$content); + + //解析只有style参数的font + $reg = '/\[font style="(.*?)"\](.*?)\[\/font\]/s'; + $rp = '${2}'; + $content = preg_replace($reg,$rp,$content); + + //滚动文本区域 + $reg = '/\[stext\](.*?)\[\/stext\]/s'; + $rp = '
${1}
'; + $content = preg_replace($reg,$rp,$content); + + //解析按钮 + $reg = '/\[btn url="(.*?)" type="(.*?)" ico="(.*?)"\](.*?)\[\/btn\]/s'; + $rp = ' ${4}'; + $content = preg_replace($reg,$rp,$content); + + //解析嵌入块 + $reg = '/\[well\](.*?)\[\/well\]/s'; + $rp = '
${1}
'; + $content = preg_replace($reg,$rp,$content); + + //解析面板 + //无参数面板 + $reg = '/\[panel\](.*?)\[\/panel\]/s'; + $rp = '
${1}
'; + $content = preg_replace($reg,$rp,$content); + //有标题的面板 + $reg = '/\[panel title="(.*?)"\](.*?)\[\/panel\]/s'; + $rp = '
${1}
${2}
'; + $content = preg_replace($reg,$rp,$content); + + echo $content; +?> \ No newline at end of file -- cgit v1.2.3