dim span : span=""
Sub makeTypeOption(topId,separateStr)
Dim i,j,k,m,TL:TL=getTypeLists():j=getTypeindex("m_id"):k=getTypeindex("m_upid"):m=getTypeindex("m_name")
for i=0 to UBound(TL,2)
if ""&TL(k,i)=""&topId then
if topId<>0 then span=span&separateStr
echo "<option value='"&TL(j,i)&"'>"&span&" |—"&TL(m,i)&"</option>"
makeTypeOption TL(j,i),separateStr
end if
next
if not isNul(span) then span=left(span,len(span)-len(separateStr))
End Sub
'yuet 2009-10-10 18:30 优化递归查询,下面旧函不用了
'Sub makeTypeOption(topId,separateStr)
' dim sqlStr,rsObj
' sqlStr= "select m_id,m_name from {pre}type where m_upid="&topId&" order by m_sort asc"
' set rsObj=conn.db(sqlStr,"records1")
' do while not rsObj.eof
' if topId<>0 then span=span&separateStr
' echo "<option value='"&rsObj("m_id")&"'>"&span&" |—"&rsObj("m_name")&"</option>"
' makeTypeOption rsObj("m_id"),separateStr
' rsObj.movenext
' loop
' if not isNul(span) then span=left(span,len(span)-len(separateStr))
' rsObj.close
' set rsObj=nothing
'End Sub
Sub makeTypeSelect(selectName)
echo "<select name='"&selectName&"'>"
echo "<option value=''>请选择视频分类</option>"
makeTypeOption 0," | "
echo "</select>"
End Sub
Function makeTopicSelect(selectName,arrayObj,strSelect,topicId)
dim i,str,selectedStr
str="<select id='"&selectName&"' name='"&selectName&"' >"
if not isNul(strSelect) then str=str&"<option value=''>"&strSelect&"</option>"
if isArray(arrayObj) then
for i=0 to ubound(arrayObj,2)
if not isNul(topicId) then
if clng(arrayObj(0,i))=clng(topicId) then selectedStr="selected" else selectedStr=""
end if
str=str &"<option value='"&arrayObj(0,i)&"' "&selectedStr&">"&arrayObj(1,i)&"</option>"
next
end if
str=str&"</select>"
makeTopicSelect=str
End Function
Function makeTopicOptions(arrayObj,strSelect)
dim i,str
if not isNul(str) then str=str&"<option value='-1'>"&strSelect&"</option>"
if isArray(arrayObj) then
for i=0 to ubound(arrayObj,2)
str=str&"<option value='"&arrayObj(0,i)&"'>"&arrayObj(1,i)&"</option>"
next
end if
makeTopicOptions=str
End Function
Function arrayToDictionay(Byval arrayObj)
dim dictionaryObj : set dictionaryObj=server.CreateObject(DICTIONARY_OBJ_NAME)
dim dicKey,dicValue,i
if isArray(arrayObj) then
for i=0 to ubound(arrayObj,2)
dicKey= arrayObj(0,i) : dicValue= arrayObj(1,i)
if not dictionaryObj.Exists(dicKey) then dictionaryObj.add dicKey,dicValue else dictionaryObj(dicKey)=dicValue
next
end if
set arrayToDictionay=dictionaryObj
End Function
'Function typeArrayToDictionay(Byval arrayObj)
' dim dictionaryObj : set dictionaryObj=server.CreateObject(DICTIONARY_OBJ_NAME)
' dim dicKey,dicValue,i
' if isArray(arrayObj) then
' for i=0 to ubound(arrayObj,2)
' dicKey= arrayObj(0,i) : dicValue= arrayObj(1,i)&","&arrayObj(2,i)&","&arrayObj(3,i)
' if not dictionaryObj.Exists(dicKey) then dictionaryObj.add dicKey,dicValue else dictionaryObj(dicKey)=dicValue
' next
' end if
' set typeArrayToDictionay=dictionaryObj
'End Function
Function typeArrayToDictionay()
dim dictionaryObj,TS : set dictionaryObj=server.CreateObject(DICTIONARY_OBJ_NAME):TS=getTypeLists()
dim dicKey,dicValue,i,j,k,l,m:j=getTypeIndex("m_id"):k=getTypeIndex("m_name"):l=getTypeIndex("m_enname"):m=getTypeIndex("m_upid")
if isArray(TS) then
for i=0 to ubound(TS,2)
dicKey= TS(j,i) : dicValue= TS(k,i)&","&TS(l,i)&","&TS(m,i)
if not dictionaryObj.Exists(dicKey) then dictionaryObj.add dicKey,dicValue else dictionaryObj(dicKey)=dicValue
next
end if
set typeArrayToDictionay=dictionaryObj
End Function
'Function getTypeNameTemplateArrayOnCache(m_id)
' dim cacheName,typeArray,elementId
' cacheName="array_type_id_name_template_upid"
' if cacheStart=1 then
' if cacheObj.chkCache(cacheName) then typeArray=cacheObj.getCache(cacheName) else typeArray=conn.db("select m_id,m_name,m_template,m_upid from {pre}type order by m_sort asc","array") : cacheObj.setCache cacheName,typeArray
' else
' typeArray=conn.db("select m_id,m_name,m_template,m_upid from {pre}type order by m_sort asc","array")
' end if
' elementId=getArrayElementID(typeArray,0,m_id)
' getTypeNameTemplateArrayOnCache=typeArray(1,elementId)&","&typeArray(2,elementId)&","&typeArray(3,elementId)
'End Function
Function getTypeNameTemplateArray(m_id)
dim typeArray,i,j,ret:j=getTypeIndex("m_id"):ret="":typeArray=getTypeLists()
for i=0 to UBound(typeArray,2)
if ""&typeArray(j,i)=""&m_id then
ret=typeArray(getTypeIndex("m_name"),i)&","&typeArray(getTypeIndex("m_template"),i)&","&typeArray(getTypeIndex("m_upid"),i):exit for
end if
next
getTypeNameTemplateArray=ret
End Function
Function getTypeNameTemplateArrayOnCache(m_id)
dim cacheName,ret:cacheName="array_type_id_name_template_upid"&m_id
if cacheStart=1 then
if cacheObj.chkCache(cacheName) then ret=cacheObj.getCache(cacheName) else ret=getTypeNameTemplateArray(m_id) : cacheObj.setCache cacheName,ret
else
ret=getTypeNameTemplateArray(m_id)
end if
getTypeNameTemplateArrayOnCache=ret
End Function
Sub echoSaveStr(ptype)
dim cssstr
cssstr="<style>body{text-align:center}#msg{background-color:white;border:1px solid #1B76B7;margin:0 auto;width:400px;text-align:left}.msgtitle{padding:3px 3px;color:white;font-weight:700;line-height:21px;height:25px;font-size:12px;border-bottom:1px solid #1B76B7; text-indent:3px; background-color:#1B76B7}#msgbody{font-size:12px;padding:40px 8px 50px;line-height:25px}#msgbottom{text-align:center;height:20px;line-height:20px;font-size:12px;background-color:#1b76b7;color:#FFFFFF}</style>"
select case ptype
case "safe"
die cssstr&"<div id='msg'><div class='msgtitle'>【警告】非法提交:</div><div id='msgbody'>你提交的数据有非法字符,你的IP【<b>"&getIp&"</b>】已被记录,操作时间:"&now()&"</div><div id='msgbottom'>Powered By "&siteName&"</div></div>"
case "null"
die cssstr&"<div id='msg'><div class='msgtitle'>【警告】参数错误:</div><div id='msgbody'><b>错误描述</b>:参数为空或不正确</div><div id='msgbottom'>Powered By "&siteName&"</div></div>"
end Select
cssstr=""
End Sub
Function preventSqlin(content,vtype)
dim sqlStr,sqlArray,i,speStr
sqlStr="<|>|%|%27|'|''|;|*|and|exec|dbcc|alter|drop|insert|select|update|delete|count|master|truncate|char|declare|where|set|declare|mid|chr"
if isNul(content) then Exit Function
sqlArray=split(sqlStr,"|")
for i=lbound(sqlArray) to ubound(sqlArray)
if instr(lcase(content),sqlArray(i))<>0 then
if vtype="filter" then
select case sqlArray(i)
case "<":speStr="<"
case ">":speStr=">"
case "'","""":speStr="""
case ";":speStr=";"
case else:speStr=""
end select
content=replace(content,sqlArray(i),speStr,1,-1,1)
else
echoSaveStr "safe" : Exit Function
end if
end if
next
preventSqlin=content
End Function
Function replaceCurrentTypeId(str)
str=replaceStr(str,"{maxcms:currenttypeid}",currentTypeId)
replaceCurrentTypeId=str
End Function
Sub checkRunMode
if runMode<>"static" then die "<div style='width:50%;margin-top:50px;background:#66CCCC;font-size:13px;'><br><font color='red'>网站运行模式非静态,不允许生成</font><br><br></div>"
End Sub
Sub isCurrentDay(timeStr)
if isNul(timeStr) then echo "":Exit Sub
dim timeStr2 : timeStr2=date
if instr(timeStr,timeStr2)>0 then echo "<span style='color:red;font-size:10px'>"&timeStr&"</span>" else echo "<span style='font-size:10px'>"&timeStr&"</span>"
End Sub
Function getFromStr(playurl)
if isNul(playurl) then getFromStr="" : Exit Function
dim playurlArray,playurlLen,i,span1,span2,urlstr : span1="$$$" : span2="$$"
playurlArray=split(playurl,span1) : playurlLen=ubound(playurlArray)
for i=0 to playurlLen
if i=playurlLen then urlstr=urlstr&split(playurlArray(i),span2)(0) else urlstr=urlstr&split(playurlArray(i),span2)(0)&","
next
getFromStr=urlstr
End Function
Function getPlayurlArray(playurl)
dim span1 : span1="$$$"
if isNul(playurl) then playurl=""
getPlayurlArray=split(playurl,span1)
End Function
Function filterDirty(content)
dim dirtyStr,dirtyStrArray,i : dirtyStr="%u80E1%u9526%u6D9B%2C%u6E29%u5BB6%u5B9D%2C%u5C3B%2C%u5C4C%2C%u64CD%u4F60%2C%u5E72%u6B7B%u4F60%2C%u8D31%u4EBA%2C%u72D7%u5A18%2C%u5A4A%u5B50%2C%u8868%u5B50%2C%u9760%u4F60%2C%u53C9%u4F60%2C%u53C9%u6B7B%2C%u63D2%u4F60%2C%u63D2%u6B7B%2C%u5E72%u4F60%2C%u5E72%u6B7B%2C%u65E5%u4F60%2C%u65E5%u6B7B%2C%u9E21%u5DF4%2C%u777E%u4E38%2C%u5305%u76AE%2C%u9F9F%u5934%2C%u5C44%2C%u8D51%2C%u59A3%2C%u808F%2C%u5976%u5B50%2C%u5976%u5934%2C%u9634%u6BDB%2C%u9634%u9053%2C%u9634%u830E%2C%u53EB%u5E8A%2C%u5F3A%u5978%2C%u7231%u6DB2%2C%u6027%u9AD8%u6F6E%2C%u505A%u7231%2C%u6027%u4EA4%2C%u53E3%u4EA4%2C%u809B%u4EA4"
dirtyStrArray=split(unescape(dirtyStr),",")
for i=0 to ubound(dirtyStrArray)
content=replace(content,dirtyStrArray(i),"***",1,-1,1)
next
filterDirty=content
End Function
Sub writeFontWaterPrint(saveImgPath,location)
dim jpegObj,strWidth,strHeight,picPath : strWidth=len(waterMarkFont)*5 : strHeight=3
on error resume next
set jpegObj=Server.CreateObject(JPEG_OBJ_NAME)
picPath=Server.MapPath(saveImgPath)
with jpegObj
.Interpolation=2 : .Open picPath : .Canvas.Font.BkMode=true : .Canvas.Font.BkColor=&HFF3300 : .Canvas.Font.Color=&Hffffff : .Canvas.Font.Family="Tahoma" : .Canvas.Font.Size=14 : .Canvas.Font.Bold=true
select case location
case "lefttop" : jpegObj.Canvas.Print 5 , strHeight, waterMarkFont
case "righttop" : jpegObj.Canvas.Print jpegObj.width-strWidth, strHeight, waterMarkFont
case "leftbottom" : jpegObj.Canvas.Print 5 , jpegObj.height-20, waterMarkFont
case "rightbottom" : jpegObj.Canvas.Print jpegObj.width-strWidth, jpegObj.height-20, waterMarkFont
case "middle" : jpegObj.Canvas.Print (jpegObj.width-strWidth)/2, (jpegObj.height-strHeight)/2, waterMarkFont
end select
.Canvas.Pen.Color=&Heeeeee : .Canvas.Pen.Width=1 : .Canvas.Brush.Solid=False : .Canvas.Bar 0, 0, jpegObj.Width, jpegObj.Height : .Save picPath
end with
set jpegObj=nothing : if err then err.clear
End Sub
Function regexFind(Byval str,Byval pattern)
if isNul(str) then : regexFind="" : Exit Function
dim regObj,match,matches,findStr : set regObj=New RegExp
regObj.Pattern=pattern : set matches=regObj.Execute(str)
for each match in matches
regexFind=match.SubMatches(0)
set regObj=nothing : set matches=nothing : Exit Function
next
End Function
Function getTimeSpan(sessionName)
dim lastTime : lastTime=session(sessionName)
if isNul(lastTime) then lastTime=0
getTimeSpan=DateDiff("s",lasttime,now())
End Function |