Location: PHPKode > projects > DataDivisions > includes/funcEmailDisplay.php
<?
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# DataDivisions, Build 1.0, 12/11/2003                                      #
# FileName: funcEmailDisplay.php                                            #
# File Description:                                                         #
#   Provides functions required for a user to email a saved display (back-  #
#   end, middle and front-end)                                              #
#                                                                           #
# +-----------------------------------------------------------------------+ #
# | DataDivisions - Website Statistic Visualization Software              | #
# | Copyright (c) 2003, Brian Willison                                    | #
# +-----------------------------------------------------------------------+ #
# | The contents of this file are subject to the GNU General Public       | #
# | License version 2 (June 1991). This file and all its contents (incl.  | #
# | functions, methods, etc.) are free for general use within any         | #
# | community. This software is distributed with the intent to allow      | #
# | developers the opportunity to copy, manipulate and revamp this        | #
# | application in part or whole for best use cases.                      | #
# |                                                                       | #
# | This software is distributed "AS-IS" with no warranties of any kind   | #
# | either expressed or implied.                                          | #
# |                                                                       | #
# | Please refer to the GPL license document for more information:        | #
# | (_docs/gplLicense.pdf)                                                | #
# +-----------------------------------------------------------------------+ #
# | Developer, Designer, Initial Creator:                                 | #
# | Brian Willison (hide@address.com)                       | #
# +-----------------------------------------------------------------------+ #
# | Initial Download Reference:                                           | #
# | http://datadivisions.sourceforge.net                                  | #
# +-----------------------------------------------------------------------+ #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

// Function: Check Register Form
function checkEmailDisplayForm($_POST) {
	if ($_POST['toEmail'] == "" || $_POST['fromName'] == "") {
		return "blankSubmit";
	} else {
		// Gather Posted Data
		$fromName = $_POST['fromName'];
		$username = $_POST['username'];
		$toEmail = $_POST['toEmail'];
		// Determine Correct/Valid Email To Send To Otherwise Generate Error Message
		if (!ereg("^[a-zA-Z0-9_.-]+@[a-zA-Z0-9_.-]+\.[a-zA-Z]+$", trim($toEmail))) {
			return "emailNotCorrect";
		}
		$msg = (isset($_POST['msg']) && ($_POST['msg'] != "")) ? $_POST['msg'] : emailDisplayMsgDefault;
		// Set HTML Header Info For Email
		$headers = "MIME-Version: 1.0\r\n";
		$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
		$headers .= "From: ".stripslashes($fromName)." <datadivisions@".websiteUrl.">\r\n";
		$displayUrl = $_POST['displayUrl'];
		// Add Email Var For Bypass
		$displayUrl .= "&entranceFromEmail=true";
		// Get HTML Email Template
		$fp = fopen(templateEmailDisplay, "r");
		if ($fp) {
			// Replace Variables In HTML Template(s)
			$body = fread($fp,filesize(templateEmailDisplay));
			$body = ereg_replace("{msg}",stripslashes($msg),$body);
			$body = ereg_replace("{fromName}",stripslashes($fromName),$body);
			$body = ereg_replace("{displayUrl}",$displayUrl,$body);
			$body = ereg_replace("{appName}",appName,$body);
			$body = ereg_replace("{appBorderColor}",appBorderColor,$body);
			$body = ereg_replace("{appHeaderColor}",appHeaderColor,$body);
			$body = ereg_replace("{displayPage}",displayPage,$body);
			$body = ereg_replace("{imgUrl}",imgUrl,$body);
		}
		// Mail Display Info
		mail($toEmail,emailDisplaySubject,$body,$headers);
	}
}
// Function: Generate Register Form
function genEmailDisplayForm($errorCheck) {
global $_POST,$_GET;
	$username = (isset($_GET['username'])) ? $_GET['username'] : $_POST['username'];
	$displayUrl = (isset($_GET['displayUrl'])) ? $_GET['displayUrl'] : $_POST['displayUrl'];
	$displayUrl = ereg_replace("\(","",$displayUrl);
	$displayUrl = ereg_replace("\)","",$displayUrl);
	$displayUrl = ereg_replace("_","&",$displayUrl);
	genAppSmHeader(pageName);
?>
	<tr>
	<td></td>
	<td valign="top" colspan="3"><p class="header">To email this display to a colleague please fill in the short form below. You may also attach a 
	personalized message to the email if you choose. When you are finished, please click "Submit."</td>
	</td>
	</tr>
	<tr>
	<td valign="top" colspan="5"><?writeSpacer(1,10);?></td>
	</tr>
<?
	if ($errorCheck != 0) {
		printf("\t<tr><td></td><td valign=\"top\" colspan=\"3\"><p class=\"error\">%s</td><td></td></tr>",genErrorMsg($errorCheck));
	}
?>
	<tr>
	<td valign="top" colspan="5"><?writeSpacer(1,10);?></td>
	</tr>
	<tr>
	<form name="emailDisplay" method="post" action="<?=phpSelf?>">
	<td></td>
	<td><p align="right">Your Name:</td>
	<td></td>
	<td><p><input type="text" name="fromName" size="25" maxlength="25" value="<?if(isset($_POST['fromName'])){echo$_POST['fromName'];}?>"></td>
	<td></td>
	</tr>
	<tr>
	<td></td>
	<td><p align="right">Colleague's Email:</td>
	<td></td>
	<td><p><input type="text" name="toEmail" size="25" maxlength="25" value="<?if(isset($_POST['toEmail'])){echo$_POST['toEmail'];}?>"></td>
	<td></td>
	</tr>
	<tr>
	<td></td>
	<td valign="top"><p align="right">Message:</td>
	<td></td>
	<td><p><textarea name="msg" cols="22" rows="3"><?if(isset($_POST['msg'])){echo$_POST['msg'];}?></textarea></td>
	<td></td>
	</tr>
	<tr>
	<td valign="top" colspan="5"><?writeSpacer(1,10);?></td>
	</tr>
	<input type="hidden" name="username" value="<?=$username?>">
	<input type="hidden" name="displayUrl" value="<?=$displayUrl?>">
	<tr>
	<td></td>
	<td></td>
	<td></td>
	<td valign="top"><input type="submit" name="submit" value="Submit" class="btnSubmit"></td>
	<td></td>
	</form>
	</tr>
	<tr>
	<td valign="top" colspan="5"><?writeSpacer(1,15);?></td>
	</tr>
<?
	genAppSmFooter(pageName);
}
?>
Return current item: DataDivisions