本文采用ASP語言制作顯示IP圖片,本程序采用動網(wǎng)論壇格式數(shù)據(jù)庫,可從動網(wǎng)論壇的data目錄找到 數(shù)據(jù)庫文件為:IPaddress.MDB
‘————————————
‘File: Ip.asp
<!–#include file=”conn.asp”–>
<!–#include file=”inc/config.asp”–>
<%Response.ContentType = “image/gif”
ConnDatabase
Dim tempip,myipnumeber,sql,rs1
Dim country,city
tempip=ReqIP
tempip = Split(tempip,”.”)
if Ubound(tempip)=3 then
For i=0 To Ubound(tempip)
tempip(i)=left(tempip(i),3)
if isnumeric(tempip(i)) then
tempip(i)=cint(tempip(i))
else
tempip(i)=0
end if
next
myipnumeber=tempip(0)*256*256*256+tempip(1)*256*256+tempip(2)*256+tempip(3)
End If
sql=”select country,city from DV_Address where IP1<=”&myipnumeber&” and IP2>=”&myipnumeber
set rs1=conn.execute(sql)
if not rs1.eof Then
country = rs1(0)
city = rs1(1)
Else
country = “51Tiao.Com”
city = “”
End If
rs1.close : Set rs1 = Nothing
CloseDatabase
Dim LocalFile,TargetFile
LocalFile = Server.MapPath(“Ip.gif”)
Dim Jpeg
Set Jpeg = Server.CreateObject(“Persits.Jpeg”)
If -2147221005=Err then
Response.write “沒有這個組件,請安裝!” ‘檢查是否安裝AspJpeg組件
Response.End()
End If
Jpeg.Open (LocalFile) ‘打開圖片
If err.number then
Response.write”打開圖片失敗,請檢查路徑!”
Response.End()
End if
Dim aa
aa=Jpeg.Binary ‘將原始數(shù)據(jù)賦給aa
‘=========加文字水印=================
Jpeg.Canvas.Font.Color = &H000000 ‘水印文字顏色
Jpeg.Canvas.Font.Family = “宋體” ‘字體
Jpeg.Canvas.Font.Bold = False ‘是否加粗
Jpeg.Canvas.Font.Size = 12 ‘字體大小
Jpeg.Canvas.Font.ShadowColor = &Hffffff ‘陰影色彩
Jpeg.Canvas.Font.ShadowYOffset = 1
Jpeg.Canvas.Font.ShadowXOffset = 1
Jpeg.Canvas.Brush.Solid = False
Jpeg.Canvas.Font.Quality = 4 ‘ ‘輸出質(zhì)量
Jpeg.Canvas.PrintText 30,30,”————————————-” ‘水印位置及文字
Jpeg.Canvas.PrintText 30,50,” 你的IP: “& ReqIP
Jpeg.Canvas.PrintText 30,70,” 你的位置: “&country&” “&city
Jpeg.Canvas.PrintText 30,90,” 操作系統(tǒng): “&ClientInfo(0)
Jpeg.Canvas.PrintText 30,110,” 瀏 覽 器: “&RegExpFilter(“Microsoft<sup>?</sup> “, ClientInfo(1), 0, “”)
Jpeg.Canvas.PrintText 30,130,”————————————-“
Jpeg.Canvas.PrintText 30,145,
bb=Jpeg.Binary ‘將文字水印處理后的值賦給bb,這時,文字水印沒有不透明度
‘============調(diào)整文字透明度================
Set MyJpeg = Server.CreateObject(“Persits.Jpeg”)
MyJpeg.OpenBinary aa
Set Logo = Server.CreateObject(“Persits.Jpeg”)
Logo.OpenBinary bb
MyJpeg.DrawImage 0,0, Logo, 0.9 ‘0.3是透明度
cc=MyJpeg.Binary ‘將最終結(jié)果賦值給cc,這時也可以生成目標圖片了
Response.BinaryWrite cc ‘將二進輸出給瀏覽器
set aa=nothing
set bb=nothing
set cc=nothing
Jpeg.close : Set Jpeg = Nothing
MyJpeg.Close : Set MyJpeg = Nothing
Logo.Close : Set Logo = Nothing
%>
‘————————————————–