<% 'depends on strings.inc 'CONST eComConnStr = "DRIVER={SQL Server};SERVER={FRONTDESK};UID=member;PWD=pB21A45;WSID=JIA;DATABASE=ecom" CONST eComConnStr = "DRIVER={SQL Server};SERVER={TS500\SBSMONITORING};UID=member;PWD=pB21A45!aq[;WSID=JIA;DATABASE=ecom" 'CONST eComConnStr = "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=ecom;Integrated Security=SSPI;" CONST eComFolder = "G:\Ref\" CONST eComPublicIP = "184.178.117.50" CONST eComLocalIP = "192.168.0.8" CONST COA = 4 CONST Contacts = 5 CONST Events = 6 CONST Status = 7 CONST StatusChange = 8 CONST Store = 9 CONST Tables = 10 CONST Tags = 11 CONST Trans = 13 CONST ItemType = 14 CONST Device = 15 CONST StateChange = 16 'these should be reset from the database by the application CONST COA_eMail = 4 CONST COA_Address = 7 CONST COA_Street = 8 CONST COA_City_State_Zip = 9 CONST COA_Price_Break = 149 CONST COA_Use_With = 150 CONST Status_Null = 5 CONST COA_New_Order = 6 CONST COA_Order_Ship = 13 CONST COA_Sales_Tax_Owed = 208 CONST ITM_Sales_Tax = 416046 CONST COA_Sales_Shipping = 211 CONST ITM_Sales_Shipping = 416050 CONST COA_Cash_InBank_PayPal = 87 Const iGenericStoreID = 2 Const MASSMIND_STORE_ID = 2091 Const iContactTable = 5 public eComConn, eComRS function eComDebug (msg) on error resume next debug msg ' response.flush end function Function eComExtract(strValue, strURL, intMaxLen) dim intStart intStart = InStr(strURL,strValue) if intStart <= 0 then intStart = InStr(1,strURL,strValue,1) if intStart <= 0 then eComExtract = "" eComDebug "eComExtract can't find:"&strValue&". in:"&strURL&"." Exit Function End If intStart = intStart + len(strValue) eComExtract = Mid(strURL,intStart,intMaxLen) eComExtract = Replace(eComExtract," "," ") intLen = InStr(eComExtract, "&") if intLen>0 Then eComExtract = Left(eComExtract,intLen-1) intLen = InStr(eComExtract, chr(34)) if intLen>0 Then eComExtract = Left(eComExtract,intLen-1) intLen = InStr(eComExtract, ">") if intLen>0 Then eComExtract = Left(eComExtract,intLen-1) intLen = InStr(eComExtract, "<") if intLen>0 Then eComExtract = Left(eComExtract,intLen-1) eComExtract = Replace(eComExtract,chr(9),"") eComExtract = Replace(eComExtract,chr(13),"") eComExtract = Replace(eComExtract,chr(10),"") eComExtract = Replace(eComExtract,"_"," ") eComExtract = Replace(eComExtract,"+"," ") eComExtract = Replace(eComExtract,"'","") intStart = Instr(1, eComExtract, "%") Do While intStart>0 and intStart+3 <= len(eComExtract) eComExtract = Left(eComExtract, intStart-1) + _ Chr(CLng("&H" & Mid(eComExtract, intStart+1, 2))) + _ Mid(eComExtract, intStart+3) intStart = Instr(intStart+1, eComExtract, "%") Loop eComExtract = trim(eComExtract) eComDebug "eComExtract found:"&eComExtract&", after:"&strValue&"." End Function function ecomURLscrape(aURL, anyPostData, anyUserName, anyPassword) if instr(aurl,"hilton")>0 then ecomURLscrape = ecomURLfromGet("", aURL, anyPostData, anyUserName, anyPassword, 10) else ecomURLscrape = ecomURLfromGet("", aURL, anyPostData, anyUserName, anyPassword, 5) end if end function function ecomURLget(aURL, anyPostData, anyUserName, anyPassword, aTimeOut) ecomURLget = ecomURLfromGet("", aURL, anyPostData, anyUserName, anyPassword, aTimeOut) end function function ecomURLfromGet(aReferer, aURL, anyPostData, anyUserName, anyPassword, aTimeOut) DIM objSrvHTTP,web,method,s on error resume next s="" set objSrvHTTP = Server.CreateObject ("Msxml2.ServerXMLHTTP.3.0") objSrvHTTP.setOption 2, 13056 if anyPostData=empty then objSrvHTTP.open "GET",aURL, true, anyUsername, anyPassword else objSrvHTTP.open "POST",aURL, true, anyUsername, anyPassword objSrvHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" end if objSrvHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)" objSrvHTTP.setRequestHeader "Referer", aReferer objSrvHTTP.send anyPostData objSrvHTTP.waitForResponse aTimeOut select case objSrvHTTP.readyState case 0 'object created, but no URL opened eComDebug "getURL("&aURL&", "&anyPostData&", "&anyUserName&", "&anyPassword&"): Object Created, no URL opened" err.raise 1, "Object Created, no URL opened" exit function case 1 'loading: URL opened, but no data sent eComDebug "getURL("&aURL&", "&anyPostData&", "&anyUserName&", "&anyPassword&"):URL opened, no data sent "&err.description err.raise 2, "URL opened, no data sent" exit function case 2 'loaded: data sent, status and headers available, no response recieved. eComDebug "getURL("&aURL&", "&anyPostData&", "&anyUserName&", "&anyPassword&"):No response from remote host" err.raise 3, "No response from remote host" exit function case 3 'interactive: some data recieved. responseBody and responseText will return partial results. eComDebug "getURL("&aURL&", "&anyPostData&", "&anyUserName&", "&anyPassword&"):Partial response recieved:" eComDebug server.htmlencode(objSrvHTTP.responseText) s = objSrvHTTP.responseText err.raise 4, "Partial response recieved" case 4 'complete: s = objSrvHTTP.responseText end select ecomURLfromGet = s end function Function eComVal(pvValue) Dim sTemp Select Case VarType(pvValue) Case 2, 3, 4, 5, 6: 'int, long, single, double, currency eComVal = pvValue 'already a number Case 8: 'String sTemp = Trim(pvValue) On Error Resume Next eComVal = CDbl(sTemp) If Err.Number <> 0 Then Err.Clear eComVal = 0 End If Case Else eComVal = 0 End Select End Function Function eComSQLStr(pvValue) Dim sTemp Select Case VarType(pvValue) Case 0, 1: eComSQLStr = "NULL" Case 2, 3, 4, 5, 6: sTemp = "" & pvValue sTemp = Replace(sTemp, "'", "''") 'probably not necessary eComSQLStr = "'" & sTemp & "'" Case 7: 'DateTime sTemp = month(pvValue)&"/"&day(pvValue)&"/"&year(pvValue)&" "&FormatDateTime(pvValue,4) eComSQLStr = "'" & sTemp & "'" Case 8: 'String sTemp = pvValue sTemp = Replace(sTemp, "'", "''") If Len(Trim(sTemp)) > 0 Then eComSQLStr = "'" & sTemp & "'" Else eComSQLStr = "NULL" End If Case Else eComSQLStr = "NULL" End Select End Function Function eComSQLDateTime(aVal) Select Case VarType(aVal) Case 7: 'Date eComSQLDateTime = "'"&right("0000"&Year(aVal),4)&"/"&right("00"&month(aVal),2)&"/"&right("00"&day(aVal),2)_ &" "_ &FormatDateTime(aVal,4)&":"&second(aVal)&"'" Case Else eComSQLDateTime = "NULL" End Select End Function function eComSQL(anSQLcmd) DIM eComRS on error resume next if Not IsObject(eComConn) then set eComConn = Server.CreateObject("ADODB.Connection") eComConn.ConnectionTimeout = 5 eComConn.Open eComConnStr if Err.Number then eComDebug "ERROR:"&Err.Description end if if IsObject(eComRS) then eComRS.Close set eComRS=Nothing end if set eComRS = CreateObject("ADODB.Recordset") eComConn.CommandTimeout = 10 eComDebug anSQLcmd eComRS.Open anSQLcmd, eComConn, 0, 3, 1 if Err.Number then eComDebug "ERROR:"&Err.Description set eComSQL = eComRS end function function eComSQLJoin(anSQLcmd, aString) 'Collects all matching records for each field, delimited by aString, into a dictionary object. 'Each Field is a seperate Item in the dictionary and all the records for that field are "joined" by aString in the items value DIM eComRS, field, I set eComSQLJoin = CreateObject("Scripting.Dictionary") eComSQLJoin.CompareMode=1 'text mode (case insensitive) Set eComRS = eComSQL(anSQLcmd) if eComRS.State<>1 then exit function ' Open while Not eComRS.EOF for I = 0 to eComRS.Fields.Count-1 field = eComRS.Fields(I).Name eComSQLJoin.Item(field) = eComSQLJoin.Item(field) & aString & trim(eComRS(I)) next eComRS.MoveNext wend end function function dTags(anID, aTable) DIM rsTags,dict,sName,aValue,sValue,nType,sStreet,nValue,tagStringLength set dict = CreateObject("Scripting.Dictionary") dict.CompareMode=1 'text mode (case insensitive) tagStringLength = cint(eComSQLjoin("SELECT COL_LENGTH('tags', 'string') AS x","")("X")) Set rsTags = eComSQL("SELECT coa.Name as name, tags.string as string, tags.value as value, coa.id as type FROM TAGS INNER JOIN COA ON TAGS.tagTreeID = COA.id WHERE COA.TableID = '"&aTable&"' AND TAGS.TargetID='"&anID&"' ORDER BY Value, targetID, tags.ID;") while rsTags.State = 1 AND Not rsTags.EOF aValue = Empty nType = rsTags("type") sName = nType & chr(9) & trim(rsTags("name")) aValue = replace(trim(split(rsTags("string")&chr(0),chr(0))(0)),chr(10),"") nValue = trim(rsTags("value")) sValue = nValue if nValue = 0 then sValue = " " if nType = COA_Address OR nType = COA_Street then sValue = replace(replace(formatNumber(nValue,4,0,0,0),".","-"),"-0000","") sName = nType&":"&sValue&chr(9)&"Contact Address" end if if dict.Exists(sName) then if len(aValue)=tagStringLength then aValue=dict(sName)&aValue 'assume this is a continuation of a single tag entry that was too long for one record. else aValue=dict(sName)&chr(13)&aValue 'assume this is a new tag entry end if dict.remove(sName) end if if nType = COA_Address OR nType = COA_Street then if instr(aValue,chr(10)) < 1 then sStreet = eComSQLJoin("SELECT string FROM Tags WHERE tagTreeID=" & COA_Street & " AND value="&nvalue&" AND targetID<0;", " ")("string") ' if its partial get the rest of the standard address for the beginning. if left(aValue,1)="," then aValue = sStreet & aValue else if nValue<>0 and (nValue - int(nValue) > 0) then dict.add nType&":"&sValue&chr(9)&"Standard Addr "&Chr(13)&"@"&sValue, sStreet & chr(13) & chr(10) & eComSQLJoin("SELECT string FROM Tags WHERE tagTreeID="&COA_City_State_Zip&" AND targetID='-"&int(nValue)&"';"," ")("string") & " " & replace(sValue,".","-") end if end if 'Get the city, state zip on it and tag it as processed. If no Zip, just the tag. aValue = aValue & chr(13) & chr(10) & eComSQLJoin("SELECT string FROM Tags WHERE tagTreeID="&COA_City_State_Zip&" AND value="&int(nValue)&" AND targetID<0;"," ")("string") & " " & replace(sValue,".","-") else if left(aValue, 2)=", " then 'move add ons to just before the tag. aValue = split( replace(aValue, chr(10), split(aValue&chr(13),chr(13),1,1)(0) & chr(10)) ,chr(13),2,1)(1) end if 'any new contact specific shit is already appended on to the front. end if if nType = COA_Address then 'if its a distinct address, title it by replaceing the most recent line seperator with a tab aValue = replace(aValue, chr(13),chr(9)&chr(13),1,1) end if sValue = "" end if if IsNumeric(sValue) then if sValue = 0 then sValue = "" dict.add sName, trim(aValue & " " & sValue) debug sValue rsTags.MoveNext wend rsTags.Close for each sName in dict.keys aValue = dict(sName) if instr(aValue,chr(9)&chr(13))>1 then dict.item(sName) = split(aValue,chr(9)&chr(13),2)(1): dict.key(sName)=sName & chr(13) & split(aValue,chr(9))(0) next set dTags = dict end function 'returns a dictionary of tags by name with the complete string, an ASCII tab, and the value. function eComGetTagd(anID, aTable) DIM rsTags,dict,oStr,sName,aStr,aValue,tagStringLength set dict = CreateObject("Scripting.Dictionary") dict.CompareMode=1 'text mode (case insensitive) tagStringLength = cint(eComSQLjoin("SELECT COL_LENGTH('tags', 'string') AS x","")("X")) oStr="" Set rsTags = eComSQL("SELECT coa.Name as name, tags.string as string, tags.value as value FROM TAGS INNER JOIN COA ON TAGS.tagTreeID = COA.id WHERE COA.TableID = '"&aTable&"' AND TAGS.TargetID='"&anID&"' ORDER BY targetID, tags.ID;") set eComGetTagd = dict if rsTags.State<>1 then exit function while Not rsTags.EOF sName = trim(split(rsTags("name"),"(#")(0)) aStr = trim(split(rsTags("string")&chr(0),chr(0))(0)) aValue = trim(rsTags("value")) if not IsNumeric(aValue) then aValue = 0 if aValue = 0 then aValue = "" else aValue = chr(9)&aValue if dict.Exists(sName) then if len(oStr)=tagStringLength then oStr = aStr 'save the last string to check for continuation. aStr=dict(sName)&aStr 'assume this is a continuation of a single tag entry that was too long for one record. else oStr = aStr 'save the last string to check for continuation. aStr=dict(sName)&chr(13)&aStr 'assume this is a new tag entry end if dict.remove(sName) else oStr = aStr 'save the last string to check for continuation. end if dict.add sName, aStr & aValue rsTags.MoveNext wend rsTags.Close set eComGetTagd = dict end function function eComGetTag(byRef storeID, name, bmakeTagType) DIM eComRS if IsNumeric(name) then set eComRS = eComSQL("SELECT coa.id, Coa.storeID, Tables.name, coa.TableID FROM Coa JOIN Tables ON Coa.TableID = Tables.ID WHERE Coa.storeID IN ('"&storeID&"','"&iGenericstoreID&"') AND Coa.id = '"&name&"'") else set eComRS = eComSQL("SELECT coa.id, Coa.storeID, Tables.name, coa.TableID FROM Coa JOIN Tables ON Coa.TableID = Tables.ID WHERE Coa.storeID IN ('"&storeID&"','"&iGenericstoreID&"') AND Coa.name = '"&name&"'") end if if eComRS.eof then if not bMakeTagType then err.raise vbObjectError + 1,"eComGetTag","no such tag("&name&") for store("&storeID&")." else 'need to add code for a new tag 'was this causing |-|343|80040001|Invalid_advise_flags__ ? err.raise vbObjectError + 1,"eComGetTag","no such tag("&name&") for store("&storeID&")." end if end if storeID = eComRS("storeID") set eComGetTag = eComRS end function function eComAddTag(byVal storeID, name, byVal targetID, string, byVal value) 'find or make a tag type 'add a new tag string and value DIM eComRS, tagTreeID, Table, store eComAddTag = false Store = storeID set eComRS = eComGetTag(storeID, name, true) tagTreeID = eComRS("id") Table = trim(eComRS("name")) TableID = eComRS("TableID") if store = iGenericStoreID then targetID = 0 - targetID 'all generic data targets negative values else set eComRS = eComSQL("SELECT "&Table&".id FROM "&Table&" WHERE id = '"&targetID&"';") if eComRS.eof then err.raise vbObjectError + 1,"no such targetID("&targetID&") for the table("&table&") targeted by tag("&name&")." end if tagStringLength = eComSQLjoin("SELECT COL_LENGTH('tags', 'string') AS x"," ")("X") if not isNumeric(value) then value = 0 string = replace(string, chr(9), "") 'string can not have tab so tabs can seperate string and value when tags are returned as a dictionary object string = replace(string, chr(13), "") 'string can not have Cr so Cr can seperate multiple tags of same type when returned as a dictionary object while len(string) > 0 if eComRS.state=1 then eComRS.Close ' adStateOpen sSQL="INSERT INTO tags (tagTreeID, string, value, targetID) VALUES ('"&tagTreeID&"', "&eComSQLStr(left(string, tagStringLength))&", '"&value&"', '"&targetID&"');" eComDebug "Add tag:"&name &". s="& store &"c="& targetID & sSQL eComRS.open sSQL,eComConn,,3 'eComRS.close 'its already closed if len(string)>tagStringLength then string = mid(string, tagStringLength+1) else string = "" wend eComAddTag = true end function function eComUpTag(byVal storeID, name, targetID, string, value) 'find the tag and update its string and value. DIM eComRS, tagTreeID, Table, store set eComRS = eComGetTag(storeID, name, false) 'changes storeID tagTreeID = eComRS("id") Table = eComRS("name") TableID = eComRS("TableID") set eComRS = eComSQL("SELECT * FROM Tags WHERE tagTreeID = '"&tagTreeID&"' AND targetID = '"&targetID&"';") if eComRS.eof then err.raise vbObjectError + 1,"no such tag("&name&") for targetID("&targetID&") in table("&table&")." eComDebug "TAG "&name & ":'" & eComRS("string") & "' := '" & string & "', " & eComRS("value") & " := " & value eComRS("string")=string eComRS("value")=value eComRS.update eComRS.close set eComRS = nothing end function function eComLearnTag(byVal storeID, name, byVal targetID, string, value) 'find the tag type and make one if it doesn't exist 'find the target tag ' add one if it doesn't exist ' update the string and value if it does DIM eComRS, sSQL, tagTreeID, table, TableID, store, tagStringLength store = storeID set eComRS = eComGetTag(storeID, name, true) 'changes storeID if generic type data tagTreeID = eComRS("id") Table = trim(eComRS("name")) TableID = eComRS("TableID") if store = iGenericStoreID then targetID = 0 - targetID 'all generic data targets negative values else set eComRS = eComSQL("SELECT "&Table&".id FROM "&Table&" WHERE id = '"&targetID&"';") if eComRS.eof then err.raise vbObjectError + 1,"no such targetID("&targetID&") for the table("&table&") targeted by tag("&name&")." end if set eComRS = eComSQL( "SELECT * FROM Tags WHERE tagTreeID = '"&tagTreeID&"' AND targetID = '"&targetID&"';") tagStringLength = eComRS("string").DefinedSize if not isNumeric(value) then value = 0 while len(string) > 0 if eComRS.state=1 then if eComRS.eof then eComRS.Close ' adStateOpen if eComRS.state = 0 then ' adStateClosed sSQL="INSERT INTO tags (tagTreeID, string, value, targetID) VALUES ('"&tagTreeID&"', "&eComSQLStr(left(string, tagStringLength))&", '"&value&"', '"&targetID&"');" eComDebug "Add tag:"&name &". s="& store &"c="& targetID & sSQL eComRS.open sSQL,eComConn,,3 'eComRS.close 'its already closed else if trim(eComRS("string"))=left(string,tagStringLength) then eComDebug "Known tag:"& name &". s="& store &"c="& targetID &" '" & trim(eComRS("string")) & "', " & eComRS("value") else eComDebug "Update tag:"& name &". s="& store &"c="& targetID &" '" & trim(eComRS("string")) & "' := '" & left(string, tagStringLength) & "', " & eComRS("value") & " := " & value eComRS("string")=left(string, tagStringLength) eComRS("value")=value eComRS.update end if eComRS.moveNext end if if len(string)>tagStringLength then string = mid(string, tagStringLength+1) else string = "" wend set eComRS = nothing end function function eComNewTag(byVal storeID, name, byVal targetID, string, value) 'find the tag type and make one if it doesn't exist 'find the target tag ' add one if it doesn't exist DIM eComRS, sSQL, tagTreeID, table, TableID, store, tagStringLength store = storeID set eComRS = eComGetTag(storeID, name, true) 'changes storeID if generic type data tagTreeID = eComRS("id") Table = trim(eComRS("name")) TableID = eComRS("TableID") if store = iGenericStoreID then targetID = 0 - targetID 'all generic data targets negative values else set eComRS = eComSQL("SELECT "&Table&".id FROM "&Table&" WHERE id = '"&targetID&"';") if eComRS.eof then err.raise vbObjectError + 1,"no such targetID("&targetID&") for the table("&table&") targeted by tag("&name&")." end if set eComRS = eComSQL( "SELECT * FROM Tags WHERE tagTreeID = '"&tagTreeID&"' AND targetID = '"&targetID&"';") tagStringLength = eComRS("string").DefinedSize if not isNumeric(value) then value = 0 while len(string) > 0 if eComRS.state=1 then if eComRS.eof then eComRS.Close ' adStateOpen if eComRS.state = 0 then ' adStateClosed sSQL="INSERT INTO tags (tagTreeID, string, value, targetID) VALUES ('"&tagTreeID&"', "&eComSQLStr(left(string, tagStringLength))&", '"&value&"', '"&targetID&"');" eComDebug "Add tag:"&name &". s="& store &"c="& targetID & sSQL eComRS.open sSQL,eComConn,,3 'eComRS.close 'its already closed else eComDebug "Known tag:"& name &". s="& store &"c="& targetID &" '" & trim(eComRS("string")) & "', " & eComRS("value") eComRS.moveNext end if if len(string)>tagStringLength then string = mid(string, tagStringLength+1) else string = "" wend set eComRS = nothing end function DIM dStateCodes set dStateCodes = CreateObject("Scripting.Dictionary") dStateCodes.CompareMode = 1 dStateCodes.Add "AL","Alabama" dStateCodes.Add "AK","Alaska" dStateCodes.Add "AZ","Arizona" dStateCodes.Add "AR","Arkansas" dStateCodes.Add "CA","California" dStateCodes.Add "CO","Colorado" dStateCodes.Add "CT","Connecticut" dStateCodes.Add "DE","Delaware" dStateCodes.Add "DC","District of Columbia" dStateCodes.Add "FL","Florida" dStateCodes.Add "GA","Georgia" dStateCodes.Add "HI","Hawaii" dStateCodes.Add "ID","Idaho" dStateCodes.Add "IL","Illinois" dStateCodes.Add "IN","Indiana" dStateCodes.Add "IA","Iowa" dStateCodes.Add "KS","Kansas" dStateCodes.Add "KY","Kentucky" dStateCodes.Add "LA","Louisiana" dStateCodes.Add "ME","Maine" dStateCodes.Add "MD","Maryland" dStateCodes.Add "MA","Massachusetts" dStateCodes.Add "MI","Michigan" dStateCodes.Add "MN","Minnesota" dStateCodes.Add "MS","Mississippi" dStateCodes.Add "MO","Missouri" dStateCodes.Add "MT","Montana" dStateCodes.Add "NE","Nebraska" dStateCodes.Add "NV","Nevada" dStateCodes.Add "NH","New Hampshire" dStateCodes.Add "NJ","New Jersey" dStateCodes.Add "NM","New Mexico" dStateCodes.Add "NY","New York" dStateCodes.Add "NC","North Carolina" dStateCodes.Add "ND","North Dakota" dStateCodes.Add "OH","Ohio" dStateCodes.Add "OK","Oklahoma" dStateCodes.Add "OR","Oregon" dStateCodes.Add "PA","Pennsylvania" dStateCodes.Add "PR","Puerto Rico" dStateCodes.Add "RI","Rhode Island" dStateCodes.Add "SC","South Carolina" dStateCodes.Add "SD","South Dakota" dStateCodes.Add "TN","Tennessee" dStateCodes.Add "TX","Texas" dStateCodes.Add "UT","Utah" dStateCodes.Add "VT","Vermont" dStateCodes.Add "VA","Virginia" dStateCodes.Add "WA","Washington" dStateCodes.Add "WV","West Virginia" dStateCodes.Add "WI","Wisconsin" dStateCodes.Add "WY","Wyoming" function ValidStateCode(aStateCode) ValidStateCode = dStateCodes.Exists(aStateCode) end function function StateName(aStateCode) dim s s=ucase(left(trim(aStateCode),2)) if dStateCodes.Exists(s) then StateName = dStateCodes(s) end function function StateCode(aStateName) dim a,b, s s = uCase(aStateName) a = dStateCodes.Items b = dStateCodes.Keys for i = 0 to dStateCodes.Count -1 if uCase(a(i)) = s then StateCode = b(i) next end function function sZipState(sZip) 'given a 5 digit zip code, find the state with a matching range of zip codes. 'http://javascript.internet.com/forms/zip-to-state.html DIM z,s,i s = "00215NH00544NY00795PR00851VI00988PR02791MA02940RI03897NH04992ME05495VT05544MA05907VT"_ &"06389CT06390NY06928CT08989NJ09899AE14925NY19640PA19980DE20099DC20199VA20599DC21930MD"_ &"24658VA26886WV28909NC29945SC31999GA33994FL34099AA34997FL36925AL38589TN39776MS39901GA"_ &"42788KY45999OH47997IN49971MI52809IA54990WI56763MN57799SD58856ND59937MT62999IL65899MO"_ &"67954KS69367NE71497LA72959AR73199OK73344TX74966OK79999TX81658CO83128WY83422ID83422WY"_ &"83888ID84791UT86556AZ88441NM88595TX89883NV96162CA96698AP96797HI96799AS96898HI96932GU"_ &"96940PW96944FM96952MP96970MH97920OR99403WA99950AK" ZipState = "" if VarType(sZip)<>8 AND IsNumeric(sZip) then z = right("00000"&cStr(int(sZip)),5) 'vbString=8 if len(sZip)=2 and instr(1,s,sZip,1)>0 then sZipState = ucase(sZip) eComDebug "sZipState("&sZip&"): VALID" exit function end if z=left(sZip,5) 'so we have a 5 digit zip but don't loose the +4 if it is there. if len(z)<>5 OR sZip="00000" then exit function for i = 1 to len(s) step 7 if z <= mid(s,i,5) then sZipState=mid(s,i+5,2) eComDebug "sZipState("&sZip&"): "&z&"="&sZipState exit function end if next eComDebug "sZipState("&sZip&"): "&z&" invalid" end function function StdWrd (this, that) eComDebug "StdWrd("&this&","&that&")" StdWrd=join(filter(split(that,"="),","&split(this)(0)&",",true,1)) eComDebug " using rule:"&StdWrd&"." if len(StdWrd) > 0 then StdWrd = split(StdWrd,",")(0)&" "&split(this)(1) else StdWrd = this end if eComDebug " ="&StdWrd&"." end function function NormAddr(sStreet) DIM s,i DIM n, Dir, Name, Typ on error resume next eComDebug "'"&sStreet&"'" if sStreet=empty then exit function 'need lot of work here s = trim(ucase(sStreet)) name = "" 'twice for grid addresses (e.g. Salt Lake City) for j = 1 to 2 'get a street number for i=1 to len(s) if instr(" 0123456789/.-()",mid(s,i,1))<1 then Exit For next n = trim(left(s,i-1)) if len(n)>0 then eComDebug " -number:"&n&"." name = mid(s,i) NormAddr = NormAddr & n if ubound(split(name))>2 then 'norm NORTH->N. SOUTH->S. EAST->E. WEST->W. s = "=N,N,NORTH,=S,S,SOUTH,=E,E,EAST,=W,W,WEST,=NE,NORTHEAST,=SE,SOUTHEAST,=NW,NORTHWEST,=SW,SOUTHWEST " s=join(filter(split(s,"="),","&split(Name)(0)&",")) if len(s)>0 then eComDebug " -convert:"&name&"." s = split(s,",")(0) Name = trim(split(Name&" "," ",2)(1)) eComDebug " - to:"&s&". and:"&name&"." NormAddr = NormAddr & " " & s end if end if s = name NormAddr = trim(NormAddr) & " " next 'get street name? Name = split(Name," ") for i = 0 to ubound(name)-1: eComDebug " -keep:"&name(i)&".":NormAddr = NormAddr & name(i) & " ": next 'norm abbreviation as per H:\techref\datafile\streetabr.txt s=",=ALY,ALLEE,ALLEY,ALLY,"_ &"=ANX,ANEX,ANNEX,ANNX,"_ &"=ARC,ARCADE,"_ &"=AVE,AV,AVNUE,AVEN,AVENU,AVENUE,AVN,"_ &"=BYU,BAYOO,BAYOU,"_ &"=BCH,BEACH,"_ &"=BND,BEND,"_ &"=BLF,BLUF,BLUFF,"_ &"=BLFS,BLUFFS,"_ &"=BTM,BOT,BOTTOM,BOTTM,"_ &"=BLVD,BOULV,BOUL,BOULEVARD,"_ &"=BR,BRANCH,BRNCH,"_ &"=BRG,BRDGE,BRIDGE,"_ &"=BRK,BROOK,"_ &"=BRKS,BROOKS,"_ &"=BG,BURG,"_ &"=BGS,BURGS,"_ &"=BYP,BYPASS,BYPA,BYPAS,BYPS,"_ &"=CP,CAMP,CMP,"_ &"=CYN,CANYN,CANYON,CNYN,"_ &"=CPE,CAPE,"_ &"=CSWY,CAUSEWAY,CAUSWAY,"_ &"=CTR,CEN,CENT,CENTER,CENTR,CENTRE,CNTER,CNTR,"_ &"=CTRS,CENTERS,"_ &"=CIR,CRCLE,CIRC,CIRCL,CIRCLE,CRCL,"_ &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E,TRNPK,TURNPIKE,TURNPK,"_ &"=UPAS,UNDERPASS,"_ &"=UN,UNION,"_ &"=UNS,UNIONS,"_ &"=VLY,VALLEY,VALLY,VLLY,"_ &"=VLYS,VALLEYS,"_ &"=VIA,VDCT,VIADUCT,VIADCT,"_ &"=VW,VIEW,"_ &"=VWS,VIEWS,"_ &"=VLG,VILL,VILLAG,VILLAGE,VILLG,VILLIAGE,"_ &"=VLGS,VILLAGES,"_ &"=VL,VILLE,"_ &"=VIS,VSTA,VIST,VISTA,VST,"_ &"=WALK,WALKS,"_ &"=WAY,WY,"_ &"=WL,WELL,"_ &"=WLS,WELLS," _ &"=AVE,AVENIDA," _ &"=CLL,CALLE," _ &"=CMT,CAMINITO," _ &"=CAM,CAMINO," _ &"=CER,CERRADA," _ &"=CIR,CIRCULO," _ &"=ENT,ENTRADA," _ &"=PSO,PASEO," _ &"=PLA,PLACITA," _ &"=RCH,RANCHO," _ &"=VER,VEREDA," _ &"=VIS,VISTA," s=join(filter(split(s,"="),","&name(i)&",")) if len(s)>0 then s = split(s,",")(0) eComDebug " -convert:"&name(i)&". to:"&s&"." NormAddr = trim(NormAddr & s) else eComDebug " -keep:"&name(i)&"." NormAddr = trim(NormAddr & name(i)) end if NormAddr = fcase(NormAddr) end function function ecomCounty(fips) 'expects fips to be an array with sfips as the first element and cfips as the second DIM sI on error resume next if ubound(fips)<>1 then err.raise 1, "ecomCounty() Expects two element array as parameter":exit function if isNumeric(fips(0)) AND isNumeric(fips(1)) then sSQL = "SELECT name FROM Counties WHERE sfips = "&fips(0)&" AND cfips = '"&trim(fips(1))&"';" eComDebug sSQL ecomCounty = eComSQLJoin(sSQL,",")("name") else err.raise 2, "ecomCounty() Expects numeric array elements" exit function end if end function function sZipPlus4(sName, byRef sAddress, sCity, sState, aZip, byRef sCounty) DIM nZip, sZip, i, sI, sStreetNo DIM rsTags, sSQL eComDebug "sZipPlus4(sName="&sName&", byRef sAddress="&sAddress&", sCity="&sCity&", sState="&sState&", aZip="&aZip&", sCounty="&sCounty&")" sZip = aZip nZip = 0 sState = ucase(trim(sState)) sZip = replace(trim(sZip),"-",".") if IsNumeric(sZip) then nZip = cdbl(sZip) 'if it looks reasonable, add it if sCity<>Empty AND sState<>Empty AND nZip>1 AND sZipState(nZip)=sState then eComNewTag iGenericStoreID, COA_City_State_Zip, int(nZip), fcase(sCity)&", "&sState, int(nZip) end if sZip = right("00000"&CSTR(int(nZip)),5) eComDebug "sZip="&sZip&". nZip="&nZip if nZip > 1 AND sCity = Empty then 'look for a ZIP to City State relation sSQL = "SELECT Tags.string as cityState "_ &" FROM Tags INNER JOIN Coa ON Tags.tagTreeID = Coa.id "_ &" WHERE Coa.name = 'City State Zip'"_ &" AND Tags.targetID < 0 "_ &" AND Tags.value >= "&nZip&" AND Tags.value < "&nZip+1&";" set rsTags = ecomSQL(sSQL) if rsTags.eof then rsTags.Close sZipPlus4 = sZip else eComDebug "ZIP:"&sZip&" known as "&rsTags("cityState") sZipPlus4 = sZip sCity = split(rsTags("cityState"),",")(0) eComDebug "sCity:"&sCity&"." sState = mid(rsTags("cityState"),len(sCity)+3,2) if sZipState(sZip)<>sState then eComDebug "bad:'"&sState&"'~'"&sZipState(sZip)&"'" eComDebug "sState:"&sState&"." end if end if sAddress=NormAddr(sAddress) if nZip > 1 AND nZip - int(nZip) > 0 AND sAddress = Empty then 'we were given a specific zip+4 and no sAddress sSQL = "SELECT tags.string as address"_ &" FROM TAGS INNER JOIN COA ON TAGS.tagTreeID = COA.id "_ &" WHERE COA.Name = 'Street'"_ &" AND TAGs.TargetID < 0 "_ &" AND TAGs.Value="&nZip&";" set rsTags = ecomSQL(sSQL) if rsTags.eof then rsTags.Close nZip = int(nZip) else eComDebug "ZIP+4:"&sZip&" known as "&rsTags("address") sI = split(rsTags("address")&vbCr&"", vbCr,2) sStreet = trim(sI(0)) sCounty = ecomCounty(split(si(1),":",2)) if sStreet=left(sAddress,len(sStreet)) then sAddress = ", "&mid(sAddress,len(sStreet)) end if end if if sAddress<>Empty AND (nZip>1 OR (sCity<>Empty AND sState<>Empty) ) then ' The first Zip found for a city name is only one of many possible Zip codes for that city. ' we need to be recording and retrieving a RANGE of zip codes for each city. sSQL = "SELECT Tags.string as address, Tags.value as zip FROM Tags" sSQL = sSQL & " WHERE Tags.tagTreeID=" & COA_Street 'stree address sSQL = sSQL & " AND Tags.targetID < 0" 'generic data only if nZip > 1 then sSQL = sSQL & " AND FLOOR(Tags.value) = "&int(nZip) 'zip -4 else sSQL = sSQL & " AND FLOOR(Tags.value) IN " 'zip -4 sSQL = sSQL & " ( SELECT Tags.value FROM Tags " sSQL = sSQL & " WHERE Tags.tagTreeID = " & COA_City_State_Zip 'city, state sSQL = sSQL & " AND Tags.targetID < 0" 'generic data only sSQL = sSQL & " AND Tags.string = "&eComSQLStr(fcase(sCity)&", "&sState) sSQL = sSQL & " )" end if sSQL = sSQL & " AND Tags.string LIKE "&eComSQLStr(sAddress&"%")&";" set rsTags = ecomSQL(sSQL) if rsTags.eof then sZip4Scrape sName, sAddress, sCity, sState, sZip, sCounty else nZip = abs(rsTags("zip"))'abs required 'cause generic zips may be negative sZip = split(cStr(nZip),".") sZip(0) = right(string(5,"0")&sZip(0),5) sZip = join(sZip,"-") if len(sZip)>6 then sZip = left(sZip&string(4,"0"),10) sI = split(rsTags("address")&vbCr&"", vbCr)(1) sCounty = ecomCounty(split(si,":",2)) eComDebug "Street:"&sAddress&" known as "&sZip&" in county"&sCounty&" fips:"&sI&"="&rsTags("address") end if end if sZipPlus4 = sZip end function function sZip4Scrape(sName, byRef sAddress, SCity, sState, sZip, byRef sCounty) DIM nZip, i, sI, sStreet, sStreetNo, sFips DIM rsTags, sSQL, sPost, xobj, sRetVal eComDebug "sZip4Scrape(sName="&sName&", byRef sAddress="&sAddress&", SCity="&sCity&", sState="&sState&", sZip="&sZip&", sCounty="&sCounty&")" if sZip = "00000" then zZip = "" if (sAddress <> Empty and sCity <> Empty and sState <> Empty) or (sZip <> Empty and sAddress <> Empty) or len(sZip) > 8 then else eComDebug " nothing to look up" exit function end if 'sURL = "http://www.usps.com/cgi-bin/zip4/zip4inq2" 'sURL = "http://zip4.usps.com/zip4/zip4_responseA.jsp" 'sURL = "http://zip4.usps.com/zip4/zcl_0_results.jsp" 'sURL = "https://tools.usps.com/go/SearchAction.action" sURL = "https://tools.usps.com/go/ZipLookupResultsAction!input.action" sPost = "" sPost = sPost & "resultMode=1" sPost = sPost & "&companyName=" '& URLEncode(sName) sPost = sPost & "&address1=" & Server.URLEncode(sAddress) sPost = sPost & "&address2=" sPost = sPost & "&city=" & Server.URLEncode(sCity) sPost = sPost & "&state=" & Server.URLEncode(sState) sPost = sPost & "&urbanCode=" sPost = sPost & "&postalCode=" sPost = sPost & "&zip=" & Server.URLEncode(zZip) 'sPost = sPost & "&submit%2Ex=30" 'sPost = sPost & "&submit%2Ey=8" eComDebug "scrapeing:"&sURL&" with data:"&sPost&"." on error resume next sRetVal = ecomURLscrape(sURL,sPost,"","") eComDebug "Scraped" if err<>0 then eComDebug err:eComDebug err.description:response.end on error goto 0 i = 0 ' if i=0 then i = instr(sRetVal,"The standardized address is") ' if i=0 then i = instr(sRetVal,"The address you entered was found") ' if i=0 then i = instr(sRetVal,"Official Postal Format") ' if i=0 then i = instr(sRetVal,"Address (Standard Format)") if i=0 then i = instr(sRetVal,"Here's the full address") if i>0 then eComDebug "address returned" sRetVal = replace(mid(sRetVal,i), " ", " ") sStreetNo = split(sAddress)(0) if IsNumeric(sStreetNo) then si = eComExtract(""&sStreetNo, sRetVal, 40) if len(sI)=0 then sI = eComExtract(sStreetNo&" ", sRetVal, 40) if Len(sI)>0 then sI = sStreetNo&" "&sI end if 'if Len(si)=0 then sI = eComExtract("",join(filter(split(sRetVal,">"),"","->")&sCrLf&" -->" if InDebugMode then print "","->"),"
","",1,1,1),"
")(0)&sCrLf&" -->" end if end function function statusPrint(amsg) 'to be over-ridden in your program. end function function scrapePhone(sArea, sPhone, byRef sFName, byRef sMName, byRef sLName, byRef sStreet, byRef sCity, byRef sState, byRef sZip) dim sI,iI dim sRetVal, sPost, aName if len(sArea) < 1 then if len(sPhone) > 8 then sPhone = replace(sPhone,"(","") if left(sPhone,1) = "1" then sPhone = mid(sPhone,2) if left(sPhone,1) = "-" then sPhone = mid(sPhone,2) sArea = left(sPhone,3) sPhone = mid(sPhone,4) if left(sPhone,1) = "-" then sPhone = mid(sPhone,2) end if end if sPhone=left(replace(replace(sPhone,"-","")," ",""),7) 'sPhone=left(sPhone,3)&"-"&mid(sPhone,4) statusPrint "*Looking up ("&sArea&") " & sPhone & " in public phone listings." randomize On Error Resume Next 'Good test numbers '?a=541&p=8466647 '?a=541&p=8466808 '?a=541&p=8466357 '?a=760&p=7580615 '?a=760&p=7499721 '?a=619&p=2834205 '?a=405&p=3727380 '?a=805&p=3891664 'http://anywhoyp.yellowpages.com/reversephonelookup?from=anywho_cobrand&fap_terms%5Bphone%5D=%28937%29+429-5500 sURL = "http://people.yellowpages.com/reversephonelookup" sPost = "phone="& Server.URLEncode(sArea) & Server.URLEncode(sPhone) sPost = sPost + "&site=79" 'sPost = sPost + "&btnsubmit.x=" & Server.URLEncode(59*rnd+1) 'sPost = sPost + "&btnsubmit.y=" & Server.URLEncode(21*rnd+1) 'xobj.AddCookie(CookieName, CookieValue) xobj.ConnectionTimeout=2000 ' URL, action, payload, username, password eComDebug "" eComDebug "" sRetval = ecomURLscrape(sURL&"?"& sPost, "", "", "") StatusPrint chr(13)&"Recieved response" eComDebug server.HTMLEncode(sRetval) ' response.end If Err.Number <> 0 Then StatusPrint " E:"&Err.Number: exit function sTel="1-"&sArea&"-"&sPhone 'sRetVal = left(TextAfter(sRetVal,"yellowpagescom.intelius.com"), 100) sFName=eComExtract("qf=", sRetVal,30) sMName=textafter(sFName," ") sLName=eComExtract("qn=", sRetVal,30) sName=trim(sFName & " " & sLName) sCity=eComExtract("qc=", sRetval,40) sStreet=split(eComExtract("
", sRetval,40)&sCity,sCity)(0) sState=eComExtract("qs=", sRetval, 5) sZip=eComExtract("qz=", sRetval,10) sI = "" for I=1 to len(sZip) if IsNumeric(mid(sZip,I,1)) then sI = sI & mid(sZip,I,1) next if IsNumeric(sI) then sZip=right("00000"&CStr(CInt(sI)),5) sState = sZipState(sState) if sState=Empty then sState = sZipState(sZip) sCode="n/a" sEMail=eComExtract("email=", sRetval,40) ' sWeb=eComExtract("| if sName <> Empty OR sStreet <> Empty OR sEMail <> Empty then StatusPrint sFName & " " & sMName & " " & sLName StatusPrint "Street: " & sStreet StatusPrint "City: " & sCity StatusPrint "State: " & sState StatusPrint "Zip: " & sZip StatusPrint "EMail: " & sEMail StatusPrint "WebSite: "& sWeb end if ' eComDebug "
" & server.HTMLencode(mid(sRetVal,instr(sRetVal,"state="),20)) Err.Number = 0 end function sub xecurrency(Amount) %>

to
<% end sub function USPSRateScrape(DestCountry, Lbs, Ozs, OrginZip, DestZip) DIM shtml,sURL,sCo sCo = DestCountry 'need to remove text after "," or "+" sURL = "&sd=1" if instr(sCo,"US Possession")>1 then sCo = "US Possession" if instr(sCo,"Virgin Islands")>1 AND instr(sCo, "British")<1 then sCo = "US Possession" select case sCo case "USA","US","United States", "United States of America", "America" if OriginZip=Empty OR DestZip=Empty then err.raise 1, "Addresses in the USA require source and destination zip codes" sURL = "&OZ="&OriginZip&"&DZ="&DestZip sCo = "Domestic" case "US Possession", "Wake Island","Virgin Islands","Howard Island","Guam","Frederiksted, US Virgin Islands","Commonwealth of the Northern Mariana Islands","American Samoa" sURL = "&OZ="&OriginZip&"&DZ="&DestZip sCo = "US Possession" end select shtml = ecomURLscrape("http://ircalc.usps.gov/MailServices.aspx?Country="&sCo&"&M=2&P="&Lbs&"&O="&Ozs&sURL, "", "", "") 'http://ircalc.usps.gov/MailServices.aspx?Country=Domestic&M=2&P=1&O=0&OZ=92027&DZ=92590 end function %>