1.网站数据统计中pv、统计统计uv、源码ip的代码区别
2.vb å¦ä½å®ç°ç»è®¡ IP
网站数据统计中pv、uv、统计统计go 源码安装ip的源码区别
做网站,数据统计不可或缺。代码安装统计代码,统计统计可了解网站流量。源码
网站流量统计中有PV、代码UV、统计统计IP三项数据。源码活动行 源码新入门的代码SEO者,常混淆这三者的统计统计区别。接下来,源码我将解析它们。代码
首先,电子喜帖 源码来了解三者定义:
IP指独立IP数,小时内相同公网IP只算一次。
PV是Page View缩写,即页面浏览量或点击量,每次刷新,ext源码分析PV计数。
UV是Unique Visitor缩写,指访问网站的每台电脑客户端,:-:内相同客户端只计一次。
明白了定义,php内核源码三者的区别清晰可见:
IP统计的是某IP地址计算机访问网站次数,真实,衡量网站流量。
PV反映浏览网站的页面数,每次刷新,PV增加。PV与来访者数量成正比,但不反映实际来访者数量。
UV统计访问网站的电脑数量,通过浏览器缓存判断来访者身份。更换IP但不清除cookies,UV数不变。
总结,IP与UV数据相似,IP反映网络地址数量,UV对应实际浏览者数量。统计局限于互联网,本地网站无法统计。
vb å¦ä½å®ç°ç»è®¡ IP
GetIpAddrTable ByVal 0&, Ret, True
If Ret <= 0 Then Exit Sub
ReDim bBytes(0 To Ret - 1) As Byte
GetIpAddrTable bBytes(0), Ret, False
CopyMemory Listing.dEntrys, bBytes(0), 4
CopyMemory Listing.mIPInfo(0), bBytes(4), Len(Listing.mIPInfo(0))
'å¨è¿éåå¾IP
T_ip.Text = ConvertAddressToString(Listing.mIPInfo(0).dwAddr)
-------------------------------------------------------------------------
Public Declare Function GetIpAddrTable Lib "IPHlpApi" (pIPAdrTable As Byte, pdwSize As Long, ByVal Sort As Long) As Long
Public Declare Sub CopyMemory Lib "kernel" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Const MAX_IP = 5
Type IPINFO
dwAddr As Long
dwIndex As Long
dwMask As Long
dwBCastAddr As Long
dwReasmSize As Long
unused1 As Integer
unused2 As Integer
End Type
Type MIB_IPADDRTABLE
dEntrys As Long
mIPInfo(MAX_IP) As IPINFO
End Type
Type IP_Array
mBuffer As MIB_IPADDRTABLE
BufferLen As Long
End Type
Public Function ConvertAddressToString(longAddr As Long) As String
Dim MyByte(3) As Byte
Dim Cnt As Long
CopyMemory MyByte(0), longAddr, 4
For Cnt = 0 To 3
ConvertAddressToString = ConvertAddressToString + CStr(MyByte(Cnt)) + "."
Next Cnt
ConvertAddressToString = Left$(ConvertAddressToString, Len(ConvertAddressToString) - 1)
End Function
ãyadianerã:
ä» ä» æ¯é对æ¬æºï¼æç®åçåæ³æ¯ç¨winsockäºï¼å¦æ¥¼ä¸
ä¸é¢æ¯ç¨API
侦æµç®å设å¤ä¸æ使ç¨ç IP å°å
' 设å®å¨æ¨ç计ç®æºä¸ï¼æå¤å¯è½ä½¿ç¨ 5 ç» IP å°åï¼å¹¶ä¸ç¨æ¥äº§çç¼å²åº
Private Const MAX_IP =
Private Type IPINFO
dwAddr As Long ' IP å°å
dwNICIndex As Long ' NIC çé¢ç´¢å¼
dwSubnetMask As Long ' åç½æ©ç
dwBroadCastAddr As Long ' å°å 广æå°å
dwReAssemblySize As Long ' ç»è¯å¤§å°
unused1 As Integer ' æä¸ä½¿ç¨
unused2 As Integer ' æä¸ä½¿ç¨
End Type
Private Type MIB_IPADDRTABLE
dwEntrys As Long ' çªä½ä¸ç»å½çæ°é
arIPInfo(MAX_IP) As IPINFO ' IP å°åç»å½æ°ç»
End Type
Private Type IP_Array
mBuffer As MIB_IPADDRTABLE ' IP å°åæ¸ åæ°ç»
BufferLen As Long ' ç¼å²åºé¿åº¦
End Type
Private Declare Sub CopyMemory Lib "kernel" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Function GetIpAddrTable Lib "IPHlpApi" (pIPAdrTable As Byte, pdwSize As Long, ByVal Sort As Long) As Long
' å°é¿æ´æ°è½¬æ¢ä¸ºå符串
Public Function ConvertAddr2Str(LongAddress As Long) As String
Dim addrByte(3) As Byte
Dim Cnt As Long
CopyMemory addrByte(0), LongAddress, 4
For Cnt = 0 To 3
ConvertAddr2Str = ConvertAddr2Str + CStr(addrByte(Cnt)) + "."
Next Cnt
ConvertAddr2Str = Left$(ConvertAddr2Str, Len(ConvertAddr2Str) - 1)
End Function
Private Sub Form_Load()
Text1.Text = ""
Me.Caption = "åå¾è®¡ç®æºä¸æ使ç¨ç IP å°å"
Text1.Font.Size =
Start
End Sub
Private Sub Form_Resize()
Text1.Height = Me.Height - * Screen.TwipsPerPixelY
Text1.Width = Me.Width - * Screen.TwipsPerPixelX
End Sub
Private Sub Start()
Dim lRet As Long, I As Long
Dim Buffer() As Byte
Dim ListDatas As MIB_IPADDRTABLE
Text1 = ""
On Error GoTo Errors
GetIpAddrTable ByVal 0&, lRet, True
If lRet <= 0 Then Exit Sub
ReDim Buffer(0 To lRet - 1) As Byte
' åå IP å°åçç¸å ³æ°æ®
GetIpAddrTable Buffer(0), lRet, False
Debug.Print Buffer(0)
' å©ç¨å·²ç»å®è£ IP å°åçåå个åèï¼æ¥åå¾ç»å½çä¿¡æ¯
CopyMemory ListDatas.dwEntrys, Buffer(0), 4
Text1 = "å¨æ¨ç计ç®æºä¸ï¼å ±æ " & ListDatas.dwEntrys & " ç»å·²ç»è®¾å®ä½¿ç¨ç IP å°å" & vbCrLf
Text1 = Text1 & String(, "=") & vbCrLf
For I = 0 To ListDatas.dwEntrys - 1
' å°åå¨å åä¹ä¸çå°åç»æï¼å¤å¶å°æ¸ åä¹ä¸
CopyMemory ListDatas.arIPInfo(I), Buffer(4 + (I * Len(ListDatas.arIPInfo(0)))), Len(ListDatas.arIPInfo(I))
Text1 = Text1 & "IP å°å ï¼" & ConvertAddr2Str(ListDatas.arIPInfo(I).dwAddr) & vbCrLf
Text1 = Text1 & "IP åç½æ©ç ï¼" & ConvertAddr2Str(ListDatas.arIPInfo(I).dwSubnetMask) & vbCrLf
Text1 = Text1 & "IP 广æå°å ï¼" & ConvertAddr2Str(ListDatas.arIPInfo(I).dwBroadCastAddr) & vbCrLf
Text1 = Text1 & String(, "*") & vbCrLf & vbCrLf
Next
Exit Sub
Errors:
End Sub
ãyadianerã:
å¦ææ¯éå¤ç½ï¼å¯ä»¥ç¨ä¸é¢çï¼åçæ¯æ ¹æ®è®¿é®ç½é¡µå¾å°
Private Const ERROR_SUCCESS As Long = 0
Private Const MAX_ADAPTER_NAME_LENGTH As Long =
Private Const MAX_ADAPTER_DESCRIPTION_LENGTH As Long =
Private Const MAX_ADAPTER_ADDRESS_LENGTH As Long = 8
Private Type IP_ADDRESS_STRING
IpAddr(0 To ) As Byte
End Type
Private Type IP_MASK_STRING
IpMask(0 To ) As Byte
End Type
Private Type IP_ADDR_STRING
dwNext As Long
IpAddress As IP_ADDRESS_STRING
IpMask As IP_MASK_STRING
dwContext As Long
End Type
Private Type IP_ADAPTER_INFO
dwNext As Long
ComboIndex As Long 'reserved
sAdapterName(0 To (MAX_ADAPTER_NAME_LENGTH + 3)) As Byte
sDescription(0 To (MAX_ADAPTER_DESCRIPTION_LENGTH + 3)) As Byte
dwAddressLength As Long
sIPAddress(0 To (MAX_ADAPTER_ADDRESS_LENGTH - 1)) As Byte
dwIndex As Long
uType As Long
uDhcpEnabled As Long
CurrentIpAddress As Long
IpAddressList As IP_ADDR_STRING
GatewayList As IP_ADDR_STRING
DhcpServer As IP_ADDR_STRING
bHaveWins As Long
PrimaryWinsServer As IP_ADDR_STRING
SecondaryWinsServer As IP_ADDR_STRING
LeaseObtained As Long
LeaseExpires As Long
End Type
Private Declare Function GetAdaptersInfo Lib "iphlpapi.dll" _
(pTcpTable As Any, _
pdwSize As Long) As Long
Private Declare Sub CopyMemory Lib "kernel" _
Alias "RtlMoveMemory" _
(dst As Any, _
src As Any, _
ByVal bcount As Long)
Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Private Declare Function DeleteUrlCacheEntry Lib "Wininet.dll" _
Alias "DeleteUrlCacheEntryA" _
(ByVal lpszUrlName As String) As Long
Private Declare Function lstrlenW Lib "kernel" _
(ByVal lpString As Long) As Long
Private Sub Form_Load()
Command1.Caption = "Get Public IP"
Text1.Text = LocalIPAddress()
Text2.Text = ""
End Sub
Private Sub Command1_Click()
Text2.Text = GetPublicIP()
End Sub
Private Function GetPublicIP()
Dim sSourceUrl As String
Dim sLocalFile As String
Dim hfile As Long
Dim buff As String
Dim pos1 As Long
Dim pos2 As Long
'site returning IP address
sSourceUrl = ".mvps.org/resources/tools/getpublicip.shtml"
sLocalFile = "c:\ip.txt"
'ensure this file does not exist in the cache
Call DeleteUrlCacheEntry(sSourceUrl)
'download the public IP file,
'read into a buffer and delete
If DownloadFile(sSourceUrl, sLocalFile) Then
hfile = FreeFile
Open sLocalFile For Input As #hfile
buff = Input$(LOF(hfile), hfile)
Close #hfile
'look for the IP line
pos1 = InStr(buff, "var ip =")
'if found,
If pos1 Then
'get position of first and last single
'quotes around address (e.g. '...')
pos1 = InStr(pos1 + 1, buff, "'", vbTextCompare) + 1
pos2 = InStr(pos1 + 1, buff, "'", vbTextCompare) '- 1
'return the IP address
GetPublicIP = Mid$(buff, pos1, pos2 - pos1)
Else
GetPublicIP = "(unable to parse IP)"
End If 'pos1
Kill sLocalFile
Else
GetPublicIP = "(unable to access shtml page)"
End If 'DownloadFile
End Function
Private Function DownloadFile(ByVal sURL As String, _
ByVal sLocalFile As String) As Boolean
DownloadFile = URLDownloadToFile(0, sURL, sLocalFile, 0, 0) = ERROR_SUCCESS
End Function
Private Function LocalIPAddress() As String
Dim cbRequired As Long
Dim buff() As Byte
Dim ptr1 As Long
Dim sIPAddr As String
Dim Adapter As IP_ADAPTER_INFO
Call GetAdaptersInfo(ByVal 0&, cbRequired)
If cbRequired > 0 Then
ReDim buff(0 To cbRequired - 1) As Byte
If GetAdaptersInfo(buff(0), cbRequired) = ERROR_SUCCESS Then
'get a pointer to the data stored in buff()
ptr1 = VarPtr(buff(0))
Do While (ptr1 <> 0)
'copy the data from the pointer to the
'first adapter into the IP_ADAPTER_INFO type
CopyMemory Adapter, ByVal ptr1, LenB(Adapter)
With Adapter
'the DHCP IP address is in the
'IpAddress.IpAddr member
sIPAddr = TrimNull(StrConv(.IpAddressList.IpAddress.IpAddr, vbUnicode))
If Len(sIPAddr) > 0 Then Exit Do
ptr1 = .dwNext
End With 'With Adapter
'ptr1 is 0 when (no more adapters)
Loop 'Do While (ptr1 <> 0)
End If 'If GetAdaptersInfo
End If 'If cbRequired > 0
'return any string found
LocalIPAddress = sIPAddr
End Function
Private Function TrimNull(startstr As String) As String
TrimNull = Left$(startstr, lstrlenW(StrPtr(startstr)))
End Function