Foros del Web » Programación para mayores de 30 ;) » Programación General »

Libro de Visitas! con plantillas "Exelente" pero no es con MySql.-

Estas en el tema de Libro de Visitas! con plantillas "Exelente" pero no es con MySql.- en el foro de Programación General en Foros del Web. Libro de Visitas! con plantillas "Excelente" pero no es con MySql.- .....hola amigos tengo este estupendo script PL que baje de http://fgguestbook.sourceforge.net realmente es unos ...
  #1 (permalink)  
Antiguo 17/12/2004, 21:14
Avatar de xyyy7  
Fecha de Ingreso: enero-2004
Ubicación: Maracay.-
Mensajes: 637
Antigüedad: 20 años, 3 meses
Puntos: 5
Exclamación Libro de Visitas! con plantillas "Exelente" pero no es con MySql.-

Libro de Visitas! con plantillas "Excelente" pero no es con MySql.-



.....hola amigos tengo este estupendo script PL que baje de http://fgguestbook.sourceforge.net realmente es unos de los GuetBook - Libro de visitas mejores que e visto es este codigo de pl.-

mi pregunta es muy simple : y a la ves algo compleja :

esto se podra pasar a MySql.- para que pueda tener un funcionamiento optimo y mejor administracion

por lo menos si hablamos del achivo data que es el file que encierra toda la informacion de se dispara en el html

Código:
#----------------------------- BEGIN CONFIGURATION ----------------------------#

# Number of entries you want to see at each page.
# Set to 1000 or so to have all on one page.
my $eppage = 20;

# Length of the visible pagebar.
my $pagebar_length = 11;

# If a word is larger then this value, then it will be wraped.
# A good protection against design killers. ;-)
# Set to 0 to disable.
my $wrap_at = 27;

# Allow posting HTML-code?
# 0 = off , 1 = on
my $allowhtml = 0;

# Make a link from an posted URL?
my $set_link = 0;

# Find and kill duplicates?
my $find_duplicate = 1;

# Check Browserstring, if doesn't match, guestbook will deny display.
# Protection against spambots
my $check_browserstring = 1;
my $allowed_browsers = ['mozilla','lynx','links','googlebot','scooter','fast-webcrawler','w3c_validator','opera'];

# Convert the email to ascii-ordinal-numbers?
# So spambots can't read it.
my $convert_email = 1;

# Enable logging?
my $logging = 1;

# Filtering bad words?
my $badword_filter = 1;

# Word to replace with
my $badword_replace = "*****";

# Use emoticons?
my $use_emoticons = 1;

# URI to the emoticonpath.It can be absolut _or_ relativ..
my $emoticon_path = "/emoticons/";

# Force input in the name field?
# That should be.. :)
my $force_name = 1;

# Force the email field?
my $force_email = 0;

# Force the homepage field?
my $force_homepage = 0;

# Force the text field?
my $force_text = 1;

# Error text, if somebody filled not out a forced field.
my $error_text = "<p>Sorry, you must fill in the portion listed below.<br>Go back and do it.<br>\n";

# Enable email notification?
my $send_email_notification = 0;

# The mailprogram
# Most it's ok so..
my $email_program = "/usr/sbin/sendmail";

# Your email
# You must set the '@' with a backslash '\@' !
my $your_email = "noname\@nodomain.com";

# Email subject
my $mail_subject = "New guestbook entry";

# Email message
my $mail_msg = "There is a new guestbook entry!\n";

# Thanx message, if somebody signed the guestbook.
my $thanxmsg = "Danki ! !  ! ! ! ! ";

# Will be displayed if no homepage was given.
# Leave blank to disable.
my $nohomepage = "n/a";

#------------------------------ END CONFIGURATION -----------------------------#

# That was it!

# ---------- BEGIN MAIN

my $gdata = "./gdata/";

my %params = &get_param();

if($params{'cwrite'})
  {
    &check_input($error_text,$gdata,$params{'Name'},$params{'Name2'},$params{'Homepage'},$params{'Text'},$force_name,$force_email,$force_homepage,$force_text);
    my $timestring = &get_timestring();
    if(&write_message($gdata,$allowhtml,$set_link,$wrap_at,$params{'Name'},$params{'Name2'},$params{'Homepage'},$params{'Text'},$nohomepage,$find_duplicate,$timestring,$convert_email))
      {
	unless(&count_message($gdata)) { &common_error('count_message'); }
	if($logging)
	  { unless(&write_log($gdata,$timestring)) { &common_error('write_log'); } }
	if($send_email_notification)
	  {
	    unless(&send_mail_notification($email_program,$your_email,$mail_subject,$mail_msg))
	      { &common_error('send email notification'); }
	  }
      }
  }

