<?php /*

             UPDATE (Apr 14, 2007): Well, it's official. This
             script cannot be relied upon becuase it is not
             100% effective. It has been found by user-agent
             spoofing 'bots and I now get 1-2 smal emails per
             week to this address. I would like to suggest an
             alternive email protection script I wrote [1] or
             my contact forms [2,3]

     [1] http://mikecherim.com/experiments/php_email_protector.php
     [2] http://green-beast.com/blog/?page_id=71 (stand-alone)
     [3] http://green-beast.com/blog/?page_id=136 (WordPress plugin)

   +------------------------------------------------------------------+
   | Green-Beast.com                                                  |
   | PHP: Hide Email                                                  |
   | PHP Hypertext Preprocessor                                       |
   | Copyright Jun 2006                                               |
   | Use with attribution by visible link please!                     |
   | Attribute to: <a href="http://green-beast.com/">Mike Cherim</a>  |
   +------------------------------------------------------------------+
*/
?>


<?php /*
   To use, include this script anywhere on your pages provided it is
   included before the email output location starting from the top.
   Include the phe script (below) like this:
    <?php include_once("phe_script.php"); ?>
   Then output it with this where you want it:
    <?php echo( ''.$phe_output.'' ); ?>
*/
?>


<?php                            // PHE SCRIPT
##############################################
// Begin configuration

   
$eml_account=  "yourEmail";
   
$eml_domain=   "yourDomain";
   
$eml_dotwhat=  "com";

   
$eml_linktext= "";  // If empty, email address will be displayed
   
$eml_title=    "";  // Optional email link title
   
$eml_subject=  "";  // Optional email subject line
   
$eml_class=    "";  // Optional link style class


// End configuration - No need to edit below
##############################################
// Combine some variables to make an email address
   
$phe_eml=  "$eml_account&#64;$eml_domain&#46;$eml_dotwhat";

// Begin link text negotiation
if ( $eml_linktext !== "" ) {
   
$phe_eml_text= "$eml_linktext";
} else {
   
$phe_eml_text= "$phe_eml";
}
// End link text negotiation

// Begin link class negotiation
if ( $eml_class !== "" ) {
   
$phe_eml_class= " class=\"$eml_class\"";
} else {
   
$phe_eml_class= "";
}
// End link class negotiation

// Begin link title negotiation
if ( $eml_title !== "" ) {
   
$phe_eml_title= " title=\"$eml_title\"";
} else {
   
$phe_eml_title= "";
}
// End link title negotiation

// Begin subject negotiation
if ( $eml_subject !== "" ) {
   
$phe_eml_subject= "?subject=$eml_subject";
} else {
   
$phe_eml_subject= "";
}
// End subject negotiation

// Begin combine and redfine variables   
   
$phe_gogo= "<a".$phe_eml_class." href=\"mailto:".$phe_eml."$phe_eml_subject\"".$phe_eml_title.">$phe_eml_text</a>";
   
$phe_nogo= "$eml_account<span>[at]</span>$eml_domain<span>[dot]</span>$eml_dotwhat";
// End combine and redfine variables

// Begin "UA OK" confirmation
   
$ua_ok= $_SERVER['HTTP_USER_AGENT'];
if (
eregi( "firefox", $ua_ok ) ||  
     
eregi( "msie", $ua_ok ) ||
     
eregi( "microsoft internet explorer", $ua_ok ) ||
     
eregi( "opera", $ua_ok ) ||
     
eregi( "netscape", $ua_ok ) ||
     
eregi( "safari", $ua_ok ) ||
     
eregi( "konqueror", $ua_ok ) ||
     
eregi( "galeon", $ua_ok ) ||
     
eregi( "aol", $ua_ok ) ||
     
eregi( "mspie", $ua_ok ) ||
     
eregi( "pocket", $ua_ok ) ||
     
eregi( "firebird", $ua_ok ) ||
     
eregi( "phoenix", $ua_ok ) ||
     
eregi( "amaya", $ua_ok ) ||
     
eregi( "libwww", $ua_ok ) ||
     
eregi( "links", $ua_ok ) ||
     
eregi( "netpositive", $ua_ok ) ||
     
eregi( "omniweb", $ua_ok ) ||
     
eregi( "icab", $ua_ok ) ||
     
eregi( "webtv", $ua_ok ) ||
     
eregi( "mozilla", $ua_ok ) && !eregi( "rv:[0-9]\.[0-9]\.[0-9]", $ua_ok ) ||
     
eregi( "mozilla", $ua_ok ) && eregi( "rv:[0-9].[0-9][a-b]", $ua_ok ) && !eregi( "netscape", $ua_ok ) ||
     
eregi( "mozilla", $ua_ok ) && eregi( "rv:[0-9]\.[0-9]", $ua_ok ) && !eregi( "netscape", $ua_ok ) )
{
// End "UA OK" confirmation

// The script retruns the email or not
   
$phe_output = "$phe_gogo";
} else {
   
$phe_output = "$phe_nogo";
}
?>