Es un solo archivo.
-----Original Message-----
From: Jos� Pablo Orozco Mar�n [mailto:[EMAIL PROTECTED]]
Sent: Jueves, 20 de Septiembre de 2001 07:05 a.m.
To: [EMAIL PROTECTED]
Subject: Re: GuestBook
Es un solo archivo o lo debo dividir??
Jorge Aguilar wrote:
**********************EMPIEZA AQU�****************************
> <?
> $page_title = "Libro de Visitas (Jorge Aguilar)";
> $admin_mail = "[EMAIL PROTECTED]";
> $admin_name = "Webmaster";
> $html_mail = "no";
> $required = array("name","email","job","comments");
> $scriptname = "geoguestbook.php";
> $records = "4";
> $messages_file = "c:\\geo\\php\\rocko\\mensajes.txt";
>
> ?>
> <HTML>
> <HEAD>
> <TITLE><?php echo $page_title; ?></TITLE>
> </HEAD>
> <BODY BGCOLOR="#FFFFFF" LINK="#000000">
> <FONT FACE="Verdana" SIZE="-2">
> <?
> /* action=view : retrieve data from the database and show it to the
> user */ if ($action == "view") {
> /* function for showing the data */
> function search_it($name) {
> /* some vars */
> global $offset,$total,$lpp,$dir,$records;
> global $table,$html_mail,$admin_name,$admin_mail,$messages_file;
> /* select the data to get out of the textfile */
> $lines = file($messages_file);
> rsort($lines);
> $total = count($lines);
>
> print "<CENTER><FONT color=\"#0000FF\" FACE=\"Verdana\"
> SIZE=\"2\"><strong><A HREF=\"$scriptname?action=add\"
> onMouseOver=\"window.status='Agregar un mensaje';return true\"
> onMouseOut=\"window.status='';return true\" TITLE=\"Agregar un
> mensaje\">(Agregar un mensaje)</A></strong></FONT></CENTER><br><br>";
> if ($total== 0) {
> print "<CENTER>Hasta el momento no hay ninguna persona
> registrada.</CENTER><br><br>";
> }
> elseif ($total> 0) {
> /* default */
> $counter=0;
> if ($dir=="") $dir="Proximo";
> $lpp = $records;
> if ($offset==0) $offset=0;
> if ($dir=="Proximo") {
> if ($total > $lpp) {
> $counter=$offset;
> $offset+=$lpp;
> $num=$offset;
> if ($num > $total) $num=$total;
> }
> else {
> $num=$total;
> }
> }
> elseif ($dir=="Anterior") {
> if ($total > $lpp) {
> $offset-=$lpp;
> if ($offset < 0) $offset=0;
> $counter=$offset-$lpp;
> if ($counter < 0)
> $counter=0;
> $num=$counter+$lpp;
> }
> else {
> $num=$total;
> }
> }
> /*
> $u = $total - $records;
> // reads the array in reverse order and outputs to
chat
> for($i = $total; $i >= $u ;$i--){
> echo $lines[$i] . "<hr>";
> }
> */
> $flag=0;
> while ($counter < $num) {
> $j=0;
> $j=$counter + 1;
> /* now really grab the data */
> list($correl,$i1,$i2,$i3,$i4) = explode( ':',
> $lines[$counter] );
> //$i1= mysql_result($result,$counter,"name");
> //$i2= mysql_result($result,$counter,"email");
> //$i3= mysql_result($result,$counter,"job");
> //$i4= mysql_result($result,$counter,"comments");
> //$i4 = stripslashes ("$i4");
> /* print it in a nice layout */
> print "<CENTER>\n";
> print "<TABLE WIDTH=600 ";
> if ($flag==0) {
> print "bgcolor=\"#CEFDFF\"";
> $flag=1;
> } else {
> print "bgcolor=\"#FFFFD9\"";
> $flag=0;
> }
> print "BORDER=2 ALIGN=CENTER VALIGN=TOP><TR><TD><FONT
> FACE=\"Verdana\" SIZE=\"-2\">\n";
> //print "<HR>\n";
> print "<BR>";
> print "<B>Nombre:</B> <A HREF=\"mailto:$i2\"
> onMouseOver=\"window.status='Email $i1';return true\"
> onMouseOut=\"window.status='';return true\" TITLE=\"Email
> $i1\">$i1</A>\n";
> print "<BR><B>Ocupacion:</B> $i3\n";
> print "<BR><B>Comentario:</B>\n";
> print "<BR>$i4\n";
> print "</FONT></TD></TR></TABLE>\n";
> print "</CENTER>\n";
> $counter++;
> }
> }
> //mysql_close();
> }
> /* execute the function */
> search_it($name);
> /* See if we need to put on the Proximo or Anterior buttons */
> if ($total > $lpp) {
> echo("<form action=\"$scriptname?action=view\"
> method=\"POST\">\n");
> /* See if we need a Anterior button */
> if ($offset > $lpp) {
> echo("<input type=\"SUBMIT\" value=\"Anterior\"
name=dir>\n");
> }
> /* See if we need a Proximo button */
> if ($offset < $total) {
> echo("<input type=\"SUBMIT\" value=\"Proximo\" name=dir>\n");
> }
> echo("<input type=hidden name=\"offset\" value=\"$offset\">\n");
> echo("<input type=hidden name=\"name\" value=\"$name\">\n");
> echo("<a href=\"http://geoaguila.saxen.net/index.php\">");
> echo("<img src=\"principal.gif\" alt=\"Regresar a la pantalla
> principal\" ></a>");
> echo("</form>");
> }
> }
> /* action=add : show a form where the user can enter data to add to
> the database */ elseif($action == "add") { ?>
> <FORM ACTION="<?php echo $scriptname; ?>?action=send"
METHOD="POST">
> <TABLE CELLSPACING="5" ALIGN="CENTER" bgcolor="#DDDDDD" border="2">
> <TR>
> <TD COLSPAN="3" ALIGN="LEFT">
> <BR>
> <B>Por favor toma unos minutos para digitar algo<BR>
> <CENTER><SMALL>[Campos requeridos esta marcados con
> *]</SMALL></CENTER></B><BR>
> </TD>
> </TR>
> <TR>
> <TD ALIGN="LEFT">Nombre</TD>
> <TD ALIGN="LEFT"><B>*</B></TD>
> <TD ALIGN="LEFT" NOWRAP>
> <INPUT TYPE="TEXT" NAME="form[name]">
> </TD>
> </TR>
> <TR>
> <TD ALIGN="LEFT">Ocupacion</TD>
> <TD ALIGN="LEFT"><B>*</B></TD>
> <TD ALIGN="LEFT" NOWRAP>
> <INPUT TYPE="TEXT" NAME="form[job]">
> </TD>
> </TR>
> <TR>
> <TD ALIGN="LEFT">Email</TD>
> <TD ALIGN="LEFT"><B>*</B></TD>
> <TD ALIGN="LEFT" NOWRAP>
> <INPUT TYPE="TEXT" NAME="form[email]">
> </TD>
> </TR>
> <TR>
> <TD ALIGN="LEFT">Comentarios</TD>
> <TD ALIGN="LEFT"><B>*</B></TD>
> <TD ALIGN="LEFT" NOWRAP>
> <TEXTAREA NAME="form[comments]" COLS="30" ROWS="8"
> WRAP="VIRTUAL"></TEXTAREA>
> </TD>
> </TR>
> <TR ALIGN="CENTER">
> <TD COLSPAN="3">
> <BR>
> <INPUT TYPE="SUBMIT" VALUE="Grabar"> <INPUT TYPE="RESET"
> VALUE="Reset">
> <a href="http://geoaguila.saxen.net/index.php">
> <img src="principal.gif" alt="Regresar a la pantalla principal"
> ></a>
> </TD>
> </TR>
> </TABLE>
> </FORM>
> <?
> }
> /* action=send : add the data from the user into the database */
> elseif($action == "send") {
> $reset = reset($required);
> while (list($key, $value) = each($required)) {
> if ($form[$value] == "") {
> $count++;
> }
> }
> if ($count > 0) {
> ?>
> <FORM ACTION="<?php echo $scriptname; ?>?action=send"
> METHOD="POST">
> <TABLE CELLSPACING="2" ALIGN="CENTER">
> <TR>
> <TD COLSPAN="3" ALIGN="LEFT">
> <B>Please take your time to enter something<BR>
> <CENTER><SMALL>[<FONT COLOR="red">you forgot some fields
> (marked with *)</FONT>]</SMALL></CENTER></B><BR>
> </TD>
> </TR>
> <TR>
> <TD ALIGN="LEFT">Name</TD>
> <TD ALIGN="LEFT"><B>*</B></TD>
> <TD ALIGN="LEFT" NOWRAP>
> <INPUT TYPE="TEXT" NAME="form[name]" VALUE="<?php echo
> $form[name]; ?>">
> </TD>
> </TR>
> <TR>
> <TD ALIGN="LEFT">Job</TD>
> <TD ALIGN="LEFT"><B>*</B></TD>
> <TD ALIGN="LEFT" NOWRAP>
> <INPUT TYPE="TEXT" NAME="form[job]" VALUE="<?php echo
> $form[job]; ?>">
> </TD>
> </TR>
> <TR>
> <TD ALIGN="LEFT">Email</TD>
> <TD ALIGN="LEFT"><B>*</B></TD>
> <TD ALIGN="LEFT" NOWRAP>
> <INPUT TYPE="TEXT" NAME="form[email]" VALUE="<?php echo
> $form[email]; ?>">
> </TD>
> </TR>
> <TR>
> <TD ALIGN="LEFT">Comments</TD>
> <TD ALIGN="LEFT"><B>*</B></TD>
> <TD ALIGN="LEFT" NOWRAP>
> <TEXTAREA NAME="form[comments]" COLS="23" ROWS="8"
> WRAP="VIRTUAL"><?php echo $form[comments]; ?></TEXTAREA>
> </TD>
> </TR>
> <TR ALIGN="CENTER">
> <TD COLSPAN="3">
> <INPUT TYPE="SUBMIT" VALUE="Grabar"> <INPUT TYPE="RESET"
> VALUE="Reset">
> </TD>
> </TR>
> </TABLE>
> </FORM>
> <?
> }
> else {
> if (!$form[email]) {
> $form[email] = "n/a";
> }
> if (!$form[subject]) {
> $form[subject] = "n/a";
> }
> if (!$form[name]) {
> $form[name] = "n/a";
> }
> /* check if a HTML-mail should be send or a plain/text mail */
> /*
> if ($html_mail == "yes") {
> mail("$admin_name <$admin_mail>","PHP3 Guestbook
> Addition","<HTML><BODY><FONT FACE=\"Century Gothic\"><TABLE
> BORDER=\"0\" WIDTH=\"100%\" CELLSPACING=\"4\"><TR>$form[name]
> ($form[email]) wrote the following message in the guestbook
> :</TR><TR><TD ALIGN=\"LEFT\"> </TD><TD ALIGN=\"LEFT\"
> NOWRAP> </TD></TR><TR><TD ALIGN=\"LEFT\">$form[comments]</TD><TD
> ALIGN=\"LEFT\" NOWRAP> </TD></TR><TR><TD
> ALIGN=\"LEFT\"> </TD><TD ALIGN=\"LEFT\"
> NOWRAP> </TD></TR><TR><TD ALIGN=\"LEFT\">Name:</TD><TD
> ALIGN=\"LEFT\" NOWRAP>$form[name]</TD></TR><TR><TD
> ALIGN=\"LEFT\">Beroep:</TD><TD ALIGN=\"LEFT\"
> NOWRAP>$form[job]</TD></TR><TR><TD ALIGN=\"LEFT\">Email:</TD><TD
> ALIGN=\"LEFT\"
> NOWRAP>$form[email]</TD></TR></TABLE></BODY></FONT></HTML>", "From:
> $form[name] <$form[email]>\nReply-To: $form[name]
> <$form[email]>\nContent-type: text/html\nX-Mailer: PHP/" .
> phpversion());
> }
> else {
> mail("$admin_mail","PHP3 Guestbook Addition","$form[name]
> ($form[email]) wrote the following message in the guestbook : \n\n
> $form[comments]\n\n Name: $form[name] \n Job: $form[job] \n Email:
> $form[email] \n", "From: $form[name] <$form[email]>\nReply-To:
> $form[name] <$form[email]>\nContent-type: text/plain\nX-Mailer: PHP/"
> . phpversion());
> }
> */
> /* MySQL really hates it when you try to put things with ' or "
> characters into a database, so strip these...*/
> $form[comments] = addslashes ("$form[comments]");
> $linea = "$form[name]:$form[email]:$form[job]:$form[comments]";
>
> $lines = file($messages_file);
> $a = count($lines)+1;
> $fp = fopen($messages_file, "a+");
> $fw = fwrite($fp, "\n$a:$linea");
> fclose($fp);
> ?>
> <BR><P ALIGN = CENTER><FONT color=\"#0000FF\" FACE=\"Verdana\"
> SIZE=\"2\"><strong>Gracias, <?php echo $form[name]; ?>, por agregar tu
> comentario.</strong></FONT>
> <BR><P ALIGN = CENTER><FONT color=\"#0000FF\" FACE=\"Verdana\"
> SIZE=\"2\"><strong><A HREF="<?php echo $scriptname; ?>?action=view"
> onMouseOver="window.status='Ver tu comentario ahora';return true"
> onMouseOut="window.status='';return true" TITLE="Ver tu comentario
> ahora">Ver tu comentario ahora.</A></strong></FONT><BR><BR>
> <?
> }
> }
> /* if there's no action given, then we must show the main page */ else
> {
> /* get the number of entries written into the guestbook*/
> $lines = file($messages_file);
> $a = count($lines);
> if ($a==0) {
> $entry = "Hasta el momento no hay personas";
> }
> elseif ($a==1) {
> $entry = "Hasta el Momento hay una persona";
> }
> else {
> $entry = "Hasta el momento hay $a personas";
> }
> echo "<CENTER><BR>";
> //echo "<TABLE ALIGN=\"CENTER\" bgcolor=\"#DDDDDD\"
> border=\"2\">";
> echo "<TABLE ALIGN=\"CENTER\" bgcolor=\"#DDDDDD\"
border=\"2\">";
> echo "<TR>";
> echo "<TD colspan=\"2\">";
> echo "<BR>";
> echo "<FONT color=\"#0000FF\" FACE=\"Verdana\"
> SIZE=\"2\"><strong>$entry en mi libro de visitas.</strong></font>";
> echo "</TD>";
> echo "</TR>";
> echo "<TR>";
> echo "<TD>";
> echo "<img src=\"text.gif\">";
> echo "</TD>";
> echo "<TD>";
> echo "<H4><FONT FACE=\"Verdana\" SIZE=\"3\"><A
> HREF=\"$scriptname?action=add\" onMouseOver=\"window.status='Agregar
> un mensaje a mi libro de visitas';return true\"
> onMouseOut=\"window.status='';return true\" TITLE=\"Agregar un mensaje
> a mi libro de visitas\">Agregar un mensaje a mi libro de
> visitas</A></FONT></H4>";
> echo "</TD>";
> if ($a > 0) {
> echo "<TR>";
> echo "<TD>";
> echo "<img src=\"handopen.gif\">";
> echo "</TD>";
> echo "<TD>";
> echo "<H4><FONT FACE=\"Verdana\" SIZE=\"3\"><A
> HREF=\"$scriptname?action=view\" onMouseOver=\"window.status='Ver los
> nombres en mi libro de visitas';return true\"
> onMouseOut=\"window.status='';return true\" TITLE=\"Ver los nombres en
> mi libro de visitas\">Ver los nombres en mi libro de
> visitas</A></FONT></H4>";
> echo "</TD>";
> }
> echo "<TR>";
> echo "<TD>";
> echo "<img src=\"regresar.gif\">";
> echo "</TD>";
> echo "<TD>";
> echo "<H4><FONT FACE=\"Verdana\" SIZE=\"3\"><A
> HREF=\"http://geoaguila.saxen.net/index.php\"
> onMouseOver=\"window.status='Regresar a la pantalla principal';return
> true\" onMouseOut=\"window.status='';return true\" TITLE=\"Regresar a
> la pagina principal\">Regresar a la pagina principal</A></FONT></H4>";
> echo "</TD>";
> echo "</TR>";
> echo "</TABLE></CENTER>";
> // echo "</TABLE>";
> }
> /* <BR><SMALL><CENTER>Script by <A HREF="http://www.aitsh.com/"
> onMouseOver="window.status='Script by Advanced IT Services
> Holland';return true" onMouseOut="window.status='';return true"
> TITLE="Script by Advanced IT Services Holland">Advanced IT Services
> Holland</A></CENTER></SMALL> */ ?>
> </FONT>
> </BODY>
> </HTML>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
--
�Desea desuscribirse? Escriba a [EMAIL PROTECTED] con
el tema "unsubscribe".