[ Index ]

PHP Cross Reference of phpwcms V1.5.0 _r431 (28.01.12)

title

Body

[close]

/include/inc_front/content/cnt_functions/ -> cnt23.func.inc.php (source)

   1  <?php
   2  
   3  /*************************************************************************************
   4     Copyright notice
   5     
   6     (c) 2002-2012 Oliver Georgi <oliver@phpwcms.de> // All rights reserved.
   7   
   8     This script is part of PHPWCMS. The PHPWCMS web content management system is
   9     free software; you can redistribute it and/or modify it under the terms of
  10     the GNU General Public License as published by the Free Software Foundation;
  11     either version 2 of the License, or (at your option) any later version.
  12    
  13     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  14     A copy is found in the textfile GPL.txt and important notices to the license 
  15     from the author is found in LICENSE.txt distributed with these scripts.
  16    
  17     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  18     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  19     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  20   
  21     This copyright notice MUST APPEAR in all copies of the script!
  22  *************************************************************************************/
  23  
  24  // necessary form functions
  25  
  26  // Get Field specific class enhanced by error class
  27  function getFieldErrorClass($field_class, $error_class) {
  28      return trim($field_class.' '.$error_class);
  29  }
  30  
  31  
  32  function block_comment_spam(&$POST_val, $field_names=NULL) {
  33      
  34      global $cnt_form;
  35  
  36      if(is_array($field_names)) {
  37          $spam_identified = false;
  38          foreach($field_names as $field_name) {
  39              if(!$spam_identified && !empty($POST_val[$field_name]) && empty($GLOBALS['POST_ERR'][$field_name])) {    
  40                  // check against Spam BB Code
  41                  if(preg_match('/\[link=|\[url=|SEO /i', $POST_val[$field_name]) || count(explode('http:/', strtolower($POST_val[$field_name]))) > 2 || linksleeve_comment_check($POST_val[$field_name]) == 'SPAM') {            
  42                      // spam trying
  43                      $GLOBALS['POST_ERR'][$field_name] = empty($cnt_form["fields"][$field_name]['error']) ? '@@Content looks like Spam.@@' : $cnt_form["fields"][$field_name]['error'];
  44                      // we need to block only once
  45                      $spam_identified = true;
  46                  }
  47              }
  48          }        
  49      }
  50  }
  51  
  52  function linksleeve_comment_check($content) {
  53  
  54      $data    = 'content='.$content;
  55      $buf    = ''; 
  56      
  57      $fp         = fsockopen("www.linksleeve.org", 80, $errno, $errstr, 30);
  58      
  59      if(!$fp) {
  60          return NULL;
  61      }
  62      
  63      $header  = "POST /pslv.php HTTP/1.0\r\n";
  64      $header .= "Host: www.linksleeve.org\r\n";
  65      $header .= "Content-type: application/x-www-form-urlencoded\r\n";
  66      $header .= "Content-length: " . strlen($data) . "\r\n";
  67      $header .= "User-agent: Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)\r\n";
  68      $header .= "Connection: close\r\n\r\n";
  69      $header .= $data;
  70      
  71      fputs($fp, $header, strlen($header));
  72      
  73      while (!feof($fp)) {
  74          $buf .= fgets($fp, 128);
  75      }
  76      
  77      fclose($fp);
  78      
  79      return !stristr($buf,"-slv-1-/slv-") ? 'SPAM' : 'HAM';
  80  }
  81  
  82  
  83  ?>


Generated: Sun Jan 29 16:31:14 2012 Cross-referenced by PHPXref 0.7.1