este lo guardo como post.php
Código:
este como foro.php<?php session_start(); require("vars.php"); require("functions.php"); function textFilter($str) { global $badWordFilter; if ($badWordFilter) { $str = htmlspecialchars( $str ); $result = mysql_query( "SELECT word FROM badwords" ) or error( mysql_error() ); while($row = mysql_fetch_array( $result )) $str = eregi_replace( $row['word'], "", $str ); return $str; } } if(($_SESSION['security_code'] == $_POST['security_code']) && (! empty($_SESSION['security_code'])) ) { dbConnect(); $ip = $_SERVER['REMOTE_ADDR']; $ip = addslashes(textFilter($ip)); $eip = explode(".", $ip); if( count($eip) != 4) error("Intento de hacking!"); $autor = $_POST["name"]; $mail = $_POST["email"]; $tema = $_POST["topic"]; $mensaje = $_POST["msg"]; $parent = $_POST["pid"]; $mensaje = nl2br($mensaje); if(!empty($autor) and !empty($mail) and !empty($tema)) { $autor = trim($autor); $mail = trim($mail); $tema = trim($tema); $mensaje = trim($mensaje); $tema = htmlentities($tema); $tema = addslashes($tema); $autor = htmlentities($autor); $autor = addslashes($autor); $mail = addslashes($mail); $mensaje = addslashes($mensaje); $tema = ereg_replace( "<", "<", $tema ); $autor = ereg_replace( "<", "<", $autor ); $mail = ereg_replace( "<", "<", $mail ); $tema = ereg_replace( ">", ">", $tema ); $autor = ereg_replace( ">", ">", $autor ); $mail = ereg_replace( ">", ">", $mail ); $autor = strip_tags($autor); $mail = strip_tags($mail); $tema = strip_tags($tema); $mensaje = strip_tags($mensaje, "<br />"); } else { if(empty($autor)) $autor = "Anonimo"; if(empty($mail)) $mail = "[email protected]"; if(empty($tema)) $tema = "Tema Nuevo"; } if(empty($mensaje)) error("Es que no quieres escribir nada?"); else $mensaje = textFilter($mensaje); if(!eregi( "[a-z0-9].", $tema )) error( "Que diablos pones como tema?"); else $tema = textFilter($tema); if(!eregi( "[a-z0-9].", $autor )) error( "Nombre invalido, pon algo coherente"); else $autor = textFilter($autor); if(!eregi( "^([._a-z0-9-]+[._a-z0-9-]*) @(([a-z0-9-]+\.)*([a-z0-9-]+)(\.[a- z]{2,3})?)$", $mail)) error( "Pon un correo valido, o si no,deja el que esta" ); else $mail = textFilter($mail); $sql = "INSERT INTO forum (pid, user, mail, asunto, texto, fecha, ip) "; $sql.= "VALUES ('$parent','$autor','$mail', '$tema','$mensaje', NOW(), '$ip')"; $rs = mysql_query($sql) or die("Error al grabar un mensaje: ".mysql_error); Header("Location: foro.php"); unset($_SESSION['security_code']); } else { Header("Location: foro.php"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <body> </body> </html>
Código:
este como reply.php<?php session_start();?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Documento sin título</title> </head> <body> <form method=post action=post.php> <input type=hidden name=pid value=0> <a name=postnew> <table border=0 cellpadding=0 cellspacing=2 width=430> <tr> <td width=80 height=18><b>Asunto:</b></td> <td width=430 height=18><input type=text name=topic size = 40 maxlength=50></td> </tr> <tr> <td width=80 height=18><b>Nombre:</b></td> <td width=430 height=18><input type=text name=name size=20 maxlength=20 value='Anonimo'></td> </tr> <tr> <td width=80 height=18><b>E-mail:</b></td> <td width=430 height=18><input type=text name=email size=40 maxlength=40 value='anonimo@anonimo. com'></td> </tr> <tr> <td width=80 valign='top'><b>Mensaje:</b><br><input type=submit value="Enviar"></td> <td width=430><textarea style='width:100%;' name=msg rows=10 maxlength=2000></textarea></td> </tr> <tr><center><td><p align=><img src="CaptchaSe curityImages.php" /></p></td></center></tr> <tr> <td width=80 height=18></td> <td width=430 height=18 align="center"><b>Introduzca el codigo de seguridad: </b><input id="security_code" name="security_code" type="text" size=6/></td> </tr> </table> </form> <?php require("vars.php"); require("functions.php"); dbConnect(); global $maxThread; $page = $_GET["page"]; if ( !$page ) $page = 1; $rst = mysql_query("SELECT COUNT(*) FROM forum WHERE pid=0;") or die( mysql_error() ); $row = mysql_fetch_row( $rst ); $totalRows = $row[0]; $pages = intval($totalRows / $maxThread) + 1; echo "<p align=left><b>Pagina:</b> "; for ($i = 1; $i <= $pages; $i++) { if ($i == $page) echo "<b>[".$i."]</b> "; else echo "<a href=\"./foro.php?page=".$i."\">[".$i."]</ a> "; } echo "<a href=#postnew>< Nuevo mensaje ></a>"; echo "<hr size=1 color=#01a9c0 width=100%>"; findposts(0, 0, $page); ?> </body> </html>
Código:
este como vars.php<?php session_start();?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Documento sin título</title> </head> <body> <form method=post action=post.php> <input type=hidden name=pid value=<?php echo $row["id"] ?>> <table border=0 cellpadding=0 cellspacing=2 width=430> <tr> <td width=80 height=18><b>Asunto:</b></td> <td width=430 height=18><input type=text name=topic size=40 maxlength=50 value="RE: <?php echo $row["asunto"]; ?>"> </tr> <tr> <td width=80 height=18><b>Nombre:</b></td> <td width=430 height=18><input type=text name=name size=20 maxlength=20 value='Anonimo'></td> </tr> <tr> <td width=80 height=18><b>E-mail:</b></td> <td width=430 height=18><input type=text name=email size=40 maxlength=40 value='[email protected]'></td> </tr> <tr> <td width=80 valign='top'><b>Mensaje:</b><br> <input type=submit value="Enviar"></td> <td width=500><textarea style='height:auto;' name=msg rows=10 cols=46 maxlength=2000> </textarea></td> </tr> <tr> <td width=80 height=18></td> <td width=430 height=18><input type=hidden name=getmail value=no></td> </tr> <tr> <td width=80 height=18></td> <td width=430 height=18 align="center"> <b>Introduzca el codigo de seguridad: </b><input id="security_code" name="security_code" type="text" size=6/></td> </tr> </table> </form> <?php require(“functions.php”); $id = $_GET["id"]; dbConnect(); $result = mysql_query("SELECT * FROM forum WHERE id='$id'", $con); if(mysql_num_rows($result) == 1) { $row = mysql_fetch_assoc($result); echo "<table border=0 cellpadding=0 cellspacing=0 width=80%>\n"; echo "<tr><td><b>DE:</b> ".$row["user"]. "</td></tr>\n"; echo "<tr><td><b>ASUNTO:</b> ".$row["asunto"]. "</td></tr></table>\n"; echo "<p><b>MENSAJE:</b></p>\n"; echo "<p align=\"center\"><pre>"; echo $row["texto"]; echo "</pre></p>\n"; } ?> <H5>Respuestas:</H5> <?php if (!findposts($id, 0, 1)) echo "<H6> Vacio </H6>\n"; ?> <?php require(“vars.php”); require(“functions.php”); function findposts($PID, $sp = 0, $pagina) { global $maxThread; dbConnect(); $n = 0; $n1 = ($pagina - 1) * $maxThread; $n2 = $maxThread; $res = mysql_query("SELECT * FROM forum WHERE pid='$PID' ORDER BY id DESC LIMIT $n1,$n2", $con); $num = mysql_num_rows($res); if (!$num) { mysql_free_result($res); return FALSE; } for ($num--; $num >= 0; $num--) { $tam = $sp * 8; echo "<p>"; for($i = 0; $i < $tam; $i++) echo " "; $row = mysql_fetch_array($res); $n += 1; $ttime = date("F j, Y, g: i", $row["fecha"]); echo $n.". <a href=\"reply.php?id=".$row["id"]. "\">".$row["asunto"]."</a> [De: ".$row["user"]. "], <small>(".$row["fecha"].")</small></p>\n"; findposts($row["id"], $sp + 1, 1); } mysql_free_result($res); return TRUE; } ?> </body> </html>]
Código:
y este como functions.php<?php session_start();?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Documento sin título</title> </head> <body> <!--Listado uno--> <!--[vars.php]--> <?php $dbHost = "localhost"; // Servidor MySQL $dbName = "foro"; // Base de datos $dbUser = "root"; // Usuario $dbPasswd = ""; // Contraseña $badWordFilter = 0; // ¿Filtrado de palabras? $banIP = 1; // ¿Banear IP's? $emailAdmin = 1; // ¿Enviar posts? $adminEmail = "[email protected]"; // Email administrador $maxThread = "20"; // Posts por página ?> <!--[fin vars.php]--> </body> </html>
Código:
y mas abajito sin enviar peticion me sale esto <?php session_start();?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Documento sin título</title> </head> <body> <!--listado dos--> <!--[functions.php]--> <?php require("vars.php"); function dbConnect() { global $dbHost, $dbUser, $dbPasswd, $dbName; @mysql_connect("localhost","root","","foro") or error(mysql_error()); mysql_select_db($dbName); } function error( $error ) { echo "<html><head></head><body>"; echo " <center><h4><font color=#FF0000> Error:$error</font></h4></center> <p align=center> <a href=javascript:history.back(); >Regresar</a></p>"; echo "</body></html>"; exit; } ?> <!--[fin functions.php]--> </body> </html>
Cita:
Fatal error: Call to undefined function findposts()