how to pass a function to the javascript code.
As I have mentioned in earlier posts, I am using special code to strip out
all html, and only allow the bbcode tags I create.
The javascript preview code is
Code: Select all
<SCRIPT LANGUAGE="JavaScript">
<!--
function bashPreview(form) {
var ink = "<div align=center>Preview News Submissions Coming Soon<br><a href=javascript:self.close();>Close this window</a></div><br><br><br>";
var int = "Your Name: " + form.username.value + "<br>";
var inf = "Your Bash: " + form.userbash.value;
win = window.open(", ", 'popup', 'width=400,height=400,left=312,top=184,toolbar=0,location=0,directories=0,status=0,scrollbars=0,menubar=0,resizable=0');
win.document.write("" + ink + int + inf + "");
}
//-->
</script>Code: Select all
<input name='preview' type='button' class='submit' value='Preview' onClick='bashPreview(this.form)'>Code: Select all
function submitTags($html, $media=0, $font=0)
{
$html = preg_replace('#</?.*?\>#i','',$html);
$html = preg_replace('#<script[^>]*?>.*?</script>#i','',$html);
$html = htmlspecialchars($html);
if($media){
$html = preg_replace("#\[link\](.*?)\[/link\]#i", "<a href=\"\\1\" target=\"_blank\" title=\"bashmyex.com Bash Your Ex Girlfriend or Boyfriend Link!\">\\1</a>", $html);
}else{
$html = preg_replace("#\[link\](.*?)\[/link\]#i", "", $html);
}
if($font)
$html = preg_replace("#\[br\]#i", "<br>", $html);
return($html);
}from databse by using something similar to
Code: Select all
function one_random_news_entry() {
$result = mysql_unbuffered_query("SELECT * FROM news ORDER BY RAND() LIMIT 1");
while ($row = mysql_fetch_assoc($result))
{
$newposts = array ( "Name" => $row['name'], "Past Loves" => $row['lova'], "Bash" => $row['news'] );
foreach ( $newposts as $postfield => $postinput )
{
$postinput = submitTags($postinput, 1, 1);
echo "<b>{$postfield}:</b> {$postinput}<br />";
}
echo "<p> </p>";
}
}do the same for the javascript preview.