PHP和.NET版客户端信息自动生成
我使用的是全角,大家修改为半角
不是本人原创
再一些学习教程中大多有简单介绍
效果
.NET版本
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);
%>
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);
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











MySQL is a commonly used relational database management system that provides a variety of functions to process and operate data. Among them, the REPLACE function is used to replace the specified part of the string. In this article, we will introduce how to use the REPLACE function for string replacement in MySQL and demonstrate its usage through code examples. First, let’s take a look at the syntax of the REPLACE function: REPLACE(str,search_str,replace_str).

What are the string search and replace techniques in Python? (Specific code example) In Python, strings are a common data type, and we often encounter string search and replace operations in daily programming. This article will introduce some common string search and replacement techniques, accompanied by specific code examples. To find a specific substring in a string, you can use the find() method or index() method of the string. The find() method returns the index of the first occurrence of the substring in the string.

Differences: 1. Make can only be used to allocate and initialize data of types slice, map, and chan; while new can allocate any type of data. 2. New allocation returns a pointer, which is the type "*Type"; while make returns a reference, which is Type. 3. The space allocated by new will be cleared; after make allocates the space, it will be initialized.

1. Concept In the Java language, the "new" expression is responsible for creating an instance, in which the constructor is called to initialize the instance; the return value type of the constructor itself is void, not "the constructor returns the newly created Object reference", but the value of the new expression is a reference to the newly created object. 2. Purpose: Create an object of a new class. 3. Working mechanism: Allocate memory space for object members, and specify default values. Explicitly initialize member variables, perform construction method calculations, and return reference values. 4. Instance new operation often means opening up new memory in the memory. The memory space is allocated in the heap area in the memory. It is controlled by jvm and automatically manages the memory. Here we use the String class as an example. Pu


How does the new operator in js work? Specific code examples are needed. The new operator in js is a keyword used to create objects. Its function is to create a new instance object based on the specified constructor and return a reference to the object. When using the new operator, the following steps are actually performed: create a new empty object; point the prototype of the empty object to the prototype object of the constructor; assign the scope of the constructor to the new object (so this points to new object); execute the code in the constructor and give the new object

Fujifilm has seen a lot of success in recent years, largely due to its film simulations and the popularity of its compact rangefinger-style cameras on social media. However, it doesn't seem to be resting on its laurels, according to Fujirumors. The u

In Java, use the replace() method of the StringBuilder class to replace part of the content in a string. In Java programming, strings are a very important data type, and strings often need to be processed and manipulated. And sometimes we need to replace part of the string to meet our needs. In Java, you can use the replace() method of the StringBuilder class to implement string replacement operations. StringBuilder is a
