Nullified
01-08-2005, 03:24 AM
My php version: 4.3.10
My script:
if ($_POST['do'] == 'add_banner')
{
if ($_POST['site_link'] == '')
{
$error_link = "color: #FF0000";
}
if ($_POST['alt_text'] == '')
{
$error_text = "color: #FF0000";
}
if ($_FILES['banner']['tmp_name'] == '')
{
$error_file = "color: #FF0000";
}
else
{
$dimensions = getimagesize($_FILES['banner']['tmp_name']);
if ($_FILES['banner']['type'] !== 'image/gif')
{
$error_type = "<div><font color=\"#FF0000\">Image must be in gif format.</font></div>";
}
if ($_FILES['banner']['size'] > '20480')
{
$error_size = "<div><font color=\"#FF0000\">Image can't be more then 20KB in size.</font></div>";
}
if ($dimensions[0] !== '468' OR $dimensions[1] !== '60')
{
$error_dimensions = "<div><font color=\"#FF0000\">Image dimensions must be 468x60 pixels.</font></div>";
}
}
if (isset($error_type) OR ($error_size) OR ($error_dimensions) OR ($error_link) OR ($error_text) OR ($error_file))
{
$site_link = $_POST['site_link'];
$alt_text = $_POST['alt_text'];
$navbits[''] = $vbphrase['add_banner'];
$templatename = 'banners_add';
}
else
{
$ext = '.gif';
$uploaddir = '/home/whd/public_html/images/banners/';
$uploadfile = $uploaddir.$bbuserinfo['userid'].$ext;
move_uploaded_file($_FILES['banner']['tmp_name'],$uploadfile);
}
}
The code works fine except for the following portion:
if ($dimensions[0] !== '468' OR $dimensions[1] !== '60')
{
$error_dimensions = "<div><font color=\"#FF0000\">Image dimensions must be 468x60 pixels.</font></div>";
}
I have tried several different variations of this code and have even taken out the exclamation marks and tried validating the width and height independantly and nothing will work. I have tried several differently sized gifs under 20k in size and none will upload unless I take out this snippet of code. I have changed the quotation marks to apostrophes and other script variations. I have tried calling (in the main script) $dimensions = getimagesize($file); and defining $file = $_FILES['banner']['tmp_name'];. But of course that didn't work. In my site I have added the code:
$dimensions, $dimensions[0], $dimensions[1]
And of course it correctly displays: Array, 468, 60. Or whichever dimensions apply to the current image. I, also know my code isn't top notch quality, so feel free to improve on any other imperfections if you want.
My script:
if ($_POST['do'] == 'add_banner')
{
if ($_POST['site_link'] == '')
{
$error_link = "color: #FF0000";
}
if ($_POST['alt_text'] == '')
{
$error_text = "color: #FF0000";
}
if ($_FILES['banner']['tmp_name'] == '')
{
$error_file = "color: #FF0000";
}
else
{
$dimensions = getimagesize($_FILES['banner']['tmp_name']);
if ($_FILES['banner']['type'] !== 'image/gif')
{
$error_type = "<div><font color=\"#FF0000\">Image must be in gif format.</font></div>";
}
if ($_FILES['banner']['size'] > '20480')
{
$error_size = "<div><font color=\"#FF0000\">Image can't be more then 20KB in size.</font></div>";
}
if ($dimensions[0] !== '468' OR $dimensions[1] !== '60')
{
$error_dimensions = "<div><font color=\"#FF0000\">Image dimensions must be 468x60 pixels.</font></div>";
}
}
if (isset($error_type) OR ($error_size) OR ($error_dimensions) OR ($error_link) OR ($error_text) OR ($error_file))
{
$site_link = $_POST['site_link'];
$alt_text = $_POST['alt_text'];
$navbits[''] = $vbphrase['add_banner'];
$templatename = 'banners_add';
}
else
{
$ext = '.gif';
$uploaddir = '/home/whd/public_html/images/banners/';
$uploadfile = $uploaddir.$bbuserinfo['userid'].$ext;
move_uploaded_file($_FILES['banner']['tmp_name'],$uploadfile);
}
}
The code works fine except for the following portion:
if ($dimensions[0] !== '468' OR $dimensions[1] !== '60')
{
$error_dimensions = "<div><font color=\"#FF0000\">Image dimensions must be 468x60 pixels.</font></div>";
}
I have tried several different variations of this code and have even taken out the exclamation marks and tried validating the width and height independantly and nothing will work. I have tried several differently sized gifs under 20k in size and none will upload unless I take out this snippet of code. I have changed the quotation marks to apostrophes and other script variations. I have tried calling (in the main script) $dimensions = getimagesize($file); and defining $file = $_FILES['banner']['tmp_name'];. But of course that didn't work. In my site I have added the code:
$dimensions, $dimensions[0], $dimensions[1]
And of course it correctly displays: Array, 468, 60. Or whichever dimensions apply to the current image. I, also know my code isn't top notch quality, so feel free to improve on any other imperfections if you want.
