home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
WinFiles.com 1998 June
/
WF0698_3.ISO
/
servers-websrv
/
websuite.exe
/
CHATCMD.AP_
/
CHATCMD.AP
Wrap
Text File
|
1998-04-01
|
7KB
|
232 lines
<[
// WINC - Chat Command
// (c) 1997-98 SmartDesk, Inc., All Rights Reserved
FUNCTION AddChatRecord( session, filename, name, msg, uid )
local data, x, z, id, rc
rc = 1
x = chr( 1 ) // field delimeter
z = chr( 2 ) // record delimeter
data = date( "YYYYMMDD" ) + x + time( ) + x + name + x + msg + x + uid + z
id = "CHATBUF." + filename
if ( ! sessionDataAppend( session.websrvr, -1, id, data ) )
sessionDataFlushRecords( session.websrvr, -1, id, filename, z, 0 )
rc = sessionDataAppend( session.websrvr, -1, id, data )
end
return( rc )
END
// MAIN
_apGenerate( )
websrvr = 0 + param( 1 )
sessionId = 0 + param( 2 )
session = new( "session", websrvr, sessionId )
channel = 0 + session.var( "channel" )
if ( channel < 1 )
channel = 1
end
filename = fileFixPath( webServerHome( websrvr ) + "\\chat\\chan" + channel + ".dat" )
cmd = session.var( "cmd" )
id = session.var( "id" )
alias = session.var( "alias" )
qstr = "?id=" + webEncodeUrl( id ) + "&alias=" + webEncodeUrl( alias )
switch ( cmd )
case "logon"
if ( session.data( "winc_islogged" ) != "1" )
AddChatRecord( session, filename, "ADMIN", "Welcome <B>" + alias + " (<FONT COLOR=red>" + session.data( "winc_name" ) + "</FONT>)</B> to the conversation.", id )
session.data( "winc_islogged", "1" )
end
session.data( "winc_cmd", "" )
break
case "logoff"
// AddChatRecord( session, filename, "ADMIN", "<B>" + alias + " (<FONT COLOR=red>" + session.data( "winc_name" ) + "</FONT>)</B> has left the conversation." )
session.data( "winc_islogged", "0" )
// session.response( "HTTP/1.0 302 Redirect\r\nDate: " + webGMT( ) + "\r\nServer: SmartDesk Personal Web Server v1.0\r\nLocation: /chat/dir.htm\r\n\r\n" )
session.redir( "dir.htm" + qstr )
return( 1 )
case "chat"
msg = session.var( "msg" )
if ( ! strempty( msg ) )
AddChatRecord( session, filename, alias, msg, id )
end
break
case "image"
desc = session.var( "image" )
if ( ( ! strempty( desc ) ) && ( left( desc + " ", 4 ) != "----" ) )
file = fileFixPath( webServerHome( websrvr ) + "\\chat\\chan" + channel + ".cfg" )
channelData = new( "iniFile", file )
if ( type( channelData ) == "O" )
data = channelData.getItems( "Images" )
cnt = chrcount( ";", data ) + 1
for ( i=1; i<=cnt; i++ )
item = strextract( data, ";", i )
if ( strempty( item ) )
continue
end
line = channelData.getString( "Images", item )
if ( desc == strextract( line, "|", 1 ) )
// AddChatRecord( session, filename, alias, "<IMG BORDER=0 SRC=\"" + strextract( line, "|", 2 ) + "\">" )
AddChatRecord( session, filename, alias, "<A HREF=\"" + strextract( line, "|", 2 ) + "\">" + strextract( line, "|", 1 ) + "</A>", id )
end
end
end
end
session.data( "winc_cmd", "" )
break
case "link"
desc = session.var( "link" )
if ( ( ! strempty( desc ) ) && ( left( desc + " ", 4 ) != "----" ) )
file = fileFixPath( webServerHome( websrvr ) + "\\chat\\chan" + channel + ".cfg" )
channelData = new( "iniFile", file )
if ( type( channelData ) == "O" )
data = channelData.getItems( "Links" )
cnt = chrcount( ";", data ) + 1
for ( i=1; i<=cnt; i++ )
item = strextract( data, ";", i )
if ( strempty( item ) )
continue
end
line = channelData.getString( "Links", item )
if ( desc == strextract( line, "|", 1 ) )
AddChatRecord( session, filename, alias, "<A HREF=\"" + strextract( line, "|", 2 ) + "\" TARGET=\"_top\">" + desc + "</A>", id )
end
end
end
end
session.data( "winc_cmd", "" )
break
case "sound"
desc = session.var( "sound" )
if ( ( ! strempty( desc ) ) && ( left( desc + " ", 4 ) != "----" ) )
file = fileFixPath( webServerHome( websrvr ) + "\\chat\\chan" + channel + ".cfg" )
channelData = new( "iniFile", file )
if ( type( channelData ) == "O" )
data = channelData.getItems( "Sounds" )
cnt = chrcount( ";", data ) + 1
for ( i=1; i<=cnt; i++ )
item = strextract( data, ";", i )
if ( strempty( item ) )
continue
end
line = channelData.getString( "Sounds", item )
if ( desc == strextract( line, "|", 1 ) )
AddChatRecord( session, filename, alias, "<<< <A HREF=\"" + strextract( line, "|", 2 ) + "\">" + desc + "</A> >>>", id )
end
end
end
end
session.data( "winc_cmd", "" )
break
case "transcript"
if ( sessionDataGet( websrvr, -1, "IsInTranscript" ) == "1" )
break
end
sessionDataGet( websrvr, -1, "IsInTranscript", "1" )
if ( fileExists( filename ) )
ferase( filename )
end
hfile = fileCreate( filename )
if ( hfile < 1 )
break
end
data = sessionDataGet( websrvr, -1, "CHATBUF." + filename )
data = chrswap( data, chr( 1 ), "," )
data = strswap( data, chr( 2 ), "\r\n" )
fwrite( hfile, data, len( data ) )
fclose( hfile )
webServerSendFile( websrvr, hsock, filename )
sessionDataGet( websrvr, -1, "IsInTranscript", 0 )
session.data( "winc_cmd", "" )
session.redir( "/chat/chan" + channel + ".dat" )
return( 1 )
break
case "preferences"
session.data( "winc_reload_time", session.var( "freq" ) )
session.data( "winc_pglen", session.var( "pglen" ) )
session.data( "winc_cmd", "" )
break
case "comment"
str = session.var( "comment" )
str2 = ""
if ( left( str + " ", 4 ) != "----" )
str2 = str
end
data = fileReadASCII( webServerHome( session.websrvr ) + "\\chat\\users\\" + id + ".dat" )
name = strextract( data, "|", 3 )
email = strextract( data, "|", 5 )
str = session.var( "action" )
if ( left( str + " ", 4 ) != "----" )
switch ( upper( str ) )
case "USER NAME"
str = name
break
case "ALIAS"
str = alias
break
case "EMAIL ADDRESS"
str = email
str = "<A HREF=\"mailto: " + str + "\">" + str + "</A>"
break
case "TIME STAMP"
str = cdow( jdate( ) ) + date( ", MMMM DDDD, YYYY at " ) + timetostr( time( ), 0 ) + "m"
break
case "DATE"
str = cdow( jdate( ) ) + date( ", MMMM DDDD, YYYY at " )
break
case "TIME"
str = timetostr( time( ), 0 ) + "m"
break
end
if ( ! strempty( str2 ) )
str2 += " " + str
else
str2 = str
end
end
str = session.var( "icon" )
if ( left( str + " ", 4 ) != "- Em" ) // emoticons
if ( ! strempty( str2 ) )
str2 += " " + str
else
str2 = str
end
end
if ( ! strempty( str2 ) )
AddChatRecord( session, filename, alias, str2, id )
end
session.data( "winc_cmd", "" )
break
end
session.redir( "sdchat.htm?cmd=ChatText&id=" + id + "&channel=" + channel + "&alias=" + webEncodeUrl( alias ) )
return( 1 )
]>