?% '===========pblog2 ubb代码转换代码========== ' author:puterjam ' copryright pblog2 ' update: 2005-12-29 '=========================================== function ubbcode(byval strcontent,dissm,disubb,disimg,autourl,autokey) if isempty(strcontent) or isnull(strcontent) then exit function else dim re, strmatchs, strmatch, rndid,tmpstr1,tmpstr2,tmpstr3,tmpstr4 set re=new regexp re.ignorecase =true re.global=true if autourl=1 then re.pattern="([^=\]][\s]*?|^)(http|https|rstp|ftp|mms|ed2k)://([a-za-z0-9\.\/=\?%\-_~`@':+!]*)" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=strmatch.submatches(0) tmpstr2=strmatch.submatches(1) tmpstr3=checkurl(strmatch.submatches(2)) strcontent=replace(strcontent,strmatch.value,tmpstr1&""&tmpstr2&"://"&tmpstr3&"",1,-1,0) next 're.pattern="(^|\s)(www\.\s+)" 'strcontent=re.replace(strcontent,"$1$2") end if if not disubb=1 then if not disimg=1 then re.pattern="(\[img\])(.[^\]]*)\[\/img\]" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=(strmatch.submatches(1)) strcontent=replace(strcontent,strmatch.value,"",1,-1,0) next re.pattern="\[img=(left|right|center|absmiddle|)\](.[^\]]*)(\[\/img\])" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=strmatch.submatches(0) tmpstr2=checkurl(strmatch.submatches(1)) strcontent=replace(strcontent,strmatch.value,"",1,-1,0) next re.pattern="\[img=(\d*|),(\d*|)\](.[^\]]*)\[\/img\]" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=strmatch.submatches(0) tmpstr2=strmatch.submatches(1) tmpstr3=checkurl(strmatch.submatches(2)) strcontent=replace(strcontent,strmatch.value,"",1,-1,0) next re.pattern="\[img=(\d*|),(\d*|),(left|right|center|absmiddle|)\](.[^\]]*)(\[\/img\])" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=strmatch.submatches(0) tmpstr2=strmatch.submatches(1) tmpstr3=strmatch.submatches(2) tmpstr4=checkurl(strmatch.submatches(3)) strcontent=replace(strcontent,strmatch.value,"",1,-1,0) next else re.pattern="(\[img\])(.[^\]]*)\[\/img\]" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=checkurl(strmatch.submatches(1)) strcontent=replace(strcontent,strmatch.value,"查看图片",1,-1,0) next re.pattern="\[img=(left|right|center|absmiddle|)\](.[^\]]*)(\[\/img\])" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=strmatch.submatches(0) tmpstr2=checkurl(strmatch.submatches(1)) strcontent=replace(strcontent,strmatch.value,"查看图片",1,-1,0) next re.pattern="\[img=(\d*|),(\d*|)\](.[^\]]*)\[\/img\]" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=strmatch.submatches(0) tmpstr2=strmatch.submatches(1) tmpstr3=checkurl(strmatch.submatches(2)) strcontent=replace(strcontent,strmatch.value,"查看图片",1,-1,0) next re.pattern="\[img=(\d*|),(\d*|),(left|right|center|absmiddle|)\](.[^\]]*)(\[\/img\])" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=strmatch.submatches(0) tmpstr2=strmatch.submatches(1) tmpstr3=strmatch.submatches(2) tmpstr4=checkurl(strmatch.submatches(3)) strcontent=replace(strcontent,strmatch.value,"查看图片",1,-1,0) next end if '-----------多媒体标?--------------- re.pattern="\[(swf|wma|wmv|rm|ra|qt)(=\d*?|)(,\d*?|)\]([^<>]*?)\[\/(swf|wma|wmv|rm|ra|qt)\]" set strmatchs=re.execute(strcontent) dim strtype,strwidth,strheight,strsrc,titletext for each strmatch in strmatchs randomize strtype=strmatch.submatches(0) if strtype="swf" then titletext="flash动画" elseif strtype="wma" then titletext="播放音频文件" elseif strtype="wmv" then titletext="播放视频文件" elseif strtype="rm" then titletext="播放real视频流文? elseif strtype="ra" then titletext="播放real音频流文? elseif strtype="qt" then titletext="播放mov视频文件" end if strwidth=strmatch.submatches(1) strheight=strmatch.submatches(2) if (len(strwidth)=0) then strwidth="400" else strwidth=right(strwidth,(len(strwidth)-1)) end if if (len(strheight)=0) then strheight="300" else strheight=right(strheight,(len(strheight)-1)) end if strsrc=checkurl(strmatch.submatches(3)) rndid="temp"&int(100000 * rnd) strcontent= replace(strcontent,strmatch.value,"
"&titletext&"
在线播放
") next set strmatchs=nothing re.pattern="(\[mid\])(.[^\]]*)\[\/mid\]" strcontent= re.replace(strcontent,"") '-----------常规标签---------------- re.pattern = "\[url=(.[^\]]*)\](.[^\[]*)\[\/url]" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=checkurl(strmatch.submatches(0)) tmpstr2=strmatch.submatches(1) strcontent=replace(strcontent,strmatch.value,""&tmpstr2&"",1,-1,0) next re.pattern = "\[url](.[^\[]*)\[\/url]" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=checkurl(strmatch.submatches(0)) strcontent=replace(strcontent,strmatch.value,""&tmpstr1&"",1,-1,0) next re.pattern = "\[ed2k=([^\r]*?)\]([^\r]*?)\[\/ed2k]" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=checkurl(strmatch.submatches(0)) tmpstr2=strmatch.submatches(1) strcontent=replace(strcontent,strmatch.value,""&tmpstr2&"",1,-1,0) next re.pattern = "\[ed2k]([^\r]*?)\[\/ed2k]" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=checkurl(strmatch.submatches(0)) strcontent=replace(strcontent,strmatch.value,""&tmpstr1&"",1,-1,0) next re.pattern = "\[email=(.[^\]]*)\](.[^\[]*)\[\/email]" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=checkurl(strmatch.submatches(0)) tmpstr2=strmatch.submatches(1) strcontent=replace(strcontent,strmatch.value,""&tmpstr2&"",1,-1,0) next re.pattern = "\[email](.[^\[]*)\[\/email]" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=checkurl(strmatch.submatches(0)) strcontent=replace(strcontent,strmatch.value,""&tmpstr1&"",1,-1,0) next '-----------字体格式---------------- re.pattern="\[align=(\w{4,6})\]([^\r]*?)\[\/align\]" strcontent=re.replace(strcontent,"
$2
") re.pattern="\[color=(#\w{3,10}|\w{3,10})\]([^\r]*?)\[\/color\]" strcontent=re.replace(strcontent,"$2") re.pattern="\[size=(\d{1,2})\]([^\r]*?)\[\/size\]" strcontent=re.replace(strcontent,"$2") re.pattern="\[font=([^\r]*?)\]([^\r]*?)\[\/font\]" strcontent=re.replace(strcontent,"$2") re.pattern="\[b\]([^\r]*?)\[\/b\]" strcontent=re.replace(strcontent,"$1") re.pattern="\[i\]([^\r]*?)\[\/i\]" strcontent=re.replace(strcontent,"$1") re.pattern="\[u\]([^\r]*?)\[\/u\]" strcontent=re.replace(strcontent,"$1") re.pattern="\[s\]([^\r]*?)\[\/s\]" strcontent=re.replace(strcontent,"$1") re.pattern="\[sup\]([^\r]*?)\[\/sup\]" strcontent=re.replace(strcontent,"$1") re.pattern="\[sub\]([^\r]*?)\[\/sub\]" strcontent=re.replace(strcontent,"$1") re.pattern="\[fly\]([^\r]*?)\[\/fly\]" strcontent=re.replace(strcontent,"$1") end if '-----------特殊标签---------------- re.pattern = "\[down=(.[^\]]*)\](.[^\[]*)\[\/down]" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=checkurl(strmatch.submatches(0)) tmpstr2=strmatch.submatches(1) strcontent=replace(strcontent,strmatch.value," "&tmpstr2&"",1,-1,0) next re.pattern = "\[down\](.[^\[]*)\[\/down]" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=checkurl(strmatch.submatches(0)) strcontent=replace(strcontent,strmatch.value," 下载此文?/a>",1,-1,0) next re.pattern = "\[mdown=(.[^\]]*)\](.[^\[]*)\[\/mdown]" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=checkurl(strmatch.submatches(0)) tmpstr2=strmatch.submatches(1) if len(memname)>0 then strcontent=replace(strcontent,strmatch.value," "&tmpstr2&"",1,-1,0) else strcontent=replace(strcontent,strmatch.value," 该文件只允许会员下载! 登录 | 注册",1,-1,0) end if next re.pattern = "\[mdown\](.[^\[]*)\[\/mdown]" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs tmpstr1=checkurl(strmatch.submatches(0)) if len(memname)>0 then strcontent=replace(strcontent,strmatch.value," 下载此文?/a>",1,-1,0) else strcontent=replace(strcontent,strmatch.value," 该文件只允许会员下载! 登录 | 注册",1,-1,0) end if next re.pattern="\[code\](.*?)\[\/code\]" strcontent= re.replace(strcontent,"
程序代码
$1
") re.pattern="\[quote\](.*?)\[\/quote\]" strcontent= re.replace(strcontent,"
引用内容
$1
") re.pattern="\[quote=(.[^\]]*)\](.*?)\[\/quote\]" strcontent= re.replace(strcontent,"
引用来自 $1
$2
") re.pattern="\[hidden\](.*?)\[\/hidden\]" if len(memname)>0 then strcontent= re.replace(strcontent,"
显示被隐藏内?/div>
$1
") else strcontent= re.replace(strcontent,"
隐藏内容
该内容已经被作者隐?只有会员才允许查?登录 | 注册
") end if re.pattern="\[hidden=(.[^\]]*)\](.*?)\[\/hidden\]" if len(memname)>0 then strcontent= re.replace(strcontent,"
显示被隐藏内容来?$1
$2
") else strcontent= re.replace(strcontent,"
隐藏内容
该内容已经被作者隐?只有会员才允许查?登录 | 注册
") end if re.pattern="\[html\](.*?)\[\/html\]" set strmatchs=re.execute(strcontent) for each strmatch in strmatchs randomize rndid="temp"&int(100000 * rnd) strcontent=replace(strcontent,strmatch.value,"
html代码


[ctrl+a 全部选择 提示:你可先修改部分代码,再按运行]
",1,-1,0) next set strmatchs=nothing '-----------list标签---------------- strcontent = replace(strcontent,"[list]","
") end if if action=1 then category_code="" if ubound(arr_category,1)=0 then exit sub category_len=ubound(arr_category,2) for i=0 to category_len if int(arr_category(9,i))=0 or int(arr_category(9,i))=2 then if arr_category(4,i) then if cbool(arr_category(10,i)) then if stat_showhiddencate or stat_admin then category_code=category_code&(""&arr_category(1,i)&"
") else category_code=category_code&(""&arr_category(1,i)&"
") end if else if cbool(arr_category(10,i)) then if stat_showhiddencate or stat_admin then category_code=category_code&(""&arr_category(1,i)&" ["&arr_category(7,i)&"]
") else category_code=category_code&(""&arr_category(1,i)&" ["&arr_category(7,i)&"]
") end if end if end if next end if end sub '========================end sub=============================== '========================日志归档缓存============================ function archive(byval action)'日志归档 dim blog_archive,i '-----------------写入日志归档缓存-------------------- if not isarray(application(cookiename&"_blog_archive")) or action=2 then dim log_archives sql="select count(log_id) as [count], year([log_posttime]) as postyear, month([log_posttime]) as postmonth " &_ "from blog_content where blog_content.log_isdraft=false "&_ "group by year([log_posttime]), month([log_posttime]) "&_ "order by year([log_posttime]) desc, month([log_posttime]) desc" set log_archives=conn.execute(sql) sqlquerynums=sqlquerynums+1 if log_archives.eof or log_archives.bof then redim blog_archive(0,0) else blog_archive=log_archives.getrows() end if set log_archives=nothing application.lock application(cookiename&"_blog_archive")=blog_archive application.unlock else blog_archive=application(cookiename&"_blog_archive") end if '-----------------读取日志归档缓存-------------------- if action<>2 then dim archive_item_len,month_array if ubound(blog_archive,1)=0 then archive="":exit function month_array=array("一?,"二月","三月","四月","五月","六月","七月","八月","九月","十月","十一?,"十二?) archive_item_len=ubound(blog_archive,2) for i=0 to archive_item_len archive=archive&""&blog_archive(1,i)&"?&month_array(blog_archive(2,i)-1)&" ["&blog_archive(0,i)&"]" next end if end function '=====================end function======================== '=====================最新评论缓?==================== function newcomment(byval action) dim blog_comment,showlen,i showlen=10 '显示最新评论预览数? '-----------------写入最新评论缓?------------------- if not isarray(application(cookiename&"_blog_comment")) or action=2 then dim log_comments sql="select top "&showlen&" comm_id,blog_id,comm_author,comm_content,comm_posttime" &_ " from blog_comment as c,blog_content as t,blog_category as a where c.blog_id=t.log_id and t.log_isshow=true and t.log_cateid=a.cate_id and a.cate_secret=false order by c.comm_posttime desc" set log_comments=conn.execute(sql) sqlquerynums=sqlquerynums+1 if log_comments.eof or log_comments.bof then redim blog_comment(0,0) else blog_comment=log_comments.getrows(showlen) end if set log_comments=nothing application.lock application(cookiename&"_blog_comment")=blog_comment application.unlock else blog_comment=application(cookiename&"_blog_comment") end if '-----------------读取最新评论缓?------------------- if action<>2 then dim comment_item_len if ubound(blog_comment,1)=0 then newcomment="":exit function comment_item_len=ubound(blog_comment,2) for i=0 to comment_item_len newcomment=newcomment&""&ccencode(cutstr(delquote(blog_comment(3,i)),25))&"" next end if end function '=====================end function======================== '====================写入标签tag缓存===================== dim arr_tags function tags(byval action) if not isarray(application(cookiename&"_blog_tags")) or action=2 then dim log_tags,log_tagslist set log_tags=conn.execute("select tag_id,tag_name,tag_count from blog_tag") sqlquerynums=sqlquerynums+1 tempvar="" do while not log_tags.eof log_tagslist=log_tagslist&tempvar&log_tags("tag_id")&"||"&log_tags("tag_name")&"||"&log_tags("tag_count") tempvar="," log_tags.movenext loop set log_tags=nothing arr_tags=split(log_tagslist,",") application.lock application(cookiename&"_blog_tags")=arr_tags application.unlock else arr_tags=application(cookiename&"_blog_tags") end if end function '======================end function======================== '====================写入表情符号缓存===================== dim arr_smilies function smilies(byval action) if not isarray(application(cookiename&"_blog_smilies")) or action=2 then dim log_smilies,log_smilieslist set log_smilies=conn.execute("select sm_id,sm_image,sm_text from blog_smilies") sqlquerynums=sqlquerynums+1 tempvar="" do while not log_smilies.eof log_smilieslist=log_smilieslist&tempvar&log_smilies("sm_id")&"|"&log_smilies("sm_image")&"|"&log_smilies("sm_text") tempvar="," log_smilies.movenext loop set log_smilies=nothing arr_smilies=split(log_smilieslist,",") application.lock application(cookiename&"_blog_smilies")=arr_smilies application.unlock else arr_smilies=application(cookiename&"_blog_smilies") end if end function '======================end function======================== '======================写入关键字列?===================== dim arr_keywords function keywords(byval action) if not isarray(application(cookiename&"_blog_keywords")) or action=2 then dim log_keywords,log_keywordslist set log_keywords=conn.execute("select key_id,key_text,key_url,key_image from blog_keywords") sqlquerynums=sqlquerynums+1 tempvar="" do while not log_keywords.eof if log_keywords("key_image")<>empty then log_keywordslist=log_keywordslist&tempvar&log_keywords("key_id")&"$|$"&log_keywords("key_text")&"$|$"&log_keywords("key_url")&"$|$"&log_keywords("key_image") else log_keywordslist=log_keywordslist&tempvar&log_keywords("key_id")&"$|$"&log_keywords("key_text")&"$|$"&log_keywords("key_url")&"$|$none" end if tempvar="|$|" log_keywords.movenext loop set log_keywords=nothing arr_keywords=split(log_keywordslist,"|$|") application.lock application(cookiename&"_blog_keywords")=arr_keywords application.unlock else arr_keywords=application(cookiename&"_blog_keywords") end if end function '======================end function========================= '=======================写入首页链接列表==================== dim arr_bloglinks function bloglinks(byval action) if not isarray(application(cookiename&"_blog_bloglinks")) or action=2 then dim log_bloglinks,log_bloglinkslist set log_bloglinks=conn.execute("select link_name,link_url,link_image from blog_links where link_ismain=true order by link_order asc") sqlquerynums=sqlquerynums+1 tempvar="" do while not log_bloglinks.eof if log_bloglinks("link_image")<>empty then log_bloglinkslist=log_bloglinkslist&tempvar&log_bloglinks("link_name")&"$|$"&log_bloglinks("link_url")&"$|$"&log_bloglinks("link_image") else log_bloglinkslist=log_bloglinkslist&tempvar&log_bloglinks("link_name")&"$|$"&log_bloglinks("link_url")&"$|$none" end if tempvar="|$|" log_bloglinks.movenext loop set log_bloglinks=nothing arr_bloglinks=split(log_bloglinkslist,"|$|") application.lock application(cookiename&"_blog_bloglinks")=arr_bloglinks application.unlock else arr_bloglinks=application(cookiename&"_blog_bloglinks") end if if action=1 then dim arr_bloglink,arr_bloglinkitem,imglink,textlink bloglinks="" for each arr_bloglink in arr_bloglinks arr_bloglinkitem=split(arr_bloglink,"$|$") if blog_imglink then if arr_bloglinkitem(2)="none" then textlink=textlink&""&arr_bloglinkitem(0)&"" else imglink=imglink&" " end if else bloglinks=bloglinks&""&arr_bloglinkitem(0)&"" end if next if blog_imglink then bloglinks=imglink&textlink end if end function '=====================end function======================= '======================自定义模块缓?==================== dim side_html_default,side_html,content_html_top_default,content_html_top,content_html_bottom_default,content_html_bottom,function_plugin function log_module(byval action) dim blog_modules side_html_default="" '首页侧栏代码 side_html="" '普通页面侧栏代?content_html_top_default="" '首页内容代码顶部 content_html_top="" '普通页面内容代码顶?content_html_bottom_default="" '首页内容代码底部 content_html_bottom="" '普通页面内容代码底?function_plugin="" 'blog功能插件 if not isarray(application(cookiename&"_blog_module")) or action=2 then dim blog_module,blog_module_array,tempdiv tempdiv="" sql="select type,title,name,htmlcode,indexonly,sortid,pluginpath,installfolder from blog_module where ishidden=false order by sortid" set blog_module=conn.execute(sql) sqlquerynums=sqlquerynums+1 do until blog_module.eof if blog_module("type")="sidebar" then side_html_default=side_html_default&"
" if len(blog_module("title"))>0 then side_html_default=side_html_default&"

"&blog_module("title")&"

" side_html_default=side_html_default&"
"&blog_module("htmlcode")&"
" if blog_module("indexonly")=false then side_html=side_html&"
" if len(blog_module("title"))>0 then side_html=side_html&"

"&blog_module("title")&"

" side_html=side_html&"
"&blog_module("htmlcode")&"
" end if end if if blog_module("type")="content" and blog_module("name")<>"contentlist" then if blog_module("sortid")<0 then content_html_top_default=content_html_top_default&"
"&blog_module("htmlcode")&"
" if blog_module("indexonly")=false then content_html_top=content_html_top&"
"&blog_module("htmlcode")&"
" end if else content_html_bottom_default=content_html_bottom_default&"
"&blog_module("htmlcode")&"
" if blog_module("indexonly")=false then content_html_bottom=content_html_bottom&"
"&blog_module("htmlcode")&"
" end if end if end if if blog_module("type")="function" then function_plugin=function_plugin&tempdiv&blog_module("name")&"%|%"&blog_module("pluginpath")&"%|%"&blog_module("installfolder") tempdiv="$*$" end if blog_module.movenext loop set blog_module=nothing blog_modules=array(side_html_default,side_html,content_html_top_default,content_html_top,content_html_bottom_default,content_html_bottom,function_plugin) application.lock application(cookiename&"_blog_module")=blog_modules application.unlock else blog_modules=application(cookiename&"_blog_module") end if if action<>2 then side_html_default=uncheckstr(blog_modules(0)) '首页侧栏代码 side_html=uncheckstr(blog_modules(1)) '普通页面侧栏代? content_html_top_default=uncheckstr(blog_modules(2)) '首页内容代码顶部 content_html_top=uncheckstr(blog_modules(3)) '普通页面内容代码顶? content_html_bottom_default=uncheckstr(blog_modules(4)) '首页内容代码底部 content_html_bottom=uncheckstr(blog_modules(5)) '普通页面内容代码底? function_plugin=blog_modules(6) 'blog功能插件 end if end function '========================end function========================= '======================重新加载blog缓存===================== sub reloadcache getinfo(2) userright(2) categorylist(2) archive(2) newcomment(2) tags(2) smilies(2) keywords(2) bloglinks(2) log_module(2) calendar "","","",2 end sub %>