[ Index ]

PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09)

title

Body

[close]

/template/inc_script/frontend_render/disabled/ -> makeEmailSpamSave.php (source)

   1  <?php
   2  
   3  // this script tries to replace all email addresses by
   4  // code to avoid email harvesting by spam bots
   5  // all "mailto:" links will be replaced by combination
   6  // of onclick javascript function  and "#" anchor
   7  
   8  $content['all'] = replaceEmailAddress($content['all']);
   9  
  10  
  11  function replaceEmailAddress($str) {
  12  
  13      preg_match_all('/<input[^>]+>/U', $str, $input_tags);
  14      preg_match_all('/<textarea[^>]+>.*<\/textarea>/U', $str, $textarea_tags);
  15      preg_match_all('/<option[^>]+>/U', $str, $option_tags);
  16  
  17      foreach($input_tags[0] as $key => $value) {
  18          $str = str_replace($value, '[%---I'.$key.'---%]', $str);
  19      }
  20      foreach($textarea_tags[0] as $key => $value) {
  21          $str = str_replace($value, '[%---T'.$key.'---%]', $str);
  22      }
  23      foreach($option_tags[0] as $key => $value) {
  24          $str = str_replace($value, '[%---O'.$key.'---%]', $str);
  25      }
  26  
  27      $regex = "([\xA1-\xFEa-z0-9_\.\-]+)(@)([\xA1-\xFEa-z0-9_\-]+\.[\xA1-\xFEa-z0-9\-\._\-]+[\.]*[a-z0-9]\??[\xA1-\xFEa-z0-9=]*)";
  28  
  29      $src = "/href=[\"' ]*mailto:".$regex."[\"']*([^>]+>)/i";
  30      $tar = 'href="#" onclick="mailtoLink(\'$1\',\'$3\');return false;" title="Email: $1 at $3##--##$4';
  31  
  32      $str = preg_replace($src, $tar, $str);
  33      $str = preg_replace_callback('/'.$regex.'/i', 'rewriteEmailText', $str);
  34  
  35      foreach($input_tags[0] as $key => $value) {
  36          $str = str_replace('[%---I'.$key.'---%]', $value, $str);
  37      }
  38      foreach($textarea_tags[0] as $key => $value) {
  39          $str = str_replace('[%---T'.$key.'---%]', $value, $str);
  40      }
  41      foreach($option_tags[0] as $key => $value) {
  42          $str = str_replace('[%---O'.$key.'---%]', $value, $str);
  43      }
  44  
  45      $str = str_replace('##--##"', '"', $str);
  46      $str = str_replace('##--##',  '"', $str);
  47  
  48      return $str;
  49  }
  50  
  51  function rewriteEmailText($part) {
  52      
  53      $part[1] = str_replace('.', '<script type="text/javascript">
  54  //<![CDATA[
  55  document.write("&#"+"46");
  56  //]]>
  57  </script><noscript>(.)</noscript>', $part[1]);
  58      $part[2] = '<script type="text/javascript">
  59  //<![CDATA[
  60  document.write("&#"+"64");
  61  //]]>
  62  </script><noscript>(@)</noscript>';
  63      $part[3] = str_replace('.', '<script type="text/javascript">
  64  //<![CDATA[
  65  document.write("&#"+"46");
  66  //]]>
  67  </script><noscript>(.)</noscript>', $part[3]);
  68      
  69      return $part[1].$part[2].$part[3];
  70      
  71  }
  72  
  73  
  74  ?>


Generated: Wed Dec 30 05:55:15 2009 Cross-referenced by PHPXref 0.7