|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
×
不是本人原创
再一些学习教程中大多有简单介绍
效果
- <%@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);
- %>
复制代码- <?php
- //处理要显示的相关信息
- if(!(strpos($_SERVER["HTTP_ACCEPT_LANGUAGE"],"zh-cn")===false)){
- $sLanguage="Chinese";
- }
- else
- {
- $sLanguage=$_SERVER["HTTP_ACCEPT_LANGUAGE"];
- }
- $aUserAgent=explode(";",$_SERVER["HTTP_USER_AGENT"]);
- if(count($aUserAgent)>2){
- $sBrowser=trim(str_replace("MSIE","Internet Explorer",$aUserAgent[1]));
- if(trim($sBrowser)=="U"){
- $sBrowser="Mozilla";
- }
- $sSys=str_replace(")","",$aUserAgent[2]);
- $sSys=str_replace("NT 5.2","2003",$sSys);
- $sSys=str_replace("NT 5.1","XP",$sSys);
- $sSys=str_replace("NT 5.0","2000",$sSys);
- $sSys=trim(str_replace("9x","Me",$sSys));
- }
- else
- {
- $sBrowser="Unknown";
- $sSys="Unknown";
- }
- header ("Content-type: image/png");
- //定义图片宽高
- $nWidth=250;
- $nHeight=90;
- $im = @imagecreate ($nWidth,$nHeight) or die ("Cannot Initialize new GD image stream");
- //图片色彩设置
- $background_color = imagecolorallocate ($im, 235, 235, 240);
- $sColorRed = imagecolorallocate ($im, 200, 14, 91);
- $sColorBlack = imagecolorallocate ($im, 0, 0, 0);
- $sColorBlue = imagecolorallocate ($im, 0, 0, 255);
- $sColorGreen = imagecolorallocate ($im, 0, 160, 0);
- //绘制图片边框
- imagefilledrectangle($im, 0, 0, $nWidth - 1, $nHeight - 1, $background_color);
- imagerectangle($im, 0, 0, $nWidth - 1, $nHeight - 1, $sColorBlack);
- //生成图片文字
- imagestring ($im, 3, 6, 6, "Your IP : " . $_SERVER["REMOTE_ADDR"], $sColorRed);
- imagestring ($im, 3, 6, 26, "Language : " . $sLanguage, $sColorBlack);
- imagestring ($im, 3, 6, 46, "Your OS : " . $sSys, $sColorBlue);
- imagestring ($im, 3, 6, 66, "Browser : " . $sBrowser, $sColorGreen);
- //产生图片
- imagepng ($im);
- imagedestroy ($im);
- ?>
复制代码
PS:我不会怎么用啊。会用的写上方法来。 |
|