Next: unlock.mak
Up: Code Listing
Previous: tek222.bas
'
' Author: Terence Kelly
' Date: 5 September 1995
'
' This module serves exactly one purpose in life: it helps you
' "unlock" the WEBRTI program by deleting that program's lock file.
' The name of the file is stored in a global variable. A simple
' message is returned to the Web client indicating whether the
' unlock operation is successful or not.
'
Global Const strLockFile$ = "C:\HTTPD\HTDOCS\WEBRTI\WEBRTI.LOK"
Function Click_Here () As String
'
' Return a string consisting of an HTML document containing a
' button to click to unlock the RTI board.
'
URL$ = "http://piper.princeton.edu/cgi-win/unlock.exe?unlock"
Link$ = "<a href=" & Chr$(34) & URL$ & Chr$(34) & ">UNLOCK</a>"
B$ = HTML_H1("Unlock the WEBRTI program") & CRLF()
B$ = B$ & HTML_H2("Current lockfile:") & CRLF()
B$ = B$ & HTML_pre(FileContents(strLockFile$)) & CRLF() & CRLF()
B$ = B$ & "<p>" & CRLF() & "If you are <em>absolutely sure</em> "
B$ = B$ & "that the " & CRLF()
B$ = B$ & "WEBRTI program is really not in use, i.e. that the "
B$ = B$ & "program is " & CRLF()
B$ = B$ & "erroneously locked (due e.g. to a server or "
B$ = B$ & "executable crash), " & CRLF()
B$ = B$ & "then click on the UNLOCK link below." & CRLF()
B$ = B$ & "</p>" & CRLF()
B$ = B$ & HTML_H1(Link$) & CRLF()
Click_Here = HTML_document("Unlock the WEBRTI program", B$)
End Function
Sub Main ()
'
' Remove lock file. Return a happy or sad message to the
' client.
'
strCmdLine$ = Command$
strOutputFile$ = Split(strCmdLine$, 3, " ")
strURLArgs$ = Split(strCmdLine$, 4, " ")
If strURLArgs$ <> "unlock" Then
strReturn = Click_Here()
Else
strReturn = Unlock_RTI()
End If
Filenumber% = FreeFile
Open strOutputFile$ For Output As #Filenumber%
Print #Filenumber%, strReturn
Close #Filenumber%
End Sub
Function Unlock_RTI ()
'
' Unlock the RTI board by deleting the lock file, return a
' diagnostic message to the user.
'
If Dir$(strLockFile$) <> "" Then
Kill strLockFile
Title$ = "Unlock succeeded"
MSG$ = HTML_H1("Lock file removed")
Else
Title$ = "Unlock failed"
MSG$ = HTML_H1("Lock file not found")
End If
Unlock_RTI = HTML_document(Title$, MSG$)
End Function