コード例 #1
0
ファイル: jbadword.class.php プロジェクト: joomux/jTips
 /**
  * Load one or more badword objects by passing an array of key value pairs to lookup
  * the record on non-key fields and to perform joins
  *
  * @return mixed An array if more than one, otherwise the object
  */
 function loadByParams($params = array(), $limit = FALSE, $offset = FALSE)
 {
     global $database;
     $extra_clause = "";
     if ($limit !== FALSE and !empty($limit)) {
         $extra_clause .= " LIMIT {$limit}";
     }
     if ($offset !== FALSE and !empty($offset)) {
         $extra_clause .= " OFFSET {$offset}";
     }
     $query = "SELECT id FROM " . $this->_tbl . " " . buildWhere($params) . " {$extra_clause};";
     $database->setQuery($query);
     $database->query();
     if ($database->getNumRows() > 1) {
         $jObjs = array();
         $list = (array) $database->loadAssocList();
         foreach ($list as $row => $id) {
             $jObj = new jBadWord($database);
             $jObj->load($id['id']);
             array_push($jObjs, $jObj);
         }
         return $jObjs;
     } else {
         if ($database->getNumRows() == 1) {
             $this->load($database->loadResult());
             return $this;
         } else {
             return FALSE;
         }
     }
 }
コード例 #2
0
ファイル: CheckComment.php プロジェクト: joomux/jTips
 * Website: www.jtips.com.au
 * @author Jeremy Roberts
 * @copyright Copyright © 2009, jTips
 * @license Commercial - See website for details
 * 
 * @since 2.1 - 16/10/2008
 * @version 2.1
 * @package jTips
 * 
 * Description: 
 */
global $database, $mosConfig_absolute_path;
ob_clean();
require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jbadword.class.php';
$comment = jTipsGetParam($_REQUEST, 'comment', '');
$jBad = new jBadWord($database);
$badwords = forceArray($jBad->loadByParams(array()));
$count = $deleted = $replaced = 0;
$results = array();
foreach ($badwords as $jBadWord) {
    $search = '/' . $jBadWord->badword . '/' . ($jBadWord->match_case == 1 ? 'i' : '');
    $found = preg_match_all($search, $comment, $matches);
    if ($found > 0) {
        $count++;
        $found = $found + $jBadWord->hits;
        $jBadWord->hits = $found;
        if ($jBadWord->action == 'delete') {
            $deleted++;
            array_push($results, 0);
        } else {
            $new_comment = preg_replace($search, $jBadWord->replace, $comment);
コード例 #3
0
ファイル: list.php プロジェクト: joomux/jTips
 * @package jTips
 * 
 * Description: Prepares a paginated list of badwords
 */
global $database, $jTips;
require_once 'components/com_jtips/classes/jbadword.class.php';
$formData = array('title' => $jLang['_ADMIN_BW_HEADER'], 'editTask' => 'edit', 'module' => 'BadWords', 'icon' => 'badwords');
$currentDir = jTipsGetParam($_REQUEST, 'filter_order_Dir', 'asc');
if ($currentDir == 'asc') {
    $dir = 'desc';
} else {
    $dir = 'asc';
}
//The header row
$header = array('', "<a href='javascript:tableOrdering(\"badword\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_BW_BAD_WORD'] . "</a>", "<a href='javascript:tableOrdering(\"match_case\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_BW_CASE_SENSITIVE'] . "</a>", "<a href='javascript:tableOrdering(\"action\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_BW_ACTION'] . "</a>", "<a href='javascript:tableOrdering(\"replace\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_BW_REPLACEMENT'] . "</a>", "<a href='javascript:tableOrdering(\"hits\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_BW_HITS'] . "</a>", "<a href='javascript:tableOrdering(\"updated\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_BW_UPDATED'] . "</a>");
$jBadWord = new jBadWord($database);
$limitstart = jTipsGetParam($_REQUEST, 'limitstart', 0);
$limit = jTipsGetParam($_REQUEST, 'limit', 25);
$direction = jTipsGetParam($_REQUEST, 'filter_order_Dir', 'asc');
if (empty($direction)) {
    $direction = 'asc';
}
$orderby = jTipsGetParam($_REQUEST, 'filter_order', 'badword');
if (empty($orderby)) {
    $orderby = 'badword';
}
$params = array('order' => array('type' => 'order', 'direction' => $direction, 'by' => $orderby));
$jBadWords = forceArray($jBadWord->loadByParams($params, $limit, $limitstart));
$pageNav = new mosPageNav($jBadWord->getCount(), $limitstart, $limit);
$data = array();
$i = 0;
コード例 #4
0
ファイル: functions.inc.php プロジェクト: joomux/jTips
function cleanComment($comment)
{
    global $jTips;
    if ($jTips['EnableCommentFilter'] != '1') {
        return $comment;
    }
    $badwords = jBadWord::loadAll();
    $count = $deleted = $replaced = 0;
    $results = array();
    foreach ($badwords as $jBadWord) {
        $search = '/' . $jBadWord->get('badword') . '/' . ($jBadWord->get('match_case') == 1 ? 'i' : '');
        $found = preg_match_all($search, $comment, $matches);
        if ($found > 0) {
            $count++;
            $found = $found + $jBadWord->get('hits');
            $jBadWord->set('hits', $found);
            if ($jBadWord->get('action') == 'delete') {
                $deleted++;
                array_push($results, 0);
            } else {
                $comment = preg_replace($search, $jBadWord->get('replace'), $comment);
                $replaced++;
                array_push($results, 1);
            }
            $jBadWord->save();
            continue;
        }
    }
    if (in_array(0, $results)) {
        return false;
    }
    return $comment;
}
コード例 #5
0
ファイル: save.php プロジェクト: joomux/jTips
defined('_JEXEC') or defined('_VALID_MOS') or die('Restricted Access');
/**
 * Website: www.jtips.com.au
 * @author Jeremy Roberts
 * @copyright Copyright &copy; 2009, jTips
 * @license Commercial - See website for details
 * 
 * @since 2.1 - 02/10/2008
 * @version 2.1
 * @package jTips
 * 
 * Description: Creates a new BadWord or updates an existing one.
 */
