-
Notifications
You must be signed in to change notification settings - Fork 2
/
action.cgi
48 lines (35 loc) · 1013 Bytes
/
action.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl
# action.cgi
#
# Perform selected tasks for the client outside of the regular refreshing
#
use CGI qw(:standard);
print "Content-type: text/html\n\n";
if(param()) {
#All actions have these included
$chanName = param('chan');
$nickName = param('name');
if( param('msg') ) { #Standard chat commands
#Get a list of all users on this channel
@files = `ls -1 channels/$chanName/*.ncu`;
foreach $userFile (@files) {
#No need to send message to self
if( !($userFile =~ /\/$nickName\.ncu/) ) {
$userFile =~ s/\.ncu/.ncm/;
chomp($userFile);
#Check if file exists and has data (this is to determine if it needs a comma before it
my $com = "";
if(-e "./$userFile") {
$com = ",";
}
open(FILE , ">> $userFile") or die("action.cgi error - file write error");
print FILE $com . '{"name":"' . $nickName . '","msg":"' . param('msg') . '"}';
close(FILE);
}
}
}
}
else {
die("action.cgi error - no parameters");
}
print "success";