|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
因为现在数据库都使用标准的SQL语言对数据库进行管理,所以如果是标准SQL语言,两者基本上都可以通用的。SQLServer还有更多的扩展,可以用存储过程,数据库大小无极限限制。ip地点|转换将IP地点转换为长整型
Convertsastringipaddress("192.168.0.1")toaLongnumber(3232235521).OneofthereasonstodothiswouldbetostoreIPaddressesindatabases.Numbersgreatlyreducethesizerequiredtostorethisinformation.
Inputs:asNewIP-StringIPaddress("192.168.0.1")toconverttoanumber.
Returns:ReturnsaLongIntegerrepresentingtheIPaddress(3232235521)
Assumes:ThisfunctionassumesthatyourIPaddresshas4integersdelimitedbydecimalsandthatthenumbersrangefrom0to255.
FunctionCLngIP(ByValasNewIP)
DimlnResults
DimlnIndex
DimlnIpAry
SplittheIPaddressusingthedotasadelimiter
lnIpAry=Split(asNewIP,".",4)
LoopthroughEachnumberIntheIPaddress
ForlnIndex=0To3
IfweareNotworkingWiththelastnumber...
IfNotlnIndex=3Then
ConvertthenumberToavaluerangethatcanbeparsedfromtheothers
lnIpAry(lnIndex)=lnIpAry(lnIndex)*(256^(3-lnIndex))
EndIf
AddthenumberTotheresults
lnResults=lnResults+lnIpAry(lnIndex)
Next
IfstoringnumberwithinanAccessDatabase,
ThevariableType"Long"rangesfrom-2147483648To2147483647
YouwillneedTosubtract2147483648fromthenumber
beforequeryingthedatabase.
lnResults=lnResults-2147483648
Returntheresults
CLngIP=lnResults
EndFunction
将长整型转换为IP地点
Name:ConvertLongIPtoStringIP
Description:ThisfunctionconvertsaLongNumber(3232235521)intoanIPAddress("192.168.0.1").Whywouldyouwanttodothis?Clickhere.
Inputs:anNewIP-IPAddressasaLongNumber(nodots)
Returns:ReturnsthestringrepresentationofanIPAddress("192.168.0.1")
FunctionCStrIP(ByValanNewIP)
DimlsResultsResultsTobereturned
DimlnTempTemporaryvaluebeingparsed
DimlnIndexPositionofnumberbeingparsed
IfpullingnumberfromanAccessDatabase,
ThevariableType"Long"rangesfrom-2147483648To2147483647
YouwillfirstneedToadd2147483648tothenumbertoparsecorrectly.
anNewIP=anNewIP+2147483648
Parsehighestnumbersfirst
ForlnIndex=3To0Step-1
ParsethecurrentvalueForthisposition
lnTemp=Int(anNewIP/(256^lnIndex))
AppendthenumberTothefinalresultsdelimitedbyadot
lsResults=lsResults&lnTemp&"."
Removethenumberthatwejustparsed
anNewIP=anNewIP-(lnTemp*(256^lnIndex))
Next
Cutofflastdot
lsResults=Left(lsResults,Len(lsResults)-1)
Returntheresults
CStrIP=lsResults
EndFunction源代码保护方面其实现在考虑得没那么多了..NET也可以反编译.ASP写得复杂的话别人能看得懂的话.他也有能力自己写了.这方面担心的倒不太多.纵观现在网上可以下载的那些所谓BBS还有什么网站等等的源代码 |
|