|
Mostrar Mensajes
|
Páginas: [1] 2
|
3
|
Programación / PHP / ayuda con sistema de comentarios y sistema de censura
|
en: 21 Noviembre 2011, 22:45 pm
|
bueno esq un amigo me paso su sistema de comentarios para adaptarlo a mi web el sistema jala bien pero lo que qiero hacer es que no puedan publicar groserias bueno les paso mi codigo index.php <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top"><form action="#" method="post" name="comentarios" id="comentarios">
<?php include("funciones/funciones.php"); include("funciones/config.php");
$conexion = mysql_connect($config[host], $config[usuario], $config[clave]);
if(!$conexion) { die("Error al intentar conectar: ".mysql_error()); } $conectar = mysql_select_db($config[base], $conexion); if(!$conectar) { die('Error al intentar seleccionar la base de datos'. mysql_error()); } if(isset($_POST['enviar']) && $_POST['enviar'] == 'Comentar'){ if(!empty($_POST['usuario']) && !empty($_POST['comentarios'])){ $usuario = inyeccion(mysql_real_escape_string($_POST['usuario'])); $comentarios = inyeccion(mysql_real_escape_string($_POST['comentarios'])); $consulta = mysql_query("INSERT INTO Comentarios (fecha, usuario, comentarios) VALUES (CURRENT_TIMESTAMP(), '$usuario', '$comentarios')", $conexion) or die(mysql_error()); echo "Tu comentario fue agregado."; }else{ print "Debe llenar todos los campos"; } }
?> <table width="455" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="14" colspan="2" valign="top"> <div align="left">Nombre de usuario:</div></td> </tr><tr> <td height="22" colspan="2" valign="top"><input name="usuario" type="text" class="text-field" id="usuario" style="width: 455px;" value="" /></td> </tr> <tr> <td width="79%" height="19" valign="middle">Mensaje:</td> <td width="21%" valign="top"><img src="imagenes/bold.gif" width="24" height="20" onclick="bbcode('b');"/><img src="imagenes/italic.gif" width="24" height="20" onclick="bbcode('i');"/><img src="imagenes/under.gif" width="24" height="20" onclick="bbcode('u');"/><img src="imagenes/url.gif" width="24" height="20" onclick="bbcode('url');"/></td> </tr> <tr> <td height="50" colspan="2" valign="top"><textarea style="width: 455px; height: 50px;" name="comentarios" id="comentarios" class="text-field"></textarea></td> </tr> <tr> <td height="24" colspan="2" valign="top"><input type="submit" class="boton" name="enviar" value="Comentar" /></td> </tr> </table> </form></td> </tr> <tr> <td></td> </tr> <tr> <td valign="top"> <div id="contenido" style="color:#000000"><?php $conexion = mysql_connect($config[host], $config[usuario], $config[clave]); if(!$conexion) { die("Error al intentar conectar: ".mysql_error()); } $conectar = mysql_select_db($config[base], $conexion); if(!$conectar) { die('Error al intentar seleccionar la base de datos'. mysql_error()); } $registrostope=20; if(isset($_GET['a'])){ $inicio=($_GET['a']-1)*$registrostope; $pagina=$_GET['a']; }else{ $inicio=0; $pagina=1; }
$resultados=mysql_query("SELECT * FROM Comentarios ORDER BY ID DESC LIMIT $inicio, $registrostope"); $i = 0; echo "<table width='463' border='0' align='center' cellpadding='5' cellspacing='2' bgcolor='#FFFFFF'>"; while($datos=mysql_fetch_array($resultados)){ $color = ($i % 2 == 0) ? '#edeff4' : '#d8dfea'; echo "<tr><td bgcolor='$color'><span style='color: #006699;'><strong>$datos[usuario]</strong></span> @ <span title='". fecha($datos['fecha']) ."'>". nl2br(tiempofecha($datos['fecha'])) ."</span><br>". nl2br(bbcode($datos['comentarios'])) ."<br /></td></tr>"; $i++; } echo "</table>";
$total=mysql_num_rows(mysql_query("SELECT * FROM Comentarios")); $anterior=$pagina-1; $siguiente=$pagina+1; $ultimo=$total/$pagina;
$rest=$total%$pagina;
if($rest>0) $ultimo=floor($ultimo)+1;
echo "<div align='center'>"; echo "<a style=\"cursor: pointer;\" onclick=\"pagina('1')\">Primero</a> - "; if($pagina>1) echo "<a style=\"cursor: pointer;\" onclick=\"pagina('$anterior')\">Anterior</a> "; echo "<strong>".$pagina."/".$ultimo."</strong>"; if($pagina<$ultimo) echo " <a style=\"cursor: pointer;\" onclick=\"pagina('$siguiente')\">Siguiente</a> "; echo " - <a style=\"cursor: pointer;\" onclick=\"pagina('$ultimo')\">Ultimo</a>"; echo "</div>"; ?></div> </td> </tr> </table /ajax/comentarios.php <?php include("../funciones/funciones.php"); include("../funciones/config.php"); $conexion = mysql_connect($config[host], $config[usuario], $config[clave]); if(!$conexion) { die("Error al intentar conectar: ".mysql_error()); } $conectar = mysql_select_db($config[base], $conexion); if(!$conectar) { die('Error al intentar seleccionar la base de datos'. mysql_error()); } $registrostope=20; if(isset($_GET['a'])){ $inicio=($_GET['a']-1)*$registrostope; $pagina=$_GET['a']; }else{ $inicio=0; $pagina=1; }
$resultados=mysql_query("SELECT * FROM Comentarios ORDER BY ID DESC LIMIT $inicio, $registrostope"); $i = 0; echo "<table width='463' border='0' align='center' cellpadding='5' cellspacing='2' bgcolor='#FFFFFF'>"; while($datos=mysql_fetch_array($resultados)){ $color = ($i % 2 == 0) ? '#edeff4' : '#d8dfea'; echo "<tr><td bgcolor='$color'><span style='color: #006699;'><strong>$datos[usuario]</strong></span> @ <span title='". fecha($datos['fecha']) ."'>". nl2br(tiempofecha($datos['fecha'])) ."</span><br>". nl2br(bbcode($datos['comentarios'])) ."<br /></td></tr>"; $i++; } echo "</table>";
$total=mysql_num_rows(mysql_query("SELECT * FROM Comentarios")); $anterior=$pagina-1; $siguiente=$pagina+1; $ultimo=$total/$pagina;
$rest=$total%$pagina;
if($rest>0) $ultimo=floor($ultimo)+1;
echo "<div align='center'>"; echo "<a style=\"cursor: pointer;\" onclick=\"pagina('1')\">Primero</a> - "; if($pagina>1) echo "<a style=\"cursor: pointer;\" onclick=\"pagina('$anterior')\">Anterior</a> "; echo "<strong>".$pagina."/".$ultimo."</strong>"; if($pagina<$ultimo) echo " <a style=\"cursor: pointer;\" onclick=\"pagina('$siguiente')\">Siguiente</a> "; echo " - <a style=\"cursor: pointer;\" onclick=\"pagina('$ultimo')\">Ultimo</a>"; echo "</div>"; ?> /funciones/funciones.php <?php function bbcode($texto) { $texto = str_replace(" ","<strong>",$texto); $texto = str_replace("","</strong>",$texto); $texto = str_replace(" ","<i>",$texto); $texto = str_replace("","</i>",$texto); $texto = str_replace(" ","<span style=\"text-decoration:underline;\">",$texto); $texto = str_replace("","</span>",$texto); $texto = str_replace("[linea]","<hr />",$texto); $texto = eregi_replace("\\ *)\\]([^\\[]*)\\[/url\\]",'<a href="\\1">\\2</a>', $texto); $texto = eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]",'<a target="_blank" href="\\1">\\1</a>', $texto); $texto = str_replace('','<img src="iconos/smiley.gif">', $texto); $texto = str_replace('','<img src="iconos/enojado.gif">', $texto); $texto = str_replace('','<img src="iconos/tedoy.gif">', $texto); $texto = str_replace('','<img src="iconos/sonrisa.gif">', $texto); $texto = str_replace(':cool:','<img src="iconos/cool.gif">', $texto); $texto = str_replace('','<img src="iconos/lengua.gif">', $texto); $texto = str_replace(':cry:','<img src="iconos/cry.gif">', $texto); $texto = str_replace(':besito:','<img src="iconos/besote.gif">', $texto); $texto = str_replace(':indeciso:','<img src="iconos/indeciso.gif">', $texto); $texto = str_replace(':labiossellados:','<img src="iconos/labiossellados.gif">', $texto); $texto = str_replace(':ojitos:','<img src="iconos/ojazos.gif">', $texto); $texto = str_replace(':pff:','<img src="iconos/pffja.gif">', $texto); $texto = str_replace(':wow:','<img src="iconos/sorprendido.gif">', $texto); $texto = str_replace(':triste:','<img src="iconos/triste.gif">', $texto); $texto = str_replace(':uh:','<img src="iconos/uh.gif">', $texto); $texto = str_replace(':ruborizado:','<img src="iconos/verguenza.gif">', $texto); return $texto; }
function tiempofecha($time) {
if( !is_numeric($time) ) $time = strtotime($time); $elapsed = time() - $time; $a = array( 12 * 30 * 24 * 60 * 60 => 'año', 30 * 24 * 60 * 60 => 'mes', 24 * 60 * 60 => 'día', 60 * 60 => 'hora', 60 => 'minuto', 1 => 'segundo' ); foreach ($a as $secs => $str) { $d = $elapsed / $secs; if ($d >= 1) { $r = round($d); if($str == 'día' and $r == 1) return 'Ayer'; if($str == 'mes' and $r > 1) $str .= 'e'; return 'Hace '.$r.' '.$str.($r > 1 ? 's' : ''); } } } function fecha($date) { $dia = explode("-", $date, 3); $year = $dia[0]; $month = (string)(int)$dia[1]; $day = (string)(int)$dia[2]; $dias = array("Domingo","Lunes","Martes","Miércoles" ,"Jueves","Viernes","Sábado"); $tomadia = $dias[intval((date("w",mktime(0,0,0,$month,$day,$year))))]; $meses = array("", "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"); return $tomadia.", ".$day." de ".$meses[$month]." de ".$year; } function inyeccion($texto) { $texto = htmlspecialchars($texto, ENT_QUOTES); if(get_magic_quotes_gpc()) $texto = stripslashes($texto); return $texto; } ?>/funciones/config.php <?php $config[host] = "sql301.eshost.es"; $config[base] = "eshos_9644735_foro"; $config[usuario] = "eshos_9644735"; $config[clave] = "acayucan"; ?> e echo este codigo pero no logro adaptarlo <?php $msj=$_POST["comentarios"]; $nom=$_POST["usuario"]; $palabras_malas=array('gay','idiotas','pendejos','nacos','choto','verga','puto','reputamadre','p**a','gay','putito','shet','*****','porno','tonto','idiota','menso','culo','tarado','tarado','chotito','puñeta','estupido','estupida','lesbiana','chingada','culito','naca','mensa','coño','putote','pto','chot','lesbi','pendejito','putonsote','zorra','mensote',); $bus=$palabras_malas; $remp="GROSERIA_ELIMINADA"; $msj = str_ireplace($bus,$remp, $msj); $nom = str_ireplace($bus,$remp, $nom); ?> ayuda endonde podria agregar ese codigo
|
|
|
4
|
Programación / PHP / Re: PHP para Cambiar un Echo Con contraseña
|
en: 18 Noviembre 2011, 21:18 pm
|
BUenO PUeS graCIAS a LA idea AnterIOR ArmE esTE COdE <form id="form1" method="post" action="avisos.php"> <label> <input type="text" name="pass" id="pass" /> <textarea name="text" id="text" cols="45" rows="5"></textarea> </label> </form> Y EL ´PHP: <?php $id=$_POST['avisos']; $pass=$_POST['pass']; $master=fopen('/lst/avisos.txt',a); fwrite($master," AVISO: ".$id." && por: " .$pass." "); fclose($master); echo "<Ubo un grave ERROR- Error 009281>"; ?>
aOrA LO QUE NESESITO ES Que revISE LA PASWoRD y QUE ANtes dE esCriBir EL txt boorrre todo el texto dentro de el (perdon por laS LETRAS PERO EL tECLADO FallA )
|
|
|
5
|
Programación / PHP / PHP para Cambiar un Echo Con contraseña
|
en: 18 Noviembre 2011, 01:24 am
|
nesesito un php que modifique un echo pero que para modificarlo se necesite una contraseña
(es para una sección donde va haber anuncios y que solo los administradores puedan cambiar eso)
help
|
|
|
|
|
|
|