Source for file mosemailcloak.php

Documentation is available at mosemailcloak.php

  1. <?php
  2. /**
  3. @package Mambo
  4. @author Mambo Foundation Inc see README.php
  5. @copyright Mambo Foundation Inc.
  6. *  See COPYRIGHT.php for copyright notices and details.
  7. @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see
  8. *  LICENSE.php
  9. *  Mambo is free software; you can redistribute it and/or
  10. *  modify it under the terms of the GNU General Public License
  11. *  as published by the Free Software Foundation; version 2 of the
  12. *  License.
  13. */
  14.  
  15. /** ensure this file is being included by a parent file */
  16. defined'_VALID_MOS' or die'Direct Access to this location is not allowed.' );
  17.  
  18. $_MAMBOTS->registerFunction'onPrepareContent''botMosEmailCloak' );
  19.  
  20. /**
  21. * Mambot that Cloaks all emails in content from spambots via javascript
  22. */
  23. function botMosEmailCloak$published&$row&$cparams$page=0$params {
  24.     global $database;
  25.  
  26.     // load mambot params info
  27.     /*$query = "SELECT id FROM #__mambots WHERE element = 'mosemailcloak' AND folder = 'content'";
  28.     $database->setQuery( $query );
  29.     $id     = $database->loadResult();
  30.     $mambot = new mosMambot( $database );
  31.     $mambot->load( $id );*/
  32.     $mambots =mosMambotHandler::getInstance();
  33.     $mambot $mambots->getBot('mosemailcloack','content');
  34.     $params =new mosParameters( (isset($mambot->params)?$mambot->params:'') );
  35.         
  36.      $mode        $params->def'mode');
  37.      //$search     = "([[:alnum:]_\.\-]+)(\@[[:alnum:]\.\-]+\.+)([[:alnum:]\.\-]+)";
  38.      $search     "([[:alnum:]_\.\-]+)(\@[[:alnum:]\.\-]+\.+)([[:alnum:]\.\-\?\=\%]+)";
  39.      $search_text     "([[:alnum:][:space:][:punct:]][^<>]+)";
  40.  
  41.     // search for derivativs of link code <a href="mailto:email@amail.com">email@amail.com</a>
  42.     // extra handling for inclusion of title and target attributes either side of href attribute
  43.     $searchlink    "(<a [[:alnum:] _\"\'=\@\.\-]*href=[\"\']mailto:"$search ."[\"\'][[:alnum:] _\"\'=\@\.\-]*>)"$search ."</a>";
  44.     if (is_callable(array($row'getText'))) $localtext $row->getText();
  45.     else $localtext $row->text;
  46.     whileeregi$searchlink$localtext$regs ) ) {
  47.         $mail         $regs[2$regs[3$regs[4];
  48.         $mail_text     $regs[5$regs[6$regs[7];
  49.  
  50.         // check to see if mail text is different from mail addy
  51.         if $mail_text {
  52.             $replacement     mosHTML::emailCloaking$mail$mode$mail_text );
  53.         else {
  54.             $replacement     mosHTML::emailCloaking$mail$mode );
  55.         }
  56.  
  57.         // replace the found address with the js cloacked email
  58.         $localtext     str_replace$regs[0]$replacement$localtext );
  59.     }
  60.  
  61.     // search for derivativs of link code <a href="mailto:email@amail.com">anytext</a>
  62.     // extra handling for inclusion of title and target attributes either side of href attribute
  63.     $searchlink    "(<a [[:alnum:] _\"\'=\@\.\-]*href=[\"\']mailto:"$search ."[\"\'][[:alnum:] _\"\'=\@\.\-]*)>"$search_text ."</a>";
  64.     whileeregi$searchlink$localtext$regs ) ) {
  65.         $mail         $regs[2$regs[3$regs[4];
  66.         $mail_text     $regs[5];
  67.  
  68.         $replacement     mosHTML::emailCloaking$mail$mode$mail_text);
  69.  
  70.         // replace the found address with the js cloacked email
  71.         $localtext     str_replace$regs[0]$replacement$localtext );
  72.     }
  73.  
  74.     // search for plain text email@amail.com
  75.     whileeregi$search$localtext$regs ) ) {
  76.         $mail $regs[0];
  77.  
  78.         $replacement mosHTML::emailCloaking$mail$mode );
  79.  
  80.         // replace the found address with the js cloacked email
  81.         $localtext str_replace$regs[0]$replacement$localtext );
  82.     }
  83.  
  84.     if (is_callable(array($row'saveText'))) $row->saveText($localtext);
  85.     else $row->text $localtext;
  86.  
  87. }
  88. ?>

Documentation generated on Mon, 05 May 2008 16:21:29 +0400 by phpDocumentor 1.4.0