当前位置: 首页>>代码示例>>PHP>>正文


PHP Sanitize类代码示例

本文整理汇总了PHP中Sanitize的典型用法代码示例。如果您正苦于以下问题:PHP Sanitize类的具体用法?PHP Sanitize怎么用?PHP Sanitize使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Sanitize类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: purchase_product

 function purchase_product()
 {
     // Clean up the post
     uses('sanitize');
     $clean = new Sanitize();
     $clean->paranoid($_POST);
     // Check if we have an active cart, if there is no order_id set, then lets create one.
     if (!isset($_SESSION['Customer']['order_id'])) {
         $new_order = array();
         $new_order['Order']['order_status_id'] = 0;
         // Get default shipping & payment methods and assign them to the order
         $default_payment = $this->Order->PaymentMethod->find(array('default' => '1'));
         $new_order['Order']['payment_method_id'] = $default_payment['PaymentMethod']['id'];
         $default_shipping = $this->Order->ShippingMethod->find(array('default' => '1'));
         $new_order['Order']['shipping_method_id'] = $default_shipping['ShippingMethod']['id'];
         // Save the order
         $this->Order->save($new_order);
         $order_id = $this->Order->getLastInsertId();
         $_SESSION['Customer']['order_id'] = $order_id;
         global $order;
         $order = $new_order;
     }
     // Add the product to the order from the component
     $this->OrderBase->add_product($_POST['product_id'], $_POST['product_quantity']);
     global $config;
     $content = $this->Content->read(null, $_POST['product_id']);
     $this->redirect('/product/' . $content['Content']['alias'] . $config['URL_EXTENSION']);
 }
开发者ID:risnandar,项目名称:testing,代码行数:28,代码来源:cart_controller.php

示例2: getrss

 function getrss()
 {
     uses('Sanitize');
     Configure::write('debug', '0');
     //turn debugging off; debugging breaks ajax
     $this->layout = 'ajax';
     $mrClean = new Sanitize();
     $limit = 5;
     $start = 0;
     if (empty($this->params['form']['url'])) {
         die('Incorrect use');
     }
     $url = $this->params['form']['url'];
     if (!empty($this->params['form']['limit'])) {
         $limit = $mrClean->paranoid($this->params['form']['limit']);
     }
     if (!empty($this->params['form']['start'])) {
         $start = $mrClean->paranoid($this->params['form']['start']);
     }
     $feed = $this->Simplepie->feed_paginate($url, (int) $start, (int) $limit);
     $out['totalCount'] = $feed['quantity'];
     $out['title'] = $feed['title'];
     $out['image_url'] = $feed['image_url'];
     $out['image_width'] = $feed['image_width'];
     $out['image_height'] = $feed['image_height'];
     foreach ($feed['items'] as $item) {
         $tmp['title'] = strip_tags($item->get_title());
         $tmp['url'] = strip_tags($item->get_permalink());
         $tmp['description'] = strip_tags($item->get_description(), '<p><br><img><a><b>');
         $tmp['date'] = strip_tags($item->get_date('d/m/Y'));
         $out['items'][] = $tmp;
     }
     $this->set('json', $out);
 }
开发者ID:vad,项目名称:taolin,代码行数:34,代码来源:wrappers_controller.php

示例3: _cleanKeywords

 /**
  * clean keywords string
  */
 private function _cleanKeywords($data)
 {
     $keywords = $data['keywords'];
     if (!empty($keywords)) {
         $san = new Sanitize();
         $keywords = $san->html($keywords);
     } else {
         $keywords = '';
     }
     return $keywords;
 }
开发者ID:yamaguchitarou,项目名称:bakesale,代码行数:14,代码来源:search_controller.php

示例4: detalleIndex_get

 public function detalleIndex_get()
 {
     $sanador = new Sanitize();
     $user = $sanador->clean_string($this->get('usuario'));
     $validacion = $this->validaUsuario($user);
     if ($validacion) {
         $respuesta = $this->llenaIndex($user);
     } else {
         $respuesta = new Response(400, "withOutUser");
     }
     $this->response($respuesta);
 }
开发者ID:sabagip,项目名称:shop_register,代码行数:12,代码来源:User.php

示例5: logueo_get

 public function logueo_get()
 {
     $sanador = new Sanitize();
     $user = $sanador->clean_string($this->get('usuario'));
     $pass = $sanador->clean_string($this->get('pass'));
     $response = $this->m_consultas->login($user, $pass);
     if ($response == FALSE) {
         $respuesta = new Response(400, "userPassFail");
         $this->response($respuesta);
     }
     $respuesta = new Response(200, $response);
     $this->response($respuesta);
 }
开发者ID:sabagip,项目名称:shop_register,代码行数:13,代码来源:Login.php

示例6: addComment

 function addComment(&$Model, $params, $user_id, $tpl_params = array(), $comment_type_name = null, $model_alias = null)
 {
     $mrClean = new Sanitize();
     $notification_data = a();
     $foreign_id = $params['form']['foreign_id'];
     $text = $mrClean->html($params['form']['comment']);
     $comment = array('Comment' => array('body' => $text, 'name' => $user_id, 'email' => 'abc@example.com'));
     $out = $Model->createComment($foreign_id, $comment);
     $comment_id = $Model->Comment->id;
     if (!$model_alias) {
         $model_alias = $Model->alias;
     }
     // Retrieve ids belonging to users that have be notified (eg each users that commented this object before)
     $comments = Set::extract($this->getComments($Model, $foreign_id, TRUE), '{n}.Comment.name');
     // Remove duplicated values
     $tbn = array_unique($comments);
     // Retrieve owner of the commented object
     $owner = $Model->read('user_id', $foreign_id);
     $owner_id = $owner[$model_alias]['user_id'];
     // owner should be notified as well
     if (!in_array($owner_id, $tbn)) {
         array_push($tbn, $owner_id);
     }
     $users = array_diff($tbn, array($user_id));
     if (!empty($users)) {
         $this->setupUserModel();
         $commenter = $this->user->read(array('name', 'surname'), $user_id);
         $owner = $this->user->read(array('name', 'surname'), $owner_id);
         $subject = $this->Conf->get('Site.name') . " comment notification";
         $domain = $this->Conf->get('Organization.domain');
         foreach ($users as $c_id) {
             // check whether the user is can be notified or not
             $active = $this->Acl->check(array('model' => 'User', 'foreign_key' => $c_id), 'site');
             $nfb = $this->user->read('notification', $c_id);
             if ($active && $nfb['User']['notification']) {
                 if ($c_id == $owner_id) {
                     $is_owner = true;
                 } else {
                     $is_owner = false;
                 }
                 array_push($notification_data, array('from' => 'noreply@' . $domain, 'to' => $this->user->getemail($c_id, $this->Conf->get('Organization.domain')), 'subject' => $subject, 'own' => $is_owner, 'owner' => $owner['User'], 'commenter' => $commenter['User']));
             }
         }
     }
     $Model->addtotimeline($tpl_params, null, 'comment', $user_id, $model_alias, $foreign_id, $comment_id, $comment_type_name);
     # clear cache
     clearCache($this->cacheName, '', '');
     return $notification_data;
 }
开发者ID:vad,项目名称:taolin,代码行数:49,代码来源:comment.php

示例7: createComment

 function createComment(&$model, $id, $data = array())
 {
     if (!empty($data[$this->__settings[$model->alias]['class']])) {
         unset($data[$model->alias]);
         $model->Comment->validate = array($this->__settings[$model->alias]['column_author'] => array('notempty' => array('rule' => array('notempty'))), $this->__settings[$model->alias]['column_content'] => array('notempty' => array('rule' => array('notempty'))), $this->__settings[$model->alias]['column_email'] => array('notempty' => array('rule' => array('notempty')), 'email' => array('rule' => array('email'), 'message' => 'Please enter a valid email address')), $this->__settings[$model->alias]['column_class'] => array('notempty' => array('rule' => array('notempty'))), $this->__settings[$model->alias]['column_foreign_id'] => array('notempty' => array('rule' => array('notempty'))), $this->__settings[$model->alias]['column_status'] => array('notempty' => array('rule' => array('notempty'))), $this->__settings[$model->alias]['column_points'] => array('notempty' => array('rule' => array('notempty')), 'numeric' => array('rule' => array('numeric'))));
         $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_class']] = $model->alias;
         $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_foreign_id']] = $id;
         $data[$this->__settings[$model->alias]['class']] = $this->_rateComment($model, $data['Comment']);
         if ($data[$this->__settings[$model->alias]['class']]['status'] == 'spam') {
             $data[$this->__settings[$model->alias]['class']]['active'] == 0;
         } else {
             if (Configure::read('Comments.auto_moderate') === true && $data[$this->__settings[$model->alias]['class']]['status'] != 'spam') {
                 $data[$this->__settings[$model->alias]['class']]['active'] == 1;
             }
         }
         if ($this->__settings[$model->alias]['sanitize']) {
             App::import('Sanitize');
             $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_author']] = Sanitize::clean($data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_author']]);
             $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_email']] = Sanitize::clean($data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_email']]);
             $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_content']] = Sanitize::clean($data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_content']]);
         } else {
             $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_author']] = $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_author']];
             $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_email']] = $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_email']];
             $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_content']] = $data[$this->__settings[$model->alias]['class']][$this->__settings[$model->alias]['column_content']];
         }
         if ($this->_checkForEmptyVal($data[$this->__settings[$model->alias]['class']]) == false) {
             $model->Comment->create();
             if ($model->Comment->save($data)) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:sdoney,项目名称:infinitas,代码行数:34,代码来源:commentable.php

示例8: getListingFavorites

 function getListingFavorites($listing_id, $user_id, $passedArgs)
 {
     $conditions = array();
     $avatar = Sanitize::getInt($passedArgs['module'], 'avatar', 1);
     // Only show users with avatars
     $count = Sanitize::getInt($passedArgs['module'], 'module_limit', 5);
     $module_id = Sanitize::getInt($passedArgs, 'module_id');
     $rand = Sanitize::getFloat($passedArgs, 'rand');
     $fields = array('Community.' . $this->realKey . ' AS `User.user_id`', 'User.name AS `User.name`', 'User.username AS `User.username`');
     if ($avatar) {
         $conditions[] = 'Community.thumb <> "components/com_community/assets/default_thumb.jpg"';
     }
     if ($listing_id) {
         $conditions[] = 'Community.' . $this->realKey . ' in (SELECT user_id FROM #__jreviews_favorites WHERE content_id = ' . $listing_id . ')';
     }
     $order = array('RAND(' . $rand . ')');
     $joins = array('LEFT JOIN #__users AS User ON Community.' . $this->realKey . ' = User.id');
     $profiles = $this->findAll(array('fields' => $fields, 'conditions' => $conditions, 'order' => $order, 'joins' => $joins));
     if (Sanitize::getInt($passedArgs['module'], 'ajax_nav', 1)) {
         $fields = array('count(Community.' . $this->realKey . ')');
         $group = array('Community.' . $this->realKey);
         $this->count = $this->findCount(array('fields' => $fields, 'conditions' => $conditions, 'group' => $group, 'joins' => $joins));
     } else {
         $this->count = Sanitize::getInt($passedArgs['module'], 'module_limit', 5);
     }
     return $this->addProfileInfo($profiles, 'User', 'user_id');
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:27,代码来源:anahita.php

示例9: verifyUserByToken

 public function verifyUserByToken($username, $token)
 {
     $username = Sanitize::html($username);
     $token = Sanitize::html($token);
     $username = trim($username);
     $token = trim($token);
     if (empty($username) || empty($token)) {
         Log::set(__METHOD__ . LOG_SEP . 'Username or Token-email empty. Username: ' . $username . ' - Token-email: ' . $token);
         return false;
     }
     $user = $this->dbUsers->getDb($username);
     if ($user == false) {
         Log::set(__METHOD__ . LOG_SEP . 'Username does not exist: ' . $username);
         return false;
     }
     $currentTime = Date::current(DB_DATE_FORMAT);
     if ($user['tokenEmailTTL'] < $currentTime) {
         Log::set(__METHOD__ . LOG_SEP . 'Token-email expired: ' . $username);
         return false;
     }
     if ($token === $user['tokenEmail']) {
         // Set the user loggued.
         $this->setLogin($username, $user['role']);
         // Invalidate the current token.
         $this->dbUsers->generateTokenEmail($username);
         Log::set(__METHOD__ . LOG_SEP . 'User logged succeeded by Token-email - Username: ' . $username);
         return true;
     } else {
         Log::set(__METHOD__ . LOG_SEP . 'Token-email incorrect.');
     }
     return false;
 }
开发者ID:clstrfcuk,项目名称:bludit,代码行数:32,代码来源:login.class.php

示例10: adminBodyEnd

    public function adminBodyEnd()
    {
        global $layout;
        $html = '';
        // Load CSS and JS only on Controllers in array.
        if (in_array($layout['controller'], $this->loadWhenController)) {
            $pluginPath = $this->htmlPath();
            $html = '<script>' . PHP_EOL;
            $html .= '$(document).ready(function() { ' . PHP_EOL;
            $html .= 'var simplemde = new SimpleMDE({
					element: document.getElementById("jscontent"),
					status: false,
					toolbarTips: true,
					toolbarGuideIcon: true,
					autofocus: false,
					lineWrapping: true,
					autoDownloadFontAwesome: false,
					indentWithTabs: true,
					tabSize: ' . $this->getDbField('tabSize') . ',
					spellChecker: false,
					toolbar: [' . Sanitize::htmlDecode($this->getDbField('toolbar')) . ']
			});';
            $html .= '$("#jsaddImage").on("click", function() {
					var filename = $("#jsimageList option:selected" ).text();
					if(!filename.trim()) {
						return false;
					}
					var text = simplemde.value();
					simplemde.value(text + "![alt text]("+filename+")" + "\\n");
			});';
            $html .= '}); </script>';
        }
        return $html;
    }
开发者ID:Tetoq,项目名称:bludit-plugins,代码行数:34,代码来源:plugin.php

示例11: s

 public function s()
 {
     $result = array();
     if (isset($this->request->query['term'])) {
         $keyword = Sanitize::clean($this->request->query['term']);
     }
     if (!empty($keyword)) {
         $cacheKey = "ElectionsS{$keyword}";
         $result = Cache::read($cacheKey, 'long');
         if (!$result) {
             $keywords = explode(' ', $keyword);
             $countKeywords = 0;
             $conditions = array('Election.parent_id IS NOT NULL');
             foreach ($keywords as $k => $keyword) {
                 $keyword = trim($keyword);
                 if (!empty($keyword) && ++$countKeywords < 4) {
                     $conditions[] = "Election.keywords LIKE '%{$keyword}%'";
                 }
             }
             $result = $this->Election->find('all', array('fields' => array('Election.id', 'Election.name', 'Election.lft', 'Election.rght'), 'conditions' => $conditions, 'limit' => 50));
             foreach ($result as $k => $v) {
                 $parents = $this->Election->getPath($v['Election']['id'], array('name'));
                 $result[$k]['Election']['name'] = implode(' > ', Set::extract($parents, '{n}.Election.name'));
             }
             Cache::write($cacheKey, $result, 'long');
         }
     }
     $this->set('result', $result);
 }
开发者ID:parker00811,项目名称:elections,代码行数:29,代码来源:ElectionsController.php

