114 lines
3.4 KiB
Perl
114 lines
3.4 KiB
Perl
#!/bin/perl
|
|
|
|
use Cwd;
|
|
use CGI;
|
|
do {
|
|
my $q = CGI->new;
|
|
use DBD::Pg;
|
|
use utf8;
|
|
use utf8::all;
|
|
use Encode;
|
|
use Data::Dumper;
|
|
use HTML::Entities;
|
|
use feature "say";
|
|
my $username = "CHANGEME";
|
|
my $password = "CHANGEME";
|
|
my $host = "CHANGEME";
|
|
my $dbh = DBI->connect("dbi:Pg:dbname=guestbook;host=$host;port=5432",
|
|
$username,
|
|
$password,
|
|
{AutoCommit => 1, RaiseError => 1, PrintError => 1}
|
|
);
|
|
|
|
print $q->header(-charset => "utf-8");
|
|
|
|
my $sth = $dbh->prepare("select * from guestbook");
|
|
$sth->execute();
|
|
my $results = $sth->fetchrow_hashref;
|
|
|
|
my $EntriesMin = $results->{id};
|
|
|
|
$sth = $dbh->prepare("select * from guestbook order by ID desc");
|
|
$sth->execute();
|
|
$results = $sth->fetchrow_hashref;
|
|
my $EntriesMax = $results->{id};
|
|
|
|
open(my $fh, "<header.html");
|
|
print while <$fh>;
|
|
print "<div class='container'>";
|
|
print $q->h2("Libro de visitas de SURAGU.NET");
|
|
print $q->p("No compréis nada que se anuncie aquí, te timarían y yo me reiría de ti.");
|
|
print $q->p("Al igual que la version original, este libro de visitas tambien va como el puto culo");
|
|
print $q->p("<b>Negros de lainchan cometer suicidio</b>");
|
|
|
|
|
|
|
|
print "<table id='entries' style='width:50%'>\n";
|
|
print "<tr>\n";
|
|
print "<th>ID</th>\n";
|
|
print "<th>Nombre</th>\n";
|
|
print "<th>Email</th>\n";
|
|
print "<th>Comentario</th>\n";
|
|
print "<th>País</th>\n";
|
|
print "<th>Fecha</th>\n";
|
|
|
|
print "</tr>\n";
|
|
# No se en que cojones estaba pensando mi yo de hace 3 años, pero
|
|
# vaya genio en verdad
|
|
|
|
for (my $x = $EntriesMax; $x >= $EntriesMin; $x--) {
|
|
$sth = $dbh->prepare("select * from guestbook where ID = $x");
|
|
$sth->execute();
|
|
my $data = $sth->fetchrow_hashref;
|
|
print "<tr>\n";
|
|
# Hay otakus que ponen cosas en japonés, codear todo en
|
|
# UTF-8 para que el navegador no se cague encima
|
|
my $Name = decode("utf8",$data->{name});
|
|
my $Website = $data->{website};
|
|
my $Email = $data->{email};
|
|
my $Comment = decode("utf8",$data->{comment});
|
|
my $Date = $data->{date};
|
|
my $Country = decode("utf8",$data->{country});
|
|
my $referenced_post_id;
|
|
$Name =~ s/<[^>]*>//g;
|
|
$Email =~ s/@/[at)/g;
|
|
$Email =~ s/<[^>]*>//g;
|
|
$Country =~ s/<[^>]*>//g;
|
|
$Website =~ s/<[^>]*>//g;
|
|
$Country =~ s/Israel/Palestine/g;
|
|
$Comment =~ s/<[^>]*>//g;
|
|
|
|
if ($Comment =~ /(\d+)/) {
|
|
$referenced_post_id = $1;
|
|
$Comment =~ s/^>>$referenced_post_id/<a href="#$referenced_post_id">>>$referenced_post_id<\/a>/;
|
|
}
|
|
|
|
print "<td id=\"$x\">$x</td>";
|
|
if ($Website eq "" ) {
|
|
print "<td>$Name</td>";
|
|
} else {
|
|
print "<td><a href='$Website'>$Name</a></td>";
|
|
}
|
|
print "<td>$Email</td>\n";
|
|
print "<td class='comment'>$Comment</td>\n";
|
|
print "<td>$Country</td>\n";
|
|
print "<td>$Date</td>\n";
|
|
|
|
print "</tr>\n";
|
|
}
|
|
print "</table>\n";
|
|
print "<h3>Firma el libro</h3>";
|
|
print "<form method='post' action='post.cgi'>\n";
|
|
print "<input name='name' placeholder='Nombre' type='text' required>\n";
|
|
print "<input name='website' placeholder='Sitio web (opcional)' type='text'>";
|
|
print "<input name='email' placeholder='email (opcional)' type='email'>\n";
|
|
print "<input name='comment' placeholder='comment' type='text' required>\n";
|
|
print "<input name='captcha' placeholder='Quinta de Do' required>\n";
|
|
print "<input id='country' placeholder='Pais' name='country' required>";
|
|
print "<input type='submit'>\n";
|
|
print "</form>\n";
|
|
print "</div>";
|
|
print "</body>\n";
|
|
print "</html>\n";
|
|
}
|