<%@ LANGUAGE=VBScript LCID=1033%>
<%
' Utility sample for Aspicore GSM Tracker
' Show URL arguments as plain text and stores data into MS Access database (or MS SQL Server)
'
' This sample demonstrates, how Aspicore GSM Tracker sends location data to the server via HTTP.
'
' Usage: Set "Internet page URL" in Aspicore GSM Tracker settings to point to this page.
' You see the output in your phone in the Info tab every time the phone sends
' some location data to the server via a HTTP connection.
'
' Note: For simplicity, this script stores GPS data only.
' You can amend it to store also the cell tower info.
'
' (c) Aspicore Ltd 2005, www.aspicore.com
'
' Tested with Windows XP, IIS ASP 5.1 and Windows 2000, IIS ASP 5.0
' ADODB v2.7
' ------------------------------
' Change History:
' 2005-04-14 jje - Script created
%>
<% Option Explicit
Response.Buffer = True
Response.ContentType = "text/plain; charset=ISO-8859-1"
Response.Expires = 0
' Response.LCID = 1033 ' Windows 2000 does not support this, so replaced by the following line
Session.LCID = 1033 ' Geographical locale telling how to format dates and times, 1033 = English - US
%>
<!--#INCLUDE FILE="adovbs.inc"-->
<%
Dim vImei
Dim vStatus
Dim vLat
Dim vLon
Dim vSpeed
Dim vCourse
Dim vTime
Dim vDate
Dim vLabel
Dim vRemoteIP
vImei = Null
vStatus = Null
vLat = Null
vLon = Null
vSpeed = Null
vCourse = Null
vTime = Null
vDate = Null
vLabel = Null
vRemoteIP = Request.ServerVariables("REMOTE_ADDR")
' ------------------------
' Show time and arguments in the response to the HTTP client
Response.Write Now() & vbCrLf
Dim item
Dim itemValue
For Each item In Request.QueryString
itemValue = Request.QueryString(item)
Response.Write item & " => " & itemValue
Select Case item
Case "imei"
vImei = itemValue
Case "status"
vStatus = itemValue
Case "lat"
ON ERROR RESUME NEXT
vLat = CDbl(itemValue)
ON ERROR GOTO 0
Case "lon"
ON ERROR RESUME NEXT
vLon = CDbl(itemValue)
ON ERROR GOTO 0
Case "speed"
ON ERROR RESUME NEXT
vSpeed = CDbl(itemValue)
ON ERROR GOTO 0
Case "course"
ON ERROR RESUME NEXT
vCourse = CDbl(itemValue)
ON ERROR GOTO 0
Case "time"
vTime = itemValue
Case "date"
vDate = itemValue
Case "label"
vLabel = itemValue
Case Else ' Other values.
Response.Write " (Ignored)"
End Select
Response.Write vbCrLf
Next
Response.Write vbCrLf
' ------------------------
' Show message in the response to the HTTP client
If IsNull(vLat) AND IsNull(vLon) Then ' *****
Response.Write "lat and lon missing" & vbCrLf
Response.Write "No data added into DB" & vbCrLf
Else ' *****
' ------------------------
' Store new data into Access database (or MS SQL Server db)
' (Make sure the file storemdb.mdb with table GPS exists in the location given in strConn,
' perhaps rather somewhere else than the C:\WINDOWS\Temp\ directory used in the sample.)
' ------------------------
' Connecting, selecting database
Dim objDBConn ' As ADODB.Connection
Dim strConn
' ***********************************************************************
' Enable either of the following connect strings
' ***********************************************************************
' Microsoft Access 2000 (*.mdb) Connect String
strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\WINDOWS\Temp\storemdb.mdb"
' ***********************************************************************
' MS SQL Server Connect String
' strConn="Provider=SQLOLEDB.1;Data Source=(local);Initial Catalog=GSM_Tracker;User ID=UID;Password=PWD;Persist Security Info=True"
' ***********************************************************************
Set objDBConn = Server.CreateObject("ADODB.Connection")
objDBConn.Open strConn
' Performing SQL query
Dim cmd ' As ADODB.Command
Dim prm ' As ADODB.Parameter
Dim sSQL
' Prepare an insert statement
sSQL = "INSERT INTO GPS (PHONE,STATUS,LATITUDE,LONGITUDE,SPEED_KNOTS,COURSE_DEG,UTCTIME,UTCDATE,LABEL,REMOTE_IP)" _
& " VALUES (?,?,?,?,?,?,?,?,?,?)"
Set cmd = Server.CreateObject("ADODB.Command")
cmd.CommandText = sSQL
cmd.CommandType = adCmdText
' Create parameters
Set prm = cmd.CreateParameter(, adVarChar, AdParamInput, 30, vImei)
cmd.Parameters.Append prm
Set prm = cmd.CreateParameter(, adChar, AdParamInput, 1, vStatus)
cmd.Parameters.Append prm
Set prm = cmd.CreateParameter(, adDouble, AdParamInput, , vLat)
cmd.Parameters.Append prm
Set prm = cmd.CreateParameter(, adDouble, AdParamInput, , vLon)
cmd.Parameters.Append prm
Set prm = cmd.CreateParameter(, adDouble, AdParamInput, , vSpeed)
cmd.Parameters.Append prm
Set prm = cmd.CreateParameter(, adDouble, AdParamInput, , vCourse)
cmd.Parameters.Append prm
Set prm = cmd.CreateParameter(, adVarChar, AdParamInput, 10, vTime)
cmd.Parameters.Append prm
Set prm = cmd.CreateParameter(, adVarChar, AdParamInput, 6, vDate)
cmd.Parameters.Append prm
Set prm = cmd.CreateParameter(, adVarChar, AdParamInput, 20, vLabel)
cmd.Parameters.Append prm
Set prm = cmd.CreateParameter(, adVarChar, AdParamInput, 15, vRemoteIP)
cmd.Parameters.Append prm
Set cmd.ActiveConnection = objDBConn
' Execute the statement
cmd.Execute
' Release resources
Set prm = Nothing
Set cmd = Nothing
' close connection
objDBConn.Close
Set objDBConn = Nothing
' Show message in the response to the HTTP client
Response.Write "Row added into DB" & vbCrLf
End If ' *****
%>