Hi,
Can someone check over this quickly for security please? I needs to be as secure as possible as the site it's going on has around 7,000 uniques a day.
Config.php
Show_News.php
This is the part that will be on the front page:
Show_Story.php
This is the pop up page:
Items can only be posted by administrators, it will be protected with htaccess so no worries there.
Any help is appreciated.
Thanks
Craig.
Can someone check over this quickly for security please? I needs to be as secure as possible as the site it's going on has around 7,000 uniques a day.
Config.php
Code:
<?php
function add_magic_quotes($array) {
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = add_magic_quotes($v);
} else {
$array[$k] = addslashes($v);
}
}
return $array;
}
if (!get_magic_quotes_gpc()) {
$_GET = add_magic_quotes($_GET);
$_POST = add_magic_quotes($_POST);
$_COOKIE = add_magic_quotes($_COOKIE);
}
$host = "localhost";
$dbuser = "****_****";
$dbpass = "******";
$dbname = "****_********";
mysql_connect("$host","$dbuser","$dbpass");
mysql_select_db($dbname);
?>
Show_News.php
This is the part that will be on the front page:
Code:
<?PHP
include "config.php";
$sql = "SELECT ID, Title, ShortNews, Date FROM News";
$result = mysql_query($sql);
while ($field = mysql_fetch_array($result)) {
$ID = $field["ID"];
$Title = $field["Title"];
$ShortNews = $field["ShortNews"];
$Date = $field["Date"];
?>
<script language="JavaScript">
function POPUP_NEWS() {
window.open('show_story.php?id=<?PHP echo $ID; ?> ','EANITHING','toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=no,copyhistory=no,scrollbars=no,width=500,height=300');
}
</script>
<?PHP
echo "
<a href=\"javascript:POPUP_NEWS()\" onmouseover=\"window.status='Show news'; return true\">$Title</a> - $Date
<hr>
$ShortNews
";
}
?>
Show_Story.php
This is the pop up page:
Code:
<?PHP
error_reporting(0);
include "config.php";
$ID = $_GET['id'];
if($ID == "")
{
echo "Item ID incorrect";
}
else
{
$sql = "SELECT Title, LongNews, Date FROM News WHERE ID = $ID";
$result = mysql_query($sql);
while ($field = mysql_fetch_array($result)) {
$Title = $field["Title"];
$LongNews = $field["LongNews"];
$Date = $field["Date"];
echo "
$Title - $Date
<hr>
$LongNews
";
}
}
if (mysql_affected_rows() < 1)
{
echo "Incorrect item ID";
}
?>
<title><? echo $Title; ?></title>
Items can only be posted by administrators, it will be protected with htaccess so no worries there.
Any help is appreciated.
Thanks
Craig.
Last edited: