-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_c.cgi
executable file
·137 lines (108 loc) · 3.83 KB
/
_c.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/local/bin/perl
#################################################################################
# _C.CGI
#
# Author : Zheileman (zheileman at gmail.com)
# URL : http://github.com/zheileman/potiphoti
#
# Copyright 2003-2011, Zheileman.
#
#
# This file is part of PotiPhoti.
#
# PotiPhoti is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# any later version.
#
# PotiPhoti is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PotiPhoti; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#################################################################################
use strict;
use CGI;
use lib::BASE;
my $img = $BASE::img;
my $xml = $BASE::xml;
print "Content-type: text/html\n\n";
my $q = new CGI;
my $id = $q->param('id') || 0;
my $send = $q->param('send') || 0;
# Remove HTML shit
$id =~ s/<.+?>//g;
$send =~ s/<.+?>//g;
if (!$id) {
&printRespuesta($BASE::noid);
exit;
}
if (!$send) {
&printForm($id);
} else {
my $author = BASE::trim($q->param('author')) || 0;
my $url = BASE::trim($q->param('url')) || 0;
my $text = BASE::trim($q->param('text')) || 0;
# Remove HTML shit
$author =~ s/<.+?>//g;
$url =~ s/<.+?>//g;
$text =~ s/<.+?>//g;
# Spam-protect the email address
$url =~ s/@/\&\#64\;/g;
$url =~ s/\./\&\#46\;/g;
if (!$author || !$url || !$text) {
&printRespuesta($BASE::invalidtext);
} else {
if (open XML, "< $xml$id.xml") {
my @file = <XML>;
close(XML);
my $filejoin = join '', @file;
my $fecha = BASE::getFecha(BASE::getFecha());
my $newcomment = " <Comentario>
<Fecha>$fecha</Fecha>
<Autor>$author</Autor>
<Url>$url</Url>
<Texto><![CDATA[$text]]></Texto>
</Comentario>
</Foto>";
$filejoin =~ s/<\/Foto>/$newcomment/g;
open XML, "> $xml$id.xml";
print XML "$filejoin";
close(XML);
&printRespuesta($BASE::commentok);
} else {
&printRespuesta($BASE::commenterror);
}
}
}
sub printForm {
my $html = BASE::joinTemplate("template_c.txt");
my $code = "
<form method=\"post\" action=\"_c.cgi?id=$_[0]\" name=\"comments_form\" onsubmit=\"return formCheck(this)\">
<input type=\"hidden\" name=\"send\" value=\"1\" />
<input type=\"hidden\" name=\"id\" value=\"$_[0]\" />
<div style=\"width:100px; padding-right:15px; margin-right:15px; float:left; text-align:left;\">
<label for=\"author\">$BASE::labelname</label><br />
<input tabindex=\"1\" id=\"author\" name=\"author\" /><br /><br />
<label for=\"url\">$BASE::labelemail</label><br />
<input tabindex=\"2\" id=\"url\" name=\"url\" /><br /><br />
</div>
<br />
<textarea tabindex=\"3\" id=\"text\" name=\"text\" rows=\"8\" cols=\"29\"></textarea><br /><br />
<input type=\"button\" onclick=\"window.close()\" value=\" $BASE::labelcancel \" />
<input style=\"font-weight: bold;\" type=\"submit\" name=\"post\" value=\" $BASE::labelsend \" />
</form>
";
$html =~ s/<!--<CUERPO>-->/$code/;
print $html;
}
sub printRespuesta {
my $html = BASE::joinTemplate("template_c.txt");
my $msg = "<br /><br />$_[0]";
$html =~ s/<!--<CUERPO>-->/$msg/;
print $html;
}