diff options
| author | 阔落 <45323514+BigCoke233@users.noreply.github.com> | 2019-03-30 15:30:52 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-30 15:30:52 +0800 |
| commit | 9ae13dfa011baab12843b6855c2e9a4d6ca92075 (patch) | |
| tree | 07399ca9dfed868bc74a4ace8bc14e11d31e364d /includes/post-content.php | |
| parent | d5ff633699d665803d400551dc66c14ec480bb5f (diff) | |
Add files via upload
Diffstat (limited to 'includes/post-content.php')
| -rw-r--r-- | includes/post-content.php | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/includes/post-content.php b/includes/post-content.php new file mode 100644 index 0000000..c2f1a12 --- /dev/null +++ b/includes/post-content.php @@ -0,0 +1,47 @@ +<?php
+ //解析灯箱及图片描述
+ $content = preg_replace('/<img(.*?)src="(.*?)" alt="(.*?)" title="(.*?)"(.*?)>/s','<a data-fancybox="gallery" href="${2}"><img${1}src="${2}"${5}></a><span class="post-img-alt">${4}</span>',$this->content);
+
+ //短代码(无参数)
+ $reg = '/\[scode\](.*?)\[\/scode\]/s';
+ $rp = '<div class="tip">${1}</div>';
+ $content = preg_replace($reg,$rp,$content);
+
+ //短代码(有参数)
+ $reg = '/\[scode.*?type="(.*?)"\](.*?)\[\/scode\]/s';
+ $rp = '<div class="tip ${1}">${2}</div>';
+ $content = preg_replace($reg,$rp,$content);
+
+ //font文字排版
+ //无参数时,自动解析为红色
+ $reg = '/\[font\](.*?)\[\/font\]/s';
+ $rg = '<span style="color:red;">${1}</span>';
+ $content = preg_replace($reg,$rp,$content);
+
+ //解析只有color参数的font
+ $reg = '/\[font color="(.*?)"\](.*?)\[\/font\]/s';
+ $rp = '<span style="color:${1}">${2}</span>';
+ $content = preg_replace($reg,$rp,$content);
+
+ //解析只有bg参数的font
+ $reg = '/\[font bg="(.*?)"\](.*?)\[\/font\]/s';
+ $rp = '<span style="background-color:${1}">${2}</span>';
+ $content = preg_replace($reg,$rp,$content);
+
+ //解析只有size参数的font
+ $reg = '/\[font size="(.*?)"\](.*?)\[\/font\]/s';
+ $rp = '<span style="font-size:${1}">${2}</span>';
+ $content = preg_replace($reg,$rp,$content);
+
+ //解析只有style参数的font
+ $reg = '/\[font style="(.*?)"\](.*?)\[\/font\]/s';
+ $rp = '<span style="${1}">${2}</span>';
+ $content = preg_replace($reg,$rp,$content);
+
+ //滚动文本区域
+ $reg = '/\[stext\](.*?)\[\/stext\]/s';
+ $rp = '<div class="post-stext">${1}</div>';
+ $content = preg_replace($reg,$rp,$content);
+
+ echo $content
+?>
\ No newline at end of file |