jTipsSpoofCheck();
global $database;
require_once 'components/com_jtips/classes/jbadword.class.php';
$focus = new jBadWord($database);
$id = jTipsGetParam($_REQUEST, 'id', false);
if ($id) {
    $focus->load($id);
}
$focus->bind($_POST);
if (jTipsGetParam($_REQUEST, 'reset_hits', 0) == 1) {
    $focus->hits = 0;
}
if ($focus->save()) {
    $message = $jlang['_ADMIN_BADWORD_SAVE_SUCCESS'];
} else {
    $message = $jlang['_ADMIN_BADWORD_SAVE_FAILURE'];
}
mosRedirect('index2.php?option=com_jtips&task=list&module=BadWords', $message);
コード例 #6
0
ファイル: edit.php プロジェクト: joomux/jTips
<?php

defined('_JEXEC') or defined('_VALID_MOS') or die('Restricted Access');
/**
 * Website: www.jtips.com.au
 * @author Jeremy Roberts
 * @copyright Copyright &copy; 2009, jTips
 * @license Commercial - See website for details
 * 
 * @since 2.1 - 02/10/2008
 * @version 2.1
 * @package jTips
 * 
 * Description: 
 */
jTipsSpoofCheck();
global $database, $jTips, $jLang;
require_once 'components/com_jtips/classes/jbadword.class.php';
$focus = new jBadWord($database);
$ids = jTipsGetParam($_REQUEST, 'cid', array());
//Do we have an existing Season?
$id = array_shift($ids);
if (is_numeric($id)) {
    $focus->load($id);
}
$title = $jLang['_ADMIN_BW_HEADER'] . ": " . ($focus->exists() ? $jLang['_ADMIN_OTHER_EDIT'] : $jLang['_ADMIN_OTHER_NEW']);
$mainframe->addCustomHeadTag("<script type='text/javascript' src='components/com_jtips/modules/BadWords/Edit.js'></script>");
$formData = array('basic' => array('legend' => '_ADMIN_EDIT_MAIN_INFORMATION', 'fields' => array('id' => array('field' => array('type' => 'hidden', 'attributes' => array('type' => 'hidden', 'name' => 'id', 'id' => 'id', 'value' => $focus->id))), 'badword' => array('label' => '_ADMIN_BW_BAD_WORD', 'field' => array('type' => 'text', 'attributes' => array('size' => 50, 'name' => 'badword', 'id' => 'badword', 'class' => 'inputbox', 'value' => jTipsStripslashes(htmlentities($focus->badword, ENT_QUOTES)), 'type' => 'text'))), 'match_case' => array('label' => '_ADMIN_BW_CASE_SENSITIVE', 'field' => array('type' => 'bool', 'attributes' => array('name' => 'match_case', 'id' => 'match_case', 'class' => 'inputbox'), 'selected' => $focus->match_case)), 'action' => array('label' => '_ADMIN_BW_ACTION', 'field' => array('type' => 'select', 'attributes' => array('name' => 'action', 'id' => 'action', 'class' => 'inputbox', 'onChange' => 'toggleReplace();'), 'options' => array(jTipsHTML::makeOption('', $jLang['_ADMIN_CONF_NONE']), jTipsHTML::makeOption('replace', $jLang['_ADMIN_CONF_COMMENTSACTION_REPLACE']), jTipsHTML::makeOption('delete', $jLang['_ADMIN_CONF_COMMENTSACTION_DELETE'])), 'selected' => $focus->action)), 'replace' => array('label' => '_ADMIN_BW_REPLACEMENT', 'field' => array('type' => 'text', 'attributes' => array('size' => 50, 'name' => 'replace', 'id' => 'replace', 'class' => 'inputbox', 'type' => 'text', 'disabled' => 'disabled', 'value' => jTipsStripslashes(htmlentities($focus->replace, ENT_QUOTES))))), 'reset_hits' => array('label' => '_ADMIN_BW_RESET_HITS', 'field' => array('type' => 'bool', 'attributes' => array('name' => 'reset_hits', 'id' => 'reset_hits', 'class' => 'inputbox'), 'selected' => 0)))));
jTipsAdminDisplay::EditView($title, $formData, 'badwords');
コード例 #7
0
ファイル: remove.php プロジェクト: joomux/jTips
<?php

defined('_JEXEC') or defined('_VALID_MOS') or die('Restricted Access');
/**
 * Website: www.jtips.com.au
 * @author Jeremy Roberts
 * @copyright Copyright &copy; 2009, jTips
 * @license Commercial - See website for details
 * 
 * @since 2.1 - 02/10/2008
 * @version 2.1
 * @package jTips
 * 
 * Description: 
 */
jTipsSpoofCheck();
global $database;
require_once 'components/com_jtips/classes/jbadword.class.php';
$ids = jTipsGetParam($_REQUEST, 'cid', array());
if (!is_array($ids)) {
    mosRedirect('index2.php?option=com_jtips&task=list&module=BadWords', 'Invalid Selection');
}
$focus = new jBadWord($database);
$deleted = 0;
foreach ($ids as $id) {
    if ($focus->destroy($id)) {
        $deleted++;
    }
}
$message = "Deleted {$deleted}/" . count($id) . " BadWords";
mosRedirect('index2.php?option=com_jtips&task=list&module=BadWords', $message);
コード例 #8
0
ファイル: process.php プロジェクト: joomux/jTips
 * Website: www.jtips.com.au
 * @author Jeremy Roberts
 * @copyright Copyright &copy; 2009, jTips
 * @license Commercial - See website for details
 * 
 * @since 2.1 - 02/10/2008
 * @version 2.1
 * @package jTips
 * 
 * Description: 
 */
jTipsSpoofCheck();
global $database;
require_once 'components/com_jtips/classes/jbadword.class.php';
require_once 'components/com_jtips/classes/jcomment.class.php';
$jBadWordFocus = new jBadWord($database);
$jCommentFocus = new jComment($database);
$badwords = forceArray($jBadWordFocus->loadByParams());
$comments = forceArray($jCommentFocus->loadByParams());
$count = $deleted = $replaced = 0;
foreach ($comments as $jComment) {
    foreach ($badwords as $jBadWord) {
        $search = '/' . $jBadWord->badword . '/' . ($jBadWord->match_case == 1 ? 'i' : '');
        $found = preg_match_all($search, $jComment->comment, $matches);
        if ($found > 0) {
            $count++;
            $found = $found + $jBadWord->hits;
            $jBadWord->hits = $found;
            if ($jBadWord->action == 'delete') {
                $jComment->delete($jComment->id);
                $deleted++;