cooper101 Posted November 16, 2007 Share Posted November 16, 2007 I got this shoutbox block for my PHPnuke site. I did not write it, (Especially since I don't speak spanish) It seems to have code to check if either the nickname or the message is empty or if the nickname = "nickname" or the message = "message" and to issue an error message if either case is correct. However, it doesn't work. I can't seem to spot the problem, can anyone see what it is I need to change? (NOTE: This is not the entire code, I have tried to include only the code that applies to my problem, if you need to see the entire code please let me know) <script> function revisar(campo) { if(campo.value=='Your Nick{ campo.value='' ; } if(campo.value=='Message') { campo.value='' ; } } function validar() { if(formulario.nick.value == '' || formulario.nick.value == 'Nickname') { alert('Your nick is empty') ; return false ; } if(formulario.mensaje.value == '' || formulario.mensaje.value == 'Message') { alert('Your message is empty') ; return false ; } } </script> AND <div align="center"> <br> <form name="formulario" method="post" action="minichat.php" onsubmit="return validar()"> <input type="text" name="nick" size="10" maxlength="<? echo $max_nick ?>" value="Nickname" onfocus="revisar(this)" class="formulario"><br> <textarea cols="21" rows="7" name="mensaje" <? echo $max_mensaje ?>" value="Message" onfocus="revisar(this)" class="formulario">Message</textarea><br> <input type="submit" name="enviar" value="Send" class="formulario"></form> <p align="center"> Link to comment https://forums.phpfreaks.com/topic/77646-shoutbox-code/ Share on other sites More sharing options...
atlanta Posted November 16, 2007 Share Posted November 16, 2007 Forgot to close some parts <script> function revisar(campo) { if(campo.value=='Your Nick'){ campo.value='' ; } if(campo.value=='Message') { campo.value='' ; } } function validar() { if(formulario.nick.value == '' || formulario.nick.value == 'Nickname') { alert('Your nick is empty') ; return false ; } if(formulario.mensaje.value == '' || formulario.mensaje.value == 'Message') { alert('Your message is empty') ; return false ; } } </script> <div align="center"> <form name="formulario" method="post" action="minichat.php" onsubmit="return validar()"> <input type="text" name="nick" size="10" maxlength="<? echo $max_nick ?>" value="Nickname" onfocus="revisar(this)" class="formulario"> <textarea cols="21" rows="7" name="mensaje" <? echo $max_mensaje ?>" value="Message" onfocus="revisar(this)" class="formulario">Message</textarea> <input type="submit" name="enviar" value="Send" class="formulario"></form> <p align="center"> Link to comment https://forums.phpfreaks.com/topic/77646-shoutbox-code/#findComment-393042 Share on other sites More sharing options...
Karl33to Posted November 16, 2007 Share Posted November 16, 2007 i think your problem is that the revisar function is checking for a different value to the validar function and also different to the default value of the input, so just change the following and it should work ok if(campo.value=='Nickname'){ campo.value='' ; } This should really go in Javascript section Link to comment https://forums.phpfreaks.com/topic/77646-shoutbox-code/#findComment-393067 Share on other sites More sharing options...
cooper101 Posted November 16, 2007 Author Share Posted November 16, 2007 Thanks guys for the quick replies. I made the changes mentioned here but it's still not working. I'll post the whole code here I hope that's ok, it's not very long. <? //**************************** //*** MiniChat v.1.2 *** //*** Creado por: Electros *** //*** Web: www.electros.tk *** //**************************** //********************* //*** Configuración *** //********************* // Mensajes a mostrar (0 para mostrar todos) $mostrar = 30 ; // Maximo de caracteres por nick $max_nick = 20 ; // Maximo de caracteres por mensaje $max_mensaje = 200 ; // Maximo de caracteres por web $max_web = 50 ; // Maximo de caracteres por palabra (palabras muy grandes como una URL puede descuadrar el diseño // y ocasionar que el minichat no se vea correctamente) si no deseas esta opción pon 0. $max_palabra = 25 ; // smilies $smilies = "ON" ; // Censura de palabras $censura = "OFF" ; // Permitir código HTML (se recomienda que esté desactivado) $codigo = "OFF" ; // Altura de la tabla de mensajes (cuando los mensajes mostrados rebasan la altura marcada // aparece una barra de desplazamiento) $altura = 230 ; // csschat (archivo que contiene el csschat del minichat, tipo de letra, tamaño, color, fondo) $csschat = "csschat.php" ; // Lista de smilies (si $smilies está en ON) if($smilies == "ON") { function smilies($texto) { // --> Inicio smilies $texto = str_replace("","[:alegre.gif:]",$texto) ; $texto = str_replace(":8","[:asustado.gif:]",$texto) ; $texto = str_replace("","[:burla.gif:]",$texto) ; $texto = str_replace(":S","[:confundido.gif:]",$texto) ; $texto = str_replace(":(1","[:demonio.gif:]",$texto) ; $texto = str_replace(":(2","[:demonio2.gif:]",$texto) ; $texto = str_replace(":?","[:duda.gif:]",$texto) ; $texto = str_replace(":-(","[:enojado.gif:]",$texto) ; $texto = str_replace("","[:guino.gif:]",$texto) ; $texto = str_replace(":'(","[:llorar.gif:]",$texto) ; $texto = str_replace(":lol","[:lol.gif:]",$texto) ; $texto = str_replace(":M","[:moda.gif:]",$texto) ; $texto = str_replace(":|","[:neutral.gif:]",$texto) ; $texto = str_replace("","[:risa.gif:]",$texto) ; $texto = str_replace(":-)","[:sonrisa.gif:]",$texto) ; $texto = str_replace(":R","[:sonrojado.gif:]",$texto) ; $texto = str_replace("","[:sorprendido.gif:]",$texto) ; $texto = str_replace("","[:triste.gif:]",$texto) ; // --> Fin smilies $texto = str_replace("[:","<img src=\"smilies/",$texto) ; $texto = str_replace(":]","\" width=\"15\" height=\"15\">",$texto) ; return $texto ; } } // Lista de censura de palabras (si $censura está en ON) if($censura == "ON") { function censura($texto) { // --> Inicio palabras $texto = str_replace("insulto","***",$texto) ; // --> Fin palabras return $texto ; } } // Código HTML (si $codigo está en OFF) if($codigo == "OFF") { function codigo($texto) { $texto = htmlspecialchars($texto) ; return $texto ; } } //******************************* //*** Fin de la configuración *** //******************************* // *** Guardar mensaje *** if($enviar) { function quitar($texto) { $texto = trim($texto) ; $texto = stripslashes($texto) ; return $texto ; } $nick = quitar($nick) ; $mensaje = quitar($mensaje) ; $web = quitar($web) ; if($codigo == "OFF") { $nick = codigo($nick) ; $mensaje = codigo($mensaje) ; $web = codigo($web) ; } // Si $max_palabra es mayor que cero if($max_palabra > 0) { $palabras = explode(" ",$mensaje) ; $total = count($palabras) ; for($a = 0 ; $a < $total ; $a++) { if(strlen($palabras[$a]) > $max_palabra) { $palabras[$a] = chunk_split($palabras[$a],$max_palabra," ") ; } } $mensaje = implode($palabras," ") ; } $minichat = fopen("minichat.txt",a) ; if($web == "" || $web == "http://") { fwrite($minichat,"\n<b><$nick></b> $mensaje") ; } else { fwrite($minichat,"\n<a href=\"$web\" target=\"_blank\"><$nick></a> $mensaje") ; } fclose($minichat) ; } ?> <html> <head> <title></title> <? include("$csschat") ; ?> </head> <body> <div style="height: <? echo $altura ?> ; overflow: auto"> <? // *** Mostrar los mensajes *** $mensajes = file("minichat.txt") ; $total = count($mensajes) ; if($total < $mostrar || $mostrar == 0) { $maximo = 0 ; } else { $maximo = $total - $mostrar ; } while($total > $maximo) { $total-- ; $mensaje = $mensajes[$total] ; if($smilies == "ON") { $mensaje = smilies($mensaje) ; } if($censura == "ON") { $mensaje = censura($mensaje) ; } ?> <table width="100%" border="0" cellpadding="1" cellspacing="0" class="mensaje"> <tr> <td> <? echo $mensaje ?> </td> </tr> </table> <div style="margin-top: 1"></div> <? } ?> </div> <script> function revisar(campo) { if(campo.value=='Nickname'}{ campo.value='' ; } if(campo.value=='Message') { campo.value='' ; } } function validar() { if(formulario.nick.value == '' || formulario.nick.value == 'Nickname') { alert('Your nick is empty') ; return false ; } if(formulario.mensaje.value == '' || formulario.mensaje.value == 'Message') { alert('Your message is empty') ; return false ; } } </script> <div align="center"> <script> function smilies(codigo) { formulario.mensaje.value += codigo ; formulario.mensaje.focus() ; } </script> <div align="center"> <br> <form name="formulario" method="post" action="minichat.php" onsubmit="return validar()"> <input type="text" name="nick" size="10" maxlength="<? echo $max_nick ?>" value="Nickname" onfocus="revisar(this)" class="formulario"> <textarea cols="21" rows="7" name="mensaje" <? echo $max_mensaje ?>" value="Message" onfocus="revisar(this)" class="formulario">Message</textarea> <input type="submit" name="enviar" value="Send" class="formulario"></form> <p align="center"> <b>Smilies:</b><br> <table border="0" cellpadding="5" cellspacing="0" align="center"> <tr> <td><a href="javascript:smilies('')"> <img src="smilies/alegre.gif" width="15" height="15" border="0"></a></td> <td><a href="javascript:smilies(':8')"> <img src="smilies/asustado.gif" width="15" height="15" border="0"></a></td> <td><a href="javascript:smilies('')"> <img src="smilies/burla.gif" width="15" height="15" border="0"></a></td> <td><a href="javascript:smilies(':S')"> <img src="smilies/confundido.gif" width="15" height="15" border="0"></a></td> <td><a href="javascript:smilies(':(1')"> <img src="smilies/demonio.gif" width="15" height="15" border="0"></a></td> </tr> <tr> <td><a href="javascript:smilies(':(2')"> <img src="smilies/demonio2.gif" width="15" height="15" border="0"></a></td> <td><a href="javascript:smilies(':?')"> <img src="smilies/duda.gif" width="15" height="15" border="0"></a></td> <td><a href="javascript:smilies(':-(')"> <img src="smilies/enojado.gif" width="15" height="15" border="0"></a></td> <td><a href="javascript:smilies('')"> <img src="smilies/guino.gif" width="15" height="15" border="0"></a></td> <td><a href="javascript:smilies(':\'(')"> <img src="smilies/llorar.gif" width="15" height="15" border="0"></a></td> </tr> <tr> <td><a href="javascript:smilies(':lol')"> <img src="smilies/lol.gif" width="15" height="15" border="0"></a></td> <td><a href="javascript:smilies(':M')"> <img src="smilies/moda.gif" width="15" height="15" border="0"></a></td> <td><a href="javascript:smilies(':|')"> <img src="smilies/neutral.gif" width="15" height="15" border="0"></a></td> <td><a href="javascript:smilies('')"> <img src="smilies/risa.gif" width="15" height="15" border="0"></a></td> <td><a href="javascript:smilies(':-)')"> <img src="smilies/sonrisa.gif" width="15" height="15" border="0"></a></td> </tr> <tr> <td></td> <td><a href="javascript:smilies(':R')"> <img src="smilies/sonrojado.gif" width="15" height="15" border="0"></a></td> <td><a href="javascript:smilies('')"> <img src="smilies/sorprendido.gif" width="15" height="15" border="0"></a></td> <td><a href="javascript:smilies('')"> <img src="smilies/triste.gif" width="15" height="15" border="0"></a></td> <td></td> </tr> </table> <p> </p> <tr> <p align="center"> <a href="http://zulkiplyharun.com" target="_blank">ChatMini</a> </body> </html> Link to comment https://forums.phpfreaks.com/topic/77646-shoutbox-code/#findComment-393160 Share on other sites More sharing options...
darkfreaks Posted November 16, 2007 Share Posted November 16, 2007 <?php //**************************** //*** MiniChat v.1.2 *** //*** Creado por: Electros *** //*** Web: www.electros.tk *** //**************************** //********************* //*** Configuración *** //********************* // Mensajes a mostrar (0 para mostrar todos) $mostrar = 30 ; // Maximo de caracteres por nick $max_nick = 20 ; // Maximo de caracteres por mensaje $max_mensaje = 200 ; // Maximo de caracteres por web $max_web = 50 ; // Maximo de caracteres por palabra (palabras muy grandes como una URL puede descuadrar el diseño // y ocasionar que el minichat no se vea correctamente) si no deseas esta opción pon 0. $max_palabra = 25 ; // smilies $smilies = "ON" ; // Censura de palabras $censura = "OFF" ; // Permitir código HTML (se recomienda que esté desactivado) $codigo = "OFF" ; // Altura de la tabla de mensajes (cuando los mensajes mostrados rebasan la altura marcada // aparece una barra de desplazamiento) $altura = 230 ; // csschat (archivo que contiene el csschat del minichat, tipo de letra, tamaño, color, fondo) $csschat = "csschat.php" ; // Lista de smilies (si $smilies está en ON) if($smilies == "ON") { function smilies($texto) { // --> Inicio smilies $texto = str_replace("","[:alegre.gif:]",$texto) ; $texto = str_replace(":8","[:asustado.gif:]",$texto) ; $texto = str_replace("","[:burla.gif:]",$texto) ; $texto = str_replace(":S","[:confundido.gif:]",$texto) ; $texto = str_replace(":(1","[:demonio.gif:]",$texto) ; $texto = str_replace(":(2","[:demonio2.gif:]",$texto) ; $texto = str_replace(":?","[:duda.gif:]",$texto) ; $texto = str_replace(":-(","[:enojado.gif:]",$texto) ; $texto = str_replace("","[:guino.gif:]",$texto) ; $texto = str_replace("","[:llorar.gif:]",$texto) ; $texto = str_replace(":lol","[:lol.gif:]",$texto) ; $texto = str_replace(":M","[:moda.gif:]",$texto) ; $texto = str_replace(":|","[:neutral.gif:]",$texto) ; $texto = str_replace("","[:risa.gif:]",$texto) ; $texto = str_replace(":-)","[:sonrisa.gif:]",$texto) ; $texto = str_replace(":R","[:sonrojado.gif:]",$texto) ; $texto = str_replace("","[:sorprendido.gif:]",$texto) ; $texto = str_replace("","[:triste.gif:]",$texto) ; // --> Fin smilies $texto = str_replace("[:","<img src=\"smilies/",$texto) ; $texto = str_replace(":]","\" width=\"15\" height=\"15\">",$texto) ; return $texto ; } } // Lista de censura de palabras (si $censura está en ON) if($censura == "ON") { function censura($texto) { // --> Inicio palabras $texto = str_replace("insulto","***",$texto) ; // --> Fin palabras return $texto ; } } // Código HTML (si $codigo está en OFF) if($codigo == "OFF") { function codigo($texto) { $texto = htmlspecialchars($texto) ; return $texto ; } } //******************************* //*** Fin de la configuración *** //******************************* // *** Guardar mensaje *** if($enviar) { function quitar($texto) { $texto = trim($texto) ; $texto = stripslashes($texto) ; return $texto ; } $nick = quitar($nick) ; $mensaje = quitar($mensaje) ; $web = quitar($web) ; if($codigo == "OFF") { $nick = codigo($nick) ; $mensaje = codigo($mensaje) ; $web = codigo($web) ; } // Si $max_palabra es mayor que cero if($max_palabra > 0) { $palabras = explode(" ",$mensaje) ; $total = count($palabras) ; for($a = 0 ; $a < $total ; $a++) { if(strlen($palabras[$a]) > $max_palabra) { $palabras[$a] = chunk_split($palabras[$a],$max_palabra," ") ; } } $mensaje = implode($palabras," ") ; } $minichat = fopen("minichat.txt",a) ; if($web == "" || $web == "http://") { fwrite($minichat,"\n<$nick> $mensaje") ; } else { fwrite($minichat,"\n<a href=\"$web\" target=\"_blank\"><$nick>[/url] $mensaje") ; } fclose($minichat) ; } ?> <html> <head> <title></title> <?php include("$csschat") ; ?> </head> <body> <div style="height: <?php echo $altura ?> ; overflow: auto"> <?php // *** Mostrar los mensajes *** $mensajes = file("minichat.txt") ; $total = count($mensajes) ; if($total < $mostrar || $mostrar == "0") { $maximo = "0" ; } else { $maximo = $total - $mostrar ; } while($total > $maximo) { $total-- ; $mensaje = $mensajes[$total] ; if($smilies == "ON") { $mensaje = smilies($mensaje) ; } if($censura == "ON") { $mensaje = censura($mensaje) ; } ?> <table width="100%" border="0" cellpadding="1" cellspacing="0" class="mensaje"> <tr> <td> <?php echo $mensaje; ?> </td> </tr> </table> <div style="margin-top: 1"></div> <?php } ?> </div> <script> function revisar(campo) { if(campo.value=='Nickname'}{ campo.value='' ; } if(campo.value=='Message') { campo.value='' ; } } function validar() { if(formulario.nick.value == '' || formulario.nick.value == 'Nickname') { alert('Your nick is empty') ; return false ; } if(formulario.mensaje.value == '' || formulario.mensaje.value == 'Message') { alert('Your message is empty') ; return false ; } } </script> <div align="center"> <script> function smilies(codigo) { formulario.mensaje.value += codigo ; formulario.mensaje.focus() ; } </script> <div align="center"> <form name="formulario" method="post" action="minichat.php" onsubmit="return validar()"> <input type="text" name="nick" size="10" maxlength="<?php echo $max_nick; ?>" value="Nickname" onfocus="revisar(this)" class="formulario"> <textarea cols="21" rows="7" name="mensaje" "<?php echo $max_mensaje; ?>" value="Message" onfocus="revisar(this)" class="formulario">Message</textarea> <input type="submit" name="enviar" value="Send" class="formulario"></form> <p align="center"> Smilies: <table border="0" cellpadding="5" cellspacing="0" align="center"> <tr> <td><a href="javascript:smilies('')"> <img src="smilies/alegre.gif" width="15" height="15" border="0">[/url]</td> <td><a href="javascript:smilies(':8')"> <img src="smilies/asustado.gif" width="15" height="15" border="0">[/url]</td> <td><a href="javascript:smilies('')"> <img src="smilies/burla.gif" width="15" height="15" border="0">[/url]</td> <td><a href="javascript:smilies(':S')"> <img src="smilies/confundido.gif" width="15" height="15" border="0">[/url]</td> <td><a href="javascript:smilies(':(1')"> <img src="smilies/demonio.gif" width="15" height="15" border="0">[/url]</td> </tr> <tr> <td><a href="javascript:smilies(':(2')"> <img src="smilies/demonio2.gif" width="15" height="15" border="0">[/url]</td> <td><a href="javascript:smilies(':?')"> <img src="smilies/duda.gif" width="15" height="15" border="0">[/url]</td> <td><a href="javascript:smilies(':-(')"> <img src="smilies/enojado.gif" width="15" height="15" border="0">[/url]</td> <td><a href="javascript:smilies('')"> <img src="smilies/guino.gif" width="15" height="15" border="0">[/url]</td> <td><a href="javascript:smilies(':\'(')"> <img src="smilies/llorar.gif" width="15" height="15" border="0">[/url]</td> </tr> <tr> <td><a href="javascript:smilies(':lol')"> <img src="smilies/lol.gif" width="15" height="15" border="0">[/url]</td> <td><a href="javascript:smilies(':M')"> <img src="smilies/moda.gif" width="15" height="15" border="0">[/url]</td> <td><a href="javascript:smilies(':|')"> <img src="smilies/neutral.gif" width="15" height="15" border="0">[/url]</td> <td><a href="javascript:smilies('')"> <img src="smilies/risa.gif" width="15" height="15" border="0">[/url]</td> <td><a href="javascript:smilies(':-)')"> <img src="smilies/sonrisa.gif" width="15" height="15" border="0">[/url]</td> </tr> <tr> <td></td> <td><a href="javascript:smilies(':R')"> <img src="smilies/sonrojado.gif" width="15" height="15" border="0">[/url]</td> <td><a href="javascript:smilies('')"> <img src="smilies/sorprendido.gif" width="15" height="15" border="0">[/url]</td> <td><a href="javascript:smilies('')"> <img src="smilies/triste.gif" width="15" height="15" border="0">[/url]</td> <td></td> </tr> </table> <p> </p> <tr> <p align="center"> ChatMini </body> </html> Link to comment https://forums.phpfreaks.com/topic/77646-shoutbox-code/#findComment-393178 Share on other sites More sharing options...
cooper101 Posted November 17, 2007 Author Share Posted November 17, 2007 Thanks for the reply, I replaced the entire code that you posted darkfreaks (Had to remove the [/url] that was on the smilies part at the end, it was on my code I posted, but not in the actual file, I have to assume the forum software added it for some reason) but it still doesn't work. I'm stumped. I may have to just give up on it working and manually go in and correct the minichat.txt file everytime someone screws it up. :-\ Link to comment https://forums.phpfreaks.com/topic/77646-shoutbox-code/#findComment-393229 Share on other sites More sharing options...
cooper101 Posted November 30, 2007 Author Share Posted November 30, 2007 Ok, I just installed a new shout box module/block made by someone called "Supercat" at www.ourscripts.net which apparently doesn't exist anymore. I love it except that my users want a text BOX instead of a single small text line to input their text so they can see their whole message before they click submit. I know the difference is between the code input type="text" and the code textarea cols="21" rows="7". However, I don't know how to change the code in the block-Shout_Box.php file to fix this. Here is the section of code I believe to be the correct part: if ($conf['anonymouspost'] == "yes" && $username == "Anonymous") { if ($PreviousUsername) { $boxtext = $PreviousUsername; } else { $boxtext = ""._NAME.""; } $bottom_content .= "<tr><td align=\"center\"><input type=\"text\" name=\"shoutuid\" size=\"$ShoutNameWidth\" value=\"$boxtext\" maxlength=\"25\" onfocus=\"if ( this.value == '"._NAME."' ) { this.value=''; }\" onblur=\"if (this.value == '') { this.value='"._NAME."' }\" /></td></tr>\n"; } if ($PreviousComment) { $boxtext = $PreviousComment; } else { $boxtext = ""._SB_MESSAGE.""; } $bottom_content .= "<tr><td align=\"center\" nowrap=\"nowrap\"><input type=\"text\" name=\"ShoutComment\" size=\"$ShoutTextWidth\" value=\"$boxtext\" maxlength=\"2500\" onfocus=\"if ( this.value == '"._SB_MESSAGE."' ) { this.value=''; }\" onblur=\"if (this.value == '') { this.value='"._SB_MESSAGE."' }\" /></td></tr>"; $bottom_content .= "<tr><td align=\"center\"><input type=\"hidden\" name=\"ShoutSubmit\" value=\"ShoutPost\" />"; $bottom_content .= "<div id=\"smilies_hide\" style=\"display: block;\"><div class=\"content\"><input type=\"submit\" name=\"button\" value=\""._SHOUT."\" /> <span onclick=\"changeBoxSize ('show'); return false;\"><input type=\"button\" value=\""._SMILIES."\" /></span></div></div>"; $bottom_content .= "<div id=\"smilies_show\" style=\"display: none;\"><div class=\"content\"><input type=\"submit\" name=\"button\" value=\""._SHOUT."\" /> <span onclick=\"changeBoxSize ('hide'); return false;\"><input type=\"button\" value=\""._SMILIES."\" /></span><br /><br />"; $sql = "select distinct image from ".$prefix."_shoutbox_emoticons"; $nameresult1 = $db->sql_query($sql); $flag = 1; Can anyone here tell me how to change this so instead of a small 20 character text line I can get a 21 col by 7 row text box? Link to comment https://forums.phpfreaks.com/topic/77646-shoutbox-code/#findComment-403084 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.