Scripts

SNP Shoutbox v1.0

/* ************ */ /* */ /* Readme */ /* */ /* ************ */ ------------------ Author ------------------ Name : Dennis van den Hout Website : http://www.scripters.nl ------------------ Disclaimer ------------------ Your allowed to change some source codes for you OWN website, DON'T release this version WITHOUT PERMISSION of the author. ------------------ Useage ------------------ - Upload all files to your server - Edit your config.php ( SQL Info ) - Run the installer and follow the steps - Go to SHOUTBOX.PHP and there it is ------------------ Bugs ------------------ - Report them to [email protected] - Ask in our forums /* ************ */ /* */ /* Versions */ /* */ /* ************ */ ----------------- Version : Beta 1.0 Date : March 7th 2004 Changes : - 1st release, everything is new :) ----------------- Version : Beta 1.1 Date : March 7th 2004 Changes : - Added antiflood protection - Fixed .SQL file (some ppl had errors) - Changed admin a bit - If you dont fill in website/email you'll get an error now - Admin pass is now hidden, if you wanna change it... just type a new password - added "or die(mysql_error());" to most of the queries, when there's an error users can now report it and we can help them better ;) - Added option to display all messages in your shoutbox ----------------- Version : 1.0 Date : March 8th 2004 Changes : - First Official release !!! - Added copyright - If user has entered a URL it'll open in a blank page now - In admin you can edit height + width of your shoutbox - If you hover a shout you'll get the date and time when the shout has been posted - Added field on config... "DATE_FORMAT" to edit the way of presenting the date - Made field "TIME" a DATETIME field - Made installer to easily install the shoutbox - If your shoutbox is empty, it'll display "No Shouts Yet!" :) Preview : http://members.lycos.nl/xdragoon/shoutbox/shoutbox.php Download : http://members.lycos.nl/xdragoon/snp_shoutbox_v10.zip Smiles : http://members.lycos.nl/xdragoon/smiles.zip

snp-shoutbox-v10
ADMIN.PHP
-----------------------------------------------
<?
############################################
#  Filename   : ADMIN.PHP                  #
#------------------------------------------#
#  Written By : Dennis van den Hout        #
#  Email      : [email protected]     #
#  Website    : www.scripters.nl           #
#  Questions? : www.scripters.nl/forum     #
#------------------------------------------#
#   Editing source is allowed, unless you  #
#         give it to other users           #
#------------------------------------------#
############################################

error_reporting(E_ALL);
session_start();
ob_start();

