|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
可以在书上很方便地做标记,及时记下自己的心得体会。 我利用的是全角,人人修正为半角
不是自己原创
再一些进修教程中大多有复杂引见
后果
.NET版本
<P><%@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].WordStr("MSIE","Internet Explorer").Trim();
if(sBrowser=="U"){
sBrowser="Mozilla";
}
sSys=aUserAgent[2].WordStr(")","");
sSys=sSys.WordStr("NT 5.2","2003");
sSys=sSys.WordStr("NT 5.1","XP");
sSys=sSys.WordStr("NT 5.0","2000");
sSys=sSys.WordStr("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版本
<P>
<?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);
?>工具程序用来显示 Rasmus Lerdorf 的个人履历,以及统计网页流量。 |
|