⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 globals.inc

📁 一个关于网站权限管理的经典例子,适合初学者
💻 INC
字号:
<%
  Dim sPageTitle, nRecordsPerPage0, nRecordsPerPage1, Fso1, myFso, myFile, htm

  '--------------------------------------------------------------
  '网页标题:
    sPageTitle="权限表测试代码"

  '--------------------------------------------------------------
  '记录分页显示,每页记录数:
    nRecordsPerPage0 = 19  ' for rear admin pages
    nRecordsPerPage1 = 20  ' for front pages

  '--------------------------------------------------------------
  'myIif 函数(二选一简化函数):(??????)
  Sub myIif(lCondition, result1, result2)
    If lCondition=True Then
      response.write result1
    Else
      response.write result2
    End If
  End Sub

  '--------------------------------------------------------------
  '判断表里满足条件的记录的数目:
  function HaveRecordCounts(TableName,FldName,FldVal, ValType)
    Dim rs, sSQL
    select case ValType
      case "String"
        sSQL="select * from " & tableName & " where " & FldName & "=" & "'" & FldVal & "'"
      case "Number"
        sSQL="select * from " & tableName & " where " & FldName & "=" & "" & FldVal & ""
    end select
    'response.write sSQL
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.open sSQL,sConn,1,1
    HaveRecordCounts = rs.recordcount
    'if rs.recordcount>0 then
    '  hasRec=True
    'else
    '  hasRec=False
    'end if
    set rs=nothing
  end function

  '---------------------------------------------------------------
  '生成顺序号
  function makeSortid(tablename)
    Dim sSQL, rs
    sSQL="select max(f_i_orderid) as maxsortid from " & tablename
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open sSQL, sConn, 1, 1
    if isNull(rs("maxsortid")) then  '表为空
      makeSortid = 5
    else                             '表中有记录
      makeSortid=rs("maxsortid") + 5
    end if
    set rs=nothing
  end function

  '--------------------------------------------------------------
  '重新排列记录的顺序号(顺序号数字间隔为5):
  sub sort_table_by_sortid(tablename)
    Dim sSQL, rs, i
    sSQL="select f_i_Orderid from " & tablename & " order by f_i_Orderid"
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open sSQL, sConn, 3, 3
    rs.MoveFirst
    i=1
    Do while not rs.eof
      rs("f_i_Orderid")=5*i
      i=i+1
      rs.MoveNext
    Loop
    set rs=nothing
  end sub

  '--------------------------------------------------------------
  function hasFile(Fn)
    Set Fso1 = CreateObject("Scripting.FileSystemObject")
    if Fso1.FileExists(Fn) then
      hasFile=true
    else
      hasFile=false
    end if
    set Fso1=nothing
  end function

  '--------------------------------------------------------------
  function strlen(str)
    Dim ilen, i
    ilen = 0
    strlen = 0
    if str<>"" then
      ilen = len(str)
      for i=1 to ilen
        if asc(mid(str,i,1))<0 then
          strlen = strlen + 2
        else
          strlen = strlen + 1
        end if
      next
    end if
  end function

  Function FormatStr(sStr,nLen)
    dim p_num, i
    if strlen(sStr)<=nLen then
      FormatStr=sStr
    else
      p_num=0
      i=0
      while not p_num>nLen
        i=i + 1
        if asc(mid(sStr,i,1))<0 then
          p_num=p_num + 2
        else
          p_num=p_num + 1
        end if
      wend
      FormatStr=left(trim(sStr),i-1) & "…"
    end if
  End function

  Function FormatStr0(sStr,nLen)
    FormatStr=sSTR
    if len(sStr)>nLen then
      FormatStr=left(sStr,nLen) & "…"
    end if
  end function

  '--------------------------------------------------------------
  function htmlspaces(n)
    Dim sTmp,i
    sTmp=""
    if n>=1 then
      for i=1 to n
        sTmp=sTmp+"&nbsp;"
      next
    end if
    htmlspaces=sTmp
  end function

  '--------------------------------------------------------------
  function changechr2html(str)
    changechr2html=replace(replace(replace(replace(str,"<","&lt;"),">","&gt;"),chr(13),"<br>")," ","&nbsp;")
    'changechr2html=replace(replace(changechr2html,"[img&nbsp;src","<img src"),"][/img]","></img>")
    'changechr2html=replace(replace(replace(replace(changechr2html,"[/sayyes]","></img>"),"[/b]","</b>"),"[/red]","</font>"),"[/big]","</font>")
  end function
  '--------------------------------------------------------------
  function changehtml2chr(str)
    changehtml2chr=replace(str, "&nbsp;", " ")
    changehtml2chr=replace(changehtml2chr, "<br>", "")
  end function

  '--------------------------------------------------------------
  function make_auto_id()
    make_auto_id = now()
    make_auto_id = replace(make_auto_id,"-","")
    make_auto_id = replace(make_auto_id," ","")
    make_auto_id = replace(make_auto_id,":","")
    make_auto_id = replace(make_auto_id,"PM","")
    make_auto_id = replace(make_auto_id,"AM","")
    make_auto_id = replace(make_auto_id,"上午","")
    make_auto_id = replace(make_auto_id,"下午","")
  end function

  '--------------------------------------------------------------
  function save2file(aPath_and_aFilename, aStr)
    Set myfso = Server.CreateObject("Scripting.FileSystemObject")
    Set myFile = myfso.CreateTextFile(aPath_and_aFilename)
    myFile.WriteLine aStr
    myFile.close
    set myfso=nothing
  end function

  '--------------------------------------------------------------
  function makehtml(title1, title, title2, article)
    htm=    "<!-本文档用“超文本格式生成器v1.0”生成 By zhangking@263.net 2003.4.20-->" & chr(13) & chr(10)
    htm=htm & "<html>" & chr(13) & chr(10)
    htm=htm & " <head>" & chr(13) & chr(10)
    htm=htm & "  <title>《陕西师大报》电子版</title>" & chr(13) & chr(10)
    htm=htm & "  <meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & chr(13) & chr(10)
    htm=htm & "  <meta name='keywords' content='教育,报纸,education,newspaper'>" & chr(13) & chr(10)
    htm=htm & "  <meta name='description' content='教育,报纸,education,newspaper'>" & chr(13) & chr(10)
    htm=htm & "  <meta http-equiv='Page-Enter' content='blendTrans(Duration=1.0)'>" & chr(13) & chr(10)
    htm=htm & "  <meta http-equiv='Page-Exit' content='blendTrans(Duration=1.0)'>" & chr(13) & chr(10)
    htm=htm & "  <link href='../style/style.css' rel='stylesheet' type='text/css'>" & chr(13) & chr(10)
    htm=htm & "  <script language'javascript' src='/xb_consts/scripts/scroll_screen.js'></script>" & chr(13) & chr(10)
    htm=htm & "</head>" & chr(13) & chr(10)
    htm=htm & "" & chr(13) & chr(10)
    htm=htm & "<body topmargin=0 leftmargin=0 onload='moveTo(0,0); resizeTo(screen.width,screen.height-25)'>" & chr(13) & chr(10)
    htm=htm & "<table border=0 cellpadding=0 cellspacing=0 width=758 align=center>" & chr(13) & chr(10)
    htm=htm & "  <tr>" & chr(13) & chr(10)
    htm=htm & "    <td width=757 height=72 colspan=2 background='../images/article_top.jpg'></td>" & chr(13) & chr(10)
    htm=htm & "    <td width=1 bgcolor=#3C75AF></td>" & chr(13) & chr(10)
    htm=htm & "  </tr>" & chr(13) & chr(10)
    htm=htm & "  <tr>" & chr(13) & chr(10)
    htm=htm & "    <td width=1 bgcolor=#3C75AF></td>" & chr(13) & chr(10)
    htm=htm & "    <td width=756>" & chr(13) & chr(10)
    htm=htm & chr(13) & chr(10)
    htm=htm & "    <!--/////begin: 文章标题及内容-->" & chr(13) & chr(10)
    htm=htm & "    <table border=0 cellpadding=0 cellspacing=0 width=95% align=center>" & chr(13) & chr(10)
    htm=htm & "      <tr><td align=center height=10></td></tr>" & chr(13) & chr(10)
    htm=htm & "      <tr><td align=center valign=bottom>" & title1 & "</td></tr>" & chr(13) & chr(10)  '/////标题头
    htm=htm & "      <tr><td align=center valign=bottom><B>" & title & "</B></td></tr>" & chr(13) & chr(10)  '/////标题
    htm=htm & "      <tr><td align=center valign=top>" & title2 & "</td></tr>" & chr(13) & chr(10)    '/////副标题
    htm=htm & "      <tr><td align=center height=5></td></tr>" & chr(13) & chr(10)
    htm=htm & "      <tr>" & chr(13) & chr(10)
    htm=htm & "        <td style='line-height:15pt'>" & changechr2html(article) & "</td>" & chr(13) & chr(10)  '/////内容变为 html 格式
    htm=htm & "      </tr>" & chr(13) & chr(10)
    htm=htm & "      <tr><td align=center height=10></td></tr>" & chr(13) & chr(10)
    htm=htm & "    </table>" & chr(13) & chr(10)
    htm=htm & chr(13) & chr(10)
    htm=htm & "    <!--/////end: 文章标题及内容-->" & chr(13) & chr(10)
    htm=htm & "    <td width=1 bgcolor=#3C75AF></td>" & chr(13) & chr(10)
    htm=htm & "  <tr bgcolor=#3C75AF>" & chr(13) & chr(10)
    htm=htm & "    <td></td><td></td><td></td>" & chr(13) & chr(10)
    htm=htm & "  </tr>" & chr(13) & chr(10)
    htm=htm & "</table>" & chr(13) & chr(10) & chr(13) & chr(10)
    htm=htm & "<br><center><a href='javascript:close();'>[关闭本窗口]</a></center>"
    htm=htm & "  <hr width=758 color=green>" & chr(13) & chr(10)
    htm=htm & "  <table border=0 width=500 cellpadding=0 cellspacing=0 align=center>" & chr(13) & chr(10)
    htm=htm & "    <tr><td width=100% align=center></td></tr>" & chr(13) & chr(10)
    htm=htm & "    <tr>" & chr(13) & chr(10)
    htm=htm & "     <td width=100% align=center style='line-height:12pt'>" & chr(13) & chr(10)
    htm=htm & "       Copyright &copy; 《陕西师大报》编辑部<br>" & chr(13) & chr(10)
    htm=htm & "       Email: xiaobao@snnu.edu.cn&nbsp;&nbsp;Tel: 029-5308149" & chr(13) & chr(10)
    htm=htm & "     </td>" & chr(13) & chr(10)
    htm=htm & "    </tr>" & chr(13) & chr(10)
    htm=htm & "  </table>" & chr(13) & chr(10)
    htm=htm & chr(13) & chr(10)
    htm=htm & "</body>" & chr(13) & chr(10)
    htm=htm & "</html>"
    makehtml=htm
  end function

  '--------------------------------------------------------------
  '函数:查找版块的英文名(文件夹名),构造文章的URL路径:
  function MakeArticleUrl(path, bankuai, paperid, rs_articleid, isHtml, rs_htmlfilename)
    Dim strSQL, rs_1, article_Url
    strSQL = "select bankuai_e from Bankuai where bankuai='"& bankuai &"'"
    'response.write strSQL
    Set rs_1 = Server.CreateObject("ADODB.Recordset")
    rs_1.open strSQL,sConn,1,1
    if rs_1.eof and rs_1.bof then
      response.write("<br><center><font color=red>没有检索到版块的英文名(文件夹名)。</font></center>")
    else
      if bankuai="新闻快递" then
        if isHtml="1" then
          article_Url=path & "/articles/" & trim(rs_1("bankuai_e")) & "/" & trim(paperid) & "/" & trim(rs_htmlfilename) & ".htm"
        else
          article_Url=path & "/articles/" & trim(rs_1("bankuai_e")) & "/" & trim(paperid) & "/" & trim(rs_articleid) & ".html"
        end if
      else
        if isHtml="1" then
          article_Url=path & "/articles/" & trim(rs_1("bankuai_e")) & "/" & trim(rs_htmlfilename) & ".htm"
        else
          article_Url=path & "/articles/" & trim(rs_1("bankuai_e")) & "/" & trim(rs_articleid) & ".html"
        end if
      end if
    end if
    MakeArticleUrl = article_Url
  end function
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -