本文整理汇总了PHP中vRequest::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP vRequest::filter方法的具体用法?PHP vRequest::filter怎么用?PHP vRequest::filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vRequest
的用法示例。
在下文中一共展示了vRequest::filter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Bind the post data to the JUser object and the VM tables, then saves it
* It is used to register new users
* This function can also change already registered users, this is important when a registered user changes his email within the checkout.
*
* @author Max Milbers
* @author Oscar van Eijk
* @return boolean True is the save was successful, false otherwise.
*/
public function store(&$data)
{
$message = '';
vRequest::vmCheckToken('Invalid Token, while trying to save user');
if (empty($data)) {
vmError('Developer notice, no data to store for user');
return false;
}
//To find out, if we have to register a new user, we take a look on the id of the usermodel object.
//The constructor sets automatically the right id.
$new = false;
if (empty($this->_id) or $this->_id < 1) {
$new = true;
$user = new JUser();
//thealmega http://forum.virtuemart.net/index.php?topic=99755.msg393758#msg393758
} else {
$cUser = JFactory::getUser();
if (!vmAccess::manager('user.edit') and $cUser->id != $this->_id) {
vmWarn('Insufficient permission');
return false;
}
$user = JFactory::getUser($this->_id);
}
$gid = $user->get('gid');
// Save original gid
// Preformat and control user datas by plugin
JPluginHelper::importPlugin('vmextended');
JPluginHelper::importPlugin('vmuserfield');
$dispatcher = JDispatcher::getInstance();
$valid = true;
$dispatcher->trigger('plgVmOnBeforeUserfieldDataSave', array(&$valid, $this->_id, &$data, $user));
// $valid must be false if plugin detect an error
if (!$valid) {
return false;
}
// Before I used this "if($cart && !$new)"
// This construction is necessary, because this function is used to register a new JUser, so we need all the JUser data in $data.
// On the other hand this function is also used just for updating JUser data, like the email for the BT address. In this case the
// name, username, password and so on is already stored in the JUser and dont need to be entered again.
if (empty($data['email'])) {
$email = $user->get('email');
if (!empty($email)) {
$data['email'] = $email;
}
} else {
$data['email'] = vRequest::filter($data['email'], FILTER_VALIDATE_EMAIL, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
}
//$data['email'] = str_replace(array('\'','"',',','%','*','/','\\','?','^','`','{','}','|','~'),array(''),$data['email']);
//This is important, when a user changes his email address from the cart,
//that means using view user layout edit_address (which is called from the cart)
$user->set('email', $data['email']);
if (empty($data['name'])) {
$name = $user->get('name');
if (!empty($name)) {
$data['name'] = $name;
}
} else {
$data['name'] = vRequest::filter($data['name'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
}
$data['name'] = str_replace(array('\'', '"', ',', '%', '*', '/', '\\', '?', '^', '`', '{', '}', '|', '~'), array(''), $data['name']);
if (empty($data['username'])) {
$username = $user->get('username');
if (!empty($username)) {
$data['username'] = $username;
} else {
$data['username'] = vRequest::filter($data['username'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
}
}
if (empty($data['password'])) {
$data['password'] = vRequest::getCmd('password', '');
if ($data['password'] != vRequest::get('password')) {
vmError('Password contained invalid character combination.');
return false;
}
}
if (empty($data['password2'])) {
$data['password2'] = vRequest::getCmd('password2');
if ($data['password2'] != vRequest::get('password2')) {
vmError('Password2 contained invalid character combination.');
return false;
}
}
if (!$new and empty($data['password2'])) {
unset($data['password']);
unset($data['password2']);
}
if (!vmAccess::manager('core')) {
$whiteDataToBind = array();
if (isset($data['name'])) {
$whiteDataToBind['name'] = $data['name'];
}
//.........这里部分代码省略.........
示例2: sortSearchListQuery
/**
* New function for sorting, searching, filtering and pagination for product ids.
*
* @author Max Milbers
*/
function sortSearchListQuery($onlyPublished = TRUE, $virtuemart_category_id = FALSE, $group = FALSE, $nbrReturnProducts = FALSE, $langFields = array())
{
$app = JFactory::getApplication();
$db = JFactory::getDbo();
//User Q.Stanley said that removing group by is increasing the speed of product listing in a bigger shop (10k products) by factor 60
//So what was the reason for that we have it? TODO experiemental, find conditions for the need of group by
$groupBy = ' group by p.`virtuemart_product_id` ';
//administrative variables to organize the joining of tables
$joinLang = false;
$joinCategory = FALSE;
$joinCatLang = false;
$joinMf = FALSE;
$joinMfLang = false;
$joinPrice = FALSE;
$joinCustom = FALSE;
$joinShopper = FALSE;
$joinChildren = FALSE;
//$joinLang = false;
$orderBy = ' ';
$where = array();
//$isSite = $app->isSite ();
$isSite = true;
if ($app->isAdmin() or vRequest::get('manage', false) and vmAccess::getVendorId()) {
$isSite = false;
}
if (!empty($this->keyword) and $this->keyword !== '' and $group === FALSE) {
$keyword = vRequest::filter(html_entity_decode($this->keyword, ENT_QUOTES, "UTF-8"), FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_LOW);
$keyword = '"%' . str_replace(array(' ', '-'), '%', $keyword) . '%"';
//$keyword = '"%' . $db->escape ($this->keyword, TRUE) . '%"';
vmdebug('Current search field', $this->valid_search_fields);
foreach ($this->valid_search_fields as $searchField) {
if ($searchField == 'category_name' || $searchField == 'category_description') {
$joinCatLang = true;
} else {
if ($searchField == 'mf_name') {
$joinMfLang = true;
} else {
if ($searchField == 'product_price') {
$joinPrice = TRUE;
} else {
if ($searchField == 'product_name' or $searchField == 'product_s_desc' or $searchField == 'product_desc' or $searchField == 'slug') {
$langFields[] = $searchField;
//if (strpos ($searchField, '`') !== FALSE){
//$searchField = '`l`.'.$searchField;
$keywords_plural = preg_replace('/\\s+/', '%" AND ' . $searchField . ' LIKE "%', $keyword);
if ($app->isSite() and VmConfig::$defaultLang != VmConfig::$vmlang and !VmConfig::get('prodOnlyWLang', false)) {
$filter_search[] = '`ld`.' . $searchField . ' LIKE ' . $keywords_plural;
if (VmConfig::$defaultLang != VmConfig::$jDefLang) {
$filter_search[] = '`ljd`.' . $searchField . ' LIKE ' . $keywords_plural;
}
}
$searchField = '`l`.' . $searchField;
//}
}
}
}
}
if (strpos($searchField, '`') !== FALSE) {
$keywords_plural = preg_replace('/\\s+/', '%" AND ' . $searchField . ' LIKE "%', $keyword);
$filter_search[] = $searchField . ' LIKE ' . $keywords_plural;
} else {
$keywords_plural = preg_replace('/\\s+/', '%" AND `' . $searchField . '` LIKE "%', $keyword);
$filter_search[] = '`' . $searchField . '` LIKE ' . $keywords_plural;
//$filter_search[] = '`' . $searchField . '` LIKE ' . $keyword;
}
}
if (!empty($filter_search)) {
$where[] = '(' . implode(' OR ', $filter_search) . ')';
} else {
$where[] = '`l`.product_name LIKE ' . $keyword;
$langFields[] = 'product_name';
//If they have no check boxes selected it will default to product name at least.
}
}
// vmdebug('my $this->searchcustoms ',$this->searchcustoms);
if (!empty($this->searchcustoms)) {
$joinCustom = TRUE;
foreach ($this->searchcustoms as $key => $searchcustom) {
$custom_search[] = '(pf.`virtuemart_custom_id`="' . (int) $key . '" and pf.`customfield_value` like "%' . $db->escape($searchcustom, TRUE) . '%")';
}
$where[] = " ( " . implode(' OR ', $custom_search) . " ) ";
}
if ($isSite and !VmConfig::get('use_as_catalog', 0)) {
if (VmConfig::get('stockhandle', 'none') == 'disableit_children') {
$where[] = ' ( (p.`product_in_stock` - p.`product_ordered`) >"0" OR (children.`product_in_stock` - children.`product_ordered`) > "0") ';
$joinChildren = TRUE;
} else {
if (VmConfig::get('stockhandle', 'none') == 'disableit') {
$where[] = ' p.`product_in_stock` - p.`product_ordered` >"0" ';
}
}
}
if ($virtuemart_category_id > 0) {
$joinCategory = TRUE;
$where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id;
//.........这里部分代码省略.........
示例3: getOrderByList
/**
* Get the Order By Select List
*
* notice by Max Milbers html tags should never be in a model. This function should be moved to a helper or simular,...
*
* @author Kohl Patrick, Max Milbers
* @access public
* @param $fieds from config Back-end
* @return $orderByList
* Order,order By, manufacturer and category link List to echo Out
**/
function getOrderByList($virtuemart_category_id = FALSE)
{
$getArray = vRequest::getGet(FILTER_SANITIZE_STRING);
$fieldLink = '';
foreach ($getArray as $key => $value) {
$key = vRequest::filter($key, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_ENCODE_LOW);
$value = vRequest::filter($value, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_ENCODE_LOW);
if (is_array($value)) {
foreach ($value as $k => $v) {
if ($v == '') {
continue;
}
$fieldLink .= '&' . urlencode($key) . '[' . urlencode($k) . ']' . '=' . urlencode($v);
}
} else {
if ($key == 'dir' or $key == 'orderby') {
continue;
}
if ($value == '') {
continue;
}
$fieldLink .= '&' . urlencode($key) . '=' . urlencode($value);
}
}
$fieldLink = 'index.php?' . ltrim($fieldLink, '&');
$orderDirLink = '';
$orderDirConf = VmConfig::get('prd_brws_orderby_dir');
$orderDir = vRequest::getCmd('dir', $orderDirConf);
if ($orderDir != $orderDirConf) {
$orderDirLink .= '&dir=' . $orderDir;
//was '&order='
}
$orderbyTxt = '';
$orderby = vRequest::getString('orderby', VmConfig::get('browse_orderby_field'));
$orderby = $this->checkFilterOrder($orderby);
$orderbyCfg = VmConfig::get('browse_orderby_field');
if ($orderby != $orderbyCfg) {
$orderbyTxt = '&orderby=' . $orderby;
}
$manufacturerTxt = '';
$manufacturerLink = '';
if (VmConfig::get('show_manufacturers')) {
$manuM = VmModel::getModel('manufacturer');
vmSetStartTime('mcaching');
$mlang = (!VmConfig::get('prodOnlyWLang', false) and VmConfig::$defaultLang != VmConfig::$vmlang and Vmconfig::$langCount > 1);
if (true) {
$cache = JFactory::getCache('com_virtuemart_cat_manus', 'callback');
$cache->setCaching(true);
$manufacturers = $cache->call(array('VirtueMartModelManufacturer', 'getManufacturersOfProductsInCategory'), $virtuemart_category_id, VmConfig::$vmlang, $mlang);
vmTime('Manufacturers by Cache', 'mcaching');
} else {
$manufacturers = $manuM->getManufacturersOfProductsInCategory($virtuemart_category_id, VmConfig::$vmlang, $mlang);
vmTime('Manufacturers by function', 'mcaching');
}
// manufacturer link list
$manufacturerLink = '';
$virtuemart_manufacturer_id = vRequest::getInt('virtuemart_manufacturer_id', '');
if ($virtuemart_manufacturer_id != '') {
$manufacturerTxt = '&virtuemart_manufacturer_id=' . $virtuemart_manufacturer_id;
}
if (count($manufacturers) > 0) {
$manufacturerLink = '<div class="orderlist">';
if ($virtuemart_manufacturer_id > 0) {
$allLink = str_replace($manufacturerTxt, $fieldLink, '');
$allLink .= '&virtuemart_manufacturer_id=0';
$manufacturerLink .= '<div><a title="" href="' . JRoute::_($allLink . $orderbyTxt . $orderDirLink, FALSE) . '">' . vmText::_('COM_VIRTUEMART_SEARCH_SELECT_ALL_MANUFACTURER') . '</a></div>';
}
if (count($manufacturers) > 1) {
foreach ($manufacturers as $mf) {
$link = JRoute::_($fieldLink . '&virtuemart_manufacturer_id=' . $mf->virtuemart_manufacturer_id . $orderbyTxt . $orderDirLink, FALSE);
if ($mf->virtuemart_manufacturer_id != $virtuemart_manufacturer_id) {
$manufacturerLink .= '<div><a title="' . $mf->mf_name . '" href="' . $link . '">' . $mf->mf_name . '</a></div>';
} else {
$currentManufacturerLink = '<div class="title">' . vmText::_('COM_VIRTUEMART_PRODUCT_DETAILS_MANUFACTURER_LBL') . '</div><div class="activeOrder">' . $mf->mf_name . '</div>';
}
}
} elseif ($virtuemart_manufacturer_id > 0) {
$currentManufacturerLink = '<div class="title">' . vmText::_('COM_VIRTUEMART_PRODUCT_DETAILS_MANUFACTURER_LBL') . '</div><div class="activeOrder">' . $manufacturers[0]->mf_name . '</div>';
} else {
$currentManufacturerLink = '<div class="title">' . vmText::_('COM_VIRTUEMART_PRODUCT_DETAILS_MANUFACTURER_LBL') . '</div><div class="Order"> ' . $manufacturers[0]->mf_name . '</div>';
}
$manufacturerLink .= '</div>';
}
}
/* order by link list*/
$orderByLink = '';
$fields = VmConfig::get('browse_orderby_fields');
if (count($fields) > 1) {
$orderByLink = '<div class="orderlist">';
//.........这里部分代码省略.........