<?php

session_start();
include "../config.php";
include "../header.php";
include "../style.php";

$id = dbput( $_POST['id']);


if (isset($_POST['action'])) {
   $action = dbput( $_POST['action']);
}

if (isset($_POST['save'])) {
   $save = 1;
} else $save = 0;

if ($memtype=="FREE") {
            $savesolos = $freecashsavesolos;
        }
        elseif ($memtype=="PRO"){
           $savesolos = $procashsavesolos;
        }
		elseif ($memtype=="JVPARTNER"){
            $savesolos = $jvcashsavesolos;
        }

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

    include("navigation.php");
    include("../banners.php");
    echo "<font size=2 face='$fonttype' color='$fontcolour'><p><center>";
	
	$savedsql = mysql_query("SELECT * FROM saved_cashsolos WHERE userid = '$userid'");
	$savedcount = @mysql_num_rows($savedsql);
	
?>
		<!-- tinyMCE -->
		<script language="javascript" type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
		<script language="javascript" type="text/javascript">
		tinyMCE.init({
			mode : "textareas",
			theme : "advanced",
			extended_valid_elements : "a[href|target|name],font[face|size|color|style],span[class|align|style]"
		});
		</script>
		<!-- /tinyMCE --> 
<?
    if ($action == "send") {
	
	
		$subject = mysql_real_escape_string( $_POST['subject']);
		$adbody = mysql_real_escape_string( $_POST['adbody']);
		$url = mysql_real_escape_string( $_POST['url']);
		
		if (empty($subject)){
       		?><p>No subject entered. Click <a href=addcashsolos.php>here</a> to go back<p> <?
       		include "../footer.php";
       		exit;
    	}
		if (empty($adbody)){
       		?><p>No adbody entered. Click <a href=addcashsolos.php>here</a> to go back<p> <?
       		include "../footer.php";
       		exit;
    	}
		if (empty($url)){
       		?><p>No url entered. Click <a href=addcashsolos.php>here</a> to go back<p> <?
       		include "../footer.php";
       		exit;
    	}
		

    	$query = "update cashsolos set subject='".dbput($subject)."', adbody='".dbput($adbody)."', added=1, sent=0, url='".dbput($url)."',date='".time()."' where id=".$id;
    	$result = mysql_query ($query)
	     	or die ("Query failed");
			
		if($save AND $savedcount < $savesolos) {
			mysql_query("insert into saved_cashsolos (subject,adbody,userid,url) values('".dbput($subject)."','".dbput($adbody)."','".dbput($userid)."','".dbput($url)."')");
		}	
		?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Frame Breaker test</title>
<META HTTP-EQUIV="Refresh" Content="3; URL=addcashsolos_checked.php?id=<? echo $id; ?>">
</head>

  <frameset ROWS="60,*" BORDER=0 FRAMEBORDER=1 FRAMESPACING=0>
  <frame name="header" scrolling="no" noresize marginheight="1" marginwidth="1" target="main" src="addcashsolos_check.php">
  <frame name="main" src="<? echo $url; ?>">
  </frameset>
  
</html>		
		
    	<?
		
		
    	?>
      		<p><center>Your cash solo ad has been set up, and has been placed in the queue for sending. <a href="advertise.php">Click here</a> to go back.</center></p><BR><BR>
					
    	<?
		
		
		
		
    } else if($action == "Delete") {
			mysql_query("DELETE FROM saved_cashsolos WHERE id='".$_POST['id']."' AND userid = '".$userid."'");
			echo "<center><p><b>The saved ad has been deleted successfully.</b></p></center><br><br>";
	} else {
	
	

	
	//Solo available
	$query = "SELECT * FROM cashsolos where added=0 and userid='".$_SESSION[uname]."' limit 1";
	$result = mysql_query ($query)
		or die ("Query failed");
	while ($line = @mysql_fetch_array($result)) {
	
			
        $id = $line["id"];
		

		if($savedcount) {
			echo "<font size=3><b>Your saved ads</b></font><br><br>You can save up to $savesolos ads.";
			
			echo "<table border=1 cellpadding=5><tr align=\"center\"><td><b>Subject</b><td><b>Action</b></td></tr>";
			
			while($each = mysql_fetch_array($savedsql)) {
				
				echo "<tr><td>".dbget($each['subject'])."</td><td>";
				
					?>
						  <form method="POST" action="addcashsolos.php">
						  <input type="hidden" name="id" value="<? echo $id; ?>">
						  <input type="hidden" name="subject" value="<? echo dbgethtml($each['subject']); ?>">
						  <input type="hidden" name="adbody" value="<? echo dbgethtml($each['adbody']); ?>">
						  <input type="hidden" name="url" value="<? echo dbget($each['url']); ?>">
						  <input type="hidden" name="action" value="send">
						  <input type="submit" value="Post Solo"></p>
						  </form>
				
					<?
				
				
				echo "<form method=\"post\"><input type=\"hidden\" name=\"id\" value=\"".$each['id']."\"><input type=\"submit\" name=\"action\" value=\"Delete\"></form></td></tr>";
			}
			
			echo "</table><br><br>";
		}
		
		

            $subject = dbget($line["subject"]);
            $adbody = dbget($line["adbody"]);
            ?>
              <center><H2>Submit Your Cash Solo Ad</H2>
              <p><B>YOU ARE LIMITED TO 1 SOLO AD POSTING PER DAY.  </B><br>No adult, offensive or illegal ads (including pyramid schemes and chainletters).  <BR>
<table width="550"><tr><td>
<b><font size=3></font></p><p align="center"><font color="#000000" face="tahoma" size="2"><b>
<font size="2"><span style="background-color: #FFFF00">DO NOT INCLUDE 
URLS IN THE BODY OF YOUR SOLO AD - MANY WEBSITES BEING PROMOTED 
ARE &quot;BLACKLISTED&quot; AT THE TOP ISP'S AND IT CAUSES SOLO ADS TO BOUNCE - ONLY PLACE THE URL IN THE CREDIT LINK BOX AT THE BOTTOM</span></font></b></font></p>
<BR><BR>You may use the tags ~fname~ for the FIRST name and ~userid~ for the USERID in the body and/or the subject line.
</td></tr></table>
<br><br>
              <form method="POST" action="addcashsolos.php">
              Subject:<br>
              <input type="text" name="subject" maxsize="70"><br>
              Ad body:<br>
              <textarea  name="adbody" cols="65" rows="30">
DO NOT INCLUDE 
URLS IN THE BODY OF YOUR SOLO AD - MANY WEBSITES BEING PROMOTED 
ARE &quot;BLACKLISTED&quot; AT THE TOP ISP'S AND IT CAUSES SOLO ADS TO BOUNCE - ONLY PLACE THE URL IN THE CREDIT LINK BOX AT THE BOTTOM]

PLEASE DELETE THIS TEXT BEFORE POSTING YOUR SOLO AD</textarea>
              <br>


			  Ad URL:<br>
              <input type="text" name="url" maxsize="1250"><br>
              <input type="hidden" name="id" value="<? echo $id; ?>">
              <input type="hidden" name="action" value="send">
              <p>Enter the website address you want traffic to go to above, include 
				<span style="background-color: #FFFF00">http://</span> <br>  Double check your cash solo ad, as it cannot be edited once submitted.</p>
				<? if($savedcount < $savesolos) echo "<input type=\"checkbox\" name=\"save\" value=\"1\"> Save ad <br>"; ?>
              <input type="submit" value="Send">
              </form></center>
<br>
 <center><h3><font color=#000080>Check Your URLS for Frame Breaking Before
You Send Them Out!</font></h3></center>

<center><h3><font color=#000080>Protect Your Membership By Using the Tool
Below! <br>

(Opens in New Window)</font></h3></center>

<center>
<FORM NAME='urtotest' target="_blank" ACTION='<? echo $domain; ?>/members/sitecheck.php'
METHOD='GET' >

<input type='text' value="http://" size="50" name='url' />

<input type='submit' value='Check URL' />
</FORM>

            <?
    	}
    }
    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);
?>