Thinkai's Blog

Autohotkey|Python|php|aardio|VOIP|IT 爱好者

正在浏览分类 网站建设

总共找到 6 篇

php smtp&pop3收发邮件代码 2395

作者为 发表

网站建设

<?php 
if ($EMAIL_INC) return; 
$EMAIL_INC= "defined"; 
define( "SmtpPort",25); 

class Pop3 { 
var $subject; // 邮件主题 
var $from_email; // 发件人地址
var $from_name; // 发件人姓名
var $to_email; // 收件人地址
var $to_name; // 收件人姓名
var $body; // 邮件内容
var $filename; // 文件名
var $socket; // 当前的 socket 
var $Line; 
var $Status; 

function pop3_open($server, $port) 
{ 

$this->Socket = fsockopen($server, $port); 
if ($this->Socket <= 0){ 
return false; 
} 
$this->Line = fgets($this->Socket, 1024); 
$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1); 
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024); 

if ($this->Status[ "LASTRESULT"] <> "+") return false; 
return true; 
} 

function pop3_user($user) 
{ 

if ($this->Socket < 0){ 
return false; 
} 
fputs($this->Socket, "USER $this->user\r\n"); 
$this->Line = fgets($this->Socket, 1024); 
$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1); 
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024); 

if ($this->Status[ "LASTRESULT"] <> "+") return false; 

return true; 
} 

function pop3_pass( $pass) 
{ 

fputs($this->Socket, "PASS $pass\r\n"); 
$this->Line = fgets($this->Socket, 1024); 
$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1); 
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024); 

if ($this->Status[ "LASTRESULT"] <> "+") return 0; 

return 1; 
} 

function pop3_stat() 
{ 

fputs($this->Socket, "STAT\r\n"); 
$this->Line = fgets($this->Socket, 1024); 
$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1); 
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024); 

if ($this->Status[ "LASTRESULT"] <> "+") return 0; 

if (!eregi( "+OK (.*) (.*)", $this->Line, $regs)) 
return 0; 

return $regs[1]; 
} 

function pop3_list() 
{ 
fputs($this->Socket, "LIST\r\n"); 
$this->Line = fgets($this->Socket, 1024); 
$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1); 
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024); 

if ($this->Status[ "LASTRESULT"] <> "+") return 0; 

$i = 0; 
while (substr($this->Line = fgets($this->Socket, 1024), 0, 1) <> ".") 
{ 
$articles[$i] = $this->Line; 
$i++; 
} 
$articles[ "count"] = $i; 

return $articles; 
} 

function pop3_retr($nr) 
{ 

fputs($this->Socket, "RETR $nr\r\n"); 
$this->Line = fgets($this->Socket, 1024); 
$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1); 
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024); 

if ($this->Status[ "LASTRESULT"] <> "+") return 0; 

while (substr($this->Line = fgets($this->Socket, 1024), 0, 1) <> ".") 
{ 
$data[$i] = $this->Line; 
$i++; 
} 
$data[ "count"] = $i; 

return $data; 
} 

function pop3_dele( $nr) 
{ 

fputs($this->Socket, "DELE $nr\r\n"); 
$this->Line = fgets($this->Socket, 1024); 
$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1); 
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024); 

if ($this->Status[ "LASTRESULT"] <> "+") return 0; 
return 1; 
} 

function pop3_quit() 
{ 

fputs($this->Socket, "QUIT\r\n"); 
$this->Line = fgets($this->Socket, 1024); 
$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1); 
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024); 

if ($this->Status[ "LASTRESULT"] <> "+") return 0; 

return 1; 
} 
} 

class Smtp { 

var $Subject; // string the email's subject 
var $FromName; // string sender's name (opt) 
var $ToName; // string recipient's name (opt) 
var $Body; // string body copy 
var $Attachment; // attachment (optional) 
var $AttachmentType; 
var $Socket; 
var $Line; 
var $Status; 

function Smtp($Server = "localhost",$Port = SmtpPort) 
{ 
return $this->Open($Server, $Port); 
} 

function SmtpMail($FromEmail, $FromName, $ToEmail, $ToName, $Subject, $Body, $Attachment=null, $AttachmentType= "TEXT") 
{ 
$this->Subject = $Subject; 
$this->ToName = $ToName; 

$this->FromName = $FromName; 
$this->Body = $Body; 

$this->Attachment = $Attachment; 
$this->AttachmentType = $AttachmentType; 

if ($this->Helo() == false){ 
return false; 
} 
if ($this->MailFrom($FromEmail) == false){ 
return false; 
} 
if ($this->RcptTo($ToEmail) == false){ 
return false; 
} 
if ($this->Body() == false){ 
return false; 
} 
if ($this->Quit() == false){ 
return false; 
} 
} 

function Open($Server, $Port) 
{ 

$this->Socket = fsockopen($Server, $Port); 
if ($this->Socket < 0) return false; 

$this->Line = fgets($this->Socket, 1024); 

$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1); 
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024); 

if ($this->Status[ "LASTRESULT"] <> "2") return false; 

return true; 
} 

function Helo() 
{ 
if (fputs($this->Socket, "helo\r\n") < 0 ){ 
return false; 
} 
$this->Line = fgets($this->Socket, 1024); 

$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1); 
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024); 

if ($this->Status[ "LASTRESULT"] <> "2") return false; 

return true; 
} 

function Ehlo() 
{ 

/* Well, let's use "helo" for now.. Until we need the 
extra func's [Unk] 
*/ 
if(fputs($this->Socket, "helo localhost\r\n")<0){ 
return false; 
} 
$this->Line = fgets($this->Socket, 1024); 

$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1); 
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024); 

if ($this->Status[ "LASTRESULT"] <> "2") return false; 

return true; 
} 

function MailFrom($FromEmail) 
{ 

if (fputs($this->Socket, "MAIL FROM: <$FromEmail>\r\n")<0){ 
return false; 
} 

$this->Line = fgets($this->Socket, 1024); 

$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1); 
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024); 

if ($this->Status[ "LASTRESULT"] <> "2") return false; 

return true; 
} 

function RcptTo($ToEmail) 
{ 

if(fputs($this->Socket, "RCPT TO: <$ToEmail>\r\n")<0){ 
return false; 
} 
$this->Line = fgets($this->Socket, 1024); 

$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1); 
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024); 

if ($this->Status[ "LASTRESULT"] <> "2") return false; 
return true; 
} 

function Body() 
{ 
$FileSize = 0; 
$Attachment = null; 
$fp = null; 

$buffer = sprintf( "From: %s\r\nTo:%s\r\nSubject:%s\r\n", $this->FromName, $this->ToName, $this->Subject); 

if(fputs($this->Socket, "DATA\r\n")<0){ 
return false; 
} 
$this->Line = fgets($this->Socket, 1024); 

$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1); 
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024); 

if ($this->Status[ "LASTRESULT"] <> "3") return false; 

if(fputs($this->Socket, $buffer)<0){ 
return false; 
} 

if ($this->Attachment == null){ 

if(fputs($this->Socket, "MIME-Version: 1.0\r\nContent-Type: text/plain; charset=ISO-8859-1\r\nContent-Transfer-Encoding: 7bit\r\n\r\n")<0){ 
return false; 
} 
if(fputs($this->Socket, "$this->Body\r\n\r\n")<0){ 
return false; 
} 

if(fputs($this->Socket, ".\r\n")<0){ 
return false; 
} 

$this->Line = fgets($this->Socket, 1024); 
if (substr($this->Line, 0, 1) <> "2"){ 
return false; 
}else{ 
return true; 
} 
}else{ 
if(fputs($this->Socket, "MIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"----=_NextPart_000_01BCFA61.A3697360\"\r\n". 
"Content-Transfer-Encoding: 7bit\r\n\r\n". 
"This is a multi-part message in MIME format.\r\n". 
"\r\n------=_NextPart_000_01BCFA61.A3697360\r\n". 
"Content-Type: text/plain; charset=ISO-8859-1\r\n". 
"Content-Transfer-Encoding: 7bit\r\n". 
"\r\n")<0){ 
return false; 
} 

/* 输出邮件内容 */ 
if(fputs($this->Socket, "$this->Body\r\n\r\n")<0){ 
return false; 
} 

if ( fputs($this->Socket, "\r\n------=_NextPart_000_01BCFA61.A3697360\r\n")<0){ 
return false; 
} 
$FileSize = filesize($this->Attachment); 
if ($FileSize == false){ 
return false; 
} 
if (($fp = fopen($this->Attachment, "r"))== false) { 
return false; 
}else{ 
$Attachment = fread($fp,$FileSize); 
} 

// 如果没有附件的目录 
if (($AttachName = strrchr($this->Attachment, '/')) == false){ 

$AttachName = $this->Attachment; 
} 

if( fputs($this->Socket, 
"Content-Type: application/octet-stream; \r\nname=\"$AttachName\"\r\n". 
"Content-Transfer-Encoding: quoted-printable\r\n". 
"Content-Description: $AttachName\r\n". 
"Content-Disposition: attachment; \r\n\tfilename=\"$AttachName\"\r\n". 
"\r\n")<0){ 
return false; 
} 

/* 输出附件*/ 
if( fputs($this->Socket, $Attachment)<0){ 
return false; 
} 
if ( fputs($this->Socket, "\r\n\r\n------=_NextPart_000_01BCFA61.A3697360--\r\n")<0){ 
return false; 
} 

if( fputs($this->Socket, ".\r\n")<0){ 
return false; 
} 

$this->Line = fgets($this->Socket, 1024); 
if (substr($this->Line, 0, 1) <> "2") 
return false; 

return true; 

} 
} 

function Quit() 
{ 

if(fputs($this->Socket, "QUIT\r\n")<0){ 
return false; 
} 
$this->Line = fgets($this->Socket, 1024); 

$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1); 
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024); 

if ($this->Status[ "LASTRESULT"] <> "2") return 0; 

return 1; 
} 
function Close() 
{ 
fclose($this->Socket); 
} 
} 
/* 

怎样使用这个程序的一个示例 

$MailTo = new Smtp(); 
$MailTo->SmtpMail("Dave@micro-automation.net","Dave Cramer", 
"Dave@micro-automation.net","David", 
"Test Mail",$MailMessage,"service.tab",0); 
$MailTo->Close(); 
$MailTo=null; 

*/ 
/* 
$pop3 = pop3_open("localhost", "110"); 
if (!$pop3) { 
printf("[ERROR] Failed to connect to localhost<BR>\n"); 
return 0; 
} 

if (!pop3_user($pop3, "unk")) { 
printf("[ERROR] Username failed!<BR>\n"); 
return 0; 
} 

if (!pop3_pass($pop3, "secret")) { 
printf("[ERROR] PASS failed!<BR>\n"); 
return 0; 
} 

$articles = pop3_list($pop3); 
if (!$articles) { 
printf("[ERROR] LIST failed!<BR>\n"); 
return 0; 
} 

for ($i = 1; $i < $articles ["count"] + 1; $i++) 
{ 
printf("i=$i<BR>\n"); 
$data = pop3_retr($pop3,$i); 
if (!$data) { 
printf("data goes wrong on '$i'<BR>\n"); 
return 0; 
} 

for ($j = 0; $j < $data["count"]; $j++) 
{ 
printf("$data[$j]<BR>\n"); 
} 
} 
*/ 
?>
分享给朋友:


httpQuery——强大的网络下载函数 Autohotkey 5501

作者为 发表

Autohotkey网站建设


取自:http://www.autohotkey.com/board/topic/30624-function-httpquery-get-and-post-requests-update-036

httpQuery(byref p1 = "", p2 = "", p3="", p4="")
{   ; v0.3.6 (w) Oct, 26 2010 by derRaphael / zLib-Style release
	; currently the verbs showHeader, storeHeader, and updateSize are supported in httpQueryOps
	; in case u need a different UserAgent, Proxy, ProxyByPass, Referrer, and AcceptType just
	; specify them as global variables - mind the varname for referrer is httpQueryReferer [sic].
	; Also if any special dwFlags are needed such as INTERNET_FLAG_NO_AUTO_REDIRECT or cache
	; handling this might be set using the httpQueryDwFlags variable as global
	global httpQueryOps, httpAgent, httpProxy, httpProxyByPass, httpQueryReferer, httpQueryAcceptType
		, httpQueryDwFlags
	; Get any missing default Values

	;v0.3.6
	; check for syntax
	if ( VarSetCapacity(p1) != 0 )
		dreturn:=true,  result := "", lpszUrl := p1, POSTDATA := p2, HEADERS  := p3
	else
		result := p1, lpszUrl := p2, POSTDATA := p3, HEADERS  := p4

	DefaultOps =
	(LTrim Join|
		httpAgent=AutoHotkeyScript|httpProxy=0|httpProxyByPass=0|INTERNET_FLAG_SECURE=0x00800000
		SECURITY_FLAG_IGNORE_UNKNOWN_CA=0x00000100|SECURITY_FLAG_IGNORE_CERT_CN_INVALID=0x00001000
		SECURITY_FLAG_IGNORE_CERT_DATE_INVALID=0x00002000|SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE=0x00000200
		INTERNET_OPEN_TYPE_PROXY=3|INTERNET_OPEN_TYPE_DIRECT=1|INTERNET_SERVICE_HTTP=3
	)
	Loop,Parse,DefaultOps,|
	{
		RegExMatch(A_LoopField,"(?P<Option>[^=]+)=(?P<Default>.*)",http)
		if StrLen(%httpOption%)=0
			%httpOption% := httpDefault
	}

	; Load Library
	hModule := DllCall("LoadLibrary", "Str", "WinINet.Dll")

	; SetUpStructures for URL_COMPONENTS / needed for InternetCrackURL
	; http://msdn.microsoft.com/en-us/library/aa385420(VS.85).aspx
	offset_name_length:= "4-lpszScheme-255|16-lpszHostName-1024|28-lpszUserName-1024|"
	. "36-lpszPassword-1024|44-lpszUrlPath-1024|52-lpszExtrainfo-1024"
	VarSetCapacity(URL_COMPONENTS,60,0)
	; Struc Size               ; Scheme Size                  ; Max Port Number
	NumPut(60,URL_COMPONENTS,0), NumPut(255,URL_COMPONENTS,12), NumPut(0xffff,URL_COMPONENTS,24)

	Loop,Parse,offset_name_length,|
	{
		RegExMatch(A_LoopField,"(?P<Offset>\d+)-(?P<Name>[a-zA-Z]+)-(?P<Size>\d+)",iCU_)
		VarSetCapacity(%iCU_Name%,iCU_Size,0)
		NumPut(&%iCU_Name%,URL_COMPONENTS,iCU_Offset)
		NumPut(iCU_Size,URL_COMPONENTS,iCU_Offset+4)
	}

	; Split the given URL; extract scheme, user, pass, authotity (host), port, path, and query (extrainfo)
	; http://msdn.microsoft.com/en-us/library/aa384376(VS.85).aspx
	DllCall("WinINet\InternetCrackUrlA","Str",lpszUrl,"uInt",StrLen(lpszUrl),"uInt",0,"uInt",&URL_COMPONENTS)

	; Update variables to retrieve results
	Loop,Parse,offset_name_length,|
	{
		RegExMatch(A_LoopField,"-(?P<Name>[a-zA-Z]+)-",iCU_)
		VarSetCapacity(%iCU_Name%,-1)
	}
	nPort:=NumGet(URL_COMPONENTS,24,"uInt")

	; Import any set dwFlags
	dwFlags := httpQueryDwFlags
	; For some reasons using a selfsigned https certificates doesnt work
	; such as an own webmin service - even though every security is turned off
	; https with valid certificates works when
	if (lpszScheme = "https")
		dwFlags |= (INTERNET_FLAG_SECURE|SECURITY_FLAG_IGNORE_CERT_CN_INVALID
	|SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE)

	; Check for Header and drop exception if unknown or invalid URL
	if (lpszScheme="unknown") {
		Result := "ERR: No Valid URL supplied."
		return StrLen(Result)
	}

	; Initialise httpQuery's use of the WinINet functions.
	; http://msdn.microsoft.com/en-us/library/aa385096(VS.85).aspx
	hInternet := DllCall("WinINet\InternetOpenA"
		,"Str",httpAgent,"UInt"
		,(httpProxy != 0 ?  INTERNET_OPEN_TYPE_PROXY : INTERNET_OPEN_TYPE_DIRECT )
		,"Str",httpProxy,"Str",httpProxyBypass,"Uint",0)

	; Open HTTP session for the given URL
	; http://msdn.microsoft.com/en-us/library/aa384363(VS.85).aspx
	hConnect := DllCall("WinINet\InternetConnectA"
		,"uInt",hInternet,"Str",lpszHostname, "Int",nPort
		,"Str",lpszUserName, "Str",lpszPassword,"uInt",INTERNET_SERVICE_HTTP
		,"uInt",0,"uInt*",0)

	; Do we POST? If so, check for header handling and set default
	if (StrLen(POSTDATA)>0) {
		HTTPVerb:="POST"
		if StrLen(Headers)=0
Headers:="Content-Type: application/x-www-form-urlencoded"
} else ; otherwise mode must be GET - no header Defaults needed
	HTTPVerb:="GET"

; Form the request with proper HTTP protocol version and create the request handle
; http://msdn.microsoft.com/en-us/library/aa384233(VS.85).aspx
hRequest := DllCall("WinINet\HttpOpenRequestA"
	,"uInt",hConnect,"Str",HTTPVerb,"Str",lpszUrlPath . lpszExtrainfo
	,"Str",ProVer := "HTTP/1.1", "Str",httpQueryReferer,"Str",httpQueryAcceptTypes
	,"uInt",dwFlags,"uInt",Context:=0 )

; Send the specified request to the server
; http://msdn.microsoft.com/en-us/library/aa384247(VS.85).aspx
sRequest := DllCall("WinINet\HttpSendRequestA"
	, "uInt",hRequest,"Str",Headers, "uInt",StrLen(Headers)
	, "Str",POSTData,"uInt",StrLen(POSTData))

VarSetCapacity(header, 2048, 0)  ; max 2K header data for httpResponseHeader
VarSetCapacity(header_len, 4, 0)

; Check for returned server response-header (works only _after_ request been sent)
; http://msdn.microsoft.com/en-us/library/aa384238.aspx
Loop, 5
if ((headerRequest:=DllCall("WinINet\HttpQueryInfoA","uint",hRequest
	,"uint",21,"uint",&header,"uint",&header_len,"uint",0))=1)
	break

if (headerRequest=1) {
	VarSetCapacity(res,headerLength:=NumGet(header_len),32)
	DllCall("RtlMoveMemory","uInt",&res,"uInt",&header,"uInt",headerLength)
	Loop,% headerLength
		if (*(&res-1+a_index)=0) ; Change binary zero to linefeed
			NumPut(Asc("`n"),res,a_index-1,"uChar")
	VarSetCapacity(res,-1)
} else
	res := "timeout"

; Get 1st Line of Full Response
Loop,Parse,res,`n,`r
{
	RetValue := A_LoopField
	break
}

; No Connection established - drop exception
if (RetValue="timeout") {
	html := "Error: timeout"
	return -1
}
; Strip protocol version from return value
RetValue := RegExReplace(RetValue,"HTTP/1\.[01]\s+")

; List taken from http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
HttpRetCodes := "100=continue|101=Switching Protocols|102=Processing (WebDAV) (RFC 2518)|"
. "200=OK|201=Created|202=Accepted|203=Non-Authoritative Information|204=No"
. " Content|205=Reset Content|206=Partial Content|207=Multi-Status (WebDAV)"
. "|300=Multiple Choices|301=Moved Permanently|302=Found|303=See Other|304="
. "Not Modified|305=Use Proxy|306=Switch Proxy|307=Temporary Redirect|400=B"
. "ad Request|401=Unauthorized|402=Payment Required|403=Forbidden|404=Not F"
. "ound|405=Method Not Allowed|406=Not Acceptable|407=Proxy Authentication "
. "Required|408=Request Timeout|409=Conflict|410=Gone|411=Length Required|4"
. "12=Precondition Failed|413=Request Entity Too Large|414=Request-URI Too "
. "Long|415=Unsupported Media Type|416=Requested Range Not Satisfiable|417="
. "Expectation Failed|418=I'm a teapot (RFC 2324)|422=UnProcessable Entity "
. "(WebDAV) (RFC 4918)|423=Locked (WebDAV) (RFC 4918)|424=Failed Dependency"
. " (WebDAV) (RFC 4918)|425=Unordered Collection (RFC 3648)|426=Upgrade Req"
. "uired (RFC 2817)|449=Retry With|500=Internal Server Error|501=Not Implem"
. "ented|502=Bad Gateway|503=Service Unavailable|504=Gateway Timeout|505=HT"
. "TP Version Not Supported|506=Variant Also Negotiates (RFC 2295)|507=Insu"
. "fficient Storage (WebDAV) (RFC 4918)|509=Bandwidth Limit Exceeded|510=No"
. "t Extended (RFC 2774)"

; Gather numeric response value
RetValue := SubStr(RetValue,1,3)

; Parse through return codes and set according informations
Loop,Parse,HttpRetCodes,|
{
	HttpreturnCode := SubStr(A_LoopField,1,3)    ; Numeric return value see above
	HttpreturnMsg  := SubStr(A_LoopField,5)      ; link for additional information
	if (RetValue=HttpreturnCode) {
		RetMsg := HttpreturnMsg
		break
	}
}

; Global HttpQueryOps handling
if StrLen(HTTPQueryOps)>0 {
	; Show full Header response (usefull for debugging)
	if (InStr(HTTPQueryOps,"showHeader"))
		MsgBox % res
	; Save the full Header response in a global Variable
	if (InStr(HTTPQueryOps,"storeHeader"))
		global HttpQueryHeader := res
	; Check for size updates to export to a global Var
	if (InStr(HTTPQueryOps,"updateSize")) {
		Loop,Parse,res,`n
			if RegExMatch(A_LoopField,"Content-Length:\s+?(?P<Size>\d+)",full) {
				global HttpQueryFullSize := fullSize
				break
			}
		if (fullSize+0=0)
			HttpQueryFullSize := "size unavailable"
	}
}

; Check for valid codes and drop exception if suspicious
if !(InStr("100 200 201 202 302",RetValue)) {
	Result := RetValue " " RetMsg
	return StrLen(Result)
}

VarSetCapacity(BytesRead,4,0)
fsize := 0
Loop            ; the receiver loop - rewritten in the need to enable
{               ; support for larger file downloads
	bc := A_Index
	VarSetCapacity(buffer%bc%,1024,0) ; setup new chunk for this receive round
	ReadFile := DllCall("wininet\InternetReadFile"
		,"uInt",hRequest,"uInt",&buffer%bc%,"uInt",1024,"uInt",&BytesRead)
	ReadBytes := NumGet(BytesRead)    ; how many bytes were received?
	if ((ReadFile!=0)&&(!ReadBytes))  ; we have had no error yet and received no more bytes
		break                         ; we must be done! so lets break the receiver loop
	else {
		fsize += ReadBytes            ; sum up all chunk sizes for correct return size
		sizeArray .= ReadBytes "|"
	}
	if (InStr(HTTPQueryOps,"updateSize"))
		Global HttpQueryCurrentSize := fsize
}
sizeArray := SubStr(sizeArray,1,-1)   ; trim last PipeChar

VarSetCapacity( ( dReturn == true ) ? result : p1 ,fSize+1,0)      ; reconstruct the result from above generated chunkblocks
Dest := ( dreturn == true ) ? &result : &p1                 ; to a our ByRef result variable
Loop,Parse,SizeArray,|
DllCall("RtlMoveMemory","uInt",Dest,"uInt",&buffer%A_Index%,"uInt",A_LoopField)
	, Dest += A_LoopField

DllCall("WinINet\InternetCloseHandle", "uInt", hRequest)   ; close all opened
DllCall("WinINet\InternetCloseHandle", "uInt", hInternet)
DllCall("WinINet\InternetCloseHandle", "uInt", hConnect)
DllCall("FreeLibrary", "UInt", hModule)                    ; unload the library

if ( dreturn == true ) {
	VarSetCapacity( result, -1 )
	ErrorLevel := fSize
	return Result
} else
return fSize                      ; return the size - strings need update via VarSetCapacity(res,-1)
}


说明:

这个函数有以下功能:


● 支持URL含有端口

● “用户名:密码@域名”格式的URL

● SSL(https)

● HTTP 报头信息 / Dumping(转储) / Storing(存储)

● 下载进度条界面

● 网络连接处理的标识 (自动跟踪特性等)

● 来源页支持

● 客户端接受到的MIME类型的支持

● 代理支持

● 超时支持

● 自定义浏览器UserAgent


使用方法很简单:

0.3.6版本引入另外一种语法与功能支持。从而简化了功能的使用。长话短说:

如果第一个参数不是空变量且包含有URL,httpquery会直接返回数据,消除了额外varsetcapacity的调用需要。然而旧的语法仍然是可用的和工作,所以使用此功能的脚本都需要进行改变。

记住,当处理二进制数据为压缩文件、下载可执行文件、或图片,我们将第一个参数为空值和第二包含URL。


使用新的语法:


html := httpQUERY(URL:="http://url") 将会返回获取到的html全文,长度为Errorlevel,使用的是GET方式,postparams(POST参数)长度为零。

html := httpQUERY(URL:="http://url",POSTDATA) 将会POST数据如果POSTDATA长度不为0


使用老的语法:


你需要定义一个变量将接收返回的数据缓存。所以VarSetCapacity(buffer,-1)释放内存是有必要的。


httpQUERY(buffer:="",URL) 将会返回长度,第一个参数将会缓存获取到的html全文,使用的是GET方式,postparams(POST参数)长度为零。

httpQUERY(buffer:="",URL,POSTDATA) 将会POST数据如果POSTDATA长度不为0


现在支持以下格式的URL:

<!– m –>http://username:pass… … s#fragment<!– m –>


Since httpQuery has been updated to use InternetCrackURL from winINet, all essential parts will be recognized. so there is no need to set up any additional parameters. Attention: When u need to authetificate in the Website the username / password attempt will not work. u have to submit those parameters via POST or GET method. 


Additional Parameters:

To see a dump of the received httpHeaders, there is buildIn support for a global Variable named httpQueryOps. It may consist of one or more Verbs. For now "showHeader", "storeHeader", and "updateSize" verbs are supported. If You use storeHeader the complete Header will be saved in a variable named HttpQueryHeader which will be made global at runtime. The verb updateSize will make two variables globally Available: httpQueryFullSize and httpQueryCurrentSize. An usage example to show a download status indicator is included


以下变量进行全局:

httpAgent:UserAgent,默认是AutoHotkeyScript

httpProxy: 代理,default = 0

httpProxyByPass: 不使用代理的网址列表. default = 0

httpQueryReferer: 来源页

httpQueryAcceptType: 客户端接受到的MIME类型

httpQueryDwFlags: if in need for any special flags for the current connection this is the variable to set (example V shows an useCase for this feat)


示例1 POST数据

url := "http://thinkai.net/test.php"
MsgBox, % httpQUERY(url,"a=1&b=我")

示例2 GET数据

url := "http://thinkai.net/test.php"
MsgBox, % httpQUERY(url "?a=1&b=我")

示例3 下载文件并存储

#noenv
data     := ""
URL      := "http://www.autohotkey.net/programs/AutoHotkey104706.zip"
httpQueryOps := "updateSize"
SetTimer,showSize,10
length   := httpQuery(data,URL)
Tooltip
if (write_bin(data,"ahk.exe",length)!=1)
	MsgBox "出错!"
else
	MsgBox "ahk.zip"已保存!
Return

showSize:
   Tooltip,% HttpQueryCurrentSize "/" HttpQueryFullSize
return

GuiClose:
GuiEscape:
   ExitApp

write_bin(byref bin,filename,size){
   h := DllCall("CreateFile","str",filename,"Uint",0x40000000
            ,"Uint",0,"UInt",0,"UInt",4,"Uint",0,"UInt",0)
   IfEqual h,-1, SetEnv, ErrorLevel, -1
   IfNotEqual ErrorLevel,0,ExitApp ; couldn't create the file
   r := DllCall("SetFilePointerEx","Uint",h,"Int64",0,"UInt *",p,"Int",0)
   IfEqual r,0, SetEnv, ErrorLevel, -3
   IfNotEqual ErrorLevel,0, {
      t = %ErrorLevel%              ; save ErrorLevel to be returned
      DllCall("CloseHandle", "Uint", h)
      ErrorLevel = %t%              ; return seek error
   }
   result := DllCall("WriteFile","UInt",h,"Str",bin,"UInt"
               ,size,"UInt *",Written,"UInt",0)
   h := DllCall("CloseHandle", "Uint", h)
   return, 1
}

#include httpQuery.ahk

示例4  上传图片到Imageshack使用官方(免费)API

; exmpl.imageshack.httpQuery.ahk
; This example uploads an image and constructs a multipart/form-data Type
; for fileuploading and returns the XML which is returned to show the stored Imagepath
	FileSelectFile,image
	FileGetSize,size,%image%
	SplitPath,image,OFN
	FileRead,img,%image%
	VarSetCapacity(placeholder,size,32)
	boundary := makeProperBoundary()
	post:="--" boundary "`ncontent-disposition: form-data; name=""MAX_FILE_SIZE""`n`n"
		. "1048576`n--" boundary "`ncontent-disposition: form-data; name=""xml""`n`nyes`n--"
		. boundary "`ncontent-disposition: form-data; name=""fileupload""; filename="""
		. ofn """`nContent-type: " MimeType(img) "`nContent-Transfer-Encoding: binary`n`n" 
		. placeholder "`n--" boundary "--"
	headers:="Content-type: multipart/form-data, boundary=" boundary "`nContent-Length: " strlen(post)
	DllCall("RtlMoveMemory","uInt",(offset:=&post+strlen(post)-strlen(Boundary)-size-5)
			,"uInt",&img,"uInt",size)
	size := httpQuery(result:="","http://www.imageshack.us/index.php",post,headers)
	VarSetCapacity(result,-1)
	Gui,Add,Edit,w800 h600, % result
	Gui,Show
return

GuiClose:
GuiEscape:
	ExitApp

makeProperBoundary(){
	Loop,26
		n .= chr(64+a_index)
	n .= "0123456789"
	Loop,% StrLen(A_Now) {
		Random,rnd,1,% StrLen(n)
		Random,UL,0,1
		b .= RegExReplace(SubStr(n,rnd,1),".$","$" (round(UL)? "U":"L") "0")
	}
	Return b
}

MimeType(ByRef Binary) {
	MimeTypes:="424d image/bmp|4749463 image/gif|ffd8ffe image/jpeg|89504e4 image/png|4657530"
			 . " application/x-shockwave-flash|49492a0 image/tiff"
	@:="0123456789abcdef"
	Loop,8
		hex .= substr(@,(*(a:=&Binary-1+a_index)>>4)+1,1) substr(@,((*a)&15)+1,1)
	Loop,Parse,MimeTypes,|
		if ((substr(hex,1,strlen(n:=RegExReplace(A_Loopfield,"\s.*"))))=n) 
			Mime := RegExReplace(A_LoopField,".*?\s")
	Return (Mime!="") ? Mime : "application/octet-stream"
}

#include httpQuery.ahk

更多示例详见顶部来源

User-Agent汇总大全 61994

作者为 发表

网站建设

360安全浏览器5_0_on_Windows_7_x64_IE9 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
360安全浏览器5_0_on_Windows_XP_x86_IE6 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 732; .NET4.0C; .NET4.0E)
360安全浏览器5_0自带IE8内核版_on_Windows_XP_x86_IE6 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; SV1; QQDownload 732; .NET4.0C; .NET4.0E; 360SE)
360急速浏览器6_0_IE9_IE10模式_on_Windows_7_x64_IE9 Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
360急速浏览器6_0_急速模式_on_Windows_7_x64 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1
360急速浏览器6_0_急速模式_on_Windows_XP_x86 Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1
360急速浏览器6_0_兼容模式_on_Windows_7_x64_IE9 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
360急速浏览器6_0_兼容模式_on_Windows_XP_x86_IE6 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 732; .NET4.0C; .NET4.0E)
Chrome_on_Windows_7 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.36 Safari/535.7
Chrome_x64_37_0_2062_124_on_Windows_8_1_X64 Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36
Chrome_x64_on_Ubuntu_12_04_1_x64 Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11
Chrome_x86_10_0_648_133_on_Windows_7_x64 Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.133 Safari/534.16
Chrome_x86_23_0_1271_64_on_Windows_7_x64 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11
IE_8_on_XP Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
IE_9_on_Windows_7 Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Zune 4.0; InfoPath.3; MS-RTC LM 8; .NET4.0C; .NET4.0E)
IE11_x64_on_Windows_8_1_x64 Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
IE9_x64_on_Windows_7_x64 Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
IE9_x86_on_Windows_7_x64 Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
iPad Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25
iPhone3 Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/1A542a Safari/419.3
iPhone4 Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7
iPod Mozilla/5.0 (iPod; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3
Nokia_N97 Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 NokiaN97-1/20.0.019; Profile/MIDP-2.1 Configuration/CLDC-1.1) AppleWebKit/525 (KHTML, like Gecko) BrowserNG/7.1.18124
Opera_19_0_1326_59_on_Windows_8_1_X64 Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.102 Safari/537.36 OPR/19.0.1326.59
Opera_Mini_on_Symbian Opera/9.80 (J2ME/MIDP; Opera Mini/9.80 (S60; SymbOS; Opera Mobi/23.348; U; en) Presto/2.5.25 Version/10.54
Opera浏览器_on_Mac_OS_X_10_6 Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; en) Presto/2.9.168 Version/11.52
Opera浏览器_on_Windows_7 Opera/9.80 (Windows NT 6.1; U; en) Presto/2.9.168 Version/11.52
Opera浏览器_on_XP Opera/9.80 (Windows NT 5.1; U; en) Presto/2.9.168 Version/11.52
QQ浏览器7_0_on_Windows_7_x64_IE9 Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; QQBrowser/7.0.3698.400)
QQ浏览器7_0_on_Windows_XP_x86_IE6 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 732; .NET4.0C; .NET4.0E)
QQ浏览器7_7_2_on_Windows_8_1_X64 Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0; QQBrowser/7.7.28658.400) like Gecko
Safari_on_Mac_OS_X_10_6 Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-US) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1
Safari_on_Windows_7 Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27
UC浏览器9_9_3_on_Huawei_P6_Adorid_4_4_2 Mozilla/5.0?(Linux;?U;?Android?4.4.2;?zh-CN;?HUAWEI?P6-C00?Build/HuaweiP6-C00)?AppleWebKit/533.1?(KHTML,?like?Gecko)?Version/4.0?UCBrowser/9.9.3.478?U3/0.8.0?Mobile?Safari/533.1
UC浏览器9_9_6_on_红米1S_Adorid_4_3 Mozilla/5.0?(Linux;?U;?Android?4.3;?zh-CN;?HM?1SW?Build/JLS36C)?AppleWebKit/533.1?(KHTML,?like?Gecko)?Version/4.0?UCBrowser/9.9.6.495?U3/0.8.0?Mobile?Safari/533.1
UC浏览器PC版_高速模式_on_Windows_8_1_X64 Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 UBrowser/1.0.355.1275 Safari/537.36
UC浏览器PC版_兼容模式_on_Windows_8_1_X64 Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0 UBrowser/1.0.355.1275) like Gecko
UC浏览器PC手机模拟器 Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; .NET4.0E)/UCWEB 7.4.0.57/31/999
Waterfox_16_0_on_Windows_7_x64 Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:16.0) Gecko/20121026 Firefox/16.0
WebOS_HP_Touchpad Mozilla/5.0 (hp-tablet; Linux; hpwOS/3.0.0; U; en-US) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/233.70 Safari/534.6 TouchPad/1.0
Windows_Phone_Mango Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; HTC; Titan)
Windows_Phone_OS_7_5_and_IE_9 Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)
安卓_N1 Mozilla/5.0 (Linux; U; Android 2.3.7; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
安卓_Opera_Mobile Opera/9.80 (Android 2.3.4; Linux; Opera Mobi/build-1107180945; U; en-GB) Presto/2.8.149 Version/11.10
安卓_Pad_Moto_Xoom Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13
安卓_QQ浏览器_For_安卓 MQQBrowser/26 Mozilla/5.0 (Linux; U; Android 2.3.7; zh-cn; MB200 Build/GRJ22; CyanogenMod-7) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
安卓_UC_For_安卓 JUC (Linux; U; 2.3.7; zh-cn; MB200; 800*480) UCWEB7.9.3.103/139/999
安卓_火狐手机版Fennec Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0a1) Gecko/20110623 Firefox/7.0a1 Fennec/7.0a1
百度浏览器6_5_on_Windows_8_1_X64 Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 BIDUBrowser/6.x Safari/537.36
黑莓6 Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en) AppleWebKit/534.1+ (KHTML, like Gecko) Version/6.0.0.337 Mobile Safari/534.1+
黑莓7 Mozilla/5.0 (BlackBerry; U; BlackBerry 9850; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.115 Mobile Safari/534.11+
火狐_8_on_Linux_X11 Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0
火狐_8_on_Mac_OS_X_10_6 Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6.8; en-US; rv:8.0) Gecko/20100101 Firefox/8.0
火狐_8_on_Windows_7 Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:8.0) Gecko/20100101 Firefox/8.0
火狐_8_on_XP Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:8.0) Gecko/20100101 Firefox/8.0
火狐_x64_3_6_10_on_Ubuntu_10_10_x64 Mozilla/5.0 (X11; U; Linux x86_64; zh-CN; rv:1.9.2.10) Gecko/20100922 Ubuntu/10.10 (maverick) Firefox/3.6.10
火狐_x64_4_0b13pre_on_Windows_7_x64 Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:2.0b13pre) Gecko/20110307 Firefox/4.0b13pre
火狐_x64_on_Ubuntu_12_04_1_x64 Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:16.0) Gecko/20100101 Firefox/16.0
火狐_x86_3_6_15_on_Windows_7_x64 Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15
猎豹浏览器1_5_9_2888_急速模式on_Windows_7_x64 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.84 Safari/535.11 LBBROWSER
猎豹浏览器1_5_9_2888_兼容模式_on_Windows_7_x64 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
猎豹浏览器2_0_10_3198_急速模式on_Windows_7_x64 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.71 Safari/537.1 LBBROWSER
猎豹浏览器2_0_10_3198_兼容模式on_Windows_7_x64 Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; LBBROWSER)
猎豹浏览器2_0_10_3198_兼容模式on_Windows_XP_x86_IE6 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 732; .NET4.0C; .NET4.0E; LBBROWSER)"
搜狗浏览器4_0_高速模式_on_Windows_XP_x86 Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.84 Safari/535.11 SE 2.X MetaSr 1.0
搜狗浏览器4_0_兼容模式_on_Windows_XP_x86_IE6 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; SV1; QQDownload 732; .NET4.0C; .NET4.0E; SE 2.X MetaSr 1.0)
搜狗浏览器5_0_高速模式_on_Windows_10_X64 Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 SE 2.X MetaSr 1.0
搜狗浏览器5_1_高速模式_on_Windows_8_1_X64 Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36 SE 2.X MetaSr 1.0
搜狗浏览器5_1_兼容模式_on_Windows_8_1_X64 Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0; SE 2.X MetaSr 1.0) like Gecko
淘宝浏览器2_0_on_Windows_7_x64 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.11 TaoBrowser/2.0 Safari/536.11
微信5_4_on_Huawei_P6_Adorid_4_4_2 Mozilla/5.0 (Linux; Android 4.4.2; HUAWEI P6-C00 Build/HuaweiP6-C00) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36 MicroMessenger/5.4.0.66_r807534.480 NetType/WIFI
微信6_0_on_红米1S_Adorid_4_3 Mozilla/5.0?(Linux;?U;?Android?4.3;?zh-cn;?HM?1SW?Build/JLS36C)?AppleWebKit/534.30?(KHTML,?like?Gecko)?Version/4.0?Mobile?Safari/534.30?MicroMessenger/6.0.0.50_r844973.501?NetType/WIFI
自带浏览器_on_Huawei_P6_Adorid_4_4_2 Mozilla/5.0?(Linux;?Android?4.4.2;?HUAWEI?P6-C00?Build/HuaweiP6-C00)?AppleWebKit/537.36?(KHTML,?like?Gecko)?Version/4.0?Chrome/30.0.0.0?Mobile?Safari/537.36
自带浏览器_on_安卓_2_2 Mozilla/5.0 (Linux; U; Android 2.2.1; zh-cn; HTC_Wildfire_A3333 Build/FRG83D) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
自带浏览器_on_安卓_2_3_5 Mozilla/5.0 (Linux; U; Android 2.3.5; en-us; HTC Vision Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
自带浏览器_on_红米1S_Adorid_4_3 Mozilla/5.0?(Linux;?U;?Android?4.3;?zh-cn;?HM?1SW?Build/JLS36C)?AppleWebKit/537.36?(KHTML,?like?Gecko)?Version/4.0?Mobile?Safari/537.36?XiaoMi/MiuiBrowser/2.0.1

PHPExcel遍历获取excel数据为csv格式 12141

作者为 发表

网站建设

<?php 

//首先导入PHPExcel  
require_once 'PHPExcel.php';  
  
$filePath = "test.xlsx";  
  
//建立reader对象  
$PHPReader = new PHPExcel_Reader_Excel2007();  
if(!$PHPReader->canRead($filePath)){  
    $PHPReader = new PHPExcel_Reader_Excel5();  
    if(!$PHPReader->canRead($filePath)){  
        echo 'no Excel';  
        return ;  
    }  
}  
  
//建立excel对象,此时你即可以通过excel对象读取文件,也可以通过它写入文件  
$PHPExcel = $PHPReader->load($filePath);  
/**获取工作表数量*/  
$sheetCount = $PHPExcel->getSheetCount();
for($sheetid=0;$sheetid<=$sheetCount-1;$sheetid++){
/**读取excel文件中的第N个工作表*/  
$currentSheet = $PHPExcel->getSheet($sheetid);  
//获取sheet名
$currentSheetName = $currentSheet->getTitle();  
/**取得最大的列号*/  
$allColumn = $currentSheet->getHighestColumn();  
/**取得一共有多少行*/  
$allRow = $currentSheet->getHighestRow();  
  
//循环读取每个单元格的内容。注意行从1开始,列从A开始  
for($rowIndex=1;$rowIndex<=$allRow;$rowIndex++){
	$tmpline = NULL;  
    for($colIndex='A';$colIndex<=$allColumn;$colIndex++){  
        $addr = $colIndex.$rowIndex;  
        $cell = $currentSheet->getCell($addr)->getValue();  
        if($cell instanceof PHPExcel_RichText)     //富文本转换字符串  
            $cell = $cell->__toString();  
              $tmpline .= $cell.",";
      
    } 
    $tmpline .= "\n";
    $tmpline=str_replace(",\n","\n",$tmpline);
  echo $currentSheetName.",".$tmpline;
}
}
?>


<?php
//连接
$c = new PDO( "sqlsrv:server=(local); Database = ", "sa", "123456", array(PDO::SQLSRV_ATTR_DIRECT_QUERY => true)); 


//返回不含字段名称的查询
function query($query){
	global $c;
	//定义全局变量
	$stmt = $c->prepare( $query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
	$stmt->execute();
	global $rowcount;
	$rowcount=NULL;
	//判断sql类型
	 $rowcount = $stmt->rowCount();
	if(stripos($query, 'update') !== false){
	      return "UP".$rowcount; 
	}elseif(stripos($query, 'delete') !== false){
	      return "DE".$rowcount; 
	}elseif(stripos($query, 'insert') !== false){
	      return "IN".$rowcount; 
	}else{
	//初始化变量
	$content=NULL;
	if( $stmt->rowCount() == 0){
	      return "";
	}else{
	   while ( $row = $stmt->fetch( PDO::FETCH_NUM ) ){
		for($i = 0; $i < $stmt->columnCount(); $i++)
	     {
	          $type=gettype($row[$i]);
	          //判断是否object类型
	          if ($type=="object"){
	          	 $var=$row[$i];
	          	 //格式化时间
	          	 $time=str_replace("T"," ",$var->format(DateTime::ISO8601));
	          	 $time=substr($time,0,19);
	          	 $time=$time.".000"; 
	         	 $content=$content.$time.",";
	          }else{
	          	  $ctmp=str_replace(",",",",$row[$i]);
	          	  $content=$content.$ctmp.",";
	          	  //追加
	          }
	     }
	     $content=$content."\n";
	}
	$content=str_replace(",\n","\n",$content);
	return $content;
	}
	}
}


//返回含字段名称的查询
function qt($query){
	global $c;
	$stmt = $c->prepare( $query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
	$stmt->execute();
	global $rowcount;
	$rowcount=NULL;
	 $rowcount = $stmt->rowCount();
	if(stripos($query, 'update') !== false){
	      return "UP".$rowcount; 
	}elseif(stripos($query, 'delete') !== false){
	      return "DE".$rowcount; 
	}elseif(stripos($query, 'insert') !== false){
	      return "IN".$rowcount; 
	}else{
	$content=NULL;
	if( $stmt->rowCount() == 0){
	      return "NO";
	}else{
	 $a = $stmt->fetch( PDO::FETCH_ASSOC);
	 $Fields = array_keys($a); 
	 global $titles;
	 $titles=NULL;
	 //循环获取字段名称
	 for($i = 0; $i < $stmt->columnCount(); $i++)
		{
		$name=iconv('GB2312','UTF-8',$Fields[$i]);
		$titles=$titles."$name,";
		} 
		$titles=$titles."\r\n";
		$titles=str_replace(",\r\n","",$titles);
		$content = $titles."\r\n";
	   $stmt->execute();
	   while ( $row = $stmt->fetch( PDO::FETCH_NUM ) ){
		for($i = 0; $i < $stmt->columnCount(); $i++)
	     {
	          $type=gettype($row[$i]);
	          if ($type=="object"){
	          	 $var=$row[$i];
	          	 $time=str_replace("T"," ",$var->format(DateTime::ISO8601));
	          	 $time=substr($time,0,19);
	          	 $time=$time.".000"; 
	         	 $content=$content.$time.",";
	          }else{
	          	  $ctmp=str_replace(",",",",$row[$i]);
	          	  $content=$content.$ctmp.",";
	          }
	     }
	     $content=$content."\r\n";
	}
	$content=str_replace(",\r\n","\r\n",$content);
	return $content;
	}
	}
}


//仅执行
function get($sql){
	global $c;
	global $result;
	$result = $c->prepare( $sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
	$result->execute();
	global $rowcount;
	$rowcount=NULL;
	 $rowcount = $result->rowCount();
}
?>


PHP 环境探针 17757

作者为 发表

网站建设

<?php
/* ---------------------------------------------------- */
/* 程序名称: PHP探针
/* 程序功能: 探测系统的Web服务器运行环境
/* Date: 1970-01-01 / 2012-07-08
/* ---------------------------------------------------- */

error_reporting(0); //抑制所有错误信息
@header("content-Type: text/html; charset=utf-8"); //语言强制
ob_start();
date_default_timezone_set('Asia/Shanghai');//此句用于消除时间差

$title = 'Gimhoy.com PHP探针';

$version = "v0.4.7"; //版本号



define('HTTP_HOST', preg_replace('~^www\.~i', '', $_SERVER['HTTP_HOST']));



$time_start = microtime_float();



function memory_usage() 
{

	$memory	 = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB';

	return $memory;

}


// 计时

function microtime_float() 
{

	$mtime = microtime();

	$mtime = explode(' ', $mtime);

	return $mtime[1] + $mtime[0];

}


//单位转换
function formatsize($size) 
{
	$danwei=array(' B ',' K ',' M ',' G ',' T ');
	$allsize=array();
	$i=0;

	for($i = 0; $i <5; $i++) 
	{
		if(floor($size/pow(1024,$i))==0){break;}
	}

	for($l = $i-1; $l >=0; $l--) 
	{
		$allsize1[$l]=floor($size/pow(1024,$l));
		$allsize[$l]=$allsize1[$l]-$allsize1[$l+1]*1024;
	}

	$len=count($allsize);

	for($j = $len-1; $j >=0; $j--) 
	{
		$fsize=$fsize.$allsize[$j].$danwei[$j];
	}	
	return $fsize;
}


function valid_email($str) 
{

	return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;

}


//检测PHP设置参数

function show($varName)
{

	switch($result = get_cfg_var($varName))
	{

		case 0:

			return '<font color="red">×</font>';

		break;
		

		case 1:

			return '<font color="green">√</font>';

		break;
		

		default:

			return $result;

		break;

	}

}



//保留服务器性能测试结果

$valInt = isset($_POST['pInt']) ? $_POST['pInt'] : "未测试";

$valFloat = isset($_POST['pFloat']) ? $_POST['pFloat'] : "未测试";

$valIo = isset($_POST['pIo']) ? $_POST['pIo'] : "未测试";



if ($_GET['act'] == "phpinfo") 
{

	phpinfo();

	exit();

} 
elseif($_POST['act'] == "整型测试")
{

	$valInt = test_int();

} 
elseif($_POST['act'] == "浮点测试")
{

	$valFloat = test_float();

} 
elseif($_POST['act'] == "IO测试")
{

	$valIo = test_io();

} 
//网速测试-开始
elseif($_POST['act']=="开始测试")
{
?>
	<script language="javascript" type="text/javascript">
		var acd1;
		acd1 = new Date();
		acd1ok=acd1.getTime();
	</script>
	<?php
	for($i=1;$i<=100000;$i++)
	{
		echo "<!--567890#########0#########0#########0#########0#########0#########0#########0#########012345-->";
	}
	?>
	<script language="javascript" type="text/javascript">
		var acd2;
		acd2 = new Date();
		acd2ok=acd2.getTime();
		window.location = '?speed=' +(acd2ok-acd1ok)+'#w_networkspeed';
	</script>
<?php
}
//网速测试-结束
elseif($_GET['act'] == "Function")
{
	$arr = get_defined_functions();
	Function php()
	{
	}
	echo "<pre>";
	Echo "这里显示系统所支持的所有函数,和自定义函数\n";
	print_r($arr);
	echo "</pre>";
	exit();
}elseif($_GET['act'] == "disable_functions")
{
	$disFuns=get_cfg_var("disable_functions");
	if(empty($disFuns))
	{
		$arr = '<font color=red>×</font>';
	}
	else
	{ 
		$arr = $disFuns;
	}
	Function php()
	{
	}
	echo "<pre>";
	Echo "这里显示系统被禁用的函数\n";
	print_r($arr);
	echo "</pre>";
	exit();
}



//MySQL检测

if ($_POST['act'] == 'MySQL检测')
{

	$host = isset($_POST['host']) ? trim($_POST['host']) : '';

	$port = isset($_POST['port']) ? (int) $_POST['port'] : '';

	$login = isset($_POST['login']) ? trim($_POST['login']) : '';

	$password = isset($_POST['password']) ? trim($_POST['password']) : '';

	$host = preg_match('~[^a-z0-9\-\.]+~i', $host) ? '' : $host;

	$port = intval($port) ? intval($port) : '';

	$login = preg_match('~[^a-z0-9\_\-]+~i', $login) ? '' : htmlspecialchars($login);

	$password = is_string($password) ? htmlspecialchars($password) : '';

}
elseif ($_POST['act'] == '函数检测')
{

	$funRe = "函数".$_POST['funName']."支持状况检测结果:".isfun1($_POST['funName']);

} 
elseif ($_POST['act'] == '邮件检测')
{

	$mailRe = "邮件发送检测结果:发送";
	if($_SERVER['SERVER_PORT']==80){$mailContent = "http://".$_SERVER['SERVER_NAME'].($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']);}
	else{$mailContent = "http://".$_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT'].($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']);}
	$mailRe .= (false !== @mail($_POST["mailAdd"], $mailContent, "This is a test mail!")) ? "完成":"失败";

}


//网络速度测试
if(isset($_POST['speed']))
{
	$speed=round(100/($_POST['speed']/1000),2);
}
elseif($_GET['speed']=="0")
{
	$speed=6666.67;
}
elseif(isset($_GET['speed']) and $_GET['speed']>0)
{
	$speed=round(100/($_GET['speed']/1000),2); //下载速度:$speed kb/s
}
else
{
	$speed="<font color=\"red\">&nbsp;未探测&nbsp;</font>";
}	
	
	

// 检测函数支持

function isfun($funName = '')
{

    if (!$funName || trim($funName) == '' || preg_match('~[^a-z0-9\_]+~i', $funName, $tmp)) return '错误';

	return (false !== function_exists($funName)) ? '<font color="green">√</font>' : '<font color="red">×</font>';
}
function isfun1($funName = '')
{
    if (!$funName || trim($funName) == '' || preg_match('~[^a-z0-9\_]+~i', $funName, $tmp)) return '错误';
	return (false !== function_exists($funName)) ? '√' : '×';
}



//整数运算能力测试

function test_int()
{

	$timeStart = gettimeofday();

	for($i = 0; $i < 3000000; $i++)
	{

		$t = 1+1;

	}

	$timeEnd = gettimeofday();

	$time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"];

	$time = round($time, 3)."秒";

	return $time;

}



//浮点运算能力测试

function test_float()
{

	//得到圆周率值

	$t = pi();

	$timeStart = gettimeofday();



	for($i = 0; $i < 3000000; $i++)
	{

		//开平方

		sqrt($t);

	}



	$timeEnd = gettimeofday();

	$time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"];

	$time = round($time, 3)."秒";

	return $time;

}



//IO能力测试

function test_io()
{

	$fp = @fopen(PHPSELF, "r");

	$timeStart = gettimeofday();

	for($i = 0; $i < 10000; $i++) 
	{

		@fread($fp, 10240);

		@rewind($fp);

	}

	$timeEnd = gettimeofday();

	@fclose($fp);

	$time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"];

	$time = round($time, 3)."秒";

	return($time);

}

function GetCoreInformation() {$data = file('/proc/stat');$cores = array();foreach( $data as $line ) {if( preg_match('/^cpu[0-9]/', $line) ){$info = explode(' ', $line);$cores[]=array('user'=>$info[1],'nice'=>$info[2],'sys' => $info[3],'idle'=>$info[4],'iowait'=>$info[5],'irq' => $info[6],'softirq' => $info[7]);}}return $cores;}
function GetCpuPercentages($stat1, $stat2) {if(count($stat1)!==count($stat2)){return;}$cpus=array();for( $i = 0, $l = count($stat1); $i < $l; $i++) {	$dif = array();	$dif['user'] = $stat2[$i]['user'] - $stat1[$i]['user'];$dif['nice'] = $stat2[$i]['nice'] - $stat1[$i]['nice'];	$dif['sys'] = $stat2[$i]['sys'] - $stat1[$i]['sys'];$dif['idle'] = $stat2[$i]['idle'] - $stat1[$i]['idle'];$dif['iowait'] = $stat2[$i]['iowait'] - $stat1[$i]['iowait'];$dif['irq'] = $stat2[$i]['irq'] - $stat1[$i]['irq'];$dif['softirq'] = $stat2[$i]['softirq'] - $stat1[$i]['softirq'];$total = array_sum($dif);$cpu = array();foreach($dif as $x=>$y) $cpu[$x] = round($y / $total * 100, 2);$cpus['cpu' . $i] = $cpu;}return $cpus;}
$stat1 = GetCoreInformation();sleep(1);$stat2 = GetCoreInformation();$data = GetCpuPercentages($stat1, $stat2);
$cpu_show = $data['cpu0']['user']."%us,  ".$data['cpu0']['sys']."%sy,  ".$data['cpu0']['nice']."%ni, ".$data['cpu0']['idle']."%id,  ".$data['cpu0']['iowait']."%wa,  ".$data['cpu0']['irq']."%irq,  ".$data['cpu0']['softirq']."%softirq";
function makeImageUrl($title, $data) {$api='http://api.yahei.net/tz/cpu_show.php?id=';$url.=$data['user'].',';$url.=$data['nice'].',';$url.=$data['sys'].',';$url.=$data['idle'].',';$url.=$data['iowait'];$url.='&chdl=User|Nice|Sys|Idle|Iowait&chdlp=b&chl=';$url.=$data['user'].'%25|';$url.=$data['nice'].'%25|';$url.=$data['sys'].'%25|';$url.=$data['idle'].'%25|';$url.=$data['iowait'].'%25';$url.='&chtt=Core+'.$title;return $api.base64_encode($url);}
if($_GET['act'] == "cpu_percentage"){echo "<center><b><font face='Microsoft YaHei' color='#666666' size='3'>图片加载慢,请耐心等待!</font></b><br /><br />";foreach( $data as $k => $v ) {echo '<img src="' . makeImageUrl( $k, $v ) . '" style="width:360px;height:240px;border: #CCCCCC 1px solid;background: #FFFFFF;margin:5px;padding:5px;" />';}echo "</center>";exit();}



// 根据不同系统取得CPU相关信息

switch(PHP_OS)
{

	case "Linux":

		$sysReShow = (false !== ($sysInfo = sys_linux()))?"show":"none";

	break;
	

	case "FreeBSD":

		$sysReShow = (false !== ($sysInfo = sys_freebsd()))?"show":"none";

	break;
/*	

	case "WINNT":

		$sysReShow = (false !== ($sysInfo = sys_windows()))?"show":"none";

	break;
*/	

	default:

	break;

}



//linux系统探测

function sys_linux()

{

    // CPU

    if (false === ($str = @file("/proc/cpuinfo"))) return false;

    $str = implode("", $str);

    @preg_match_all("/model\s+name\s{0,}\:+\s{0,}([\w\s\)\(\@.-]+)([\r\n]+)/s", $str, $model);

    @preg_match_all("/cpu\s+MHz\s{0,}\:+\s{0,}([\d\.]+)[\r\n]+/", $str, $mhz);

    @preg_match_all("/cache\s+size\s{0,}\:+\s{0,}([\d\.]+\s{0,}[A-Z]+[\r\n]+)/", $str, $cache);

    @preg_match_all("/bogomips\s{0,}\:+\s{0,}([\d\.]+)[\r\n]+/", $str, $bogomips);

    if (false !== is_array($model[1]))

	{

        $res['cpu']['num'] = sizeof($model[1]);
		/*

        for($i = 0; $i < $res['cpu']['num']; $i++)

        {

            $res['cpu']['model'][] = $model[1][$i].'&nbsp;('.$mhz[1][$i].')';

            $res['cpu']['mhz'][] = $mhz[1][$i];

            $res['cpu']['cache'][] = $cache[1][$i];

            $res['cpu']['bogomips'][] = $bogomips[1][$i];

        }*/
		if($res['cpu']['num']==1)
			$x1 = '';
		else
			$x1 = ' ×'.$res['cpu']['num'];
		$mhz[1][0] = ' | 频率:'.$mhz[1][0];
		$cache[1][0] = ' | 二级缓存:'.$cache[1][0];
		$bogomips[1][0] = ' | Bogomips:'.$bogomips[1][0];
		$res['cpu']['model'][] = $model[1][0].$mhz[1][0].$cache[1][0].$bogomips[1][0].$x1;

        if (false !== is_array($res['cpu']['model'])) $res['cpu']['model'] = implode("<br />", $res['cpu']['model']);

        if (false !== is_array($res['cpu']['mhz'])) $res['cpu']['mhz'] = implode("<br />", $res['cpu']['mhz']);

        if (false !== is_array($res['cpu']['cache'])) $res['cpu']['cache'] = implode("<br />", $res['cpu']['cache']);

        if (false !== is_array($res['cpu']['bogomips'])) $res['cpu']['bogomips'] = implode("<br />", $res['cpu']['bogomips']);

	}


    // NETWORK


    // UPTIME

    if (false === ($str = @file("/proc/uptime"))) return false;

    $str = explode(" ", implode("", $str));

    $str = trim($str[0]);

    $min = $str / 60;

    $hours = $min / 60;

    $days = floor($hours / 24);

    $hours = floor($hours - ($days * 24));

    $min = floor($min - ($days * 60 * 24) - ($hours * 60));

    if ($days !== 0) $res['uptime'] = $days."天";

    if ($hours !== 0) $res['uptime'] .= $hours."小时";

    $res['uptime'] .= $min."分钟";


    // MEMORY

    if (false === ($str = @file("/proc/meminfo"))) return false;

    $str = implode("", $str);

    preg_match_all("/MemTotal\s{0,}\:+\s{0,}([\d\.]+).+?MemFree\s{0,}\:+\s{0,}([\d\.]+).+?Cached\s{0,}\:+\s{0,}([\d\.]+).+?SwapTotal\s{0,}\:+\s{0,}([\d\.]+).+?SwapFree\s{0,}\:+\s{0,}([\d\.]+)/s", $str, $buf);
	preg_match_all("/Buffers\s{0,}\:+\s{0,}([\d\.]+)/s", $str, $buffers);


    $res['memTotal'] = round($buf[1][0]/1024, 2);

    $res['memFree'] = round($buf[2][0]/1024, 2);

    $res['memBuffers'] = round($buffers[1][0]/1024, 2);
	$res['memCached'] = round($buf[3][0]/1024, 2);

    $res['memUsed'] = $res['memTotal']-$res['memFree'];

    $res['memPercent'] = (floatval($res['memTotal'])!=0)?round($res['memUsed']/$res['memTotal']*100,2):0;


    $res['memRealUsed'] = $res['memTotal'] - $res['memFree'] - $res['memCached'] - $res['memBuffers']; //真实内存使用
	$res['memRealFree'] = $res['memTotal'] - $res['memRealUsed']; //真实空闲
    $res['memRealPercent'] = (floatval($res['memTotal'])!=0)?round($res['memRealUsed']/$res['memTotal']*100,2):0; //真实内存使用率

	$res['memCachedPercent'] = (floatval($res['memCached'])!=0)?round($res['memCached']/$res['memTotal']*100,2):0; //Cached内存使用率

    $res['swapTotal'] = round($buf[4][0]/1024, 2);

    $res['swapFree'] = round($buf[5][0]/1024, 2);

    $res['swapUsed'] = round($res['swapTotal']-$res['swapFree'], 2);

    $res['swapPercent'] = (floatval($res['swapTotal'])!=0)?round($res['swapUsed']/$res['swapTotal']*100,2):0;


    // LOAD AVG

    if (false === ($str = @file("/proc/loadavg"))) return false;

    $str = explode(" ", implode("", $str));

    $str = array_chunk($str, 4);

    $res['loadAvg'] = implode(" ", $str[0]);


    return $res;

}



//FreeBSD系统探测

function sys_freebsd()
{

	//CPU

	if (false === ($res['cpu']['num'] = get_key("hw.ncpu"))) return false;

	$res['cpu']['model'] = get_key("hw.model");

	//LOAD AVG

	if (false === ($res['loadAvg'] = get_key("vm.loadavg"))) return false;

	//UPTIME

	if (false === ($buf = get_key("kern.boottime"))) return false;

	$buf = explode(' ', $buf);

	$sys_ticks = time() - intval($buf[3]);

	$min = $sys_ticks / 60;

	$hours = $min / 60;

	$days = floor($hours / 24);

	$hours = floor($hours - ($days * 24));

	$min = floor($min - ($days * 60 * 24) - ($hours * 60));

	if ($days !== 0) $res['uptime'] = $days."天";

	if ($hours !== 0) $res['uptime'] .= $hours."小时";

	$res['uptime'] .= $min."分钟";

	//MEMORY

	if (false === ($buf = get_key("hw.physmem"))) return false;

	$res['memTotal'] = round($buf/1024/1024, 2);


	$str = get_key("vm.vmtotal");

	preg_match_all("/\nVirtual Memory[\:\s]*\(Total[\:\s]*([\d]+)K[\,\s]*Active[\:\s]*([\d]+)K\)\n/i", $str, $buff, PREG_SET_ORDER);

	preg_match_all("/\nReal Memory[\:\s]*\(Total[\:\s]*([\d]+)K[\,\s]*Active[\:\s]*([\d]+)K\)\n/i", $str, $buf, PREG_SET_ORDER);


	$res['memRealUsed'] = round($buf[0][2]/1024, 2);

	$res['memCached'] = round($buff[0][2]/1024, 2);

	$res['memUsed'] = round($buf[0][1]/1024, 2) + $res['memCached'];

	$res['memFree'] = $res['memTotal'] - $res['memUsed'];

	$res['memPercent'] = (floatval($res['memTotal'])!=0)?round($res['memUsed']/$res['memTotal']*100,2):0;


	$res['memRealPercent'] = (floatval($res['memTotal'])!=0)?round($res['memRealUsed']/$res['memTotal']*100,2):0;


	return $res;

}



//取得参数值 FreeBSD

function get_key($keyName)
{

	return do_command('sysctl', "-n $keyName");

}



//确定执行文件位置 FreeBSD

function find_command($commandName)
{

	$path = array('/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin', '/usr/local/sbin');

	foreach($path as $p) 
	{

		if (@is_executable("$p/$commandName")) return "$p/$commandName";

	}

	return false;

}



//执行系统命令 FreeBSD

function do_command($commandName, $args)
{

	$buffer = "";

	if (false === ($command = find_command($commandName))) return false;

	if ($fp = @popen("$command $args", 'r')) 
	{

		while (!@feof($fp))
		{

			$buffer .= @fgets($fp, 4096);

		}

		return trim($buffer);

	}

	return false;

}



//windows系统探测

function sys_windows()
{

	if (PHP_VERSION >= 5)
	{

		$objLocator = new COM("WbemScripting.SWbemLocator");

		$wmi = $objLocator->ConnectServer();

		$prop = $wmi->get("Win32_PnPEntity");

	}
	else
	{
		return false;

	}



	//CPU

	$cpuinfo = GetWMI($wmi,"Win32_Processor", array("Name","L2CacheSize","NumberOfCores"));

	$res['cpu']['num'] = $cpuinfo[0]['NumberOfCores'];

	if (null == $res['cpu']['num']) 
	{

		$res['cpu']['num'] = 1;

	}/*

	for ($i=0;$i<$res['cpu']['num'];$i++)
	{

		$res['cpu']['model'] .= $cpuinfo[0]['Name']."<br />";

		$res['cpu']['cache'] .= $cpuinfo[0]['L2CacheSize']."<br />";

	}*/
	$cpuinfo[0]['L2CacheSize'] = ' ('.$cpuinfo[0]['L2CacheSize'].')';
	if($res['cpu']['num']==1)
		$x1 = '';
	else
		$x1 = ' ×'.$res['cpu']['num'];
	$res['cpu']['model'] = $cpuinfo[0]['Name'].$cpuinfo[0]['L2CacheSize'].$x1;

	// SYSINFO

	$sysinfo = GetWMI($wmi,"Win32_OperatingSystem", array('LastBootUpTime','TotalVisibleMemorySize','FreePhysicalMemory','Caption','CSDVersion','SerialNumber','InstallDate'));

	$sysinfo[0]['Caption']=iconv('GBK', 'UTF-8',$sysinfo[0]['Caption']);

	$sysinfo[0]['CSDVersion']=iconv('GBK', 'UTF-8',$sysinfo[0]['CSDVersion']);

	$res['win_n'] = $sysinfo[0]['Caption']." ".$sysinfo[0]['CSDVersion']." 序列号:{$sysinfo[0]['SerialNumber']} 于".date('Y年m月d日H:i:s',strtotime(substr($sysinfo[0]['InstallDate'],0,14)))."安装";

	//UPTIME

	$res['uptime'] = $sysinfo[0]['LastBootUpTime'];


	$sys_ticks = 3600*8 + time() - strtotime(substr($res['uptime'],0,14));

	$min = $sys_ticks / 60;

	$hours = $min / 60;

	$days = floor($hours / 24);

	$hours = floor($hours - ($days * 24));

	$min = floor($min - ($days * 60 * 24) - ($hours * 60));

	if ($days !== 0) $res['uptime'] = $days."天";

	if ($hours !== 0) $res['uptime'] .= $hours."小时";

	$res['uptime'] .= $min."分钟";


	//MEMORY

	$res['memTotal'] = round($sysinfo[0]['TotalVisibleMemorySize']/1024,2);

	$res['memFree'] = round($sysinfo[0]['FreePhysicalMemory']/1024,2);

	$res['memUsed'] = $res['memTotal']-$res['memFree'];	//上面两行已经除以1024,这行不用再除了

	$res['memPercent'] = round($res['memUsed'] / $res['memTotal']*100,2);


	$swapinfo = GetWMI($wmi,"Win32_PageFileUsage", array('AllocatedBaseSize','CurrentUsage'));


	// LoadPercentage

	$loadinfo = GetWMI($wmi,"Win32_Processor", array("LoadPercentage"));

	$res['loadAvg'] = $loadinfo[0]['LoadPercentage'];


	return $res;

}



function GetWMI($wmi,$strClass, $strValue = array())
{

	$arrData = array();


	$objWEBM = $wmi->Get($strClass);

	$arrProp = $objWEBM->Properties_;

	$arrWEBMCol = $objWEBM->Instances_();

	foreach($arrWEBMCol as $objItem) 
	{

		@reset($arrProp);

		$arrInstance = array();

		foreach($arrProp as $propItem) 
		{

			eval("\$value = \$objItem->" . $propItem->Name . ";");

			if (empty($strValue)) 
			{

				$arrInstance[$propItem->Name] = trim($value);

			} 
			else
			{

				if (in_array($propItem->Name, $strValue)) 
				{

					$arrInstance[$propItem->Name] = trim($value);

				}

			}

		}

		$arrData[] = $arrInstance;

	}

	return $arrData;

}



//比例条

function bar($percent)
{

?>

	<div class="bar"><div class="barli" style="width:<?php echo $percent?>%">&nbsp;</div></div>

<?php

}



$uptime = $sysInfo['uptime']; //在线时间

$stime = date('Y-m-d H:i:s'); //系统当前时间

//硬盘

$dt = round(@disk_total_space(".")/(1024*1024*1024),3); //总
$df = round(@disk_free_space(".")/(1024*1024*1024),3); //可用
$du = $dt-$df; //已用
$hdPercent = (floatval($dt)!=0)?round($du/$dt*100,2):0;

$load = $sysInfo['loadAvg'];	//系统负载


//判断内存如果小于1G,就显示M,否则显示G单位
if($sysInfo['memTotal']<1024)
{
	$memTotal = $sysInfo['memTotal']." M";
	$mt = $sysInfo['memTotal']." M";
	$mu = $sysInfo['memUsed']." M";
	$mf = $sysInfo['memFree']." M";
	$mc = $sysInfo['memCached']." M";	//cache化内存
	$mb = $sysInfo['memBuffers']." M";	//缓冲
	$st = $sysInfo['swapTotal']." M";
	$su = $sysInfo['swapUsed']." M";
	$sf = $sysInfo['swapFree']." M";
	$swapPercent = $sysInfo['swapPercent'];
	$memRealUsed = $sysInfo['memRealUsed']." M"; //真实内存使用
	$memRealFree = $sysInfo['memRealFree']." M"; //真实内存空闲
	$memRealPercent = $sysInfo['memRealPercent']; //真实内存使用比率
	$memPercent = $sysInfo['memPercent']; //内存总使用率
	$memCachedPercent = $sysInfo['memCachedPercent']; //cache内存使用率
}
else
{
	$memTotal = round($sysInfo['memTotal']/1024,3)." G";
	$mt = round($sysInfo['memTotal']/1024,3)." G";
	$mu = round($sysInfo['memUsed']/1024,3)." G";
	$mf = round($sysInfo['memFree']/1024,3)." G";
	$mc = round($sysInfo['memCached']/1024,3)." G";
	$mb = round($sysInfo['memBuffers']/1024,3)." G";
	$st = round($sysInfo['swapTotal']/1024,3)." G";
	$su = round($sysInfo['swapUsed']/1024,3)." G";
	$sf = round($sysInfo['swapFree']/1024,3)." G";
	$swapPercent = $sysInfo['swapPercent'];
	$memRealUsed = round($sysInfo['memRealUsed']/1024,3)." G"; //真实内存使用
	$memRealFree = round($sysInfo['memRealFree']/1024,3)." G"; //真实内存空闲
	$memRealPercent = $sysInfo['memRealPercent']; //真实内存使用比率
	$memPercent = $sysInfo['memPercent']; //内存总使用率
	$memCachedPercent = $sysInfo['memCachedPercent']; //cache内存使用率
}


//网卡流量

$strs = @file("/proc/net/dev"); 



for ($i = 2; $i < count($strs); $i++ )
{
	preg_match_all( "/([^\s]+):[\s]{0,}(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/", $strs[$i], $info );
	$NetOutSpeed[$i] = $info[10][0];
	$NetInputSpeed[$i] = $info[2][0];
	$NetInput[$i] = formatsize($info[2][0]);
	$NetOut[$i]  = formatsize($info[10][0]);
}


//ajax调用实时刷新

if ($_GET['act'] == "rt")

{

	$arr=array('useSpace'=>"$du",'freeSpace'=>"$df",'hdPercent'=>"$hdPercent",'barhdPercent'=>"$hdPercent%",'TotalMemory'=>"$mt",'UsedMemory'=>"$mu",'FreeMemory'=>"$mf",'CachedMemory'=>"$mc",'Buffers'=>"$mb",'TotalSwap'=>"$st",'swapUsed'=>"$su",'swapFree'=>"$sf",'loadAvg'=>"$load",'uptime'=>"$uptime",'freetime'=>"$freetime",'bjtime'=>"$bjtime",'stime'=>"$stime",'memRealPercent'=>"$memRealPercent",'memRealUsed'=>"$memRealUsed",'memRealFree'=>"$memRealFree",'memPercent'=>"$memPercent%",'memCachedPercent'=>"$memCachedPercent",'barmemCachedPercent'=>"$memCachedPercent%",'swapPercent'=>"$swapPercent",'barmemRealPercent'=>"$memRealPercent%",'barswapPercent'=>"$swapPercent%",'NetOut2'=>"$NetOut[2]",'NetOut3'=>"$NetOut[3]",'NetOut4'=>"$NetOut[4]",'NetOut5'=>"$NetOut[5]",'NetOut6'=>"$NetOut[6]",'NetOut7'=>"$NetOut[7]",'NetOut8'=>"$NetOut[8]",'NetOut9'=>"$NetOut[9]",'NetOut10'=>"$NetOut[10]",'NetInput2'=>"$NetInput[2]",'NetInput3'=>"$NetInput[3]",'NetInput4'=>"$NetInput[4]",'NetInput5'=>"$NetInput[5]",'NetInput6'=>"$NetInput[6]",'NetInput7'=>"$NetInput[7]",'NetInput8'=>"$NetInput[8]",'NetInput9'=>"$NetInput[9]",'NetInput10'=>"$NetInput[10]",'NetOutSpeed2'=>"$NetOutSpeed[2]",'NetOutSpeed3'=>"$NetOutSpeed[3]",'NetOutSpeed4'=>"$NetOutSpeed[4]",'NetOutSpeed5'=>"$NetOutSpeed[5]",'NetInputSpeed2'=>"$NetInputSpeed[2]",'NetInputSpeed3'=>"$NetInputSpeed[3]",'NetInputSpeed4'=>"$NetInputSpeed[4]",'NetInputSpeed5'=>"$NetInputSpeed[5]");

	$jarr=json_encode($arr); 
	$_GET['callback'] = htmlspecialchars($_GET['callback']);

	echo $_GET['callback'],'(',$jarr,')';

	exit;

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title><?php echo $title.$version; ?></title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- Powered by: Yahei.Net -->

<style type="text/css">
<!--
* {font-family: "Microsoft Yahei",Tahoma, Arial; }
body{text-align: center; margin: 0 auto; padding: 0; background-color:#fafafa;font-size:12px;font-family:Tahoma, Arial}
h1 {font-size: 26px; padding: 0; margin: 0; color: #333333; font-family: "Lucida Sans Unicode","Lucida Grande",sans-serif;}
h1 small {font-size: 11px; font-family: Tahoma; font-weight: bold; }
a{color: #666; text-decoration:none;}
a.black{color: #000000; text-decoration:none;}
table{width:100%;clear:both;padding: 0; margin: 0 0 10px;border-collapse:collapse; border-spacing: 0;
box-shadow: 1px 1px 1px #CCC;
-moz-box-shadow: 1px 1px 1px #CCC;
-webkit-box-shadow: 1px 1px 1px #CCC;
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=2, Direction=135, Color='#CCCCCC')";}
th{padding: 3px 6px; font-weight:bold;background:#dedede;color:#626262;border:1px solid #cccccc; text-align:left;}
tr{padding: 0; background:#FFFFFF;}
td{padding: 3px 6px; border:1px solid #CCCCCC;}
.w_logo{height:25px;text-align:center;color:#333;FONT-SIZE: 15px; width:13%; }
.w_top{height:25px;text-align:center; width:8.7%;}
.w_top:hover{background:#dadada;}
.w_foot{height:25px;text-align:center; background:#dedede;}
input{padding: 2px; background: #FFFFFF; border-top:1px solid #666666; border-left:1px solid #666666; border-right:1px solid #CCCCCC; border-bottom:1px solid #CCCCCC; font-size:12px}
input.btn{font-weight: bold; height: 20px; line-height: 20px; padding: 0 6px; color:#666666; background: #f2f2f2; border:1px solid #999;font-size:12px}
.bar {border:1px solid #999999; background:#FFFFFF; height:5px; font-size:2px; width:89%; margin:2px 0 5px 0;padding:1px; overflow: hidden;}
.bar_1 {border:1px dotted #999999; background:#FFFFFF; height:5px; font-size:2px; width:89%; margin:2px 0 5px 0;padding:1px; overflow: hidden;}
.barli_red{background:#ff6600; height:5px; margin:0px; padding:0;}
.barli_blue{background:#0099FF; height:5px; margin:0px; padding:0;}
.barli_green{background:#36b52a; height:5px; margin:0px; padding:0;}
.barli_black{background:#333; height:5px; margin:0px; padding:0;}
.barli_1{background:#999999; height:5px; margin:0px; padding:0;}
.barli{background:#36b52a; height:5px; margin:0px; padding:0;}
#page {width: 960px; padding: 0 auto; margin: 0 auto; text-align: left;}
#header{position:relative; padding:5px;}
.w_small{font-family: Courier New;}
.w_number{color: #f800fe;}
.sudu {padding: 0; background:#5dafd1; }
.suduk { margin:0px; padding:0;}
.resYes{}
.resNo{color: #FF0000;}
.word{word-break:break-all;}
-->
</style>

<script language="JavaScript" type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.7/jquery.min.js"></script>

<script type="text/javascript"> 

<!--

$(document).ready(function(){getJSONData();});
var OutSpeed2=<?php echo floor($NetOutSpeed[2]) ?>;
var OutSpeed3=<?php echo floor($NetOutSpeed[3]) ?>;
var OutSpeed4=<?php echo floor($NetOutSpeed[4]) ?>;
var OutSpeed5=<?php echo floor($NetOutSpeed[5]) ?>;
var InputSpeed2=<?php echo floor($NetInputSpeed[2]) ?>;
var InputSpeed3=<?php echo floor($NetInputSpeed[3]) ?>;
var InputSpeed4=<?php echo floor($NetInputSpeed[4]) ?>;
var InputSpeed5=<?php echo floor($NetInputSpeed[5]) ?>;

function getJSONData()

{

	setTimeout("getJSONData()", 1000);

	$.getJSON('?act=rt&callback=?', displayData);

}
function ForDight(Dight,How)
{ 
  if (Dight<0){
  	var Last=0+"B/s";
  }else if (Dight<1024){
  	var Last=Math.round(Dight*Math.pow(10,How))/Math.pow(10,How)+"B/s";
  }else if (Dight<1048576){
  	Dight=Dight/1024;
  	var Last=Math.round(Dight*Math.pow(10,How))/Math.pow(10,How)+"K/s";
  }else{
  	Dight=Dight/1048576;
  	var Last=Math.round(Dight*Math.pow(10,How))/Math.pow(10,How)+"M/s";
  }
	return Last; 
}

function displayData(dataJSON)

{
	$("#useSpace").html(dataJSON.useSpace);

	$("#freeSpace").html(dataJSON.freeSpace);
	$("#hdPercent").html(dataJSON.hdPercent);
	$("#barhdPercent").width(dataJSON.barhdPercent);

	$("#TotalMemory").html(dataJSON.TotalMemory);

	$("#UsedMemory").html(dataJSON.UsedMemory);

	$("#FreeMemory").html(dataJSON.FreeMemory);

	$("#CachedMemory").html(dataJSON.CachedMemory);
	$("#Buffers").html(dataJSON.Buffers);

	$("#TotalSwap").html(dataJSON.TotalSwap);

	$("#swapUsed").html(dataJSON.swapUsed);

	$("#swapFree").html(dataJSON.swapFree);

	$("#swapPercent").html(dataJSON.swapPercent);

	$("#loadAvg").html(dataJSON.loadAvg);

	$("#uptime").html(dataJSON.uptime);

	$("#freetime").html(dataJSON.freetime);

	$("#stime").html(dataJSON.stime);

	$("#bjtime").html(dataJSON.bjtime);

	$("#memRealUsed").html(dataJSON.memRealUsed);
	$("#memRealFree").html(dataJSON.memRealFree);
	$("#memRealPercent").html(dataJSON.memRealPercent);

	$("#memPercent").html(dataJSON.memPercent);
	$("#barmemPercent").width(dataJSON.memPercent);

	$("#barmemRealPercent").width(dataJSON.barmemRealPercent);
	$("#memCachedPercent").html(dataJSON.memCachedPercent);
	$("#barmemCachedPercent").width(dataJSON.barmemCachedPercent);

	$("#barswapPercent").width(dataJSON.barswapPercent);

	$("#NetOut2").html(dataJSON.NetOut2);

	$("#NetOut3").html(dataJSON.NetOut3);

	$("#NetOut4").html(dataJSON.NetOut4);

	$("#NetOut5").html(dataJSON.NetOut5);

	$("#NetOut6").html(dataJSON.NetOut6);

	$("#NetOut7").html(dataJSON.NetOut7);

	$("#NetOut8").html(dataJSON.NetOut8);

	$("#NetOut9").html(dataJSON.NetOut9);

	$("#NetOut10").html(dataJSON.NetOut10);
	$("#NetInput2").html(dataJSON.NetInput2);
	$("#NetInput3").html(dataJSON.NetInput3);
	$("#NetInput4").html(dataJSON.NetInput4);
	$("#NetInput5").html(dataJSON.NetInput5);
	$("#NetInput6").html(dataJSON.NetInput6);
	$("#NetInput7").html(dataJSON.NetInput7);
	$("#NetInput8").html(dataJSON.NetInput8);
	$("#NetInput9").html(dataJSON.NetInput9);
	$("#NetInput10").html(dataJSON.NetInput10);	
	$("#NetOutSpeed2").html(ForDight((dataJSON.NetOutSpeed2-OutSpeed2),3));	OutSpeed2=dataJSON.NetOutSpeed2;
	$("#NetOutSpeed3").html(ForDight((dataJSON.NetOutSpeed3-OutSpeed3),3));	OutSpeed3=dataJSON.NetOutSpeed3;
	$("#NetOutSpeed4").html(ForDight((dataJSON.NetOutSpeed4-OutSpeed4),3));	OutSpeed4=dataJSON.NetOutSpeed4;
	$("#NetOutSpeed5").html(ForDight((dataJSON.NetOutSpeed5-OutSpeed5),3));	OutSpeed5=dataJSON.NetOutSpeed5;
	$("#NetInputSpeed2").html(ForDight((dataJSON.NetInputSpeed2-InputSpeed2),3));	InputSpeed2=dataJSON.NetInputSpeed2;
	$("#NetInputSpeed3").html(ForDight((dataJSON.NetInputSpeed3-InputSpeed3),3));	InputSpeed3=dataJSON.NetInputSpeed3;
	$("#NetInputSpeed4").html(ForDight((dataJSON.NetInputSpeed4-InputSpeed4),3));	InputSpeed4=dataJSON.NetInputSpeed4;
	$("#NetInputSpeed5").html(ForDight((dataJSON.NetInputSpeed5-InputSpeed5),3));	InputSpeed5=dataJSON.NetInputSpeed5;

}

-->

</script>

</head>

<body>
<a name="w_top"></a>

<div id="page">

	
	<table>
		<tr>
			<th class="w_logo">Gimhoy.com PHP探针</th>
			<th class="w_top"><a href="#w_php">PHP参数</a></th>
			<th class="w_top"><a href="#w_module">组件支持</a></th>
			<th class="w_top"><a href="#w_module_other">第三方组件</a></th>
			<th class="w_top"><a href="#w_db">数据库支持</a></th>
			<th class="w_top"><a href="#w_performance">性能检测</a></th>
			<th class="w_top"><a href="#w_networkspeed">网速检测</a></th>
			<th class="w_top"><a href="#w_MySQL">MySQL检测</a></th>
			<th class="w_top"><a href="#w_function">函数检测</a></th>
			<th class="w_top"><a href="#w_mail">邮件检测</a></th>
			<th class="w_top"><a href="http://archives.gimhoy.cn/hishare/2013/01/e22fcdfc6333e2ea646672b83c56f158.zip">探针下载</a></th>
		</tr>
	</table>



<!--服务器相关参数-->

<table>

  <tr><th colspan="4">服务器参数</th></tr>

  <tr>

    <td>服务器域名/IP地址</td>

    <td colspan="3"><?php echo @get_current_user();?> - <?php echo $_SERVER['SERVER_NAME'];?>(<?php if('/'==DIRECTORY_SEPARATOR){echo $_SERVER['SERVER_ADDR'];}else{echo @gethostbyname($_SERVER['SERVER_NAME']);} ?>)&nbsp;&nbsp;你的IP地址是:<?php echo @$_SERVER['REMOTE_ADDR'];?></td>

  </tr>

  <tr>

    <td>服务器标识</td>

    <td colspan="3"><?php if($sysInfo['win_n'] != ''){echo $sysInfo['win_n'];}else{echo @php_uname();};?></td>

  </tr>

  <tr>

    <td width="13%">服务器操作系统</td>

    <td width="37%"><?php $os = explode(" ", php_uname()); echo $os[0];?> &nbsp;内核版本:<?php if('/'==DIRECTORY_SEPARATOR){echo $os[2];}else{echo $os[1];} ?></td>

    <td width="13%">服务器解译引擎</td>

    <td width="37%"><?php echo $_SERVER['SERVER_SOFTWARE'];?></td>

  </tr>

  <tr>

    <td>服务器语言</td>

    <td><?php echo getenv("HTTP_ACCEPT_LANGUAGE");?></td>

    <td>服务器端口</td>

    <td><?php echo $_SERVER['SERVER_PORT'];?></td>

  </tr>

  <tr>

	  <td>服务器主机名</td>

	  <td><?php if('/'==DIRECTORY_SEPARATOR ){echo $os[1];}else{echo $os[2];} ?></td>

	  <td>绝对路径</td>

	  <td><?php echo $_SERVER['DOCUMENT_ROOT']?str_replace('\\','/',$_SERVER['DOCUMENT_ROOT']):str_replace('\\','/',dirname(__FILE__));?></td>

	</tr>

  <tr>

	  <td>管理员邮箱</td>

	  <td><?php echo $_SERVER['SERVER_ADMIN'];?></td>

		<td>探针路径</td>

		<td><?php echo str_replace('\\','/',__FILE__)?str_replace('\\','/',__FILE__):$_SERVER['SCRIPT_FILENAME'];?></td>

	</tr>	

</table>



<?if("show"==$sysReShow){?>

<table>

  <tr><th colspan="6">服务器实时数据</th></tr>

  <tr>

    <td width="13%" >服务器当前时间</td>

    <td width="37%" ><span id="stime"><?php echo $stime;?></span></td>

    <td width="13%" >服务器已运行时间</td>

    <td width="37%" colspan="3"><span id="uptime"><?php echo $uptime;?></span></td>

  </tr>
  <tr>

    <td width="13%">CPU型号 [<?php echo $sysInfo['cpu']['num'];?>核]</td>

    <td width="87%" colspan="5"><?php echo $sysInfo['cpu']['model'];?></td>

  </tr>
  <tr>
    <td>CPU使用状况</td>
    <td colspan="5"><?php if('/'==DIRECTORY_SEPARATOR){echo $cpu_show." | <a href='".$phpSelf."?act=cpu_percentage' target='_blank' class='static'>查看图表</a>";}else{echo "暂时只支持Linux系统";}?>
	</td>
  </tr>
  <tr>
    <td>硬盘使用状况</td>
    <td colspan="5">
		总空间 <?php echo $dt;?>&nbsp;G,
		已用 <font color='#333333'><span id="useSpace"><?php echo $du;?></span></font>&nbsp;G,
		空闲 <font color='#333333'><span id="freeSpace"><?php echo $df;?></span></font>&nbsp;G,
		使用率 <span id="hdPercent"><?php echo $hdPercent;?></span>%
		<div class="bar"><div id="barhdPercent" class="barli_black" style="width:<?php echo $hdPercent;?>%" >&nbsp;</div> </div>
	</td>
  </tr>
  <tr>

		<td>内存使用状况</td>

		<td colspan="5">

<?php

$tmp = array(

    'memTotal', 'memUsed', 'memFree', 'memPercent',

    'memCached', 'memRealPercent',

    'swapTotal', 'swapUsed', 'swapFree', 'swapPercent'

);

foreach ($tmp AS $v) {

    $sysInfo[$v] = $sysInfo[$v] ? $sysInfo[$v] : 0;

}

?>

          物理内存:共

          <font color='#CC0000'><?php echo $memTotal;?> </font>

           , 已用

          <font color='#CC0000'><span id="UsedMemory"><?php echo $mu;?></span></font>

          , 空闲

          <font color='#CC0000'><span id="FreeMemory"><?php echo $mf;?></span></font>

          , 使用率

		  <span id="memPercent"><?php echo $memPercent;?></span>

          <div class="bar"><div id="barmemPercent" class="barli_green" style="width:<?php echo $memPercent?>%" >&nbsp;</div> </div>
<?php
//判断如果cache为0,不显示
if($sysInfo['memCached']>0)
{
?>		
		  Cache化内存为 <span id="CachedMemory"><?php echo $mc;?></span>
		  , 使用率 
          <span id="memCachedPercent"><?php echo $memCachedPercent;?></span>
		  %	| Buffers缓冲为  <span id="Buffers"><?php echo $mb;?></span>
          <div class="bar"><div id="barmemCachedPercent" class="barli_blue" style="width:<?php echo $memCachedPercent?>%" >&nbsp;</div></div>

          真实内存使用
          <span id="memRealUsed"><?php echo $memRealUsed;?></span>
		  , 真实内存空闲
          <span id="memRealFree"><?php echo $memRealFree;?></span>
		  , 使用率
          <span id="memRealPercent"><?php echo $memRealPercent;?></span>
          %
          <div class="bar_1"><div id="barmemRealPercent" class="barli_1" style="width:<?php echo $memRealPercent?>%" >&nbsp;</div></div> 
<?php
}
//判断如果SWAP区为0,不显示
if($sysInfo['swapTotal']>0)
{
?>	
          SWAP区:共
          <?php echo $st;?>
          , 已使用
          <span id="swapUsed"><?php echo $su;?></span>
          , 空闲
          <span id="swapFree"><?php echo $sf;?></span>
          , 使用率
          <span id="swapPercent"><?php echo $swapPercent;?></span>
          %
          <div class="bar"><div id="barswapPercent" class="barli_red" style="width:<?php echo $swapPercent?>%" >&nbsp;</div> </div>

<?php
}	
?>		  

	  </td>

	</tr>
	  <tr>
		<td>系统平均负载</td>
		<td colspan="5" class="w_number"><span id="loadAvg"><?php echo $load;?></span></td>
	</tr>

</table>

<?}?>



<?php if (false !== ($strs = @file("/proc/net/dev"))) : ?>

<table>

    <tr><th colspan="5">网络使用状况</th></tr>

<?php for ($i = 2; $i < count($strs); $i++ ) : ?>

<?php preg_match_all( "/([^\s]+):[\s]{0,}(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/", $strs[$i], $info );?>

     <tr>

        <td width="13%"><?php echo $info[1][0]?> : </td>
        <td width="29%">入网: <font color='#CC0000'><span id="NetInput<?php echo $i?>"><?php echo $NetInput[$i]?></span></font></td>
		<td width="14%">实时: <font color='#CC0000'><span id="NetInputSpeed<?php echo $i?>">0B/s</span></font></td>
        <td width="29%">出网: <font color='#CC0000'><span id="NetOut<?php echo $i?>"><?php echo $NetOut[$i]?></span></font></td>
		<td width="14%">实时: <font color='#CC0000'><span id="NetOutSpeed<?php echo $i?>">0B/s</span></font></td>

    </tr>

<?php endfor; ?>

</table>

<?php endif; ?>



<table width="100%" cellpadding="3" cellspacing="0" align="center">

  <tr>

    <th colspan="4">PHP已编译模块检测</th>

  </tr>

  <tr>

    <td colspan="4"><span class="w_small">

<?php

$able=get_loaded_extensions();

foreach ($able as $key=>$value) {

	if ($key!=0 && $key%13==0) {

		echo '<br />';

	}

	echo "$value&nbsp;&nbsp;";

}

?></span>

    </td>

  </tr>

</table>

<a name="w_php"></a>

<table>

  <tr><th colspan="4">PHP相关参数</th></tr>

  <tr>

    <td width="32%">PHP信息(phpinfo):</td>

    <td width="18%">

		<?php

		$phpSelf = $_SERVER[PHP_SELF] ? $_SERVER[PHP_SELF] : $_SERVER[SCRIPT_NAME];

		$disFuns=get_cfg_var("disable_functions");

		?>

    <?php echo (false!==eregi("phpinfo",$disFuns))? '<font color="red">×</font>' :"<a href='$phpSelf?act=phpinfo' target='_blank'>PHPINFO</a>";?>

    </td>

    <td width="32%">PHP版本(php_version):</td>

    <td width="18%"><?php echo PHP_VERSION;?></td>

  </tr>

  <tr>

    <td>PHP运行方式:</td>

    <td><?php echo strtoupper(php_sapi_name());?></td>

    <td>脚本占用最大内存(memory_limit):</td>

    <td><?php echo show("memory_limit");?></td>

  </tr>

  <tr>

    <td>PHP安全模式(safe_mode):</td>

    <td><?php echo show("safe_mode");?></td>

    <td>POST方法提交最大限制(post_max_size):</td>

    <td><?php echo show("post_max_size");?></td>

  </tr>

  <tr>

    <td>上传文件最大限制(upload_max_filesize):</td>

    <td><?php echo show("upload_max_filesize");?></td>

    <td>浮点型数据显示的有效位数(precision):</td>

    <td><?php echo show("precision");?></td>

  </tr>

  <tr>

    <td>脚本超时时间(max_execution_time):</td>

    <td><?php echo show("max_execution_time");?>秒</td>

    <td>socket超时时间(default_socket_timeout):</td>

    <td><?php echo show("default_socket_timeout");?>秒</td>

  </tr>

  <tr>

    <td>PHP页面根目录(doc_root):</td>

    <td><?php echo show("doc_root");?></td>

    <td>用户根目录(user_dir):</td>

    <td><?php echo show("user_dir");?></td>

  </tr>

  <tr>

    <td>dl()函数(enable_dl):</td>

    <td><?php echo show("enable_dl");?></td>

    <td>指定包含文件目录(include_path):</td>

    <td><?php echo show("include_path");?></td>

  </tr>

  <tr>

    <td>显示错误信息(display_errors):</td>

    <td><?php echo show("display_errors");?></td>

    <td>自定义全局变量(register_globals):</td>

    <td><?php echo show("register_globals");?></td>

  </tr>

  <tr>

    <td>数据反斜杠转义(magic_quotes_gpc):</td>

    <td><?php echo show("magic_quotes_gpc");?></td>

    <td>"&lt;?...?&gt;"短标签(short_open_tag):</td>

    <td><?php echo show("short_open_tag");?></td>

  </tr>

  <tr>

    <td>"&lt;% %&gt;"ASP风格标记(asp_tags):</td>

    <td><?php echo show("asp_tags");?></td>

    <td>忽略重复错误信息(ignore_repeated_errors):</td>

    <td><?php echo show("ignore_repeated_errors");?></td>

  </tr>

  <tr>

    <td>忽略重复的错误源(ignore_repeated_source):</td>

    <td><?php echo show("ignore_repeated_source");?></td>

    <td>报告内存泄漏(report_memleaks):</td>

    <td><?php echo show("report_memleaks");?></td>

  </tr>

  <tr>

    <td>自动字符串转义(magic_quotes_gpc):</td>

    <td><?php echo show("magic_quotes_gpc");?></td>

    <td>外部字符串自动转义(magic_quotes_runtime):</td>

    <td><?php echo show("magic_quotes_runtime");?></td>

  </tr>

  <tr>

    <td>打开远程文件(allow_url_fopen):</td>

    <td><?php echo show("allow_url_fopen");?></td>

    <td>声明argv和argc变量(register_argc_argv):</td>

    <td><?php echo show("register_argc_argv");?></td>

  </tr>
  <tr>
    <td>Cookie 支持:</td>
    <td><?php echo isset($_COOKIE)?'<font color="green">√</font>' : '<font color="red">×</font>';?></td>
    <td>拼写检查(ASpell Library):</td>
    <td><?php echo isfun("aspell_check_raw");?></td>
  </tr>
   <tr>
    <td>高精度数学运算(BCMath):</td>
    <td><?php echo isfun("bcadd");?></td>
    <td>PREL相容语法(PCRE):</td>
    <td><?php echo isfun("preg_match");?></td>
   <tr>
    <td>PDF文档支持:</td>
    <td><?php echo isfun("pdf_close");?></td>
    <td>SNMP网络管理协议:</td>
    <td><?php echo isfun("snmpget");?></td>
  </tr> 
   <tr>
    <td>VMailMgr邮件处理:</td>
    <td><?php echo isfun("vm_adduser");?></td>
    <td>Curl支持:</td>
    <td><?php echo isfun("curl_init");?></td>
  </tr> 
   <tr>
    <td>SMTP支持:</td>
    <td><?php echo get_cfg_var("SMTP")?'<font color="green">√</font>' : '<font color="red">×</font>';?></td>
    <td>SMTP地址:</td>
    <td><?php echo get_cfg_var("SMTP")?get_cfg_var("SMTP"):'<font color="red">×</font>';?></td>
  </tr> 

	<tr>
		<td>默认支持函数(enable_functions):</td>
		<td colspan="3"><a href='<?php echo $phpSelf;?>?act=Function' target='_blank' class='static'>请点这里查看详细!</a></td>		
	</tr>
	<tr>
		<td>被禁用的函数(disable_functions):</td>
		<td colspan="3" class="word">
<?php 
$disFuns=get_cfg_var("disable_functions");
if(empty($disFuns))
{
	echo '<font color=red>×</font>';
}
else
{ 
	//echo $disFuns;
	$disFuns_array =  explode(',',$disFuns);
	foreach ($disFuns_array as $key=>$value) 
	{
		if ($key!=0 && $key%5==0) {
			echo '<br />';
	}
	echo "$value&nbsp;&nbsp;";
}	
}

?>
		</td>
	</tr>

</table>

<a name="w_module"></a>

<!--组件信息-->

<table>

  <tr><th colspan="4" >组件支持</th></tr>

  <tr>

    <td width="32%">FTP支持:</td>

    <td width="18%"><?php echo isfun("ftp_login");?></td>

    <td width="32%">XML解析支持:</td>

    <td width="18%"><?php echo isfun("xml_set_object");?></td>

  </tr>

  <tr>

    <td>Session支持:</td>

    <td><?php echo isfun("session_start");?></td>

    <td>Socket支持:</td>

    <td><?php echo isfun("socket_accept");?></td>

  </tr>

  <tr>

    <td>Calendar支持</td>

    <td><?php echo isfun('cal_days_in_month');?>
	</td>

    <td>允许URL打开文件:</td>

    <td><?php echo show("allow_url_fopen");?></td>

  </tr>

  <tr>

    <td>GD库支持:</td>

    <td>

    <?php

        if(function_exists(gd_info)) {

            $gd_info = @gd_info();

	        echo $gd_info["GD Version"];

	    }else{echo '<font color="red">×</font>';}

	?></td>

    <td>压缩文件支持(Zlib):</td>

    <td><?php echo isfun("gzclose");?></td>

  </tr>

  <tr>

    <td>IMAP电子邮件系统函数库:</td>

    <td><?php echo isfun("imap_close");?></td>

    <td>历法运算函数库:</td>

    <td><?php echo isfun("JDToGregorian");?></td>

  </tr>

  <tr>

    <td>正则表达式函数库:</td>

    <td><?php echo isfun("preg_match");?></td>

    <td>WDDX支持:</td>

    <td><?php echo isfun("wddx_add_vars");?></td>

  </tr>

  <tr>

    <td>Iconv编码转换:</td>

    <td><?php echo isfun("iconv");?></td>

    <td>mbstring:</td>

    <td><?php echo isfun("mb_eregi");?></td>

  </tr>

  <tr>

    <td>高精度数学运算:</td>

    <td><?php echo isfun("bcadd");?></td>

    <td>LDAP目录协议:</td>

    <td><?php echo isfun("ldap_close");?></td>

  </tr>

  <tr>

    <td>MCrypt加密处理:</td>

    <td><?php echo isfun("mcrypt_cbc");?></td>

    <td>哈稀计算:</td>

    <td><?php echo isfun("mhash_count");?></td>

  </tr>

</table>

<a name="w_module_other"></a>
<!--第三方组件信息-->
<table>
  <tr><th colspan="4" >第三方组件</th></tr>
  <tr>
    <td width="32%">Zend版本</td>
    <td width="18%"><?php $zend_version = zend_version();if(empty($zend_version)){echo '<font color=red>×</font>';}else{echo $zend_version;}?></td>
    <td width="32%">
<?php
$PHP_VERSION = PHP_VERSION;
$PHP_VERSION = substr($PHP_VERSION,2,1);
if($PHP_VERSION > 2)
{
	echo "ZendGuardLoader[启用]";
}
else
{
	echo "Zend Optimizer";
}
?>
	</td>
    <td width="18%"><?php if($PHP_VERSION > 2){echo (get_cfg_var("zend_loader.enable"))?'<font color=green>√</font>':'<font color=red>×</font>';} else{if(function_exists('zend_optimizer_version')){	echo zend_optimizer_version();}else{	echo (get_cfg_var("zend_optimizer.optimization_level")||get_cfg_var("zend_extension_manager.optimizer_ts")||get_cfg_var("zend.ze1_compatibility_mode")||get_cfg_var("zend_extension_ts"))?'<font color=green>√</font>':'<font color=red>×</font>';}}?></td>
  </tr>
  <tr>
    <td>eAccelerator</td>
    <td><?php if((phpversion('eAccelerator'))!=''){echo phpversion('eAccelerator');}else{ echo "<font color=red>×</font>";} ?></td>
    <td>ioncube</td>
    <td><?php if(extension_loaded('ionCube Loader')){   $ys = ioncube_loader_iversion();   $gm = ".".(int)substr($ys,3,2);   echo ionCube_Loader_version().$gm;}else{echo "<font color=red>×</font>";}?></td>
  </tr>
  <tr>
    <td>XCache</td>
    <td><?php if((phpversion('XCache'))!=''){echo phpversion('XCache');}else{ echo "<font color=red>×</font>";} ?></td>
    <td>APC</td>
    <td><?php if((phpversion('APC'))!=''){echo phpversion('APC');}else{ echo "<font color=red>×</font>";} ?></td>
  </tr>
</table>

<a name="w_db"></a>

<!--数据库支持-->

<table>

  <tr><th colspan="4">数据库支持</th></tr>

  <tr>

    <td width="32%">MySQL 数据库:</td>

    <td width="18%"><?php echo isfun("mysql_close");?>

    <?php
    if(function_exists("mysql_get_server_info")) {

        $s = @mysql_get_server_info();

        $s = $s ? '&nbsp; mysql_server 版本:'.$s : '';

	    $c = '&nbsp; mysql_client 版本:'.@mysql_get_client_info();

        echo $s;

    }

    ?>

	</td>

    <td width="32%">ODBC 数据库:</td>

    <td width="18%"><?php echo isfun("odbc_close");?></td>

  </tr>

  <tr>

    <td>Oracle 数据库:</td>

    <td><?php echo isfun("ora_close");?></td>

    <td>SQL Server 数据库:</td>

    <td><?php echo isfun("mssql_close");?></td>

  </tr>

  <tr>

    <td>dBASE 数据库:</td>

    <td><?php echo isfun("dbase_close");?></td>

    <td>mSQL 数据库:</td>

    <td><?php echo isfun("msql_close");?></td>

  </tr>

  <tr>

    <td>SQLite 数据库:</td>

    <td><?php if(extension_loaded('sqlite3')) {$sqliteVer = SQLite3::version();echo '<font color=green>√</font> ';echo "SQLite3 Ver ";echo $sqliteVer[versionString];}else {echo isfun("sqlite_close");if(isfun("sqlite_close") == '<font color="green">√</font>') {echo "&nbsp; 版本: ".@sqlite_libversion();}}?></td>

    <td>Hyperwave 数据库:</td>

    <td><?php echo isfun("hw_close");?></td>

  </tr>

  <tr>

    <td>Postgre SQL 数据库:</td>

    <td><?php echo isfun("pg_close"); ?></td>

    <td>Informix 数据库:</td>

    <td><?php echo isfun("ifx_close");?></td>

  </tr>
  <tr>
    <td>DBA 数据库:</td>
    <td><?php echo isfun("dba_close");?></td>
    <td>DBM 数据库:</td>
    <td><?php echo isfun("dbmclose");?></td>
  </tr>    
  <tr>
    <td>FilePro 数据库:</td>
    <td><?php echo isfun("filepro_fieldcount");?></td>
    <td>SyBase 数据库:</td>
    <td><?php echo isfun("sybase_close");?></td>
  </tr> 

</table>

<a name="w_performance"></a><a name="bottom"></a>

<form action="<?php echo $_SERVER[PHP_SELF]."#bottom";?>" method="post">

<!--服务器性能检测-->

<table>

  <tr><th colspan="5">服务器性能检测</th></tr>

  <tr align="center">

    <td width="19%">参照对象</td>

    <td width="17%">整数运算能力检测<br />(1+1运算300万次)</td>

    <td width="17%">浮点运算能力检测<br />(圆周率开平方300万次)</td>

    <td width="17%">数据I/O能力检测<br />(读取10K文件1万次)</td>

    <td width="30%">CPU信息</td>

  </tr>
  <tr align="center">
    <td align="left">美国 LinodeVPS</td>
    <td>0.357秒</td>
    <td>0.802秒</td>
    <td>0.023秒</td>
    <td align="left">4 x Xeon L5520 @ 2.27GHz</td>
  </tr> 

  <tr align="center">

    <td align="left">美国 PhotonVPS.com</td>

    <td>0.431秒</td>

    <td>1.024秒</td>

    <td>0.034秒</td>

    <td align="left">8 x Xeon E5520 @ 2.27GHz</td>

  </tr>

  <tr align="center">

    <td align="left">德国 SpaceRich.com</td>

    <td>0.421秒</td>

    <td>1.003秒</td>

    <td>0.038秒</td>

    <td align="left">4 x Core i7 920 @ 2.67GHz</td>

  </tr>

  <tr align="center">

    <td align="left">美国 RiZie.com</td>

    <td>0.521秒</td>

    <td>1.559秒</td>

    <td>0.054秒</td>

    <td align="left">2 x Pentium4 3.00GHz</td>

  </tr>

  <tr align="center">

    <td align="left">埃及 CitynetHost.com</a></td>

    <td>0.343秒</td>

    <td>0.761秒</td>

    <td>0.023秒</td>

    <td align="left">2 x Core2Duo E4600 @ 2.40GHz</td>

  </tr>

  <tr align="center">

    <td align="left">美国 IXwebhosting.com</td>

    <td>0.535秒</td>

    <td>1.607秒</td>

    <td>0.058秒</td>

    <td align="left">4 x Xeon E5530 @ 2.40GHz</td>

  </tr>

  <tr align="center">

    <td>本台服务器</td>

    <td><?php echo $valInt;?><br /><input class="btn" name="act" type="submit" value="整型测试" /></td>

    <td><?php echo $valFloat;?><br /><input class="btn" name="act" type="submit" value="浮点测试" /></td>

    <td><?php echo $valIo;?><br /><input class="btn" name="act" type="submit" value="IO测试" /></td>

    <td></td>

  </tr>

</table>

<input type="hidden" name="pInt" value="<?php echo $valInt;?>" />

<input type="hidden" name="pFloat" value="<?php echo $valFloat;?>" />

<input type="hidden" name="pIo" value="<?php echo $valIo;?>" />

<a name="w_networkspeed"></a>
<!--网络速度测试-->
<table>
	<tr><th colspan="3">网络速度测试</th></tr>
  <tr>
    <td width="19%" align="center"><input name="act" type="submit" class="btn" value="开始测试" />
        <br />
	向客户端传送1000k字节数据<br />
	带宽比例按理想值计算
	</td>
    <td width="81%" align="center" >

  <table align="center" width="550" border="0" cellspacing="0" cellpadding="0" >
    <tr >
    <td height="15" width="50">带宽</td>
	<td height="15" width="50">1M</td>
    <td height="15" width="50">2M</td>
    <td height="15" width="50">3M</td>
    <td height="15" width="50">4M</td>
    <td height="15" width="50">5M</td>
    <td height="15" width="50">6M</td>
    <td height="15" width="50">7M</td>
    <td height="15" width="50">8M</td>
    <td height="15" width="50">9M</td>
    <td height="15" width="50">10M</td>
    </tr>
   <tr>
    <td colspan="11" class="suduk" ><table align="center" width="550" border="0" cellspacing="0" cellpadding="0" height="8" class="suduk">
    <tr>
      <td class="sudu"  width="<?php 
	if(preg_match("/[^\d-., ]/",$speed))
		{
			echo "0";
		}
	else{
			echo 550*($speed/11000);
		} 
		?>"></td>
      <td class="suduk" width="<?php 
	if(preg_match("/[^\d-., ]/",$speed))
		{
			echo "550";
		}
	else{
			echo 550-550*($speed/11000);
		} 
		?>"></td>
    </tr>
    </table>
   </td>
  </tr>
  </table>
  <?php echo (isset($_GET['speed']))?"下载1000KB数据用时 <font color='#cc0000'>".$_GET['speed']."</font> 毫秒,下载速度:"."<font color='#cc0000'>".$speed."</font>"." kb/s,需测试多次取平均值,超过10M直接看下载速度":"<font color='#cc0000'>&nbsp;未探测&nbsp;</font>" ?>

    </td>
  </tr>
</table>

<a name="w_MySQL"></a>

<!--MySQL数据库连接检测-->

<table>

	<tr><th colspan="3">MySQL数据库连接检测</th></tr>

  <tr>

    <td width="15%"></td>

    <td width="60%">

      地址:<input type="text" name="host" value="localhost" size="10" />

      端口:<input type="text" name="port" value="3306" size="10" />

      用户名:<input type="text" name="login" size="10" />

      密码:<input type="password" name="password" size="10" />

    </td>

    <td width="25%">

      <input class="btn" type="submit" name="act" value="MySQL检测" />

    </td>

  </tr>

</table>

  <?php

  if ($_POST['act'] == 'MySQL检测') {

  	if(function_exists("mysql_close")==1) {

  		$link = @mysql_connect($host.":".$port,$login,$password);

  		if ($link){

  			echo "<script>alert('连接到MySql数据库正常')</script>";

  		} else {

  			echo "<script>alert('无法连接到MySql数据库!')</script>";

  		}

  	} else {

  		echo "<script>alert('服务器不支持MySQL数据库!')</script>";

  	}

  }

	?>
	
<a name="w_function"></a>

<!--函数检测-->

<table>

	<tr><th colspan="3">函数检测</th></tr>

  <tr>

    <td width="15%"></td>

    <td width="60%">

      请输入您要检测的函数:

      <input type="text" name="funName" size="50" />

    </td>

    <td width="25%">

      <input class="btn" type="submit" name="act" align="right" value="函数检测" />

    </td>

  </tr>

  <?php

  if ($_POST['act'] == '函数检测') {

  	echo "<script>alert('$funRe')</script>";

  }

  ?>

</table>

<a name="w_mail"></a>

<!--邮件发送检测-->

<table>

  <tr><th colspan="3">邮件发送检测</th></tr>

  <tr>

    <td width="15%"></td>

    <td width="60%">

      请输入您要检测的邮件地址:

      <input type="text" name="mailAdd" size="50" />

    </td>

    <td width="25%">

    <input class="btn" type="submit" name="act" value="邮件检测" />

    </td>

  </tr>

  <?php

  if ($_POST['act'] == '邮件检测') {

  	echo "<script>alert('$mailRe')</script>";

  }

  ?>

</table>

</form>



	<table>
		<tr>
			<td class="w_foot"><A HREF="http://www.Gimhoy.com" target="_blank"><?php echo $title.$version;?></A></td>
			<td class="w_foot"><?php $run_time = sprintf('%0.4f', microtime_float() - $time_start);?>Processed in <?php echo $run_time?> seconds. <?php echo memory_usage();?> memory usage.</td>
			<td class="w_foot"><a href="#w_top">返回顶部</a></td>
		</tr>
	</table>

</div>

</body>

</html>



友情链接:Autohotkey中文帮助Autohotkey官网Autohotkey中文网联系作者免GooglePlay APK下载

 主题设计 • skyfrit.com  Thinkai's Blog | 保留所有权利

50 queries in 1.388 seconds |