<?php
session_start(); //Allow Sessions
include("config.php"); //get config
include("bbcode.php"); //get bbcodes or other functions
switch($_GET[x]){ //change links to ?x=*case*
default: //default page
echo "
<SCRIPT LANGUAGE=\"JavaScript\">
function refresh() {
setTimeout('dorefresh()', 30000);
}
function dorefresh() {
window.location.reload();
}
</script><body onLoad=\"refresh()\">
"; //this is the javascript and body for the shoutbox...basically for auto refresh...
$color1 = ""; //Alternating color 1
$color2 = ""; //alternating color 2
$row_count = 0; //how many rows do you start with
$gettags = mysql_query("select * from shoutbox order by id desc limit 15"); //this is for the main frame where shouts are viewed. only 15 but you can change
$nutags = mysql_num_rows($gettags); //count them all up
if($nutags == 0) { //if there are none
echo "<table width='100%'>
<tr><td bgcolor='$row_color' width='100%'>
<center>There are currenctly no tags!</center>
</td></tr>
</table>";//tell them there are none
}else{ //or do something else....
while($t=mysql_fetch_array($gettags)){ //repeat the tables
$row_color = ($row_count % 2) ? $color1 : $color2;
echo "<table width='100%'>
<tr><td bgcolor='$row_color' width='100%'>
<b> <a href=\"$t[link]\">@</a>$t[by]</b>
";//theres the header information for the shout
if($t[by] == $logged[username]) { //if name is logged in
echo "<a href='box.php?x=delete&id=$t[id]'>(Delete)</a>"; //allow them to delete
}elseif($logged['username'] && $logged['level'] == 6) { //or if the user is logged in and an admin
echo "<a href='box.php?x=delete&id=$t[id]'>(Delete)</a>"; //allow to delete
} //end that ^^;
$message = bbcode(censor($t[message])); //censor and add bbcode to it
echo "<br>$message</td></tr></table>"; //echo the mesage and end the table
$row_count++; //adds another row to the counter above :)
} //end the while...
echo "<a href=\"box.php?x=archive\">Archive</a>"; //Archive link
}
break; //end page
case 'post': //posting page
if($logged[username] && $_POST[tag]){ //check if user is logged in and the form was submitted
if(empty($_POST[message])){ //if the message is empty
echo "<b>Error</b>: You Must Enter A Message"; //echo this
}else{ //or do something else
$user = $logged[username]; //user variable
$link = strip_tags(stripslashes($_POST[link])); //link
$msg = htmlspecialchars(stripslashes($_POST[message])); //the message variable
mysql_query("INSERT INTO shoutbox (`by`,`message`,`link`) VALUES ('$user','$msg','$link')") or die(mysql_error());//do the query or die
echo "<meta http-equiv=\"refresh\" content=\"1;url=box.php\">Shout Posted"; //redirect to main :)
}//end msg empty check
}elseif($logged[username] && !$_POST[tag]){ //check if they just went there VIA Direct URL
echo "<b>Error</b>: You Must Submit The Form"; //echo this
} //end check
break; //end page
case 'delete': //delete page
$id = stripslashes(htmlspecialchars($_GET[id])); //clean up the ID
$get = mysql_query("SELECT * FROM shoutbox WHERE id = '$id'") or die(mysql_error()); //select it from DB
$t = mysql_fetch_array($get); //allow info from it to be selected
if($t[by] == $logged[username]){ //check if logged user is the same as the user who posted it.
mysql_query("DELETE FROM shoutbox WHERE id = '$id'") or die(mysql_error()); //delete if it is true
echo "<meta http-equiv=\"refresh\" content=\"1;url=box.php\"><center>Shout Deleted</center>"; //delete message
}elseif($logged[username] && $logged[level] == 6){ //or continue
mysql_query("DELETE FROM shoutbox WHERE id = '$id'") or die(mysql_error()); //query or die!
echo "<meta http-equiv=\"refresh\" content=\"1;url=box.php\"><center>Shout Deleted</center>"; //delete message
} //end
break; //end the page
case 'archive': //Post Archive
$color1 = ""; //alt color 1
$color2 = ""; //alt color 2
$row_count = 0; //row count start
$gettags = mysql_query("select * from shoutbox order by id desc limit 200"); //get the last 200 shouts
$nutags = mysql_num_rows($gettags); //get how many there are
if($nutags == 0) { //if none
echo "<table width='100%'>
<tr><td bgcolor='$row_color' width='100%'>
<center>There are currenctly no tags!</center>
</td></tr>
</table>"; //make it say so
}else{ //or continue
while($t=mysql_fetch_array($gettags)){ //continue
$row_color = ($row_count % 2) ? $color1 : $color2; //do sopme math to check if there is 1 or more shouts
echo "<table width='100%'>
<tr><td bgcolor='$row_color' width='100%'>
<b>
$t[by]</b> "; //shout headers, simpler then they really are above in the real thing ;P
if($t[by] == $logged[username]) { //if logged name is this users post name
echo "<a href='box.php?x=delete&id=$t[id]'>(Delete)</a>"; //allow to delete
}elseif($logged[username] && $logged[level] == 6) { //or if an admin
echo "<a href='box.php?x=delete&id=$t[id]'>(Delete)</a>"; //allow to delete
}//end check
$message = bbcode(censor($t[message])); //clean up the post :)
echo "
<br>
$message
</td></tr>
</table>"; //echo the rest of the shout
$row_count++; //row move up a number
} //end while
echo "<a href=\"box.php\">Return</a>"; //echo return link
} //end..shout check
break; //end page
} //end if/else
?>
Shows my name, and says delete underneath it, but not my msg.
function censor($text, $replacement = "<b>Censored</b>"){ // they said bad thing lets import it...
if( strlen($text) > 0 ){ //if there was actually text..
$name = 'badwords.txt'; //get our bad words
$words = file($name); //make sure its a file
} //end if
$text = str_replace($words, $replacement, $text); //return censored text.
return $text;
}
This is what I see:
[code] Diablosblizz (Delete)
Archive[code]
Change:
To:
</center>
Please change to:
</form>
</center>