PageRenderTime 68ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 1ms

/f.asp

https://github.com/74hu/74hujz
ASP | 692 lines | 620 code | 8 blank | 64 comment | 2 complexity | f49ec0d17cd7c28d1e995fcac9c68a11 MD5 | raw file
  1. <!--#include file="config.asp"--><%
  2. '
  3. ' 七色虎建站系统
  4. ' 核心文件F.asp
  5. ' v1.2.4.143a
  6. ' 2011.9.3
  7. ' 注:外部不要直接引用hu_前缀的变量或函数
  8. Dim wapstyle,waptitle,wapurl,wapconst,wapgonggao,wapfavor,waplink,countdown,listnums,viewtnums,titlenums
  9. '配置出错时启用,降低耦合
  10. If wapstyle<>"2" And wapstyle<>"1" Then wapstyle="2"'网站样式
  11. If waptitle="" Then waptitle="无名网站"'网站名称
  12. If wapurl="" Then wapurl="74hu.cn"'网站地址
  13. If wapconst="" Then wapconst="left"'网站排版
  14. If wapgonggao<>"1" And wapgonggao<>"0" Then wapgonggao="1"'全站显示公告
  15. If wapfavor<>"1" And wapfavor<>"0" Then wapfavor="1"'首页问候语
  16. If waplink<>"1" And waplink<>"0" Then waplink="1"'首页链接
  17. If Not IsDate(countdown) Then countdown=""'首页倒计时
  18. If Not IsNumeric(listnums) Then listnums="10"'文章列表数
  19. If Not IsNumeric(viewtnums) Then viewtnums="500"'文章每页字数
  20. Dim hu_style,hu_badWord,hu_getLeft
  21. hu_style = False' 1.0和2.0 xml不全兼容
  22. hu_getLeft = False' 文章调用字数
  23. hu_badWord = "法轮"' 敏感词过滤
  24. If wapstyle<>"1" Then hu_style = True'If hu_style Then Exit Function
  25. If IsNumeric(titlenums) Then hu_getLeft = True'If hu_getLeft Then Exit Function
  26. If wapword<>"" Then hu_badword = hu_badWord &","& wapword
  27. '
  28. ' 基本函数,外部可以直接引用
  29. ' 要求:共同属性写入底层,这部分只是用于展现
  30. ' 函数命名:getMyName,兼容旧系统,暂时没有统一
  31. '随机广告
  32. Function adstr(adsnum)
  33. Dim rsads
  34. Set rsads = Server.CreateObject("Adodb.Recordset")
  35. rsads.open"select id,name from 74hu_gogo where typeID="&adsnum&" order by id desc ",conn,1,1
  36. If Not rsads.eof Then
  37. Dim adsranNum
  38. Randomize()
  39. adsranNum = int(rsads.recordCount*rnd)+1
  40. rsads.absoluteposition=adsranNum
  41. w ("<a href='?aid=url&amp;id="&rsads("id")&"'>"&noubb(rsads("name"))&"</a>")
  42. End If
  43. rsads.close
  44. Set rsads=Nothing
  45. End Function
  46. '随机广告,定义数目
  47. Function adstrs(adsnum,num)
  48. Dim rsads
  49. Set rsads=Server.CreateObject("Adodb.Recordset")
  50. Randomize
  51. rsads.open"select top "&num&" id,name from 74hu_gogo where typeID="&adsnum&" order by rnd(-(id+" & rnd() & ")) ",conn,1,1
  52. While Not rsads.EOF
  53. w ("<a href='?aid=url&amp;id="&rsads("id")&"'>"&noubb(rsads("name"))&"</a><br/>")
  54. rsads.MoveNext
  55. Wend
  56. rsads.close
  57. Set rsads=Nothing
  58. End Function
  59. '定义广告
  60. Function adsetkf(adnum)
  61. Dim rsadset
  62. Set rsadset=Server.CreateObject("Adodb.Recordset")
  63. rsadset.open"select "&adnum&" from 74hu_control where ID=1",conn,1,1
  64. If Not rsadset.eof Then
  65. adsetkf=rsadset(adnum)
  66. End If
  67. rsadset.close
  68. Set rsadset=nothing
  69. End Function
  70. '最新文章
  71. Function newtitle(num,relid)
  72. Dim gettest,rs1,a
  73. If relid<>0 Then
  74. gettest="where classid="&relid
  75. End If
  76. Set rs1=Server.CreateObject("Adodb.Recordset")
  77. rs1.open"select id,title,classid from 74hu_article "&gettest&" order by id desc",conn,1,1
  78. If rs1.eof Then
  79. w ("还没有文章!<br/>")
  80. Else
  81. rs1.Move(0)
  82. a=1
  83. Do While ((Not rs1.EOF) And a <=num)
  84. If hu_getLeft Then
  85. w "<a href=""?aid=art&amp;id="&rs1("id")&""">"&getLeft(noubb(rs1("title")),titlenums)&"</a><br/>"
  86. Else
  87. w "<a href=""?aid=art&amp;id="&rs1("id")&""">"&noubb(rs1("title"))&"</a><br/>"
  88. End If
  89. rs1.MoveNext
  90. a=a+1
  91. Loop
  92. End If
  93. rs1.close
  94. Set rs1=Nothing
  95. End Function
  96. '最热文章
  97. Function hottitle(num,relid)
  98. dim rs2,b
  99. If relid<>0 Then
  100. gettest="where classid="&relid
  101. End If
  102. Set rs2 = Server.CreateObject("Adodb.Recordset")
  103. rs2.open"select id,title,classid from 74hu_article "&gettest&" order by hit desc",conn,1,1
  104. If rs2.eof Then
  105. w ("还没有文章!<br/>")
  106. Else
  107. rs2.Move(0)
  108. b=1
  109. Do While ((Not rs2.eof) And b <=num)
  110. If hu_getLeft Then
  111. w "<a href=""?aid=art&amp;id="&rs2("id")&""">"&getLeft(noubb(rs2("title")),titlenums)&"</a><br/>"
  112. Else
  113. w "<a href=""?aid=art&amp;id="&rs2("id")&""">"&noubb(rs2("title"))&"</a><br/>"
  114. End If
  115. rs2.MoveNext
  116. b=b+1
  117. Loop
  118. End If
  119. rs2.close
  120. Set rs2=Nothing
  121. End Function
  122. '随机文章
  123. Function wendtitle(num,relid)
  124. Dim rs3
  125. If relid<>0 Then
  126. gettest="where classid="&relid
  127. End If
  128. Set rs3=Server.CreateObject("Adodb.Recordset")
  129. Randomize
  130. rs3.open"select top "&num&" id,title,classid from 74hu_article "&gettest&" order by rnd(-(id*"&rnd()&")) ",conn,1,1
  131. While Not rs3.eof
  132. If hu_getLeft Then
  133. w "<a href=""?aid=art&amp;id="&rs3("id")&""">"&getLeft(noubb(rs3("title")),titlenums)&"</a><br/>"
  134. Else
  135. w "<a href=""?aid=art&amp;id="&rs3("id")&""">"&noubb(rs3("title"))&"</a><br/>"
  136. End If
  137. rs3.MoveNext
  138. Wend
  139. rs3.close
  140. Set rs3=Nothing
  141. End Function
  142. '翻页菜单2.0
  143. Function turnpage2(aid,add)
  144. turnpage2="<form name=""f"&Time_r&""" action=""?"" method=""get""><input name=""page"" type=""text"" size=""3"" maxlength=""2""/>"&_
  145. "<input name=""aid"" type=""hidden"" value="""&aid&"""/>"&add&"<input type=""submit"" value=""跳转""></form>"
  146. End Function
  147. '显示内容
  148. Sub w(str)
  149. Response.Write str
  150. End Sub
  151. '显示内容且停止输出
  152. Sub wn(str)
  153. Response.Write str
  154. getClose
  155. Response.End
  156. End Sub
  157. '网页跳转
  158. Sub r(str)
  159. Response.Redirect str
  160. End Sub
  161. '得到链接
  162. Sub tourl(str,name)
  163. w getUrl(str,name,"")
  164. End Sub
  165. '得到图片
  166. Sub toimg(str,name)
  167. w getImg(str,name,"")
  168. End Sub
  169. '改写left 中英文长度取定长修整
  170. Function getLeft(str,len)
  171. getLeft=hu_title(str,len)
  172. End Function
  173. '获取数据
  174. Function getD(str,def)
  175. Dim tmp
  176. tmp=getData(str)
  177. If hu_isNull(tmp) Then getD=def:Exit Function
  178. tmp=hu_common(tmp)
  179. tmp=hu_encode(tmp)
  180. getD=tmp
  181. End Function
  182. '不过滤获取数据
  183. Function getDD(str,def)
  184. Dim tmp
  185. tmp=getData(str)
  186. If hu_isNull(tmp) Then getDD=def:Exit Function
  187. getDD=tmp
  188. End Function
  189. '完全过滤获取数据
  190. Function getFilter(str,def)
  191. Dim tmp
  192. tmp=getData(str)
  193. If hu_isNull(tmp) Then getFilter=def:Exit Function
  194. getFilter=hu_filter(tmp)
  195. End Function
  196. '完全过滤数据
  197. Function setFilter(str)
  198. setFilter=hu_filter(str)
  199. End Function
  200. '获取数字
  201. Function getN(str,def)
  202. Dim tmp
  203. tmp=getData(str)
  204. If hu_isNull(tmp) Then getN=def:Exit Function
  205. If Not IsNumeric(tmp) Then getN=def:Exit Function
  206. getN=int(tmp)'避免非十进制 用clng会溢出
  207. End Function
  208. '从终端获取数据
  209. Function getData(str)
  210. Dim tmp
  211. tmp=Trim(Request.QueryString(str))
  212. If hu_isNull(tmp) Then tmp=Trim(Request.Form(str))
  213. getData=tmp
  214. End Function
  215. '标题和不使用ubb的内容noubb,后台编辑
  216. Function noubb(str)
  217. If hu_isNull(str) Then Exit Function
  218. str=Trim(str)
  219. str=hu_forShow(str)
  220. str=changeWord(str)
  221. str=Replace(str,""," ")
  222. str=Replace(str,"&nbsp;"," ")
  223. noubb=str
  224. End Function
  225. '用于链接
  226. Function noubburl(str)
  227. If hu_isNull(str) Then Exit Function
  228. str=Trim(str)
  229. str=hu_decode(str)
  230. str=changeWord(str)
  231. str=Replace(str,"&amp;","&")'勿删
  232. str=Replace(str,"&amp;","&")
  233. str=Replace(str,"<","")
  234. str=Replace(str,">","")
  235. str=Replace(str,"'","")
  236. str=Replace(str,"""","")
  237. str=Replace(str,"","")
  238. str=Replace(str,"&nbsp;","")
  239. str=Replace(str,"&#35;","#")
  240. str=Replace(str,"&#58;",":")
  241. str=Replace(str,"&#61;","=")
  242. str=Replace(str,"&#63;","?")
  243. noubburl=str
  244. End Function
  245. 'ubb展示
  246. Function ubbcode(str)
  247. If hu_isNull(str) Then Exit Function
  248. Dim newstr,re
  249. newstr=Now
  250. str=Trim(str)
  251. str=hu_forShow(str)
  252. str=changeWord(str)
  253. str=Replace(str,"&nbsp;"," ")
  254. str=Replace(str,"[br]","<br/>")
  255. str=Replace(str,"\\","<br/>")
  256. str=Replace(str,"[date]",Date)
  257. str=Replace(str,"[time]",Time)
  258. str=Replace(str,"[now]",newstr)
  259. str=Replace(str,"[week]",WeekDayName(DatePart("w",newstr)))'星期几
  260. str=Replace(str,"[month]",Month(newstr))
  261. str=Replace(str,"[day]",Day(newstr))
  262. str=Replace(str,"[hello]",gethello)
  263. str=Replace(str,"[favor]",getfavor)
  264. str=Replace(str,"[wapname]",waptitle)
  265. str=Replace(str,"[wapurl]",wapurl)
  266. Set re=new RegExp
  267. re.IgnoreCase =true
  268. re.Global=True
  269. re.pattern="(\[img\])(.[^\[]*)(\[\/img\])"
  270. str=re.Replace(str,"<img src=""$2"" alt='.'/>")
  271. re.pattern="(\[img=(.[^\]]*)\])(.[^\[]*)(\[\/img\])"
  272. str=re.Replace(str,"<a href=""$3""><img src=""$2"" alt="".""/></a>")
  273. re.pattern="(\[u\])(.[^\[]*)(\[\/u\])"
  274. str=re.Replace(str,"<u>$2</u>")
  275. re.pattern="(\[i\])(.[^\[]*)(\[\/i\])"
  276. str=re.Replace(str,"<i>$2</i>")
  277. re.pattern="(\[b\])(.[^\[]*)(\[\/b\])"
  278. str=re.Replace(str,"<b>$2</b>")
  279. re.pattern="(\[day=(.[^\]]*)\])(.[^\[]*)(\[\/day\])"
  280. str=re.Replace(str,getDiff("$2","$3"))
  281. re.pattern="(\[url\])(.[^\[]*)(\[\/url\])"
  282. str=re.Replace(str,"<a href=""$2"" >$2</a>")
  283. re.pattern="(\[url=(.[^\]]*)\])(.[^\[]*)(\[\/url\])"
  284. str=re.Replace(str,"<a href=""$2"" >$3</a>")
  285. re.Pattern="(\[m1\])(.[^\[]*)(\[\/m1\])"
  286. str=re.Replace(str,"<marquee>$2</marquee>")
  287. re.Pattern="(\[m2\])(.[^\[]*)(\[\/m2\])"
  288. str=re.Replace(str,"<marquee behavior=""alternate"">$2</marquee>")
  289. set re=Nothing
  290. ubbcode=str
  291. End Function
  292. '简单问候语
  293. Function getHello()
  294. Dim newtime
  295. newtime=Time
  296. If newtime < #06:00:00# And newtime >= #00:30:00# Then
  297. getHello="凌晨好!"
  298. ElseIf newtime < #09:00:00# And newtime >= #06:00:00# Then
  299. getHello="早上好!"
  300. ElseIf newtime < #11:30:00# And newtime >= #09:00:00# Then
  301. getHello="上午好!"
  302. ElseIf newtime < #12:30:00# And newtime >= #11:30:00# Then
  303. getHello="中午好!"
  304. ElseIf newtime < #18:00:00# And newtime >= #12:30:00# Then
  305. getHello="下午好!"
  306. ElseIf newtime < #20:00:00# And newtime >= #18:00:00# Then
  307. getHello="傍晚好!"
  308. ElseIf newtime < #23:30:00# And newtime >= #20:00:00# Then
  309. getHello="晚上好!"
  310. Else
  311. getHello="午夜好!"
  312. End If
  313. End Function
  314. '完整问候语
  315. Function getfavor()
  316. Dim newtime,newmon,newday
  317. newtime = Time:newmon = month(now):newday = day(now)
  318. If newtime < #06:00:00# And newtime >= #04:00:00# Then
  319. getfavor=""&newmon&"月"&newday&"日"&" "&"凌晨好!"
  320. ElseIf newtime < #09:00:00# And newtime >= #06:00:00# Then
  321. getfavor=""&newmon&"月"&newday&"日"&" "&"早上好!"
  322. ElseIf newtime < #11:30:00# And newtime >= #09:00:00# Then
  323. getfavor=""&newmon&"月"&newday&"日"&" "&"上午好!"
  324. ElseIf newtime < #12:30:00# And newtime >= #11:30:00# Then
  325. getfavor=""&newmon&"月"&newday&"日"&" "&"午饭时间到啦。"
  326. ElseIf newtime < #18:00:00# And newtime >= #12:30:00# Then
  327. getfavor=""&newmon&"月"&newday&"日"&" "&"下午好!"
  328. ElseIf newtime < #19:30:00# And newtime >= #18:00:00# Then
  329. getfavor=""&newmon&"月"&newday&"日"&" "&"晚饭时间到啦。"
  330. ElseIf newtime < #23:30:00# And newtime >= #19:30:00# Then
  331. getfavor=""&newmon&"月"&newday&"日"&" "&"晚上好!"
  332. Else
  333. getfavor=""&newmon&"月"&newday&"日"&" "&"夜深注意休息。"
  334. End If
  335. End Function
  336. '统一时间 2008.8.8 20:08
  337. Function fordate(str)
  338. fordate=hu_dateFormat(str,1)
  339. End Function
  340. '统一时间 8-8 20:08
  341. Function fordate2(str)
  342. fordate2=hu_dateFormat(str,2)
  343. End Function
  344. '网页头部
  345. Sub getHead(str, ver)
  346. Select Case ver
  347. Case 1
  348. Response.ContentType = "text/vnd.wap.wml; charset=utf-8"
  349. w "<?xml version=""1.0"" encoding=""utf-8""?>" &_
  350. "<!DOCTYPE wml PUBLIC ""-//WAPFORUM//DTD WML 1.1//EN"" ""http://www.wapforum.org/DTD/wml_1.1.xml"">" &_
  351. "<wml><head>" & str
  352. Case 2
  353. Response.ContentType = "text/html; charset=utf-8"
  354. w "<?xml version=""1.0"" encoding=""utf-8""?>" &_
  355. "<!DOCTYPE html PUBLIC ""-//WAPFORUM//DTD XHTML Mobile 1.0//EN"" ""http://www.wapforum.org/DTD/xhtml-mobile10.dtd"">" &_
  356. "<html xmlns=""http://www.w3.org/1999/xhtml""><head>" &_
  357. "<meta http-equiv=""Content-Type"" content=""text/html"" charset=""utf-8""/>" & str
  358. Case 0
  359. Response.ContentType = "text/html; charset=utf-8"
  360. w "<?xml version=""1.0"" encoding=""utf-8""?>" &_
  361. "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">" &_
  362. "<html xmlns=""http://www.w3.org/1999/xhtml""><head>" &_
  363. "<meta http-equiv=""Content-Type"" content=""text/html"" charset=""utf-8""/>"& str
  364. End Select
  365. End Sub
  366. '网页尾部
  367. Sub getEnd(str, ver)
  368. Select Case ver
  369. Case 1
  370. w str & "</p></card></wml>"
  371. Case 2,0
  372. w str & "</body></html>"
  373. End Select
  374. Response.End
  375. End Sub
  376. '关闭数据库连接
  377. Sub getClose()
  378. conn.close
  379. set conn=nothing
  380. End Sub
  381. '网页标题
  382. Sub getTitle(str, ver)
  383. Select Case ver
  384. Case 1
  385. w "<card title=""" & str & """>"
  386. Case 2,0
  387. w "<title>" & str & "</title>"
  388. End Select
  389. End Sub
  390. '构造链接
  391. Function getUrl(str, name, ex)
  392. Dim newstr
  393. newstr = ""
  394. If Not hu_isNull(ex) Then newstr = ex
  395. getUrl = "<a href=""" & str & """ " & newstr & ">" & name & "</a>"
  396. End Function
  397. '构造图片
  398. Function getImg(str, name, ex)
  399. Dim newstr
  400. newstr = ""
  401. If Not hu_isNull(ex) Then newstr = ex
  402. getImg = "<img src=""" & str & """ title=""" & name & """ alt=""loading.."" " & newstr & " />"
  403. End Function
  404. '清除缓存
  405. Sub cache(str)
  406. If str Then Exit Sub
  407. Response.Buffer = True
  408. Response.Expires = 0
  409. Response.ExpiresAbsolute = Now() - 1
  410. Response.CacheControl = "no-cache"
  411. Response.AddHeader "Expires",Date()
  412. Response.AddHeader "Pragma","no-cache"
  413. Response.AddHeader "Cache-Control","private, no-cache, must-revalidate"
  414. End Sub
  415. '时间比较
  416. Function getDiff(day,str)
  417. '以后可以精细到秒
  418. day = Trim(day)
  419. If Not isDate(day) Then Exit Function
  420. Dim newstr
  421. newstr = DateDiff("d",date,Cdate(day))
  422. getDiff = "距" & str & "还有" & newstr & "天"
  423. End Function
  424. '敏感词过滤
  425. Function changeWord(str)
  426. changeWord = hu_changeWord(str,hu_badWord,"[滤]")
  427. End Function
  428. '获取客户端IP
  429. Function getIP()
  430. Dim tmp
  431. tmp = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
  432. If hu_isNull(tmp) Then tmp = Request.ServerVariables("REMOTE_ADDR")
  433. If Instr(tmp,"'")>0 Or tmp="" Then tmp="0.0.0.0"
  434. GetIP = tmp
  435. End Function
  436. 'IP封锁
  437. Sub ipLock(str)
  438. Dim IpArray,WhyIpLock,IpSQL,IpRS
  439. IpArray=split(str,".")
  440. IpSQL="SELECT iplock From 74hu_IpLock Where "& _
  441. " (ipsame=4 and ip1="&Cint(IpArray(0))&" and ip2="&Cint(IpArray(1))&" and ip3="&Cint(IpArray(2))&" and ip4="&Cint(IpArray(3))&" ) "& _
  442. " Or (ipsame=3 and ip1="&Cint(IpArray(0))&" and ip2="&Cint(IpArray(1))&" and ip3="&Cint(IpArray(2))&" ) "& _
  443. " Or (ipsame=2 and ip1="&Cint(IpArray(0))&" and ip2="&Cint(IpArray(1))&" ) Or (ipsame=1 and ip1="&Cint(IpArray(0))&" ) Order By ipid "
  444. Set IpRS=Conn.execute(IpSQL)
  445. If Not (IpRS.bof or IpRS.eof) Then
  446. WhyIpLock=split(IpRS("iplock"),"|")
  447. Response.write "<card title=""出错了""><p>你使用的IP段或IP地址已被封锁<br/>封锁原因:"&WhyIpLock(1)&"<br/>封锁时间:"&WhyIpLock(0)&"</p></card></wml>"
  448. Response.End
  449. Set Conn=nothing
  450. End If
  451. Set IpRS=Nothing
  452. End Sub
  453. '流量统计
  454. Sub setStatistics(str)
  455. Dim HU_users,HU_userip,rsip
  456. HU_users="七色虎"
  457. HU_userip=str
  458. Set rsip = Server.CreateObject("ADODB.Recordset")
  459. rsip.open"select HU_Date,HU_Tod,HU_Today from 74hu_counter",conn,1,1
  460. HU_Date=rsip("HU_Date")
  461. if HU_Date<>date() then
  462. HU_day=date()-1
  463. conn.Execute"Update 74hu_counter set HU_Today=0,HU_Browser=0,HU_Date='"&date()&"',HU_Yays=HU_Yays+1,HU_Yesterday="&rsip("HU_Today")&""
  464. conn.Execute"delete from 74hu_iprr"
  465. else
  466. conn.Execute"Update 74hu_counter set HU_Browser=HU_Browser+1"
  467. if conn.execute("select HU_userip from 74hu_iprr where HU_userip='"&HU_userip&"'").eof then
  468. conn.Execute"insert into 74hu_iprr(HU_Userip,Users) values('"&HU_userip&"','"&HU_users&"')"
  469. conn.Execute"Update 74hu_counter set HU_counter=HU_counter+1,HU_Today=HU_Today+1"
  470. end if
  471. end if
  472. conn.Execute"Update 74hu_counter set HU_Tod="&rsip("HU_Today")&" where "&rsip("HU_Tod")&"<"&rsip("HU_Today")
  473. conn.Execute"Update 74hu_counter set HU_Browsers=HU_Browsers+1"
  474. rsip.close
  475. set rsip=nothing
  476. End Sub
  477. '2.0编辑后写入数据库
  478. Function forSaveByWeb(str)
  479. If hu_isNull(str) Then Exit Function
  480. str=Trim(str)
  481. str=Replace(str,"&nbsp;"," ")
  482. str=Replace(str,"&amp;","&#38;")
  483. str=Replace(str,"$$","$")'兼容1.0
  484. str=Replace(str,"","")
  485. str=Replace(str,vbnewline,"\\")
  486. str=Replace(str,VbCrLf,"\\")
  487. forSaveByWeb=str
  488. End Function
  489. '
  490. ' 底层函数,外部不要直接引用
  491. ' 要求:低耦合
  492. ' 函数命名:hu_myNameIsHu
  493. '改写IsNull
  494. Function hu_isNull(str)
  495. hu_isNull = False
  496. Select Case VarType(str)
  497. Case vbEmpty, vbNull
  498. hu_isNull = True : Exit Function
  499. Case vbstring
  500. If str="" Then hu_isNull = True : Exit Function
  501. Case vbObject
  502. If TypeName(str)="Nothing" Or TypeName(str)="Empty" Then hu_isNull = True : Exit Function
  503. Case vbArray,8194,8204,8209
  504. If Ubound(str)=-1 Then hu_isNull = True : Exit Function
  505. End Select
  506. End Function
  507. '格式化时间
  508. Function hu_dateFormat(str, style)
  509. If Not IsDate(str) Then Exit Function
  510. Select Case style
  511. Case 1'2008.8.8 20:08
  512. hu_dateFormat = year(str) & "." & month(str) & "." & day(str) & " "
  513. If Hour(str) < 10 Then hu_dateFormat = hu_dateFormat&"0"
  514. hu_dateFormat = hu_dateFormat&Hour(str)&":"
  515. If Minute(str) < 10 Then hu_dateFormat = hu_dateFormat&"0"
  516. hu_dateFormat = hu_dateFormat&Minute(str)
  517. Case 2'8-8 20:08
  518. hu_dateFormat = hu_dateFormat&month(str) & "-"
  519. hu_dateFormat = hu_dateFormat&day(str)&" "
  520. hu_dateFormat = hu_dateFormat&Hour(str)&":"
  521. If Minute(str) < 10 Then hu_dateFormat = hu_dateFormat&"0"
  522. hu_dateFormat = hu_dateFormat&Minute(str)
  523. End Select
  524. End Function
  525. '字符过滤函数
  526. Function hu_changeWord(str, badStandard, changedWord)
  527. Dim s,i
  528. s=split(badStandard,",")
  529. For i=Lbound(s) To ubound(s)
  530. str=replace(str,s(i),changedWord)
  531. Next
  532. hu_changeWord=str
  533. End Function
  534. '替换bug字符 - 展现
  535. Function hu_forShow(str)
  536. If hu_isNull(str) Then Exit Function
  537. str=hu_decode(str)
  538. If hu_style Then hu_forShow=str:Exit Function
  539. str=Replace(str,"&#","_74_asp_")
  540. str=Replace(str,"&amp;","_74_amp_")
  541. str=Replace(str,"&","&amp;")
  542. str=Replace(str,"_74_amp_","&amp;")
  543. str=Replace(str,"$$","_74_my_")
  544. str=Replace(str,"$","$$")
  545. str=Replace(str,"_74_my_","$$")
  546. str=Replace(str,"<","&lt;")
  547. str=Replace(str,">","&gt;")
  548. str=Replace(str,"'","&apos;")
  549. str=Replace(str,"""","&quot;")
  550. str=Replace(str,"_74_asp_","&#")
  551. hu_forShow=str
  552. End Function
  553. '符号写入数据库
  554. Function hu_common(str)
  555. If hu_isNull(str) Then Exit Function
  556. str=Replace(str,"&","_74_aaa_")
  557. str=Replace(str,"#","&#35;")
  558. str=Replace(str," ","&#9;")
  559. str=Replace(str," ","&#32;")
  560. str=Replace(str,"'","&#39;")
  561. str=Replace(str,"""","&#34;")
  562. str=Replace(str,"%","&#37;")
  563. str=Replace(str,"*","&#42;")
  564. str=Replace(str,":","&#58;")
  565. str=Replace(str,"<","&#60;")
  566. str=Replace(str,"=","&#61;")
  567. str=Replace(str,">","&#62;")
  568. str=Replace(str,"?","&#63;")
  569. str=Replace(str,vbnewline,"&#13;&#10;")
  570. str=Replace(str,VbCrLf,"&#13;&#10;")
  571. str=Replace(str,"_74_aaa_","&#38;")
  572. hu_common=str
  573. End Function
  574. '过滤用户数据
  575. Function hu_encode(str)
  576. If hu_isNull(str) Then Exit Function
  577. str=Replace(str,"74hu_","74_hu_",1,-1,1)'数据库表前缀替换
  578. str=Replace(str,"and","_74_an_",1,-1,1)
  579. str=Replace(str,"or","_74_or_",1,-1,1)
  580. str=Replace(str,"from","_74_fr_",1,-1,1)
  581. str=Replace(str,"mid","_74_mi_",1,-1,1)
  582. str=Replace(str,"update","_74_up_",1,-1,1)
  583. str=Replace(str,"exec","_74_ex_",1,-1,1)
  584. str=Replace(str,"select","_74_se_",1,-1,1)
  585. str=Replace(str,"insert","_74_in_",1,-1,1)
  586. str=Replace(str,"delete","_74_de_",1,-1,1)
  587. str=Replace(str,"drop","_74_dr_",1,-1,1)
  588. str=Replace(str,"create","_74_cr_",1,-1,1)
  589. str=Replace(str,"eval","_74_ev_",1,-1,1)
  590. str=Replace(str,"command","_74_co_",1,-1,1)
  591. str=Replace(str,"dir","_74_di_",1,-1,1)
  592. str=Replace(str,"truncate","_74_tr_",1,-1,1)
  593. str=Replace(str,"xp_","_74_xp_",1,-1,1)
  594. str=Replace(str,"sp_","_74_sp_",1,-1,1)
  595. str=Replace(str,"master","_74_ma_",1,-1,1)
  596. str=Replace(str,"declare","_74_dec_",1,-1,1)
  597. str=Replace(str,"count","_74_cou_",1,-1,1)
  598. str=Replace(str,"char","_74_ch_",1,-1,1)
  599. str=Replace(str,"unicode","_74_un_",1,-1,1)
  600. str=Replace(str,"ascii","_74_as_",1,-1,1)
  601. str=Replace(str,"cmd","_74_cm_",1,-1,1)
  602. str=Replace(str,"法轮","[滤]")'国内服务器拒绝写入
  603. hu_encode=str
  604. End Function
  605. '还原用户数据
  606. Function hu_decode(str)
  607. If hu_isNull(str) Then Exit Function
  608. str=Replace(str,"_74_hu_","74hu_")
  609. str=Replace(str,"_74_an_","and")
  610. str=Replace(str,"_74_or_","or")
  611. str=Replace(str,"_74_fr_","from")
  612. str=Replace(str,"_74_mi_","mid")
  613. str=Replace(str,"_74_up_","update")
  614. str=Replace(str,"_74_ex_","exec")
  615. str=Replace(str,"_74_se_","select")
  616. str=Replace(str,"_74_in_","insert")
  617. str=Replace(str,"_74_de_","delete")
  618. str=Replace(str,"_74_dr_","drop")
  619. str=Replace(str,"_74_cr_","create")
  620. str=Replace(str,"_74_ev_","eval")
  621. str=Replace(str,"_74_co_","command")
  622. str=Replace(str,"_74_di_","dir")
  623. str=Replace(str,"_74_tr_","truncate")
  624. str=Replace(str,"_74_xp_","xp_")
  625. str=Replace(str,"_74_sp_","sp_")
  626. str=Replace(str,"_74_ma_","master")
  627. str=Replace(str,"_74_dec_","declare")
  628. str=Replace(str,"_74_cou_","count")
  629. str=Replace(str,"_74_ch_","char")
  630. str=Replace(str,"_74_un_","unicode")
  631. str=Replace(str,"_74_as_","ascii")
  632. str=Replace(str,"_74_cm_","cmd")
  633. hu_decode=str
  634. End Function
  635. '用于搜索,登陆过滤等
  636. Function hu_filter(str)
  637. If hu_isNull(str) Then Exit Function
  638. str=Replace(str,"'","",1,-1,1)
  639. str=Replace(str,"""","",1,-1,1)
  640. str=Replace(str,":","",1,-1,1)
  641. str=Replace(str,"*","",1,-1,1)
  642. str=Replace(str,"<","",1,-1,1)
  643. str=Replace(str,">","",1,-1,1)
  644. str=Replace(str,"or","",1,-1,1)
  645. str=Replace(str,"74hu_","",1,-1,1)
  646. str=Replace(str,"and","",1,-1,1)
  647. str=Replace(str,"from","",1,-1,1)
  648. str=Replace(str,"mid","",1,-1,1)
  649. str=Replace(str,"update","",1,-1,1)
  650. str=Replace(str,"exec","",1,-1,1)
  651. str=Replace(str,"select","",1,-1,1)
  652. str=Replace(str,"insert","",1,-1,1)
  653. str=Replace(str,"delete","",1,-1,1)
  654. str=Replace(str,"drop","",1,-1,1)
  655. str=Replace(str,"create","",1,-1,1)
  656. str=Replace(str,"eval","",1,-1,1)
  657. str=Replace(str,"command","",1,-1,1)
  658. str=Replace(str,"dir","",1,-1,1)
  659. str=Replace(str,"truncate","",1,-1,1)
  660. str=Replace(str,"xp_","",1,-1,1)
  661. str=Replace(str,"sp_","",1,-1,1)
  662. str=Replace(str,"master","",1,-1,1)
  663. str=Replace(str,"declare","",1,-1,1)
  664. str=Replace(str,"count","",1,-1,1)
  665. str=Replace(str,"char","",1,-1,1)
  666. str=Replace(str,"unicode","",1,-1,1)
  667. str=Replace(str,"ascii","",1,-1,1)
  668. str=Replace(str,"cmd","",1,-1,1)
  669. str=Replace(str,"法轮","")'国内服务器拒绝写入
  670. hu_filter=str
  671. End Function
  672. '改写left
  673. Function hu_title(str, strlen)
  674. If hu_isNull(str) Then hu_title = "":Exit Function
  675. Dim l, t, c, i, strTemp
  676. str = Replace(Replace(Replace(Replace(Replace(str,"&nbsp;"," "),"&quot;",Chr(34)),"&gt;",">"),"&lt;","<"),"&apos;","'")
  677. l = Len(str):t = 0:strTemp = str:strlen = CLng(strlen)
  678. For i = 1 To l:c = Abs(Asc(Mid(str, i, 1)))
  679. If c = 1 Then:t = t + 1:Else:t = t + 0.6:End If'这里的0.6可酌情修改,考虑字符占位不同
  680. If t >= strlen Then:strTemp = Left(str, i):Exit For:End If
  681. Next:If strTemp <> str Then:strTemp = strTemp & "..":End If
  682. hu_title = Replace(Replace(Replace(Replace(Replace(strTemp," ","&nbsp;"),Chr(34),""""),">","&gt;"),"<","&lt;"),"'","&apos;")
  683. End Function
  684. %>