<?php /*
   +------------------------------------------------------------------+
   | MikeCherim.com                                                   |
   | PHP: Email Protector                                             |
   | PHP Hypertext Preprocessor                                       |
   | Copyright Jan 2007                                               |
   | Use with attribution by visible link, $pep_credit="show"; please |
   | Attribute to: Mike Cherim (Pre-configured)                       |
   +------------------------------------------------------------------+
*/
?>

<?php
/*
* INSTRUCTIONS:
*
* Option 1 - Direct Placement (single-use per site)...
* To use this script, simply copy the script below, fill out
* the config part of it with your information, place it on
* your *.php page where you want it to show, then style it
* as necessary. That's all there is to it.
*
* Option 2 - Included Placement (multi-use on site)...
* Save the script below  in a separate PHP file. Call it
* pepmail.php or something. Then include it on any of your
* site's page with a PHP include, like so:
*     <?php include_once("scripts/pepmail.php"); ?>
* This is an ideal solution if you want to display the
* address on mutiple pages. To secure the include, see
* this blog post: http://green-beast.com/blog/?p=144
* Use the lock and key method described in that post
*/
?>



<?php ################### PHP EMAIL PROTECTOR ##
## CONFIG BEGIN ################################
################################################

// Enter the email address
   
$pep_address= "youremail@yourdomain.com";  

// Enter subject line tag
   
$pep_subject= "[Your Site Email]";

// Enter a legend (form title)
   
$pep_legend=  "Your Title (Legend)";

// Choose valid XHTML or HTML
   
$pep_mark_up= "x";     // x=xhtml, h=html

// Choose to hide or show credit linkback
   
$pep_credit=  "show";  // or hide

################################################
## CONFIG END ##################################
################################################
// You do not need to edit below this point!

// Script-related variables
   
$pep_vers= "1.0";
   
$pep_bldn= "2007-04-14-01";
   
$pep_year= "2007";
   
$pep_code= "Gt12wSuPyLi18x";

// Input/output prep and modifications
   
$pep_disp= "<strong>Instructions:</strong> Enter a subject line and submit form to display email link.";
   
$pep_address= strtolower(stripslashes(strip_tags(trim($pep_address))));
   
$pep_valu= ''.$pep_code.''.$pep_vers.''.$pep_bldn.'';
   
$pep_valu= strtoupper(stripslashes(strip_tags(trim(rtrim(str_replace(array(".", "-", " ",), 'xfUsqi9rXz', $pep_valu))))));
   
$pep_mark_up= strtolower(trim($pep_mark_up));
   
$pep_credit= strtolower(trim($pep_credit));
   
$pep_valu= "PEP$pep_valu";
   
$pep_form= "yes";
   
$pep_clas= "nrm";

// Negotiate DTD for form validity
if($pep_mark_up == "x") {
   
$m = " /";
} else {
   
$m = "";
}

// Posted variables and sanitize
if($_POST) {
   
$pep_subj = $_POST['pep_subj'];
   
$pep_trap = $_POST['pep_trap'];  
   
$pep_subj= stripslashes(strip_tags(trim($pep_subj)));
   
$pep_trap= stripslashes(strip_tags(trim($pep_trap)));

// Check required input
if(!isset($pep_subj) || empty($pep_subj)) {
   
$pep_disp= '<strong>ERROR:</strong> Sorry, you must enter a subject line!';
   
$pep_clas= "err";
   
$pep_form= "yes";

// Verify spam trap has null value
} else if($pep_trap !== "") {
   
$pep_disp= '<strong>ERROR:</strong> Sorry, you populated a spam trap input!';
   
$pep_clas= "err";
   
$pep_form= "yes";

// Confirm the length of input (max is 60 chars for subject line)
} else if(strlen($pep_subj) > 60 ) {
   
$pep_disp= '<strong>ERROR:</strong> Sorry, your subject line exceeds 60 characters!';
   
$pep_clas= "err";
   
$pep_form= "yes";

// If nothing goes awry, give 'em the email
} else {
   
$pep_disp= "<strong class=\"suc\">SUCCESS:</strong> Click the link below to send an email!</p><p><strong>Email Address:</strong> <a href=\"mailto:$pep_address?subject=$pep_subject%20$pep_subj\">$pep_address</a>";
   
$pep_clas= "suc";
   
$pep_form= "no";
}
}
// Scripting done, here's the static and posted output mark-up
?>
<!-- ***** PHP Email Protector Begin ***** -->
<?php if($pep_form == "yes") { ?>
<form id="pep_form" method="post" action="<?php echo(''.htmlentities($_SERVER["PHP_SELF"]).''); ?>#pep">
<?php } ?>
<fieldset id="pep">
  <legend id="go"><?php echo(''.$pep_legend.''); ?></legend>
   <p class="<?php echo(''.$pep_clas.''); ?>"><?php echo(''.$pep_disp.''); ?></p>
<?php if($pep_form == "yes") { ?>
<!-- subject line -->
   <label title="Max: 60 Chars" for="pep_subj">Enter <span class="<?php echo(''.$pep_clas.''); ?>">Required</span> Email Subject Line<br<?php echo(''.$m.''); ?>>
    <input tabindex="0" title="Max: 60 Chars" type="text" name="pep_subj" id="pep_subj" size="60" maxlength="60" value=""<?php echo(''.$m.''); ?>></label>
<!-- spam trap -->
   <div style="position:absolute;top:-9000px;left:-9000px;"><br<?php echo(''.$m.''); ?>>
    <label for="pep_trap"><small><strong>Note:</strong> The input below should <em>not</em> be filled in. It is a spam trap.</small><br<?php echo(''.$m.''); ?>>
     <input type="text" name="pep_trap" id="pep_trap" alt="Pep Trap" value=""<?php echo(''.$m.''); ?>>
    </label>
   </div>
<!-- submit input -->
   <input tabindex="0" class="button" type="submit" alt="Click Button to Submit" value="Show Email" name="<?php echo(''.$pep_valu.''); ?>" id="<?php echo(''.$pep_valu.''); ?>"<?php echo(''.$m.''); ?>>
<?php } if($pep_credit == "show") { ?>
   <p class="pepcred"><small>PHP Email Protector <span title="Build Number: <?php echo(''.$pep_bldn.''); ?>">v.<?php echo(''.$pep_vers.''); ?></span> &copy; <?php echo(''.$pep_year.''); ?>, <a title="Green-Beast.com" href="http://green-beast.com/">Mike Cherim</a>.</small></p>
<?php } else { ?>
   <!--PHP Email Protector: Build number: <?php echo(''.$pep_bldn.''); ?>">v.<?php echo(''.$pep_vers.''); ?> (c) <?php echo(''.$pep_year.''); ?>, Mike Cherim (http://green-beast.com/)-->
<?php } ?>
</fieldset>
<?php if($pep_form == "yes") { ?>
</form>
<?php } ?>
<!-- ***** PHP Email Protector End ***** -->