include("config.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" content="text/css" href="style.css">
</head>

<body topmargin="10">
<?
if(file_exists("install.php"))
{
	echo "<h1>Error !</h1>";
	echo "Your tagboard isn't installed yet, please run the install file !";
	echo "<br>\n<br>\n";
	echo "» <a href=\"install.php\">Install Shoutbox</a>";
}
else
{
	if(!isset($_SESSION['admin_login']))
	{
		if(isset($_POST['login']))
		{
			if($_POST['username'] == $cfg['admin_user'] AND $_POST['password'] == $cfg['admin_pass'])
			{
				header("Location: admin.php");
				$_SESSION['admin_login'] = 1;
			}
			else
			{
				echo "<script>alert('Login Incorrect.'); document.location.href=('admin.php')</script>";
			}
		}
		else
		{
?>
<h1>Admin Login</h1>
<form method="POST">
<input type="hidden" value="1" name="login">
Username : <input type="text" name="username" maxlength="15"><br>
Password : <input type="password" name="password" maxlength="15"><br><br>

<input type="Submit" value="Login"><br><br>

<?
		}
	}
	else
	{
		echo "<script src=\"javascript.js\"></script>";

		if(!isset($_GET['act']))
		{
?>
<h1>Admin Panel</h1>
<h5 class="admin_link">Options</h5>
» <b><a href="admin.php?act=config">Configuration</a></b><br>&nbsp; <i>Change all configurations of your shoutbox here.</i><br><br>
» <b><a href="admin.php?act=list_messages">List Messages</a></b><br>&nbsp; &nbsp;View all messages ever posted in your shoutbox.<br><br>
» <b><a href="admin.php?act=smiles">Smiles</a></b><br>&nbsp; &nbsp;<i>Manage smiles that can be used in your shoutbox.</i><br><br>
<h5 class="admin_link">Maintenance</h5>
» <b><a href="javascript:delete_messages()">Delete all messages</a></b><br>&nbsp; <i>Delete all messages in your shoutbox.</i><br><br>
» <b><a href="admin.php?act=repair">Repair & Optimize Database</a></b><br>&nbsp; <i>Do this often to keep the script running fast.</i><br><br>
» <b><a href="javascript:uninstall()">UN-Install</a></b><br>&nbsp; <i>Uninstall your shoutbox script.</i><br>
<br>
<h5 class="admin_link">Others</h5>
» <b><a href="shoutbox.inc.php">My Shoutbox</a></b><br>&nbsp; <i>Go to your shoutbox.</i><br><br>
» <b><a href="admin.php?act=logoff">Log Off</a></b><br>&nbsp; <i>Log off as admin.</i>
<?
		}

		if(isset($_GET['act']))
		{
			if($_GET['act'] == "config" AND !isset($_POST['save_config']))
			{
?>
<h1>Edit Config</h1>

<form method="POST">
<input type="hidden" value="1" name="save_config">
<b>Shoutbox Title : </b><br>
<input type="text" name="name" value="<? echo $cfg['name'] ?>"><br><br>

<b>Antiflood time : </b><br>
<input type="text" name="antiflood" value="<? echo $cfg['antiflood'] ?>" size="3"> sec<br><br>

<b>Date Format : </b><br>
<input type="text" name="date_format" value="<? echo $cfg['date_format'] ?>" size="10"> 
<a href="http://www.php.net/date" target="_blank">More Info</a><br><br>

<b>Amount of messages to display : </b><br>
<input type="text" name="max_msg" value="<? echo $cfg['max_msg'] ?>" size="3"><br><br>

<b>Enable Smiles : </b><br>
<select name="smiles">
<?
				if(empty($cfg['smiles']))
				{
					$selected = " selected";
				}
				else
				{
					$selected = "";
				}
?>
<option value="1">Yes</option>
<option value="0"<? echo $selected ?>>No</option>
</select><br><br>

<b>Height of shoutbox : </b><br>
<input type="text" name="height" value="<? echo $cfg['height'] ?>" size="3"><br><br>

<b>Width of shoutbox : </b><br>
<input type="text" name="width" value="<? echo $cfg['width'] ?>" size="3"><br><br>

<b>Admin Username : </b><br>
<input type="text" name="admin_user" value="<? echo $cfg['admin_user'] ?>" size="7"><br><br>

<b>Admin Password : </b><br>
<input type="password" name="admin_pass" value="<? echo $cfg['admin_pass'] ?>" size="7"> ( Change if needed )<br><br>

<input type="submit" value="Save">
<input type="reset" value="Reset">
<input type="button" value="Cancel" OnClick="document.location.href=('admin.php')">
<?
			}

			if($_GET['act'] == "list_messages")
			{
				echo "<center><a href=\"admin.php\">Admin Index</a></center><br><hr>";

				$query = mysql_query("SELECT *,UNIX_TIMESTAMP(time) AS time FROM tbl_messages ORDER BY id DESC") or die(mysql_error());

				while($row = mysql_fetch_assoc($query))
				{
?>
<table title="Posted : <? echo date("$cfg[date_format]",$row['time']); ?>" style="border-collapse: collapse" cellpadding="2" cellspacing="0" width="100%" class="content">
  <tr>
    <td width="25%"><b>Name :</b></td>
    <td width="75%">
<?
					if(!empty($row['homepage']))
					{
						$split_url = substr($row['homepage'],0,7);

						if($split_url != "http://")
						{
							$url = "http://" . $row['homepage'];
						}
						else
						{
							$url = $row['homepage'];
						}

						echo "<a href=\"" . htmlspecialchars($url) . "\" target=\"_blank\">" . htmlspecialchars($row['name']) . "</a>";
					}
					else
					{
						echo "<a href=\"mailto:" . htmlspecialchars($row['email']) . "\">" . htmlspecialchars($row['name']) . "</a>";
					}
?>
    </td>
  </tr>
  <tr>
    <td colspan="2"><b>Message :</b></td>
  </tr>
  <tr>
    <td colspan="2">
<?
					$row['message'] = htmlspecialchars($row['message']);

					if(!empty($cfg['smiles']))
					{
						$smile_select = mysql_query("SELECT * FROM tbl_smiles ORDER BY id ASC") or die(mysql_error());

						while($smile = mysql_fetch_assoc($smile_select))
						{
							$smile['tag'] = str_replace(">","&gt;", $smile['tag']);
							$smile['tag'] = str_replace("<","&lt;", $smile['tag']);

							$row['message'] = str_replace("$smile[tag]","<img src=\"smiles/" . $smile['file'] . "\">", $row['message']);
						}
					}

					echo $row['message'];
?>
    </td>
  </tr>
</table>
<?
					echo "<center>";
					echo "<a class=\"admin_link\" href=\"admin.php?act=edit_msg&msg_id=" . $row['id'] . "\">Edit</a> - ";
					echo "<a class=\"admin_link\" href=\"javascript:del_msg('" . $row['id'] . "')\">Delete</a> - ";
					echo "<a class=\"admin_link\" href=\"admin.php?act=ip_msg&msg_id=" . $row['id'] . "\">IP</a>";
					echo "</center>";
				}
			}

			if($_GET['act'] == "smiles")
			{
?>
<h1>Smiles</h1>
<table style="border-collapse: collapse" cellpadding="2" cellspacing="0" width="100%" class="content">
  <tr>
    <td width="25%"><b>Name</b></td>
    <td width="20%"><b>Tag</b></td>
    <td width="20%"><b>Preview</b></td>
    <td width="20%" align="center"><b>Options</b></td>
  </tr>
<?
				$result = mysql_result(mysql_query("SELECT COUNT(1) FROM tbl_smiles"),0);

				if(!empty($result))
				{
					$query = mysql_query("SELECT * FROM tbl_smiles ORDER BY name ASC") or die(mysql_error());

					while($row = mysql_fetch_assoc($query))
					{
?>
  <tr>
    <td width="25%"><? echo htmlspecialchars($row['name']) ?></td>
    <td width="20%"><? echo htmlspecialchars($row['tag']) ?></td>
    <td width="20%"><img src="smiles/<? echo $row['file'] ?>"></td>
    <td width="20%" align="center"><a href="admin.php?act=edit_smile&smile_id=<? echo $row['id'] ?>">Edit</a> |
    <a href="javascript:del_smile('<? echo $row['id'] ?>')">Delete</a></td>
  </tr>
<?
					}
				}

				echo "</table>";
				echo "<br>\n";
				echo "» <a href=\"admin.php?act=add_smile\">Add Smile</a>";
				echo "<br>\n";
				echo "» <a href=\"admin.php\">Admin Index</a>";
			}

			if($_GET['act'] == "add_smile" AND !isset($_POST['add_smile']))
			{
?>
<h1>Add Smile</h1>
<form method="POST" name="form">
<input type="hidden" value="1" name="add_smile">

<b>Smile Name :</b><br>
<input type="text" name="name" maxlength="25"><br>

<b>Smile Tag :</b><br>
<input type="text" name="tag" size="5" maxlength="10"><br>

<b>Smile File :</b><br>
<select name="file" onChange="showimage()"><?

				$handle = opendir('smiles');

				while(false!==($file = readdir($handle)))
				{
					if($file != "." AND $file != "..")
					{
						if(!isset($first_smile))
						{
							$first_smile = $file;
						}

					echo "<option value=\"" . $file . "\">" . $file . "</option>\n";
					}
				}

				closedir($handle);
?>
    </select><img src="smiles/<? echo $first_smile ?>" name="icons" hspace="10"><br><br>

<input type="submit" value="Save">
<input type="reset" value="Reset">
<input type="button" value="Cancel" OnClick="history.go(-1)">
</form>
<?
			}

			if($_GET['act'] == "del_smile")
			{
				if(isset($_GET['smile_id']))
				{
					$result = mysql_result(mysql_query("SELECT COUNT(1) FROM tbl_smiles WHERE id = '" . $_GET['smile_id'] . "'"),0);

					if(!empty($result))
					{
						mysql_query("DELETE FROM tbl_smiles WHERE id = '" . $_GET['smile_id'] . "'") or die(mysql_error());
						echo "<script>alert('Smile successfully deleted.'); history.go(-1)</script>";
					}
					else
					{
						echo "<script>alert('Smile with this ID doesn\'t excist.'); history.go(-1)</script>";
					}
				}
				else
				{
					echo "<script>alert('Please validate a smile ID.'); history.go(-1)</script>";
				}
			}

			if($_GET['act'] == "edit_smile" AND !isset($_POST['save_smile']))
			{
				$result = mysql_result(mysql_query("SELECT COUNT(1) FROM tbl_smiles WHERE id = '" . $_GET['smile_id'] . "'"),0);

				if(!empty($result))
				{
					$query = mysql_query("SELECT * FROM tbl_smiles WHERE id = '" . $_GET['smile_id'] . "'") or die(mysql_error());

					while($row = mysql_fetch_assoc($query))
					{
?>
<h1>Edit Smile</h1>
<form method="POST" name="form">
<input type="hidden" value="1" name="save_smile">
<input type="hidden" value="<? echo $_GET['smile_id'] ?>" name="id">

<b>Smile Name :</b><br>
<input type="text" name="name" value="<? echo $row['name'] ?>" maxlength="25"><br>

<b>Smile Tag :</b><br>
<input type="text" name="tag" value="<? echo $row['tag'] ?>" size="5" maxlength="10"><br>

<b>Smile File :</b><br>
<select name="file" onChange="showimage()"><?

						$handle = opendir('smiles');

						while(false!==($file = readdir($handle)))
						{
							if($file != "." AND $file != "..")
							{
								if($file == $row['file'])
								{
									$selected = " selected";
								}
								else
								{
									$selected = " ";
								}

								echo "<option value=\"" . $file . "\"" . $selected . ">" . $file . "</option>\n";
							}
						}

						closedir($handle);
?>
    </select><img src="smiles/<? echo $row['file'] ?>" name="icons" hspace="10"><br><br>

<input type="submit" value="Save">
<input type="reset" value="Reset">
<input type="button" value="Cancel" OnClick="history.go(-1)">
</form>
<?
					}
				}
				else
				{
					echo "<script>alert('Smile with this ID doesn\'t excist'); history.go(-1)</script>";
				}
			}

			if($_GET['act'] == "delete_messages")
			{
				$messages = mysql_result(mysql_query("SELECT COUNT(1) FROM tbl_messages"),0);

				if(!empty($messages))
				{
					mysql_query("DELETE FROM tbl_messages") or die("<script>alert('Could not delete messages.')</script>");

					echo "<script>alert('All messages have been deleted.'); document.location.href=('admin.php')</script>";
				}
				else
				{
					echo "<script>alert('No messages found.'); document.location.href=('admin.php')</script>";
				}
			}

			if($_GET['act'] == "repair")
			{
				mysql_query("REPAIR TABLE tbl_config,tbl_messages,tbl_smiles") or die("<script>alert('Tables could not be repaired.')</script>");
				mysql_query("OPTIMIZE TABLE tbl_config") or die("<script>alert('Tables could not be optimized.')</script>");
				mysql_query("OPTIMIZE TABLE tbl_messages") or die("<script>alert('Tables could not be optimized.')</script>");
				mysql_query("OPTIMIZE TABLE tbl_smiles") or die("<script>alert('Tables could not be optimized.')</script>");

				echo "<script>alert('Tables repaired & optimized.'); document.location.href=('admin.php')</script>";
			}

			if($_GET['act'] == "uninstall")
			{
				$result = mysql_result(mysql_query("SELECT COUNT(1) FROM tbl_config"),0);

				if(!empty($result))
				{
					mysql_query("DROP TABLE tbl_config");
					mysql_query("DROP TABLE tbl_messages");
					mysql_query("DROP TABLE tbl_smiles");

					echo "SNP Shoutbox successfully uninstalled, you can now remove all files of SNP Shoutbox.";
					echo "<br>\n<br>\n";
					echo "<script>window.close()</script>";
				}
				else
				{
					echo "<script>alert('SNP Shoutbox has already been uninstalled, delete the directory containing this file to finish the un-installation.'); window.close()</script>";
				}
			}

			if($_GET['act'] == "del_msg" AND isset($_GET['msg_id']))
			{
				$result = mysql_result(mysql_query("SELECT COUNT(1) FROM tbl_messages WHERE id = '" . $_GET['msg_id'] . "'"),0);

				if(empty($result))
				{
					echo "<script>alert('Message with this ID doesn\'t exist, you might have deleted it earlier.'); document.location.href=('shoutbox.inc.php')</script>";
				}
				else
				{
					mysql_query("DELETE FROM tbl_messages WHERE id = '" . $_GET['msg_id'] . "'") or die(mysql_error());

					echo "<h1>Message Deleted</h1>";
					echo "Message successfully deleted !";
					echo "<br>\n<br>\n";
					echo "» <a href=\"shoutbox.inc.php\">My Shoutbox</a>";
					echo "<br>\n";
					echo "» <a href=\"admin.php\">Admin Index</a>";
				}
			}

			if($_GET['act'] == "ip_msg" AND isset($_GET['msg_id']))
			{
				$result = mysql_result(mysql_query("SELECT COUNT(1) FROM tbl_messages WHERE id = '" . $_GET['msg_id'] . "'"),0);

				if(empty($result))
				{
					echo "<script>alert('Message with this ID doesn\'t exist.'); document.location.href=('shoutbox.inc.php')</script>";
				}
				else
				{
					$query = mysql_query("SELECT * FROM tbl_messages WHERE id = '" . $_GET['msg_id'] . "'") or die(mysql_error());

					while($row = mysql_fetch_assoc($query))
					{
						echo "<h1>Check IP</h1>";
						echo "IP Address for this message is : <b>" . $row['ip'] . "</b>";
						echo "<br>\n<br>\n";
						echo "» <a href=\"shoutbox.inc.php\">My Shoutbox</a>";
						echo "<br>\n";
						echo "» <a href=\"admin.php\">Admin Index</a>";
					}
				}
			}

			if($_GET['act'] == "edit_msg" AND isset($_GET['msg_id']) AND !isset($_POST['save_msg']))
			{
				$result = mysql_result(mysql_query("SELECT COUNT(1) FROM tbl_messages WHERE id = '" . $_GET['msg_id'] . "'"),0);

				if(empty($result))
				{
					echo "<script>alert('Message with this ID doesn\'t exist.'); document.location.href=('shoutbox.inc.php')</script>";
				}
				else
				{
					$query = mysql_query("SELECT * FROM tbl_messages WHERE id = '" . $_GET['msg_id'] . "'") or die(mysql_error());

					while($row = mysql_fetch_assoc($query))
					{
?>
<form method="POST" target="shouts" name="form">
<input type="hidden" value="1" name="save_msg">
<input type="hidden" value="<? echo $_GET['msg_id'] ?>" name="msg_id">
<b>Name : </b><br>
<input type="text" name="name" maxlength="35" value="<? echo htmlspecialchars($row['name']) ?>"><br><br>

<b>Email / URL : </b><br>
<input type="text" name="urlemail" maxlength="125" value="<? echo htmlspecialchars($row['email']) . htmlspecialchars($row['homepage']) ?>"><br><br>

<b>Message : </b><br>
<input type="text" name="message" maxlength="150" value="<? echo htmlspecialchars($row['message']) ?>"><br><br>

<input type="submit" value="Save">
<input type="reset" value="Reset">
<input type="button" value="Cancel" OnClick="document.location.href=('shoutbox.inc.php')">
<br><br>
<?
						$query = mysql_query("SELECT * FROM tbl_smiles ORDER BY id ASC") or die(mysql_error());

						while($row = mysql_fetch_assoc($query))
						{
							echo "<a href=\"javascript:smile(' " . addslashes($row['tag']) . " ');\"><img src=\"smiles/" . $row['file'] . "\"></a> ";
						}

						echo "</form>";
					}
				}
			}

			if($_GET['act'] == "logoff")
			{
				unset($_SESSION['admin_login']);
				header("Location: shoutbox.inc.php");
			}
		}

		if(isset($_POST['save_config']))
		{
			mysql_query("UPDATE tbl_config SET name = '" . $_POST['name'] . "', antiflood = '" . $_POST['antiflood'] . "', date_format = '" . $_POST['date_format'] . "', max_msg = '" . $_POST['max_msg'] . "', smiles = '" . $_POST['smiles'] . "', height = '" . $_POST['height'] . "', width = '" . $_POST['width'] . "', admin_user = '" . $_POST['admin_user'] . "', admin_pass = '" . $_POST['admin_pass'] . "'") or die(mysql_error());

			echo "<h1>Config Saved</h1>";
			echo "Config successfully saved !";
			echo "<br>\n<br>\n";
			echo "» <a href=\"admin.php\">Admin Index</a>";
		}

		if(isset($_POST['save_smile']))
		{
			mysql_query("UPDATE tbl_smiles SET name = '" . $_POST['name'] . "', tag = '" . $_POST['tag'] . "', file = '" . $_POST['file'] . "' WHERE id = '" . $_POST['id'] . "'") or die(mysql_error());

			echo "<h1>Smile Updated</h1>";
			echo "Smile successfully updated !";
			echo "<br>\n<br>\n";
			echo "» <a href=\"admin.php?act=smiles\">Smiles</a>";
			echo "<br>\n";
			echo "» <a href=\"admin.php\">Admin Index</a>";
		}

		if(isset($_POST['add_smile']))
		{
			$result = mysql_result(mysql_query("SELECT COUNT(1) FROM tbl_smiles WHERE file = '" . $_POST['file'] . "'"),0);

			if(empty($result))
			{
				mysql_query("INSERT INTO tbl_smiles VALUES ('','" . $_POST['name'] . "', '" . $_POST['tag'] . "', '" . $_POST['file'] . "')") or die(mysql_error());

				echo "<h1>Smile Added</h1>";
				echo "Smiles successfully added !";
				echo "<br>\n<br>\n";
				echo "» <a href=\"admin.php\">Admin Index</a>";
			}
			else
			{
				echo "<script>alert('Smile already excists'); history.go(-1)</script>";
			}
		}

		if(isset($_POST['save_msg']))
		{
			if(preg_match("/^([a-z0-9_\-]+\.)*?[a-z0-9_\-]+@([a-z0-9\-_]{2,})\.[a-z0-9\-_]*(\.[a-z0-9\-_]{2,})*$/i",$_POST['urlemail']))
			{
				mysql_query("UPDATE tbl_messages SET name = '" . $_POST['name'] . "', email = '" . $_POST['urlemail'] . "', message = '" . $_POST['message'] . "' WHERE id = '" . $_POST['msg_id'] . "'") or die(mysql_error());
			}
			else
			{
				mysql_query("UPDATE tbl_messages SET name = '" . $_POST['name'] . "', homepage = '" . $_POST['urlemail'] . "', message = '" . $_POST['message'] . "' WHERE id = '" . $_POST['msg_id'] . "'") or die(mysql_error());
			}

			echo "<h1>Message Saved</h1>";
			echo "Message successfully saved !";
			echo "<br>\n<br>\n";
			echo "» <a href=\"shoutbox.inc.php\">My Shoutbox</a>";
			echo "<br>\n";
			echo "» <a href=\"admin.php\">Admin Index</a>";
		}
	}
}

ob_end_flush();
?>


</body>
</html>
-----------------------------------------------









CONFIG.PHP
-----------------------------------------------
<?
############################################
#  Filename   : CONFIG.PHP                 #
#------------------------------------------#
#  Written By : Dennis van den Hout        #
#  Email      : [email protected]     #
#  Website    : www.scripters.nl           #
#  Questions? : www.scripters.nl/forum     #
#------------------------------------------#
#   Editing source is allowed, unless you  #
#         give it to other users           #
#------------------------------------------#
############################################

## ---------------------- ##
##                        ##
##       Edit Below       ##
##                        ##
## ---------------------- ##

// If you don't know this, contact your host!
$hostname = "localhost";
$username = "user";
$password = "pass";
$database = "shoutbox";

## ---------------------- ##
##                        ##
##    Don't Edit Below    ##
##                        ##
## ---------------------- ##

mysql_connect($hostname,$username,$password) or die(mysql_error());
mysql_select_db($database);

$select_config = @mysql_query("SELECT * FROM tbl_config");

while($config = @mysql_fetch_assoc($select_config))
{
	$cfg['name'] = $config['name'];
	$cfg['antiflood'] = $config['antiflood'];
	$cfg['date_format'] = $config['date_format'];
	$cfg['max_msg'] = $config['max_msg'];
	$cfg['smiles'] = $config['smiles'];
	$cfg['width'] = $config['width'];
	$cfg['height'] = $config['height'];
	$cfg['admin_user'] = $config['admin_user'];
	$cfg['admin_pass'] = $config['admin_pass'];
	$cfg['admin_prefix'] = $config['admin_prefix'];
}
?>
-----------------------------------------------









JAVASCRIPT.JS
-----------------------------------------------
function delete_messages()
{
	if(confirm("Are you sure you want to delete all messages ?"))
	{
		document.location.href = 'admin.php?act=delete_messages';
	}
}

function uninstall()
{
	if(confirm("Are you sure you want to uninstall SNP Shoutbox ?"))
	{
		document.location.href = 'admin.php?act=uninstall';
	}
}

function smile(tag)
{
	document.form.message.value += ""+tag;
	document.form.message.focus();
}

function smile2(tag)
{
	window.opener.form.message.value += ""+tag;
	document.form.message.focus();
}

function info(url, name)
{
	window.open(url, name, 'scrollbars = 1, resizable = no, width = 250, height = 350, status = 0, menubar = 0');
}

function showimage()
{
	if(!document.images)return;
	document.images.icons.src="smiles/"+document.form.file.options[document.form.file.selectedIndex].value;
}

function del_smile(value)
{
	if(confirm("Are you sure you want to delete this smile ?"))
	{
		document.location.href = 'admin.php?act=del_smile&smile_id=' +value;
	}
}

function del_msg(value)
{
	if(confirm("Are you sure you want to delete this message ?"))
	{
		document.location.href = 'admin.php?act=del_msg&msg_id=' + value;
	}
}
-----------------------------------------------









SHOUT.PHP
-----------------------------------------------
<?
############################################
#  Filename   : SHOUT.PHP                  #
#------------------------------------------#
#  Written By : Dennis van den Hout        #
#  Email      : [email protected]     #
#  Website    : www.scripters.nl           #
#  Questions? : www.scripters.nl/forum     #
#------------------------------------------#
#   Editing source is allowed, unless you  #
#         give it to other users           #
#------------------------------------------#
############################################

error_reporting(E_ALL);
include("config.php");
ob_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" content="text/css" href="style.css">
</head>

<body>
<?
if(file_exists("install.php"))
{
	echo "<h1>Error !</h1>";
	echo "Your tagboard isn't installed yet, please run the install file !";
	echo "<br>\n<br>\n";
	echo "» <a href=\"install.php\">Install Shoutbox</a>";
}
else
{
	if(isset($_COOKIE['anti_flood']))
	{
		echo "<h1>Error !</h1>";
		echo "Antiflood is still active, you have to wait <b>" . $cfg['antiflood'] ."</b> seconds before posting another message.";
		echo "<br>\n<br>\n";
		echo "» <a href=\"shoutbox.inc.php\">Go back</a>";
		echo "<br>\n";
		echo "» <a href=\"javascript:document.location.reload()\">Refresh Page</a>";
	}
	else
	{
		if(!empty($_POST['name']) AND !empty($_POST['message']) AND !empty($_POST['urlemail']))
		{
			setcookie("anti_flood",1,time()+$cfg['antiflood']);

			if(preg_match("/^([a-z0-9_\-]+\.)*?[a-z0-9_\-]+@([a-z0-9\-_]{2,})\.[a-z0-9\-_]*(\.[a-z0-9\-_]{2,})*$/i",$_POST['urlemail']))
			{
				mysql_query("INSERT INTO tbl_messages VALUES ('','" . $_POST['name'] . "',NULL,'" . $_POST['urlemail'] . "','" . $_POST['message'] . "',NOW(),'" . $_SERVER['REMOTE_ADDR'] . "')") or die(mysql_error());
			}
			else
			{
				mysql_query("INSERT INTO tbl_messages VALUES ('','" . $_POST['name'] . "','" . $_POST['urlemail'] . "',NULL,'" . $_POST['message'] . "',NOW(),'" . $_SERVER['REMOTE_ADDR'] . "')") or die(mysql_error());
			}

			echo "<h1>Posted !</h1>";
			echo "Thanks for your message !";
			echo "<br>\n<br>\n";
			echo "» <a href=\"shoutbox.inc.php\">Go back</a>";
		}
		else
		{
			echo "<h1>Error !</h1>";
			echo "Please fill in all forms";
			echo "<br>\n<br>\n";
			echo "» <a href=\"shoutbox.inc.php\">Go back</a>";
		}
	}
}
?>


</body>
</html>
-----------------------------------------------









SHOUTBOX.PHP
-----------------------------------------------
<?
############################################
#  Filename   : SHOUTBOX.PHP               #
#------------------------------------------#
#  Written By : Dennis van den Hout        #
#  Email      : [email protected]     #
#  Website    : www.scripters.nl           #
#  Questions? : www.scripters.nl/forum     #
#------------------------------------------#
#   Editing source is allowed, unless you  #
#         give it to other users           #
#------------------------------------------#
############################################

error_reporting(E_ALL);
include("config.php");
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><? echo htmlspecialchars($cfg['name']); ?></title>
<link rel="stylesheet" content="text/css" href="style.css">
<script src="javascript.js"></script>
</head>

<body>
<?
if(file_exists("install.php"))
{
	echo "<h1>Error !</h1>";
	echo "Your tagboard isn't installed yet, please run the install file !";
	echo "<br>\n<br>\n";
	echo "» <a href=\"install.php\">Install Shoutbox</a>";
}
else
{
	if(!isset($_GET['act']))
	{
?>
<table cellpadding="2" cellspacing="0" width="<? echo $cfg['width'] ?>" height="<? echo $cfg['height'] ?>" align="center" class="content">
  <tr class="title">
    <td width="100%" align="center" class="title"><a href="shoutbox.inc.php" target="shouts"><? echo htmlspecialchars($cfg['name']); ?></a></td>
  </tr>
  <tr>
    <td width="100%" height="<? echo $cfg['height'] ?>" align="center">
    <iframe frameborder="0" name="shouts" src="shoutbox.inc.php" style="width: 95%; height: 100%"></iframe></td>
  </tr>
  <tr>
    <td width="100%">
    <form method="POST" action="shout.php" target="shouts" name="form">
    <table border="0" cellpadding="2" cellspacing="0" align="center">
      <tr>
        <td width="35%"><b>Name : </b></td>
        <td width="65%"><input type="text" name="name" maxlength="35"></td>
      </tr>
      <tr>
        <td width="35%"><b>Email / URL : </b></td>
        <td width="65%"><input type="text" name="urlemail" maxlength="125"></td>
      </tr>
      <tr>
        <td width="35%"><b>Message : </b></td>
        <td width="65%"><input type="text" name="message" maxlength="150"></td>
      </tr>
      <tr>
        <td colspan="2" align="center"><input type="submit" style="font-weight: bold" value="S h o u t !"></td>
      </tr>
      <tr>
        <td colspan="2" align="center"><br>
<?
		$query = mysql_query("SELECT * FROM tbl_smiles ORDER BY RAND() LIMIT 0,10") or die(mysql_error());

		while($row = mysql_fetch_assoc($query))
		{
			echo "<a href=\"javascript:smile('" . addslashes($row['tag']) . "')\"><img src=\"smiles/" . $row['file'] . "\"></a> ";
		}

		echo "<br>\n";
		echo "<a href=\"javascript:info('shoutbox.php?act=smiles')\">All Smiles</a> - ";
		echo "<a href=\"shoutbox.inc.php?act=all_shouts\" target=\"shouts\">All Shouts</a> - ";
		echo "<a href=\"javascript:shouts.location.reload()\">Refresh</a> - ";
		echo "<a href=\"admin.php\" target=\"shouts\">Admin</a>";
?></td>
      </tr>
      </form>
    </table>
    </td>
  </tr>
</table>
<?
		echo "<br>\n";
		echo "<center>" .$cfg['admin_prefix'] . "</center>";
	}
	else
	{
		if($_GET['act'] == "smiles")
		{
?>
<h1>Smile Info</h1>
Here are all smiles the administrator of this shoutbox has installed, click them to add them in your text box<hr>

<center>
<?
		$query = mysql_query("SELECT * FROM tbl_smiles ORDER BY id ASC") or die(mysql_error());

		while($row = mysql_fetch_assoc($query))
		{
			echo "<a href=\"javascript:smile2(' " . addslashes($row['tag']) . " ');\"><img src=\"smiles/" . $row['file'] . "\"></a> ";
		}

		echo "<hr>";
		echo "<a href=\"javascript:window.close()\">Close Window</a></center>";

		}
	}
}
?>


</body>
</html>
-----------------------------------------------









SHOUTBOX.INC.PHP
-----------------------------------------------
<?
############################################
#  Filename   : SHOUTBOX.INC.PHP           #
#------------------------------------------#
#  Written By : Dennis van den Hout        #
#  Email      : [email protected]     #
#  Website    : www.scripters.nl           #
#  Questions? : www.scripters.nl/forum     #
#------------------------------------------#
#   Editing source is allowed, unless you  #
#         give it to other users           #
#------------------------------------------#
############################################

session_start();
error_reporting(E_ALL);
include("config.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" content="text/css" href="style.css">
<script src="javascript.js"></script>
</head>

<body topmargin="10">
<?
if(file_exists("install.php"))
{
	echo "<h1>Error !</h1>";
	echo "Your tagboard isn't installed yet, please run the install file !";
	echo "<br>\n<br>\n";
	echo "» <a href=\"install.php\">Install Shoutbox</a>";
}
else
{
	if(isset($_GET['act']))
	{
		if($_GET['act'] == "all_shouts")
		{
			$query = mysql_query("SELECT *,UNIX_TIMESTAMP(time) AS time FROM tbl_messages ORDER BY id DESC") or die(mysql_error());
			$result = mysql_result(mysql_query("SELECT COUNT(1) FROM tbl_messages"),0);
		}
	}
	else
	{
		$query = mysql_query("SELECT *,UNIX_TIMESTAMP(time) AS time FROM tbl_messages ORDER BY id DESC LIMIT 0," . $cfg['max_msg'] . "") or die(mysql_error());
		$result = mysql_result(mysql_query("SELECT COUNT(1) FROM tbl_messages LIMIT 0," . $cfg['max_msg'] . ""),0);
	}

	if(!empty($result))
	{
		while($row = mysql_fetch_assoc($query))
		{
?>
<table title="Posted : <? echo date("$cfg[date_format]",$row['time']); ?>" style="border-collapse: collapse" cellpadding="2" cellspacing="0" width="100%" class="content">
  <tr>
    <td width="25%"><b>Name :</b></td>
    <td width="75%">
<?
			if(!empty($row['homepage']))
			{
				$split_url = substr($row['homepage'],0,7);

				if($split_url != "http://")
				{
					$url = "http://" . $row['homepage'];
				}
				else
				{
					$url = $row['homepage'];
				}

				echo "<a href=\"" . htmlspecialchars($url) . "\" target=\"_blank\">" . htmlspecialchars($row['name']) . "</a>";
			}
			else
			{
				echo "<a href=\"mailto:" . htmlspecialchars($row['email']) . "\">" . htmlspecialchars($row['name']) . "</a>";
			}
?>
    </td>
  </tr>
  <tr>
    <td colspan="2"><b>Message :</b></td>
  </tr>
  <tr>
    <td colspan="2">
<?
			$row['message'] = htmlspecialchars($row['message']);

			if(!empty($cfg['smiles']))
			{
				$smile_select = mysql_query("SELECT * FROM tbl_smiles ORDER BY id ASC") or die(mysql_error());

				while($smile = mysql_fetch_assoc($smile_select))
				{
					$smile['tag'] = str_replace(">","&gt;", $smile['tag']);
					$smile['tag'] = str_replace("<","&lt;", $smile['tag']);

					$row['message'] = str_replace("$smile[tag]","<img src=\"smiles/" . $smile['file'] . "\">", $row['message']);
				}
			}

			echo $row['message'];
?>
    </td>
  </tr>
</table>
<?
			if(isset($_SESSION['admin_login']))
			{
				echo "<center>";
				echo "<a class=\"admin_link\" href=\"admin.php?act=edit_msg&msg_id=" . $row['id'] . "\">Edit</a> - ";
				echo "<a class=\"admin_link\" href=\"javascript:del_msg('" . $row['id'] . "')\">Delete</a> - ";
				echo "<a class=\"admin_link\" href=\"admin.php?act=ip_msg&msg_id=" . $row['id'] . "\">IP</a>";
				echo "</center>";
			}
			else
			{
				echo "&nbsp;";
			}
		}
	}
	else
	{
?>
<table style="border-collapse: collapse" cellpadding="2" cellspacing="5" width="100%" class="content">
  <tr>
    <td colspan="2"><b class="admin_link"><center>No shouts yet!</center></b></td>
  </tr>
</table>
<?
	}
}
?>


</body>
</html>
-----------------------------------------------









STYLE.CSS
-----------------------------------------------
body
{
	font-family: Arial;
	font-size: 8pt;
	color: #808080;
	background-color: #EEEEGF;

	scrollbar-face-color: #DEDFDE;
	scrollbar-highlight-color: #C0C0C0;
	scrollbar-3dlight-color: #808080;
	scrollbar-darkshadow-color: #C0C0C0;
	scrollbar-shadow-color: #000000;
	scrollbar-arrow-color: #808080;
	scrollbar-track-color: #EEEEEE;
}

table
{
	font-family: Arial;
	font-size: 8pt;
	color: #808080;
	background-color: #DEDFDE;
}

input, textarea, select
{
	border: 1px dashed #808080;
	font-family: Arial;
	font-size: 8pt;
	background-color: #EEEEEE;
}

input
{
	text-indent: 2px;
}

a
{
	text-decoration: none;
	color: #808080;
}

a:hover
{
	color: #000000;
}

hr
{
	border: dashed;
	color: #808080;
	height: 1 px;
}

.title
{
	color: #808080;
	font-weight: bold;
	font-size: 16pt;
}

.content
{
	border: 1px solid #000000;
	background: #DEDFDE;
}

img
{
	border: 0;
}

iframe
{
	border: 1px solid #808080;
}

.admin_link
{
	font-weight: bold;
	color: #FF0000;
}
-----------------------------------------------









INSTALL.PHP
-----------------------------------------------
<?
############################################
#  Filename   : INSTALL.PHP                #
#------------------------------------------#
#  Written By : Dennis van den Hout        #
#  Email      : [email protected]     #
#  Website    : www.scripters.nl           #
#  Questions? : www.scripters.nl/forum     #
#------------------------------------------#
#   Editing source is allowed, unless you  #
#         give it to other users           #
#------------------------------------------#
############################################

error_reporting(E_ALL);
include("config.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>SNP Shoutbox Installation</title>
<link rel="stylesheet" content="text/css" href="style.css">
</head>

<body>
<?
echo "<h1>SNP Shoutbox Installation !</h1>";

if(!isset($_GET['install']))
{
	echo "You are about to install your shoutbox, but first you have to fill in some information to install
	your shoutbox correct.";
	echo "<br>\n<br>\n";
	echo "<b>Make sure you edited your config right !</b>";
	echo "<br>\n<br>\n";
	echo "» <a href=\"install.php?install\">Install Shoutbox</a>";
	echo "<br>\n";
	echo "» <a href=\"javascript:window.close()\">Cancel Installation</a>";
}
else
{
	if(isset($_GET['install']) AND !isset($_POST['install']))
	{
?>

<form method="POST">
<input type="hidden" value="1" name="install">
<b>Shoutbox Title : </b><br>
<input type="text" name="name"><br><br>

<b>Antiflood time : </b><br>
<input type="text" name="antiflood" size="3"> sec<br><br>

<b>Date Format : </b><br>
<input type="text" name="date_format" size="10"> 
<a href="http://www.php.net/date" target="_blank">More Info</a><br><br>

<b>Amount of messages to display : </b><br>
<input type="text" name="max_msg" size="3"><br><br>

<b>Enable Smiles : </b><br>
<select name="smiles">
<option value="1">Yes</option>
<option value="0">No</option>
</select><br><br>

<b>Height of shoutbox : </b><br>
<input type="text" name="height" size="3"><br><br>

<b>Width of shoutbox : </b><br>
<input type="text" name="width" size="3"><br><br>

<b>Admin Username : </b><br>
<input type="text" name="admin_user" size="7"><br><br>

<b>Admin Password : </b><br>
<input type="password" name="admin_pass" size="7"> ( Change if needed )<br><br>

<input type="submit" value="Install">
<input type="reset" value="Reset">
</form>
<?
	}
}

if(isset($_POST['install']))
{
	if(isset($_POST['name']) AND isset($_POST['antiflood']) AND isset($_POST['date_format']) AND isset($_POST['max_msg']) AND isset($_POST['width']) AND isset($_POST['height']) AND isset($_POST['width']) AND isset($_POST['admin_user']) AND isset($_POST['admin_pass']))
	{
		mysql_query("CREATE TABLE tbl_config (
		  name char(50) default '0',
		  antiflood int(5) default '0',
		  date_format char(15) default '0',
		  max_msg int(5) unsigned default '0',
		  smiles int(1) unsigned default '0',
		  width int(3) unsigned default '0',
		  height int(3) unsigned default '0',
		  admin_user char(15) default '0',
		  admin_pass char(15) default '0',
		  admin_prefix char(125) default '0'
		)") or die(mysql_error());

		mysql_query("INSERT INTO tbl_config VALUES('" . $_POST['name'] . "', '" . $_POST['antiflood'] . "', '" . $_POST['date_format'] . "', '" . $_POST['max_msg'] . "', '" . $_POST['smiles'] . "', '" . $_POST['width'] . "', '" . $_POST['height'] . "', '" . $_POST['admin_user'] . "', '" . $_POST['admin_pass'] . "', 'Powered by : <b><a href=\"http://www.scripters.nl/snp_shoutbox/\" target=\"_blank\">SNP Shoutbox v1.0</a></b>')") or die(mysql_error());

		mysql_query("CREATE TABLE tbl_messages (
		  id int(10) unsigned NOT NULL auto_increment,
		  name char(35) default '0',
		  homepage char(125) default '0',
		  email char(125) default '0',
		  message char(150) default '0',
		  time datetime default '0000-00-00 00:00:00',
		  ip char(20) default '0',
		  PRIMARY KEY (id)
		)") or die(mysql_error());

		mysql_query("CREATE TABLE tbl_smiles (
		  id int(10) unsigned NOT NULL auto_increment,
		  name char(50) default '0',
		  tag char(6) default '0',
		  file char(50) default '0',
		  PRIMARY KEY (id)
		)") or die(mysql_error());

		mysql_query("INSERT INTO tbl_smiles VALUES('1', 'Amazed', ':O', 'amazed.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('2', 'Amuse', '^_^', 'amuse.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('3', 'Big Smile', ':D', 'bigsmile.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('4', 'Blink', 'o_O', 'blink.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('5', 'Cheesy', ':P', 'cheesy.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('6', 'Confused', ':S', 'confused.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('7', 'Cool', '8)', 'cool.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('8', 'Cry', ':\'(', 'cry.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('9', 'Evil', '>8(', 'evil.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('10', 'Laugh', '=D', 'laugh.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('11', 'Mad', ':@', 'mad.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('12', 'No Trust', '=/', 'notrust.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('13', 'No Worry', 'v_v', 'noworry.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('14', 'Nuts', '8D', 'nuts.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('15', 'Oh', '\'_\'', 'oh.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('16', 'Push', '>_<', 'push.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('17', 'Rolleyes', ':roll:', 'rolleyes.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('18', 'Sad', ':(', 'sad.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('19', 'Shy', ':$', 'shy.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('20', 'Sick', ':x', 'sick.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('21', 'Smile', ':)', 'smile.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('22', 'Suspicious', '¬_¬', 'suspicious.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('23', 'Unsure', 'ó_ò', 'unsure.gif')") or die(mysql_error());
		mysql_query("INSERT INTO tbl_smiles VALUES('25', 'Wink', ';)', 'wink.gif')") or die(mysql_error());

		echo "Shoutbox has been installed successfully, have fun with your shoutbox!";
		echo "<br>\n<br>\n";
		echo "<b>Delete INSTALL.PHP from your shoutbox root to prevent the error-message !</b>";
		echo "<br>\n<br>\n";
		echo "» <a href=\"shoutbox.php\">My Shoutbox</a>";
	}
	else
	{
		echo "Please fill in ALL fields";
		echo "<br>\n<br>\n";
		echo "<a href=\"javascript:history.go(-1)\">» Go back</a>";
	}
}
?>


</body>
</html>

Reacties

0
Nog geen reacties.