示例12: index

 function index($params)
 {
     $this->action = 'directory';
     // Set view file
     # Read module params
     $dir_id = cleanIntegerCommaList(Sanitize::getString($this->params['module'], 'dir_ids'));
     $conditions = array();
     $order = array();
     $cat_id = '';
     $section_id = '';
     $directories = $this->Directory->getTree($dir_id, true);
     if ($menu_id = Sanitize::getInt($this->params, 'Itemid')) {
         $menuParams = $this->Menu->getMenuParams($menu_id);
     }
     # Category auto detect
     $ids = CommonController::_discoverIDs($this);
     extract($ids);
     if ($cat_id != '' && $section_id == '') {
         $cat_id = cleanIntegerCommaList($cat_id);
         $sql = "SELECT section FROM #__categories WHERE id IN (" . $cat_id . ")";
         $this->_db->setQuery($sql);
         $section_id = $this->_db->loadResult();
     }
     $this->set(array('directories' => $directories, 'cat_id' => is_numeric($cat_id) && $cat_id > 0 ? $cat_id : false, 'section_id' => $section_id));
     return $this->render('modules', 'directories');
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:26,代码来源:module_directories_controller.php

示例13: index

 function index($params)
 {
     $this->action = 'directory';
     // Trigger assets helper method
     if ($this->_user->id === 0) {
         $this->cacheAction = Configure::read('Cache.expires');
     }
     $page = array('title' => '', 'show_title' => 0);
     $conditions = array();
     $order = array();
     if ($menu_id = Sanitize::getInt($this->params, 'Itemid')) {
         $menuParams = $this->Menu->getMenuParams($menu_id);
         $page['title'] = Sanitize::getString($menuParams, 'title');
         $page['show_title'] = Sanitize::getString($menuParams, 'dirtitle', 0);
     }
     $override_keys = array('dir_show_alphaindex', 'dir_cat_images', 'dir_columns', 'dir_cat_num_entries', 'dir_category_hide_empty', 'dir_category_levels', 'dir_cat_format');
     if (Sanitize::getBool($menuParams, 'dir_overrides')) {
         $overrides = array_intersect_key($menuParams, array_flip($override_keys));
         $this->Config->override($overrides);
     }
     if ($this->cmsVersion == CMS_JOOMLA15) {
         $directories = $this->Directory->getTree(Sanitize::getString($this->params, 'dir'));
     } else {
         $directories = $this->Category->findTree(array('level' => $this->Config->dir_cat_format === 0 ? 2 : $this->Config->dir_category_levels, 'menu_id' => true, 'dir_id' => Sanitize::getString($this->params, 'dir'), 'pad_char' => ''));
     }
     $this->set(array('page' => $page, 'directories' => $directories));
     return $this->render('directories', 'directory');
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:28,代码来源:directories_controller.php

示例14: index

 function index()
 {
     $this->layout = '';
     $login = true;
     //	Verifica se há dados em POST
     if ($this->data) {
         //		Disponibiliza os dados postados para a model
         $this->Funcionario->set($this->data);
         //		Verifica as regras de validação
         //if($this->Funcionario->validates()){
         //		Consulta a função criada na model para validar o login, o método Sanitize::clean torna a string livre de sql hacks
         $result = $this->Funcionario->checkUsuario(Sanitize::clean($this->data));
         if ($result) {
             $this->Session->start();
             $_SESSION['funcionario'] = array('id' => $result['Funcionario']['id'], 'data' => date('d-m-Y'), 'hora' => date('h:m:i'), 'perfil_id' => $result['Funcionario']['perfil_id']);
             if ($result['Funcionario']['perfil_id'] == 1) {
                 $this->redirect('/dashboard');
             } else {
                 //						$this->redirect('/dashboard/index') ;
             }
         } else {
             $this->set('error', true);
         }
         //}
     }
 }
开发者ID:GianVizzotto,项目名称:manager.socci,代码行数:26,代码来源:login_controller.php

示例15: paranoid

 function paranoid($vars)
 {
     foreach ($vars as &$var) {
         $var = Sanitize::paranoid($var, array('.', '-', '='));
     }
     return $vars;
 }
开发者ID:rasmusbergpalm,项目名称:AESpad,代码行数:7,代码来源:app_controller.php


注:本文中的Sanitize类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。