&print_all($gdata,$eppage,$params{'next'},$params{'cwrite'},$thanxmsg,$pagebar_length,$check_browserstring);

# ---------- END MAIN

sub print_all
  {
    my $gdata = $_[0];
    my $eppage = $_[1];
    my $cache = $_[2];
    my $cwrite = $_[3];
    my $thanxmsg = $_[4];
    my $pagebar_length = $_[5];
    my $check_browserstring = $_[6];
    my $pthanxmsg = "<p><b>".$thanxmsg."</b>";
    my $scriptname = $ENV{'SCRIPT_NAME'};
    my $number_of_entries = &get_nb_of_entries($gdata);
    my $sector = $eppage;
    if($cache) { $sector = $cache; }
    my $next = $sector+$eppage;
    my $last = $sector-$eppage;
    my $page = $sector/$eppage;
    my $pagebar = &get_pagebar($eppage,$number_of_entries,$page,$scriptname,$pagebar_length);
    my @data = &get_gdata($gdata,$number_of_entries,$sector,$eppage);
    my @template_cache = &get_data($gdata,'body_template');
    my @template_data = ("");
    my $line;
    my $blback = "";
    my $blnext = "";
    my $elback = "";
    my $elnext = "";

    if($last > 0) { $blback = "<a href=\"".$scriptname."?next=".$last."\">"; $elback = "</a>"; }
    if($sector < $number_of_entries) { $blnext = "<a href=\"".$scriptname."?next=".$next."\">"; $elnext = "</a>"; }
    if($cwrite eq "") { $thanxmsg=""; $pthanxmsg=""; }

    foreach $line(@template_cache)
      {
	$line =~ s/\%PTHANXMSG\%/$pthanxmsg/g;
	$line =~ s/\%THANXMSG\%/$thanxmsg/g;
	$line =~ s/\%NUMBERENTRIES\%/$number_of_entries/g;
	$line =~ s/\%PAGE\%/$page/g;
	$line =~ s/\%PAGEBAR\%/$pagebar/g;
	$line =~ s/\%BEGINLBACK\%/$blback/g;
	$line =~ s/\%ENDLBACK\%/$elback/g;
	$line =~ s/\%BEGINLNEXT\%/$blnext/g;
	$line =~ s/\%ENDLNEXT\%/$elnext/g;
	if($line=~ s/\%DATA\%//g)
	  { push(@template_data,@data); }
	push(@template_data,$line);
      }

    print "Content-type: text/html\n\n";
    print &get_data($gdata,'header_template');
    if($check_browserstring)
    {
       if(&check_if_browser_allowed($allowed_browsers))
	{ print @template_data; }
       else
        { print "<br><br><b><div align=\"center\">Access forbidden!</div></b><br><br>"; }
    }
    print &get_data($gdata,'footer_template');
  }

sub get_param
  {
    my $data;
    my $name;
    my $value;
    my $formularfield;
    my @formularfields = ("");
    my %params;

    if($ENV{'REQUEST_METHOD'} eq 'GET')
      { $data = $ENV{'QUERY_STRING'}; }
    else
      { read(STDIN, $data, $ENV{'CONTENT_LENGTH'}); }

    @formularfields = split(/&/,$data);

    foreach $formularfield (@formularfields)
      {
	($name,$value) = split(/=/, $formularfield);
	$params{$name} = $value;
      }

    return %params;
  }

sub check_input
  {
    my $error_text = $_[0];
    my $gdata = $_[1];
    my $name = $_[2];
    my $email = &string_convert($_[3],0);
    my $homepage = &string_convert($_[4],0);
    my $text = $_[5];
    my $force_name = $_[6];
    my $force_email = $_[7];
    my $force_homepage = $_[8];
    my $force_text = $_[9];

    if((($name eq "") && $force_name) || ((($email eq "") || ($email !~ /\@/) || ($email !~ /\./)) && $force_email) || ((($homepage eq "http://") || ($homepage eq "") || ($homepage !~ /http:\/\//) || ($homepage !~ /\./)) && $force_homepage) || (($text eq "") && $force_text))
      {
	print "Content-type: text/html\n\n";
	print &get_data($gdata,'header_template');
	
	print $error_text;

	if(($name eq "") && $force_name) { print "<br><b>Name</b><br><br>\n"; }
	if((($email eq "") || ($email !~ /\@/) || ($email !~ /\./)) && $force_email) { print "<br><b>E-Mail</b><br><br>\n"; }
	if((($homepage eq "http://") || ($homepage eq "") || ($homepage !~ /http:\/\//) || ($homepage !~ /\./)) && $force_homepage) { print "<br><b>Homepage</b><br><br>\n"; }
	if(($text eq "") && $force_text) { print "<br><b>Text</b><br><br>\n"; }
	print &get_data($gdata,'footer_template');

	die;
      }
  }

sub common_error
  {
    my $catchword = $_[0];

    print "Content-type: text/html\n\n";
    print "<html>\n<head>\n<title>Guestbook error</title>\n</head>\n<body>\n";
    print "An error has accourd!<br>\nMaybe, a file couldn't be read or written?<br>\nOr another user accesses a file in the same time as you.<br><br>\nHere is a catchword:<br>\n";
    print $catchword;
    print "<br>\n</body>\n</html>\n";

    die;
  }

sub count_message
  {
    my $gdata = $_[0];
    my $filename = $gdata."count";
    my $count = &get_nb_of_entries($gdata);

    open(COUNT, ">$filename") || return 0;
    flock(COUNT,1);
    print COUNT $count+1;
    flock(COUNT,8);
    close(COUNT);

    return 1;
  }

sub write_message
  {
    my $gdata = $_[0];
    my $allowhtml = $_[1];
    my $set_link = $_[2];
    my $name = &string_convert($_[4],$allowhtml);
    my $email = &string_convert($_[5],$allowhtml);
    my $homepage = &string_convert($_[6],$allowhtml);
    my $text = &wrap_text($_[7],$_[3]);
    my $nohomepage = $_[8];
    my $find_duplicate = $_[9];
    my $timestring = $_[10];
    my $convert_email = $_[11];
    my $lhomepage;
    my $emailname;
    my $gdata_file = $gdata."data";
    my @template_cache = &get_data($gdata,'write_template');
    my @template_data = ("");
    my @data_old = ("");
    my @data = ("");
    my $line;
    my $badword;

    $text = &string_convert($text,$allowhtml);

    if($badword_filter)
      {
	foreach $badword(&get_data($gdata,'badwords'))
	  {
#	    $badword=~ s/\n//g;
#	    $badword=~ s/\r//g;
            $badword=~ s/\s//g;
	    if($badword ne "") { $text =~ s/$badword/$badword_replace/gi; }
	  }

.................. HAY MAS CODESSS !!! PERO ESTA EN EL FILE ORIGINAL.. SI GUSTAN LO PUEDEN BAJAR DE LA PAGINA WEB YA MENSIONADA ARRIBA
...O tambien bueno si alguno de ustedes saben de algun guestbook parecedo a este que trabaje con plantilla pero en mysql.-
por favor podria escribir el url para charle un vistazo.-
realemte este es muy bueno por lo facil que es de manejar y configurar ya que es con PLANTILLAS, pero me gustaria fuera en MySQL con pl o cgi




-
  #2 (permalink)  
Antiguo 18/12/2004, 18:51
Avatar de monoswim
$moderador{'Esteban'}
 
Fecha de Ingreso: febrero-2002
Ubicación: Buenos Aires - Argentina
Mensajes: 8.762
Antigüedad: 22 años, 3 meses
Puntos: 90
por lo que veo del código no debe ser tan complicado, simplemten fijate cuando hace los oPEN para almacenar la info en los archivos y cambialo a un conector de MySQL, aunque generalmente los scripts pre armados son difísiles de modifican este parece bastante fácil, fíjate que en www.perlenespanol.com tienes varios tutoriales sobre como conectarte a tu base de datos

Saludos
__________________
Esteban Quintana
  #3 (permalink)  
Antiguo 19/12/2004, 07:59
Avatar de xyyy7  
Fecha de Ingreso: enero-2004
Ubicación: Maracay.-
Mensajes: 637
Antigüedad: 20 años, 3 meses
Puntos: 5
gracias amigo, echare un vistazo a esa pagina haber si encuetro algo que me pueda orientar!
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:07.