A collection of useful ASP functions recommended by experts

Source: Internet
Author: User
Tags servervariables

I will not write asp now. This time I will share some of the previously accumulated function libraries with you. I hope they will be helpful to beginners and veterans. Thank you for your support!
<% @ LANGUAGE = "VBSCRIPT" CODEPAGE = "936" %>
<%
StartTime = timer () 'program execution time Detection
'####################################### ########################
'Bo ── VIBO ── ─
'│ Vibo studio copyright │
'Accept ── ─ accept
'Author: Vibo
'Email: vibo_cn@hotmail.com
'--------------- Common function libraries developed by the Vibo ASP site ------------------
'Opendb (vdata_url) ------------------ open the database
'Getip () ------------------------------- get the real IP Address
'Getipadress (sip) ------------------------ find the real ip Address
'Ip2num (sip) ---------------------------- restrict an IP address segment
'Chkfrom () ------------------------------ anti-site commit settings
'Getsys () ------------------------------- operating system detection
'Getbrowser () --------------------------- browser version check
'Getsearcher () -------------------------- identify a search engine
'
'---------------------- Data filtering ----------------------------
'Checkstr (byVal ChkStr) ----------------- check invalid characters
'Checksql () ----------------------------- prevent SQL Injection
'Uncheckstr (Str) ------------------------- check for invalid SQL commands
'Checkstr (Str) -------------------------- ASP latest SQL anti-injection filtering Han number
'Htmlencode (reString) ------------------- filter and convert HTML code
'Datetostr (DateTime, ShowType) ----------- date Conversion Function
'Date2chinese (iDate) -------------------- obtain the Chinese Date string of ASP
'Lenstr (str) ---------------------------- calculate the string length (in bytes)
'Createarr (str) ------------------------- generate a two-dimensional array
'Showrsarr (rsArr) ----------------------- use a table to display the table structure of the array generated by getrows in the record set
'-------------------- External components use function compute ------------------------
'Sendmail (to_Email, from_Email, from_Name, mail_Subject, mail_Body, mail_htmlBody) ----- 'jmail component sends an email
'----------------------------------------- System detection function ------------------------------------------
'Isvalidurl (url) ------------------------ check whether the webpage is valid
'Gethtmlpage (filename) ------------------ get File Content
'Checkfile (FilePath) ------------------ check whether a file exists
'Checkdir (FolderPath) ------------------- check whether a directory exists
'Makenewsdir (foldername) ---------------- generate a directory based on the specified name
'Createhtmlpage (filename, FileData, C_mode) to generate a file
'Checkbadword (byVal ChkStr) ------------- filter dirty words
'####################################### ########################
Dim ipData_url
IpData_url = "./Ip. mdb"
Response. Write ("-------------- client information detection ------------" & "<br> ")
Response. Write (getsys () & "<br> ")
Response. Write (GetBrowser () & "<br> ")
Response. Write (GetSearcher () & "<br> ")
Response. Write ("IP:" & getIp () & "<br> ")
Response. Write ("Source:" & (getIPAdress (GetIp () & "<br> ")
Response. Write ("<br> ")
Response. Write ("-------------- data submission detection --------------" & "<br> ")
If not chkFrom then
Response. write ("Please do not submit content outside the site! "&" <Br> ")
Response. end
Else
Response. write ("content submitted on this site! "&" <Br> ")
End if
Function OpenDB (vdata_url)
'------------------------------ Open the database
'Usage: Conn = OpenDB ("data/data. mdb ")
Dim vibo_Conn
Set vibo_Conn = Server. CreateObject ("ADODB. Connection ")
Vibo_Conn.ConnectionString = "Provider = Microsoft. Jet. OLEDB.4.0; Data Source =" & Server. MapPath (vdata_url)
Vibo_Conn.Open
OpenDB = vibo_Conn
End Function
Function getIp ()
'----------------------- Get the real IP Address
Userip = Request. ServerVariables ("HTTP_X_FORWARDED_FOR ")
If userip = "" Then userip = Request. ServerVariables ("REMOTE_ADDR ")
GetIp = userip
End function
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.