COLOR="Blue"]And for some reason it also calls add.php[/COLOR], though this files is used to add banners in the admin area so I have no idea why it's calling it? But have included anyway:
<?php
include("connect.php");
function is_valid_date($date) {
list($month,$day,$year) = explode("/",$date);
if($month > 12 || $month < 01 || strlen($month) != 2 || !is_numeric($month)) {return false;}
if($day > 31 || $day < 1|| strlen($day) != 2 || !is_numeric($day)) {return false;}
if(strlen($year) != 4 || !is_numeric($year)) {return false;}
return true;
}
if($_POST['submitid'] == 1) {
//Form validation
if(strlen($_POST['name']) < 3){$message = 'Please enter a name for the banner';}
if($_POST['locationtype'] == 'http' && strlen($_POST['httploc']) < 3 && $message == NULL){$message = 'Please enter location URL';}
if($_POST['locationtype'] == 'upload' && $_FILES['filename']['name'] == NULL && $message == NULL){$message = 'Please enter a filename';}
if(strlen($_POST['urlto']) < 3 && $message == NULL){$message = 'Please enter a URL location';}
if($_POST['stopit'] == 'hits' && !is_numeric($_POST['hits']) && $message == NULL){ $message = 'Invalid Hit amount to stop on';}
if($_POST['stopit'] == 'views' && !is_numeric($_POST['views']) && $message == NULL){ $message = 'Invalid Views amount to stop on';}
if($_POST['stopit'] == 'date' && is_valid_date($_POST['id1']) == false && $message == NULL){ $message = 'Invalid date to stop on';}
if($_POST['size'] == 'change' && !is_numeric($_POST['width']) && !is_numeric($_POST['height']) && $message == NULL){$message = 'Invalid width/height';}
if($message == NULL) {
$name = $_POST['name'];
$mouse_over = $_POST['mouseover'];
$urlto = $_POST['urlto'];
if($_POST['locationtype'] == 'upload') {
$filename = $_FILES['filename']['name'];
$currentdir = "images";
$expload = explode(".",$filename);
$ext = $expload[1];
if(is_file('images/' . $_FILES['filename']['name'])) {
$filename = substr (md5(uniqid(rand(),1)), 3, 5) . '.' . $ext;
}
move_uploaded_file($_FILES['filename']['tmp_name'],$currentdir.'/'. $filename);
$location = adpath.'images/' . $filename;
}
else {
$location = $_POST['httploc'];
}
if($_POST['stopit'] == 'ignore') {
$stopit = 'OFF';
}
if($_POST['stopit'] == 'hits') {
$stopit = 'H,' . $_POST['hits'];
}
if($_POST['stopit'] == 'views') {
$stopit = 'V,' . $_POST['views'];
}
if($_POST['stopit'] == 'date') {
$stopit = 'D,' . $_POST['id1'];
}
if($_POST['size'] == 'leave') {
$size = 'NORMAL';
}
if($_POST['openin'] == 'new'){
$openin = '_blank';
}
else {
$openin = '_parent';
}
$insert_banner = @mysql_query("INSERT INTO banners (`name`,`mouseover`,`location`,`urlto`,`stopit`,`openin`) VALUES ('$name','$mouse_over','$location','$urlto','$stopit','$openin')");
if($insert_banner) {
$made = date('m') . '/' . date('d') . '/' . date('Y');
if($size == 'NORMAL') {
$width = 'NA';
$height = 'NA';
}
else {
$width = $_POST['width'];
$height = $_POST['height'];
}
$hits = 0;
$uni_hits = 0;
$views = 0;
$uni_views = 0;
$get_id = @mysql_fetch_array(@mysql_query("SELECT * FROM `banners` ORDER BY `id` DESC"));
$insert_stat = @mysql_query("INSERT INTO stats (`id`,`made`,`file_location`,`width`,`length`,`hits`,`uni_hits`,`views`,`uni_views`) VALUES ('$get_id[0]','$made','$location','$width','$height','$hits','$uni_hits','$views','$uni_views')");
}
if($insert_stat) {
$message = 'Banner '.$name.' has been successfully added. ID: '.$get_id[0];
}
else {
$message = 'Database error';
}
}
}
include("header.php");
?>
<p id="section">add a banner</p>
<form name="addurl" method="post" action="<? echo $_SERVER['PHP_SELF'];?>" enctype="multipart/form-data">
<fieldset>
<legend>General</legend>
<br />
<strong>Banner title:</strong><br /><input name="name" type="text" id="name" value="<?php echo $_POST['name'];?>" size="60" /><br />
<strong>Banner tooltip:</strong><br /><input name="mouseover" type="text" id="mouseover" value="<?php echo $_POST['mouseover'];?>" size="60" /><br />
<strong>Banner link:</strong><br /><?php if($_POST['urlto'] == NULL) {$_POST['urlto'] = 'http://';}?><input name="urlto" type="text" id="urlto" value="<?php echo $_POST['urlto'];?>" size="60" /> (Enter <strong>EMPTY</strong> to disable linking)<br />
<strong>Banner link target:</strong><br />
<?php if($_POST['openin'] == 'new' || $_POST['openin'] == NULL) {$sel = 'checked';} else {$sel=NULL;}?><input name="openin" type="radio" value="new" <?=$sel;?> /> New window
<?php if($_POST['openin'] == 'same') {$sel = 'checked';} else {$sel=NULL;}?><input name="openin" type="radio" value="same" <?=$sel;?> /> Same window<br />
</fieldset>
<br />
<fieldset>
<legend>Location</legend>
<br />
<?php if($_POST['locationtype'] == 'http' || $_POST['locationtype'] == NULL) {$sel = 'checked';} else {$sel=NULL;}?><input name="locationtype" type="radio" value="http" <?=$sel;?> /> URL location or <?php if($_POST['locationtype'] == 'upload') {$sel = 'checked';} else {$sel=NULL;}?><input type="radio" name="locationtype" value="upload" <?=$sel;?> /> Upload a file<br />
<strong>URL location:</strong><br /><input name="httploc" type="text" id="httploc" value="<?php echo $_POST['httploc'];?>" size="60" /><br />
<strong>File location:</strong><br /><input name="filename" type="file" id="filename" size="60" /><br />
</fieldset>
<br />
<fieldset>
<legend>Duration</legend>
<br />
<?php if($_POST['stopit'] == 'ignore' || $_POST['stopit'] == NULL) {$sel = 'checked';} else {$sel=NULL;}?><input name="stopit" type="radio" value="ignore" <?=$sel;?> /> Forever<br />
<?php if($_POST['stopit'] == 'hits') {$sel = 'checked';} else {$sel=NULL;}?><input name="stopit" type="radio" value="hits" <?=$sel;?> /> After <input name="hits" type="text" id="hits2" value="<?php echo $_POST['hits'];?>" size="3" /> hits<br />
<?php if($_POST['stopit'] == 'views') {$sel = 'checked';} else {$sel=NULL;}?><input name="stopit" type="radio" value="views" <?=$sel;?> /> After <input name="views" type="text" id="views" value="<?php echo $_POST['views'];?>" size="3" /> views<br />
<?php if($_POST['stopit'] == 'date') {$sel = 'checked';} else {$sel=NULL;}?><input name="stopit" type="radio" value="date" <?=$sel;?> /> On this date: <input name="id1" type="textarea" value="<?php echo $_POST['id1'];?>" size="7" /> <input type="button" onClick="c1.popup('id1');" style="background:url(images/cal.gif); width: 22px;"/>
</fieldset>
<br />
<fieldset>
<legend>Misc</legend>
<br />
<strong>Resize banner:</strong><br />
<?php if($_POST['size'] == 'leave' || $_POST['size'] == NULL) {$sel = 'checked';} else {$sel=NULL;}?><input name="size" type="radio" value="leave" <?=$sel;?> /> Original size<br />
<?php if($_POST['size'] == 'change' ){$sel = 'checked';}else{$sel=NULL;}?><input name="size" type="radio" value="change" <?=$sel;?> /> Resize to: Width: <input name="width" type="text" id="width" value="<?php echo $_POST['width'];?>" size="4" /> Height: <input name="height" type="text" id="height" value="<?php echo $_POST['height'];?>" size="4" /><br />
</fieldset>
<br />
<input type="submit" name="Submit" value="Add Banner" />
<input name="submitid" type="hidden" id="submitid" value="1" />
</form>
<?php include("footer.php");?>
Cheers