Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/Mailer/
Upload File :
Current File : /var/www/cesa.co.za/Mailer/doAddArticle_old2.php

<?php
	require_once ('includes/globals.php');

	if (isset($_SESSION['database'])) {	
		if (isset($_SESSION['userid'])) {
			$userid = $_SESSION['userid'];
		} else {
			echo "<script>document.location.href='index.php';</script>\n";
		}
		

		$h_sectionid = $_POST['parentid'];
		$h_title = str_replace('"', '&quot;', str_replace("'", '&acute;', $_POST['title']));
		//$h_copy = str_replace('"', '&quot;', str_replace("'", '&acute;', $_POST['theBody'])); //, ENT_QUOTES);
		$h_copy = str_replace("'", '&acute;', $_POST['theBody']);
		
		$config = array(
				'bare' => true,
				'clean' => true,
				'show-body-only' => true,				
				'drop-proprietary-attributes' => true,
				'drop-font-tags' => true,
				'drop-empty-paras' => true,
				'hide-comments' => true,
				'quote-marks' => true,
				'join-classes' => true,
				'join-styles' => true); /*,
        'indent'        => true,
        'output-xhtml'  => true,
        'wrap'          => 200);*/

		// Tidy
		/*
		$tidy = new tidy;
		$tidy->parseString($_POST['theBody'], $config, 'utf8');
		$tidy->cleanRepair();
		
		$h_copy = $tidy;
		*/
		
/*
		echo htmlentities($_POST['theBody']);
		echo '<br/><br/>---<br/>';
		echo htmlentities($h_copy);
*/
				
		$h_image = 'n/a';
		$h_url = $_POST['link'];
		$h_linktitle = str_replace('"', '&quot;', str_replace("'", '&acute;', $_POST['linkText']));

		
		if(is_uploaded_file($_FILES['image']['tmp_name'])) {
			$h_image = $_FILES['image']['name'];
			//echo $_FILES['image']['tmp_name'];			
			move_uploaded_file($_FILES['image']['tmp_name'], $local_image_folder . $_FILES['image']['name']);
		}
				
		//echo $sql_addnewsletter;
		$db = $_SESSION['database'];
		
		$next_nlid = 1;
		$sql = "SELECT max(nOrder) as MaxOrder FROM Headlines where idSection = " . $h_sectionid;
		//echo $sql;
		
		$rs = $db->Execute($sql);
		if (! $rs->EOF) {
			$next_nlid = $rs->fields[0] + 1;		
		}

		$sql = "INSERT INTO Headlines(idSection, sTitle, txtCopy, sImage, sUrl, sLinkTitle, nOrder)\n" .
			"VALUES(" . $h_sectionid . ", '" . $h_title . "', '" . $h_copy . "', '" . $h_image . "', '" . $h_url . "', '" . $h_linktitle . "', " . $next_nlid . ")";
		
//		echo $sql;
//*		
		if ($db->Execute($sql) === false) {
		echo htmlentities($sql);
//			die("Could not add newsletter");
		} else {
		?>
		<script language="JavaScript" type="text/javascript">
			//window.close();			
			window.location = "manageNewsletter.php?id=<?php echo intval($_POST['t']); ?>&pid=<?php echo intval($_POST['s']); ?>";
		</script>
		<?php
		}
//*/
	} 
?>