Location: PHPKode > projects > WebDex > mailMgr.php
<?PHP
/*
+--------------------------+
| include the needed files |
+--------------------------+
*/
	require_once('config.inc.php');
	require_once('php_inc/lib.inc.php');
	require_once('PEAR.php');
	require_once('classess/pageMaker_class.php');
/*
+------------------+
| Notes/Misc. info |
+------------------+
*/
	/*
	+-----------------------------------------------------------------------+
	| A series of variables need to be defined to output a complete page.   |
	| $pageTitle = the string to use as the html <TITLE>                    |
	| $pageHead = The page header                                           |
	| $pageSubMenu = a sub-menu/navigation system                           |
	| $pageSubHead = The page subhead                                       |
	| $response_message = Text Error/Message or $PEAR::Error                |
	| $pageBodyContent = the html to use in the body portion of the page    |
	|                                                                       |
	| A Standard footer for putting together and displaying a page is       |
	| included at the bottom of this file. Just define the variables.       |
	| Any Response Messages or Errors that are to be displayed to the user  |
	| should be set in $response_message to maintain a standard flow.       |
	+-----------------------------------------------------------------------+
	*/
	
/*
+------------------------+
| Set require user login |
+------------------------+
*/
	// Start or Resume User Session, and switch the id
	// to prevent session highjacking
	session_start();
	$sessionBackup = $_SESSION;
	$_SESSION = array();
	session_destroy();
	session_start();
	$_SESSION = $sessionBackup;
	// make sure the user is logged in before getting anything in this script
	$login = isLoggedin();
	if (PEAR::isError($login)) {
		header("Location: ".$GLOBALS[base_url]."login.php");
		exit;
	}
	
/*
+-------------------------------------------------+
| Define page content defaults.                   |
| These can be appended to or over written in the |
| data processing/preperation area below.         |
+-------------------------------------------------+
*/
	$pageTitle = 'WebDex - A Simple Contact Management System - Mailing Center';
	$pageHead = 'Mailing Center';
	$pageSubMenu = '';
	$pageSubHead = '';
	$pageBodyContent = '';


/*
+----------------------------------------+
| Start data processing/preperation area |
+----------------------------------------+
*/
	// 1st step in sending a new mailing
	if ($_GET[action] == 'sendMailStep1') {
		$pageSubHead = 'Define New Mailing Parameters';
		$response_message = 'Your message will be sent to every contact on the below<br>selected list, if the contact has Get Mass Mail set to Yes.';
		$pageBodyContent = getNewMailingForm('popupMgr.php', 'POST', 'Send Message');
	}
	if ($_GET[action] == 'showSendMsgDone') {
		$pageSubHead = 'Mailing Archive';
		$response_message = 'Message Sent To All List Members.';
		$results = getMassMailSummary($_GET[mailing_id]);
		if (PEAR::isError($results) && $results->getMessage() == 'No Rows Found.') {
			$response_message = 'Mass Mail Sent.';
		} elseif (PEAR::isError($results)) {
			$response_message = $results;
		} else {
			$pageBodyContent = $results;
		}
	}
	if ($_GET[action] == 'showMsgArchive') {
		$pageSubHead = 'Mailing Archive';
		$results = getMassMailSummary();
		if (PEAR::isError($results)) {
			$response_message = $results;
		} else {
			$pageBodyContent = $results;
		}
	}
	// for resending a archived mailing
	if ($_GET[action] == 'resendMailing') {
		// get the archive record for this mailing
		$mailArchive = getRows($GLOBALS['dbMailArchTbl'], $_GET['mailing_id'], '', 1);
		if (PEAR::isError($mailArchive)) {
			$response_message = $mailArchive;
		} else {
			// build returned row into array to pass to getNewMailingForm() for prefilling
			$preFill = array('From'=>$mailArchive[0]['from_headers'],
							 'Reply-To'=>$mailArchive[0]['replyTo_header'],
							 'list_id'=>$mailArchive[0]['list_id'],
							 'Subject'=>$mailArchive[0]['subject_header'],
							 'html_content'=>$mailArchive[0]['html_body'],
							 'txt_content'=>$mailArchive[0]['text_body']);
			// get attachment info if needed
			$query = 'SELECT id,filename,filesize FROM '.$GLOBALS[dbMailAttchTbl].' WHERE (mailing_id = "'.$_GET['mailing_id'].'")';
			$attachRow = selectRows($query);
			if (!PEAR::isError($attachRow)) {
				$preFill['filename'] = $attachRow[0]['filename'];
				$preFill['filesize'] = $attachRow[0]['filesize'];
				$preFill['fileid'] = $attachRow[0]['id'];
			}
			// create prefilled form for body content
			$pageBodyContent = getNewMailingForm('popupMgr.php', 'POST', 'Send Message', $preFill);
		}
	}
	
/*
+--------------------------------------+
| End data processing/preperation area |
+--------------------------------------+
*/
	
/*
+--------------------------------------------+
| Start output/display the page              |
| Should not be any need to edit below here. |
+--------------------------------------------+
*/
	// build and output the page using pageMaker_class.php
	$page = new pageMaker();
	$page->setTemplateFile($GLOBALS[html_template]);
	$page->getTemplate();
	if (PEAR::isError($page)) {
		echo $page->getMessage();
		exit;
	}
	$page->setPgKey('{TITLE}', $pageTitle);
	$page->setPgKey('{EXTRAHTML}', getExtraHTML());
	$page->setPgKey('{LEFTNAV}', getLeftNav());
	$page->setPgKey('{TOPMENU}', getTopMenu());
	$page->setPgKey('{LOGINSTATUS}', getLoginStatus());
	$page->setPgKey('{HEADER}', $pageHead);
	$page->setPgKey('{SUBHEAD}', $pageSubHead);
	$page->setPgKey('{SUBMENU}', $pageSubMenu);
	$page->setPgKey('{RESPONSEMSG}', parseResponse($response_message));
	$page->setPgKey('{BODYCONTENT}', $pageBodyContent);
	if (PEAR::isError($page)) {
		echo $page->getMessage();
		exit;
	}
	$page->showPage();
?>
Return current item: WebDex