Jump to content
MakeWebGames

Recommended Posts

Posted

i was hoping to find away to make it so people can't spam in my shout box like there urls and stuff, but i can't figure out how. if someone could do that with this code it would be much appreciated.

 

<?php
session_start();
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
include "config.php";
global $_CONFIG;
define("MONO_ON", 1);
require "class/class_db_{$_CONFIG['driver']}.php";
include "global_func.php";
$db=new database;
$db->configure($_CONFIG['hostname'],
$_CONFIG['username'],
$_CONFIG['password'],
$_CONFIG['database'],
$_CONFIG['persistent']);
$db->connect();
$c=$db->connection_id;
$set=array();
$settq=$db->query("SELECT * FROM settings");
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid");
$ir=mysql_fetch_array($is);
stripslashes($variable);
print '
<style>
body {
padding: 0px 0px 0px 0px;
background: #FFFFFF;
font-family: Tahoma;
font-size: 11px;
}
a {
text-decoration: none;
color: #323232;
font-weight: bold;
}
</style>';
if($_POST['shout']) {
$message = mysql_real_escape_string(strip_tags($_POST['shout']));

mysql_query("INSERT INTO `shoutbox` (
`id` ,
`time` ,
`from` ,
`message`
)
VALUES (
NULL , unix_timestamp(), '{$userid}', '{$message}'
);") or die(mysql_error());

print '<meta http-equiv="refresh" content="0;url=shoutbox.php"/>';
}
$sql = sprintf("SELECT * FROM shoutbox ORDER BY time DESC LIMIT 150");
$q = mysql_query($sql);
if(!mysql_num_rows($q)) { print "<center>There are no shouts</center>"; } else {


while($r=$db->fetch_row($q))
{
$sql = sprintf("SELECT * FROM users WHERE userid={$r['from']}");
$t= mysql_query($sql);
if(!mysql_num_rows($t)) { $from="Unknown"; } else {
$u = mysql_fetch_array($t);
$from = "[url='viewuser.php?u={$u[']{$u['username']}[/url]";
}
//Work out if it was sent today or last week.
$la=time()-$r['time'];
if($la < 86400)
{
$when="Today";
}
if($la > 86400 && $la < 172800)
{
$when="Yesterday";
}
elseif($la >= 172800 && $la <= 604800)
{
$when="This week";
}
elseif($la >= 604800 && $la <= 2419200)
{
$when="This month";
}

$time=($r['time'] > 0) ?date('g:i:s a',$r['time']) : "Never";
$message = strip_tags($r['message']);

print "<font color='blue'>{$from} - [b]{$when}[/b] at {$time}:</font> {$message}
";

}
}
?>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...