• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Sanitize类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了Sanitize类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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' => '[email protected]'));
     $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


示例16: beforeValidate

 /**
  * This callback method extract exif data from image and sets fields as customized in settings.
  *
  * @param  Model   $model Object of model
  *
  * @return boolean Return method's status
  */
 function beforeValidate(&$model)
 {
     // If photo is uploaded
     if (isset($model->data[$model->name][$this->settings[$model->name]['filename']]) && 0 == $model->data[$model->name][$this->settings[$model->name]['filename']]['error']) {
         // Name of image file
         //$filename = $model->data[$model->name][$this->settings[$model->name]['filename']]['tmp_name'];
         $filename = WWW_ROOT . 'files' . DS . 'pictures' . DS . $model->data[$model->name][$this->settings[$model->name]['filename']];
         // Read exif data from file
         $exif = read_exif_data_raw($filename, 0);
         // If exif data contains maker note then set it empty
         if (isset($exif['SubIFD']['MakerNote'])) {
             $exif['SubIFD']['MakerNote'] = '';
         }
         // Create new sanitize object and clean exif data
         Sanitize::clean($exif);
         if (isset($exif['SubIFD']['DateTimeOriginal']) && isset($this->settings[$model->name]['exifDateField'])) {
             $model->data[$model->name][$this->settings[$model->name]['exifDateField']] = date($this->settings[$model->name]['exifDateFormat'], strtotime($exif['SubIFD']['DateTimeOriginal']));
         }
         // If the GPS Latitude and Longitude is set then add to proper fields
         if (isset($exif['GPS'])) {
             if (isset($this->settings[$model->name]['gpsLattitudeField'])) {
                 $model->data[$model->name][$this->settings[$model->name]['gpsLattitudeField']] = $exif['GPS']['Latitude'];
             }
             if (isset($this->settings[$model->name]['gpsLattitudeField'])) {
                 $model->data[$model->name][$this->settings[$model->name]['gpsLongitudeField']] = $exif['GPS']['Longitude'];
             }
         }
         // Store serialized exif data in model's data
         if (isset($this->settings[$model->name]['exifField'])) {
             $model->data[$model->name][$this->settings[$model->name]['exifField']] = serialize($exif);
         }
     }
     return true;
 }
开发者ID:rakeshtembhurne,项目名称:otts,代码行数:41,代码来源:LocalExifBehavior.php


示例17: get_slides

 /**
  * get_slides
  *
  */
 public function get_slides()
 {
     $this->Prg->commonProcess();
     $add_query = array('Slide.convert_status = ' . SUCCESS_CONVERT_COMPLETED);
     $val = isset($this->passedArgs['created_f']) ? $this->passedArgs['created_f'] : null;
     if (!empty($val)) {
         $add_query[] = "Slide.created >= '" . Sanitize::clean($val) . "'";
     }
     $val = isset($this->passedArgs['created_t']) ? $this->passedArgs['created_t'] : null;
     if (!empty($val)) {
         $add_query[] = "Slide.created <= '" . Sanitize::clean($val) . "'";
     }
     $this->Paginator->settings = array('conditions' => array($this->Slide->parseCriteria($this->passedArgs), $add_query), 'limit' => 200, 'recursive' => 1, 'order' => array('created' => 'desc'));
     try {
         $records = $this->Paginator->paginate('Slide');
     } catch (Exception $e) {
         $this->response->statusCode(400);
         $result['error']['message'] = __('Failed to retrieve results');
         $this->set('error', $result['error']);
         return $this->render('slides');
     }
     $this->response->statusCode(200);
     $this->set('slides', $records);
     return $this->render('slides');
 }
开发者ID:attakei,项目名称:open-slideshare,代码行数:29,代码来源:ApiV1Controller.php


示例18: google

 function google($address)
 {
     $this->_API['google'] = str_replace('{google_url}', Sanitize::getString($this->Config, 'geomaps.google_url', 'http://maps.google.com'), $this->_API['google']);
     $geoData = false;
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_URL, sprintf($this->_API['google'], urlencode($address)));
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     $response = trim(curl_exec($curl));
     // Process JSON
     if (!empty($response)) {
         $data = json_decode($response);
         if ($data->status == "OK" && is_array($data->results) && ($result = $data->results[0])) {
             $status = 200;
             $elev = 0;
             $lat = $result->geometry->location->lat;
             $lon = $result->geometry->location->lng;
             if (!is_numeric($lat) || !is_numeric($lon)) {
                 $status = 'error';
             }
             $geoData = array('status' => $status, 'lon' => $lon, 'lat' => $lat, 'elev' => $elev);
         }
     }
     curl_close($curl);
     return $geoData;
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:25,代码来源:geocoding.php


示例19: google

 function google($address)
 {
     $this->_API['google'] = str_replace('{google_url}', Sanitize::getString($this->Config, 'geomaps.google_url', 'http://maps.google.com'), $this->_API['google']);
     $geoData = false;
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_URL, sprintf($this->_API['google'], urlencode($address)));
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     $response = trim(curl_exec($curl));
     // Process CSV
     if ($response != '' && $response != 620 && count(explode(',', $response)) > 3) {
         // Split pieces of data by the comma that separates them
         list($status, $elev, $lat, $lon) = explode(",", $response);
         if (!is_numeric($lat) || !is_numeric($lon)) {
             $status = 'error';
         }
         $geoData = array('status' => $status, 'lon' => $lon, 'lat' => $lat, 'elev' => $elev);
         // More complete data can be found via XML
         // Create SimpleXML object from XML Content
         //                    $xmlObject = simplexml_load_string($xmlContent);
         //                    $localObject = $xmlObject->Response;
         //                    prx($localObject);
     }
     curl_close($curl);
     return $geoData;
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:25,代码来源:geocoding.php


示例20: authenticate

 /**
  * Authenticates the identity contained in a request.  Will use the `settings.userModel`, and `settings.fields`
  * to find POST data that is used to find a matching record in the `settings.userModel`.  Will return false if
  * there is no post data, either username or password is missing, of if the scope conditions have not been met.
  * @author DaiNT
  * @date: 2013/05/23
  * @param CakeRequest $request The request that contains login information.
  * @param CakeResponse $response Unused response object.
  * @return mixed.  False on login failure.  An array of User data on success.
  */
 public function authenticate(CakeRequest $request, CakeResponse $response)
 {
     if (isset($request->data['type'])) {
         $type = $request->data['type'];
         if (!isset($this->settings['types'][$type])) {
             throw new Exception(__('Type %s login not setting', $type));
         }
         $types = $this->settings['types'];
         $this->settings = array_merge(array('types' => $types), $types[$type]);
     }
     // if not set model in from then reset to request
     if (AppUtility::checkIsMobile()) {
         $this->settings['fields']['password'] = 'password_mb';
     }
     $fields = $this->settings['fields'];
     $model = $this->settings['userModel'];
     $userName = Sanitize::paranoid($request->data[$model][$fields['username']]);
     $password = Sanitize::paranoid($request->data[$model][$fields['password']]);
     if (empty($request->data[$model])) {
         $request->data[$model] = array($fields['username'] => isset($userName) ? $userName : null, $fields['password'] => isset($password) ? $password : null);
     }
     $user = parent::authenticate($request, $response);
     if (!empty($user) && is_array($user) && isset($request->data[$model]['system_permission'])) {
         $user['system_permission'] = $request->data[$model]['system_permission'];
     }
     return $user;
 }
开发者ID:nguyenthanhictu,项目名称:quanlyspa,代码行数:37,代码来源:RingiAuthenticate.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Sanitizer类代码示例发布时间:2022-05-23
下一篇:
PHP Sample类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap