PHP - [ayuda]problemas con un foro en php

 
Vista:
sin imagen de perfil

[ayuda]problemas con un foro en php

Publicado por juan jose (3 intervenciones) el 31/01/2013 06:09:39
hola a todos estoy tratando de hacer un foro en php que consegui en una revista digital y me atrevi a hacerlo

ya adelante algo del foro gracias a un usuario que me dio unos consejos aunque tuve que darle mas retoques a mi código ahora cuando trato de enviar una peticion me da error me dice intento de hacking

aca les dejo el link de la revista como aporte para el que quiera hacerlo tambien es de la pagina 32 a la 41 http://www.myupload.dk/showfile/1CIVTuqkY.rar


aca les dejo el codigo por si me pueden ayudar

este lo guardo como post.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?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 = "anonimo@anonimo.com";
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>


este como foro.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?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:&nbsp;</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>&nbsp;";
for ($i = 1; $i <= $pages; $i++) {
if ($i == $page) echo "<b>[".$i."]</b>&nbsp;";
else echo "<a href=\"./foro.php?page=".$i."\">[".$i."]</
a>&nbsp;";
}
echo "<a href=#postnew>< Nuevo mensaje ></a>";
echo "<hr size=1 color=#01a9c0 width=100%>";
findposts(0, 0, $page);
?>
</body>
</html>

este como reply.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?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='anonimo@anonimo.com'></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:&nbsp;
</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 "&nbsp;";
$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>]


este como vars.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?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 = "black@set-ezine.org"; // Email administrador
$maxThread = "20"; // Posts por página
?>
<!--[fin vars.php]-->
</body>
</html>

y este como functions.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?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>


y mas abajito sin enviar peticion me sale esto

Fatal error: Call to undefined function findposts()

si envio la peticion dice


Error:Intento de hacking!

Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder