home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 March
/
PCWK0397.iso
/
novell
/
webserv3
/
nws30.exe
/
DISK1
/
NETBASIC
/
WEB
/
ABGET.BAS
< prev
next >
Wrap
BASIC Source File
|
1996-09-23
|
11KB
|
780 lines
' Add all include files and define statements here
#include "BASIC.H"
#include "BTRIEVE.H"
#include "KEY.H"
#include "HTML.H"
#include "ERRORS.H"
#include "ABOOK.H"
Proc BTX:Index:Make
Local( "KeyPos", "KeyLen","KeyFlag" )
Local( "NotUsed", "Reserved3", "XKeyType", "MKey", "ACS" )
KeyPos = LowHigh( Param(1) )
KeyLen = LowHigh( Param(2) )
KeyFlags = LowHigh( Param(3) )
NotUsed = STR:Repeat( DATA:Char(0), 4 )
XKeyType = Param( 4, DATA:Char(0) )
Reserved3 = STR:Repeat( DATA:Char(0), 3 )
MKey = Param( 5, DATA:Char(0) )
ACS = Param( 6, DATA:Char(0) )
KeySpec = KeyPos + KeyLen + KeyFlags + NotUsed + XKeyType
KeySpec = KeySpec + Reserved3 + MKey + ACS
Return( KeySpec )
Proc BTX:Record:Make
Local( "FileSpec", "RecLen", "PageSize", "Indexes" )
Local( "Reserved4", "FileFlags", "Reserced2", "PreAlloc" )
RecLen = LowHigh( Param(1) )
PageSize = LowHigh( Param(2,1024) )
Indexes = LowHigh( Param(3,0) )
Reserved4 = STR:Repeat( DATA:Char(0), 4 )
FileFlags = LowHigh( Param(4,0))
Reserved2 = STR:Repeat( DATA:Char(0), 2 )
PreAlloc = LowHigh( Param(5,0) )
FileSpec = RecLen + PageSize + Indexes + Reserved4 + FileFlags
FileSpec = FileSpec + Reserved2 + PreAlloc
Return( FileSpec )
Sub GetOrgUnit
Local( "BtvRec", "OrgUnit", "OrgUnits", "DotPosition" )
BtvRec = Param(1)
' Skip the user object
DotPosition = STR:Search( ".", BtvRec.DISTINGUISHED_NAME )
If ( DotPosition )
OrgUnit = STR:Sub( BtvRec.DISTINGUISHED_NAME, DotPosition+1 )
OrgUnits = ""
Do While ( TRUE )
DotPosition = STR:Search( ".", OrgUnit )
If ( DotPosition != 0 )
OrgUnits = STR:Sub( OrgUnit, 1, DotPosition-1 )+ "/" + OrgUnits
OrgUnit = STR:Sub( OrgUnit, DotPosition+1 )
Else
Exit
EndIF
EndDO
EndIF
Return (OrgUnits)
End Sub
Sub GetRootObj
Local( "BtvRec", "RootObj", "TmpObj", "DotPosition" )
BtvRec = Param(1)
TmpObj = STR:Trim:All( BtvRec.DISTINGUISHED_NAME )
Do While ( TRUE )
DotPosition = STR:Search( ".", TmpObj );
If ( DotPosition )
TmpObj = STR:Sub( TmpObj, DotPosition+1 )
Else
Exit
EndIF
EndDO
RootObj = STR:Sub( TmpObj, 1, STR:Search( "@", TmpObj ) - 1 ) + "/"
Return (RootObj)
End Sub
Proc LowHigh
Local( "HI", "LO" )
' Change the integer byte order and return result as a binary string.
LO = DATA:Char( MATH:Mod( Param(1), 256 ) )
HI = DATA:Char( Param(1) / 256 )
Return( LO + HI )
Sub Main
'Declare local variables.
Local( "FileSpec", "Buf" )
Local( "Handle", "KeyBuf" )
Local( "UserObj", "OrgUnit", "RootObj", "NDS_URL", "NDS_Tree" )
Local( "BtvRec", "sHREF" )
Local( "RecCount", "iPos" )
DOC:Heading( "Address Book" )
DOC:Print( "<BODY BACKGROUND=""/images/image1.gif"">");
DOC:Tag:Begin(DOC_TAG_CENTER)
DOC:Image( "/images/novhead1.gif", "" )
DOC:Tag:End(DOC_TAG_CENTER)
' Check if BTX.NLM is loaded. If not return an error message.
If ( !NMX:Lib:Load( "BTX" ) )
DOC:Print( "BTX.NLM was not loaded or missing." ); NewLine
DOC:Print( "Please contact your administrator for assistance." );NewLine
DOC:Form:End
Return
EndIf
' Initialize sHREF variable
sHREF = "http://" + DOC:Env:Get( "SERVER_NAME" ) + "/netbasic/abform.bas"
' Get the query string
QueryStr = DOC:Env:Get( "QUERY_STRING" )
iPos = STR:Search( "&", DOC:Env:Get( "QUERY_STRING" ) )
if ( iPos = 0 )
DOC:Print( "Invalid query. Query: ", QueryStr )
Return
EndIF
' Extract the request string from the query string into ReqName
ReqName = STR:Sub( QueryStr, 6, iPos - 6 )
ReqType = "DN"
' If using btrieve data manager for DOS without btrieve.nlm loaded the
' file paths must include drive letters (A:...Z:) not volumes (SYS:).
FileSpec = BTX:Record:Make( 512, 2560, 1 )
FileSpec = FileSpec + BTX:Index:Make( 1, MAX_DGNAME, BTX_EXTTYPE_KEY )
' Get and open the database file from the configuration file.
DataBase = INI:Read( "SYS:\SYSTEM\ABOOK.CFG", "Common", "ExtractFile", "SYS:\SYSTEM\ABOOK.DBF" )
Handle = BTX:Call( "", BTX_OPEN, FileSpec, STR:Length(FileSpec), DataBase, 0 )
If ( SYS:Error:Number != 0 )
DOC:Paragraph;NewLine
DOC:Print( "Can't open a database file: ", DataBase );NewLine
DOC:Paragraph
DOC:Link:Button( sHREF, "Back to the search page" )
Return
EndIF
' Initialize KeyBuf and FileSpec
KeyBuf = STR:Pad:Right( ReqName, 512-LEN(ReqName))
FileSpec = STR:Repeat( " ", 2560 )
' Get the first record
Handle = BTX:Call( Handle, BTX_GET_LE, FileSpec, STR:Length(FileSpec), KeyBuf, 0 )
' Retrieve a btrieve or user record and return
DOC:Tag:Begin( DOC_TAG_PREFMT )
BtvRec = OBJECT:Make( "ERROR", 0 )
RecCount = 0
Do While ( SYS:Error:Number = 0 )
Buf = BTX:Data:Buffer(Handle)
BtvRec = BtvRec + OBJECT:Make( "DISTINGUISHED_NAME", STR:Sub( Buf, KEY1POSITION, MAX_DGNAME ) )
BtvRec = BtvRec + OBJECT:Make( "SURNAME", STR:Sub( Buf, KEY2POSITION, MAX_SURNAME ) )
BtvRec = BtvRec + OBJECT:Make( "GIVEN_NAME", STR:Sub( Buf, KEY3POSITION, MAX_GIVEN_NAME ) )
BtvRec = BtvRec + OBJECT:Make( "TITLE", STR:Sub( Buf, KEY4POSITION, MAX_TITLE ) )
BtvRec = BtvRec + OBJECT:Make( "DEPARTMENT", STR:Sub( Buf, KEY5POSITION, MAX_DEPARTMENT ) )
BtvRec = BtvRec + OBJECT:Make( "EMAIL_ADDRESS", STR:Sub( Buf, KEY6POSITION, MAX_EMAIL_ADDRESS ) )
BtvRec = BtvRec + OBJECT:Make( "LOCALITY_NAME", STR:Sub( Buf, KEY7POSITION, MAX_LOCALITY_NAME ) )
BtvRec = BtvRec + OBJECT:Make( "PHONE_NUMBER", STR:Sub( Buf, FIELD1POSITION, MAX_PHONE_NUMBER ) )
BtvRec = BtvRec + OBJECT:Make( "FAX_NUMBER", STR:Sub( Buf, FIELD2POSITION, MAX_FAX_NUMBER ) )
BtvRec = BtvRec + OBJECT:Make( "DESCRIPTION", STR:Sub( Buf, FIELD3POSITION, MAX_DESCRIPTION ) )
BtvRec = BtvRec + OBJECT:Make( "GEN_QUALIFIER", STR:Sub( Buf, FIELD4POSITION, MAX_GQ ) )
BtvRec = BtvRec + OBJECT:Make( "DELIVERY_OFFICE", STR:Sub( Buf, FIELD5POSITION, MAX_PD_OFFICE ) )
BtvRec = BtvRec + OBJECT:Make( "POSTAL_CODE", STR:Sub( Buf, FIELD6POSITION, MAX_POSTAL_CODE ) )
BtvRec = BtvRec + OBJECT:Make( "PO_BOX", STR:Sub( Buf, FIELD7POSITION, MAX_POBOX ) )
BtvRec = BtvRec + OBJECT:Make( "STATE", STR:Sub( Buf, FIELD8POSITION, MAX_STATE ) )
BtvRec = BtvRec + OBJECT:Make( "ADDRESS", STR:Sub( Buf, FIELD9POSITION, MAX_ADDRESS) )
If ( STR:Search( ReqName, STR:Trim:All(BtvRec.DISTINGUISHED_NAME) ) = 1 )
DOC:Print( "<FONT size=+2><B>Personal Information:</B></FONT>" );NewLine
ReturnRec( BtvRec )
RecCount = RecCount + 1
exit
EndIF
BtvRec = OBJECT:Make( "ERROR", 0 )
Handle = BTX:Call( Handle, BTX_GET_NEXT, FileSpec, STR:Length(FileSpec), Keybuf, 0 )
EndDo
' Close the database file
Handle = BTX:Call( Handle, BTX_CLOSE, FileSpec, STR:Length(FileSpec), DataBase, 0 )
If ( RecCount = 0 )
DOC:Print( "Record not found in the database. Please re-enter a new search." );NewLine
EndIf
DOC:Print( "<HR>" );NewLine
DOC:Paragraph
DOC:Link:Button(sHREF, "Back to the search page" )
DOC:Tag:End( DOC_TAG_PREFMT )
DOC:Form:End
Return
End Sub
Sub ReturnRec
Local( "BtvRec", "NDS_URL" )
Local( "UserObj", "OrgUnit", "RootObj" )
Local( "sHREF", "NDS_Tree", "DGName" )
BtvRec = Param(1)
DOC:Print("<HR>"); NewLine
UserObj = STR:Sub( BtvRec.DISTINGUISHED_NAME, 1, STR:Search( ".", STR:Trim:All(BtvRec.DISTINGUISHED_NAME ))-1 )
NDS_Tree = STR:Sub( BtvRec.DISTINGUISHED_NAME, STR:Search( "@", STR:Trim:All(BtvRec.DISTINGUISHED_NAME ))+1 )
OrgUnit = GetOrgUnit(BtvRec)
RootObj = GetRootObj(BtvRec)
NDS_URL = "/nds/"+STR:Trim:All(NDS_Tree)+"/"+RootObj+OrgUnit+UserObj
DOC:Print("<B>Name:</B> ", "<A HREF=http://", DOC:Env:Get( "SERVER_NAME" ), NDS_URL, ">", "<FONT size=+1>", STR:Trim:All(BtvRec.GIVEN_NAME), " ", STR:Trim:All(BtvRec.SURNAME), ", ", STR:Trim:All(BtvRec.GEN_QUALIFIER), "</FONT></A>" ); NewLine
DOC:Print("<B>Title:</B> ", STR:Trim:All(BtvRec.TITLE) ); NewLine
DOC:Print("<B>Dept:</B> ", STR:Trim:All(BtvRec.DEPARTMENT) ); NewLine
DOC:Print("<B>Description:</B> ", STR:Trim:All(BtvRec.DESCRIPTION) ); NewLine
DOC:Print("<B>E-Mail ID:</B> ", "<A HREF=mailto:", STR:Trim:All(BtvRec.EMAIL_ADDRESS), ">", "<FONT size=+1>", STR:Trim:All(BtvRec.EMAIL_ADDRESS), "</FONT></A>" ); NewLine
DOC:Print("<B>Phone:</B> ", STR:Trim:All(BtvRec.PHONE_NUMBER) ); NewLine
DOC:Print("<B>Fax:</B> ", STR:Trim:All(BtvRec.FAX_NUMBER) ); NewLine
DOC:Print("<B>MailStop:</B> ", STR:Trim:All(BtvRec.DELIVERY_OFFICE)); NewLine; NewLine
DOC:Paragraph
DOC:Print("<FONT size=+1>", "<B>Postal Address</B>", "</FONT>" );NewLine
DOC:Print("<B>Street:</B> ", STR:Trim:All(BtvRec.ADDRESS) ); NewLine
DOC:Print("<B>P.O Box:</B> ", STR:Trim:All(BtvRec.PO_BOX) ); NewLine
DOC:Print("<B>City:</B> ", STR:Trim:All(BtvRec.DELIVERY_OFFICE) ); NewLine
DOC:Print("<B>State:</B> ", STR:Trim:All(BtvRec.STATE) ); NewLine
DOC:Print("<B>Postal Code:</B> ", STR:Trim:All(BtvRec.POSTAL_CODE) ); NewLine
DOC:Print("<B>Locality:</B> ", STR:Trim:All(BtvRec.LOCALITY_NAME) ); NewLine
DOC:Paragraph
DOC:Print("<FONT size=+1>", "<B>Novell Directory Services</B>", "</FONT>" );NewLine
DOC:Print("<B> Tree Name:</B> ", STR:Trim:All(NDS_Tree) ); NewLine
DGName = STR:Sub( BtvRec.DISTINGUISHED_NAME, 1, STR:Search("@", STR:Trim:All(BtvRec.DISTINGUISHED_NAME))-1 )
DOC:Print("<B>Common Name (CN):</B> ", UserObj ); NewLine
DOC:Print("<B>Distinguished Name:</B> ", DGName );NewLine
Return
End Sub