-
Notifications
You must be signed in to change notification settings - Fork 0
/
postman.pl
executable file
·52 lines (41 loc) · 1.22 KB
/
postman.pl
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
#!/bin/perl
my $mode = $ARGV[0];
die if $mode ne "discussion" and $mode ne "upload";
my $thread = $ENV{'PROJECT_FORUM_THREAD'};
my $downid = $ENV{'PROJECT_FORUM_DOWNLOAD_ID'};
die if not $thread or not $downid;
my @listrepl;
my $itemrepl;
my $prologue;
if($mode eq "discussion") {
@listrepl = ("[LIST]\n", "[/LIST]\n");
$itemrepl = "[*] ";
$prologue = '[URL="http://forums.kleientertainment.com/downloads.php?do=download&downloadid=' . $downid . '"][IMG]http://forums.kleientertainment.com/images/download.png[/IMG][/URL]';
} elsif($mode eq "upload") {
@listrepl = ("", "");
$itemrepl = "> ";
$prologue = '[URL="http://forums.kleientertainment.com/showthread.php?' . $thread . '"][B]Discuss >>[/B][/URL]'
}
sub print_sample_configuration {
open EG, "<", "rc.example.lua" or die $!;
print "Sample configuration file:\n";
print "[SPOILER]\n";
print "[CODE]\n";
while(<EG>){ print; }
print "[/CODE]\n";
print "[/SPOILER]\n";
close EG;
}
while(<STDIN>) {
if (/^\@SAMPLECONFIGURATION\@\s*$/) {
print_sample_configuration if $mode eq "discussion";
$_ = "";
next;
}
s/^\s*\[LIST\]\s*/$listrepl[0]/i;
s/^\s*\[\/LIST\]\s*/$listrepl[1]/i;
s/^\s*\[\*\]\s*/$itemrepl/i;
} continue {
print;
}
print "\n", $prologue, "\n";