コード例 #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
ファイル: save.php プロジェクト: joomux/jTips
defined('_JEXEC') or defined('_VALID_MOS') or die('Restricted Access');
/**
 * Website: www.jtips.com.au
 * @author Jeremy Roberts
 * @copyright Copyright © 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);