commit d453d84a7412ec97bf5b6eef8e343df1747f6157 Author: Germán Palomares Pizarro Date: Fri Nov 10 10:32:44 2023 +0100 Initial commit diff --git a/readme.org b/readme.org new file mode 100644 index 0000000..120d0bb --- /dev/null +++ b/readme.org @@ -0,0 +1,10 @@ +* SURAGU.NET GUESTBOOK +Heredado del sitio web anterior, va como el puto culo y los cambios en +el código han sido /*MÍNIMOS*/ + +Inherited from the former website. It sucks ass and balls and the +changes in the code have been */MINIMAL/* + +** TODO +Añadir un archivo con blacklists de palabras que estaba muy bien en su +dia para que los spammers no tocasen los huevos diff --git a/src/guestbook.cgi b/src/guestbook.cgi new file mode 100644 index 0000000..8dfa0aa --- /dev/null +++ b/src/guestbook.cgi @@ -0,0 +1,113 @@ +#!/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, "; + print "
"; + 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("Negros de lainchan cometer suicidio"); + + + + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + + print "\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 "\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/>>$referenced_post_id<\/a>/; + } + + print ""; + if ($Website eq "" ) { + print ""; + } else { + print ""; + } + print "\n"; + print "\n"; + print "\n"; + print "\n"; + + print "\n"; + } + print "
IDNombreEmailComentarioPaísFecha
$x$Name$Name$Email$Comment$Country$Date
\n"; + print "

Firma el libro

"; + print "
\n"; + print "\n"; + print ""; + print "\n"; + print "\n"; + print "\n"; + print ""; + print "\n"; + print "
\n"; + print "
"; + print "\n"; + print "\n"; +} diff --git a/src/post.cgi b/src/post.cgi new file mode 100644 index 0000000..30572a0 --- /dev/null +++ b/src/post.cgi @@ -0,0 +1,68 @@ +#!/usr/bin/perl + +use POSIX qw(strftime); +use CGI; +use DBD::Pg; +my $q = CGI->new; + +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} + ); + +my $now = time(); +my $Date = strftime('%Y-%m-%d', localtime($now)); + +print $q->header; +my $Name = $q->param("name"); +my $Website = $q->param("website"); +my $Email = $q->param("email"); +my $Comment = $q->param("comment"); +my $Country = $q->param("country"); +my $Captcha = $q->param("captcha"); + +if ($Name eq "") { + print "Eres marrón\n"; + die; +} +if ($Comment eq "") { + print "Pero di algo desgraciado\n"; + die; + +} + +if (!$Website eq "") { + unless ($Website =~ /^(http|https):\/\//) { + print "El sitio web introducido no es valido (no empieza por http:// o https://)"; + die; + } +} +if (!$Email eq "") { + unless ($Email =~ /.*@.*.\..*/ || $Email eq "sage") { + print "Pon un correo maricon"; + die; + } +} + +if (length($Comment) > 200 ||length($Email) > 25 ||length($Name) > 25) { + print "Enhorabuena has superado el límite de caracteres"; + die; +} + + +unless ($Captcha eq "Sol" || $Captcha eq "sol") { + print "El filtro funciona bien :)"; + die; +} + +my $req = $dbh->prepare('INSERT INTO guestbook(NAME, EMAIL, COMMENT, DATE, COUNTRY, website) VALUES (?, ?, ?, ?, ?, ?)'); +$req->execute($Name, $Email, $Comment, $Date, $Country, $Website); + +print ""; +print ""; +print ""; +print "

Añadido satisfactoriamente

";