我使用的是全角,大家修改为半角
不是本人原创
再一些学习教程中大多有简单介绍
效果
.NET版本
<%@Page Language="C#" Debug="true"%>
<%@Import namespace="System"%>
<%@Import namespace="System.Drawing"%>
<%@Import namespace="System.IO"%>
<%
string sReferer=Request.ServerVariables["HTTP_REFERER"];
string sLanguage,sBrowser,sSys;
if(Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"].IndexOf("zh-cn")>=0){
sLanguage="Chinese";
}
else
{
sLanguage=Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"];
}
string[] aUserAgent=Request.ServerVariables["HTTP_USER_AGENT"].Split(’;’);
if(aUserAgent.Length>2){
sBrowser=aUserAgent[1].Replace("MSIE","Internet Explorer").Trim();
if(sBrowser=="U"){
sBrowser="Mozilla";
}
sSys=aUserAgent[2].Replace(")","");
sSys=sSys.Replace("NT 5.2","2003");
sSys=sSys.Replace("NT 5.1","XP");
sSys=sSys.Replace("NT 5.0","2000");
sSys=sSys.Replace("9x","Me").Trim();
}
else
{
sBrowser="Unknown";
sSys="Unknown";
}
int nWidth=260,nHeight=90;
Bitmap image=new Bitmap(nWidth,nHeight);
Graphics g=Graphics.FromImage(image);
Stream imgData=new MemoryStream();
g.Clear(Color.Snow);
g.DrawRectangle(Pens.Black,0,0,nWidth-1,nHeight-1) ;
g.DrawString("Your IP : " + Request.ServerVariables["REMOTE_ADDR"],new Font("Courier New", 9,FontStyle.Bold),new SolidBrush(Color.FromArgb(200, 14, 91)),6,6);
g.DrawString("Language : " + sLanguage,new Font("Courier New", 9,FontStyle.Bold),new SolidBrush(Color.FromArgb(0, 0, 0)),6,26);
g.DrawString("Your OS : " + sSys,new Font("Courier New", 9,FontStyle.Bold),new SolidBrush(Color.FromArgb(0,0,255)),6,46);
g.DrawString("Browser : " + sBrowser,new Font("Courier New", 9,FontStyle.Bold),new SolidBrush(Color.FromArgb(0, 160, 0)),6,66);
g.Dispose();
Response.ContentType="image/gif";
image.Save(Response.OutputStream ,System.Drawing.Imaging.ImageFormat.Gif);
%>
<%@Import namespace="System"%>
<%@Import namespace="System.Drawing"%>
<%@Import namespace="System.IO"%>
<%
string sReferer=Request.ServerVariables["HTTP_REFERER"];
string sLanguage,sBrowser,sSys;
if(Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"].IndexOf("zh-cn")>=0){
sLanguage="Chinese";
}
else
{
sLanguage=Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"];
}
string[] aUserAgent=Request.ServerVariables["HTTP_USER_AGENT"].Split(’;’);
if(aUserAgent.Length>2){
sBrowser=aUserAgent[1].Replace("MSIE","Internet Explorer").Trim();
if(sBrowser=="U"){
sBrowser="Mozilla";
}
sSys=aUserAgent[2].Replace(")","");
sSys=sSys.Replace("NT 5.2","2003");
sSys=sSys.Replace("NT 5.1","XP");
sSys=sSys.Replace("NT 5.0","2000");
sSys=sSys.Replace("9x","Me").Trim();
}
else
{
sBrowser="Unknown";
sSys="Unknown";
}
int nWidth=260,nHeight=90;
Bitmap image=new Bitmap(nWidth,nHeight);
Graphics g=Graphics.FromImage(image);
Stream imgData=new MemoryStream();
g.Clear(Color.Snow);
g.DrawRectangle(Pens.Black,0,0,nWidth-1,nHeight-1) ;
g.DrawString("Your IP : " + Request.ServerVariables["REMOTE_ADDR"],new Font("Courier New", 9,FontStyle.Bold),new SolidBrush(Color.FromArgb(200, 14, 91)),6,6);
g.DrawString("Language : " + sLanguage,new Font("Courier New", 9,FontStyle.Bold),new SolidBrush(Color.FromArgb(0, 0, 0)),6,26);
g.DrawString("Your OS : " + sSys,new Font("Courier New", 9,FontStyle.Bold),new SolidBrush(Color.FromArgb(0,0,255)),6,46);
g.DrawString("Browser : " + sBrowser,new Font("Courier New", 9,FontStyle.Bold),new SolidBrush(Color.FromArgb(0, 160, 0)),6,66);
g.Dispose();
Response.ContentType="image/gif";
image.Save(Response.OutputStream ,System.Drawing.Imaging.ImageFormat.Gif);
%>
文章来源于领测软件测试网 https://www.ltesting.net/
领测软件测试网最新更新