-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakePost.cgi
More file actions
executable file
·53 lines (38 loc) · 1.29 KB
/
Copy pathmakePost.cgi
File metadata and controls
executable file
·53 lines (38 loc) · 1.29 KB
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
49
50
51
52
#!/usr/bin/perl -w
use CGI qw/:all/;
use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
use File::Path qw(make_path);
use DataManipulation;
#warningsToBrowser(1);
$postLetters = param("myPost") or die "no post";
$zid = cookie("zid");
##if the directory does not exist, create it
if(! -d "$users_dir/$zid/posts"){
make_path("$users_dir/$zid/posts");
}
$post_num=0;
for my $postDir (glob "$users_dir/$zid/posts/*"){
$post_num++;
}
##mkdir "$users_dir/$zid/posts/$post_num" or die "can't create new directory for new post";
##make it while since we may delete some posts
while(-d "$users_dir/$zid/posts/$post_num"){
$post_num++;
}
make_path("$users_dir/$zid/posts/$post_num");
###put the message with other information into post.txt
$filename="$users_dir/$zid/posts/$post_num/post.txt";
open F,'>',$filename;
print F "from=$zid\n";
print F "message=$postLetters\n";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
print F "time="."$year\-$mon\-$mday"."T"."$hour:$min:$sec\+0000";
close F;
###send notification when zid is mentioned
if($postLetters=~/z[0-9]{7}/){
my @matesZid = ($postLetters =~ /z[0-9]{7}/g);
foreach my $mateZid (@matesZid){
sendNotificationWhenZidMentioned($mateZid,"$users_dir/$zid/posts/$post_num/post.txt");
}
}
print redirect("matelook.cgi?showUserPage=1");