<?php

session_start();

include "../config.php";
include "../header.php";
include "../style.php";

$done = $_POST['done'];
$id = $_POST['id'];
$subject = $_POST['subject'];
$url = $_POST['url'];
$desc1 = $_POST['desc1'];
$desc2 = $_POST['desc2'];


if( isset($_SESSION["ulogin"]) ) {

    include("navigation.php");
    include("../banners2.php");
    echo "<font size=2 face='$fonttype' color='$fontcolour'><p><center>";
    if ($done == "YES") {
		if (empty($subject)){
       		?><p>No subject entered. Click <a href=addfooterads.php>here</a> to go back<p> <?
       		include "../footer.php";
       		exit;
    	}
                               if (empty($desc1)){
       		?><p>No description line 1 entered. Click <a href=addfooterads.php>here</a> to go back<p> <?
       		include "../footer.php";
       		exit;
    	}
                               if (empty($desc2)){
       		?><p>No description line 2 entered. Click <a href=addfooterads.php>here</a> to go back<p> <?
       		include "../footer.php";
       		exit;
    	}
		if (empty($url)){
       		?><p>No url entered. Click <a href=addfooterads.php>here</a> to go back<p> <?
       		include "../footer.php";
       		exit;
    	}

		$subject = dbput($subject);
		$desc1 = dbput($desc1);
		$desc2 = dbput($desc2);
		$url = dbput($url);

    	$query = "update footerads set subject='$subject', desc1='$desc1', desc2='$desc2', added=1, url='$url' where id='".$id."'";
    	$result = mysql_query ($query)
	     	or die ("Query failed 1");
    	?>
      		<p><center>Your Solo Footer Ad has been added and placed in the queue for Admin approval.<br><a href="advertise.php">Click here</a> to go back.</p></center>
    	<?
    }
    else {
		if($_POST['id']) $query = "SELECT * FROM footerads where userid='".$_SESSION[uname]."' AND id='".$_POST['id']."' limit 1";
    	else $query = "SELECT * FROM footerads where added=0 and userid='".$_SESSION[uname]."' limit 1";
		
		
		$result = mysql_query ($query)
			or die ("Query failed 2");
    	while ($line = mysql_fetch_array($result)) {
            $id = dbget($line["id"]);
            $subject = dbget($line["subject"]);
            $desc1 = dbget($line["desc1"]);
            $desc2 = dbget($line["desc2"]);
            $url = dbget($line["url"]);
            ?>
              <br><center><H2>ADD SOLO FOOTER ADS</H2>
              <p><br />No adult, offensive or illegal ads (including pyramid schemes and chainletters).<BR><BR>
	  <b>Limit of 35 Characters Per Line</b><br><B></p>
              <form method="POST" action="addfooterads.php">
              Subject Line & Text Lines:<br><input type="text" name="subject" maxsize="50" size="50" value="<? echo $subject; ?>"><br>
  Description Line 1:<br>
              <input type="text" name="desc1" maxsize="50" size="50" value="<? echo $desc1; ?>"><br>
  Description Line 2:<br>
              <input type="text" name="desc2" maxsize="50" size="50" value="<? echo $desc2; ?>"><br>

			  Ad URL:<br>
              <input type="text" name="url" maxsize="250" size="50" value="<? echo $url; ?>"><br>
              <input type="hidden" name="id" value="<? echo $id; ?>">
              <input type="hidden" name="done" value="YES">
              <p>Enter the page you want traffic to view above. Include
				<span style="background-color: #FFFF00">http://</span><br><br>Double check your Solo Footer Ad before saving.<br>It cannot be edited once submitted!</b></p>
              <input type="submit" value="Save">
              </form></center>
            <?
    	}
    }
    echo "</td></tr></table>";
  }
else
  { ?>

  <p>You must be logged in to access this site. Please <a href="../index.php">click here</a> to login.</p>

  <? }

include "../footer.php";
mysql_close($dblink);
?>