Location: PHPKode > projects > SiteX > contact.php
<?PHP
ob_start();
session_start();

include("includes/globals.php.inc");
include("includes/functions.php");
include("lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("lang/".$sxSetup['Language'].".php");
include("themes/$THEME_FOLDER/config.php.inc");

protectComponentPage(7);

if($Submit)
{
	$process_form = false;
	
	// If form is secured
	if($sxSetup['FormSecurity'] == 1)
	{
		// Validate the code
		if(validateSecurityCode(htmlspecialchars($security_code), intval($codeid,10)) == true)
			$process_form = true;
		else
			$message = $sxLang['MessageSecurityCodeRejected'];
	}
	else
		$process_form = true;
	
	if($process_form)
	{
		mail($sxSetup['ContactFormEmail'], $sxLangMail['SubjectContactForm'], $sxLangMail['ContactForm'], "From: ".$sxSetup['ContactFormEmail']);
		$message = $sxLang['MessageContactMessageSent'];
	}
}

// Secure imaging
if($sxSetup['FormSecurity'] == 1)
	$sxSecureImage = sxCreateSecurityImage();

$sxTitleAddendum = getComponentName("7");
include("themes/$THEME_FOLDER/header.php");
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function submitIt(myForm)
{
	if(myForm.name.value == ""){
		alert("<?PHP echo $sxLang['ContactJSNameError']; ?>");
		myForm.name.select();
		return false;
	}
	if(myForm.email.value == ""){
		alert("<?PHP echo $sxLang['UserJSEmail1']; ?>");
		myForm.email.select();
		return false;
	}
	if(myForm.cmessage.value == ""){
		alert("<?PHP echo $sxLang['ContactJSMessageError']; ?>");
		myForm.cmessage.select();
		return false;
	}
	if(emailCheck(myForm.email.value) == false){
		myForm.email.select();
		return false;
	}
}

function emailCheck (emailStr) {
	
	// Adapted from V1.1.3: Sandeep V. Tamhankar (hide@address.com)

	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	
	if (matchArray==null) {
		alert("<?PHP echo $sxLang['UserJSEmail11']; ?>");
		return false;
	}
	
	var user=matchArray[1];
	var domain=matchArray[2];
	
	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
			alert("<?PHP echo $sxLang['UserJSEmail12']; ?>");
			return false;
	   }
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			alert("<?PHP echo $sxLang['UserJSEmail13']; ?>");
			return false;
	   }
	}
	
	if (user.match(userPat)==null) {
		alert("<?PHP echo $sxLang['UserJSEmail14']; ?>");
		return false;
	}
	
	var IPArray=domain.match(ipDomainPat);
	
	if (IPArray!=null) {
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				alert("<?PHP echo $sxLang['UserJSEmail15']; ?>");
				return false;
	   		}
		}
		return true;
	}
	
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	
	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
			alert("<?PHP echo $sxLang['UserJSEmail16']; ?>");
			return false;
	   }
	}
	
	if (checkTLD && domArr[domArr.length-1].length!=2 && 
	domArr[domArr.length-1].search(knownDomsPat)==-1) {
		alert("<?PHP echo $sxLang['UserJSEmail17']; ?>");
		return false;
	}
	
	if (len<2) {
		alert("<?PHP echo $sxLang['UserJSEmail18']; ?>");
		return false;
	}
	
	return true;
}

//-->
</script> 
  <div class="bodyWrapper">
	<h1><?PHP echo getComponentName("7"); ?></h1>
	<?PHP if($message) echo '<div class="message">' .$message . '</div>'; ?>
	<?PHP
		if((userAdmin()) OR ((userEditor()) AND ($sxSetup['EditorRightsContactManage'])))
	echo '<div class="journalAdd"><a href="admin/contact_config.php">' .$sxLang['ButtonEdit'] . '</a></div>'; 
	?>
	<!--  print contact info -->
	<div class="ContactInfo">
	<?PHP echo $sxSetup['ContactFormInfo']; ?>
	</div>
	<!--  end contact info -->
	
	<!--  start contact form -->
  <form name="form1" method="post" action="<?PHP echo $PHP_SELF; ?>" onsubmit="return submitIt(this)">
	  <table border="0" cellspacing="0" cellpadding="5">
		<tr> 
		  <td class="sxTdItem"><?PHP echo $sxLang['GeneralItemName']; ?></td>
		  <td><input name="name" type="text" id="name" maxlength="80"<?PHP if(($Submit)AND($process_form == FALSE)) echo ' value="' . $name . '"'; elseif(loggedIn()) echo ' value="' . $_SESSION['firstname'] . ' ' . $_SESSION['lastname'] . '"'; ?> /></td>
		</tr>
		<tr> 
		  <td class="sxTdItem"><?PHP echo $sxLang['GeneralItemEmail']; ?></td>
		  <td><input type="text" name="email" id="email" maxlength="80"<?PHP if(($Submit)AND($process_form == FALSE)) echo ' value="' . $email . '"'; elseif(loggedIn()) echo ' value="' . $_SESSION['email'] . '"'; ?> /></td>
		</tr>
		<tr> 
		  <td class="sxTdItem"><?PHP echo $sxLang['GeneralItemType']; ?></td>
		  <td>
			<select style="width:300px;" name="contact_type">
			  <?PHP foreach($sxThemeConfig['ContactFormTypes'] as $sxValue){ echo '<option value="' . $sxValue . '"'; if($contact_type == $sxValue){ echo ' selected="selected"'; } echo'>' . $sxValue . '</option>'; } ?>
			</select>
		  </td>
		</tr>
		<tr> 
		  <td class="sxTdItem"><?PHP echo $sxLang['GeneralItemMessage']; ?></td>
		  <td><textarea name="cmessage" id="cmessage" style="width:300px;height:200px;"><?PHP if(($Submit)AND($process_form == FALSE)) echo $cmessage; ?></textarea></td>
		</tr>
		<?PHP if($sxSetup['FormSecurity'] == 1){ ?>
		<tr> 
		  <td class="sxTdItem">&nbsp;</td>
		  <td><img src="<?PHP echo $sxSecureImage['url']; ?>" /><br/><?PHP echo $sxLang['GeneralItemSecureCase']; ?></td>
		</tr>
		<tr> 
		  <td class="sxTdItem"><?PHP echo $sxLang['GeneralItemSecureCode']; ?></td>
		  <td><input name="security_code" type="text" id="security_code" maxlength="255" />
		  	  <input type="hidden" name="codeid" value="<?PHP echo $sxSecureImage['codeid']; ?>" /></td>
		</tr>
		<?PHP } ?>
		<tr>
		  <td>&nbsp;</td>
		  <td><input type="submit" class="sxButton" name="Submit" value="<?PHP echo $sxLang['ContactButtonSubmitInfo']; ?>" /></td>
		</tr>
	  </table>
	</form>
  </div>
<?PHP
include("themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX