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


PHP Sanitize::htmlClean方法代码示例

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


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

示例1: facebookOpenGraph

 /**
  * Facebook Open Graph implementation
  * 
  * @param mixed $listing
  * @param mixed $meta
  */
 function facebookOpenGraph(&$listing, $meta)
 {
     // http://developers.facebook.com/docs/opengraph/
     $option = Sanitize::getString($_REQUEST, 'option', '');
     $view = Sanitize::getString($_REQUEST, 'view', '');
     $id = Sanitize::getInt($_REQUEST, 'id');
     // Make sure this is a Joomla article page
     if (!($option == 'com_content' && $view == 'article' && $id)) {
         return;
     }
     $Config = Configure::read('JreviewsSystem.Config');
     if (empty($Config)) {
         $cache_file = 'jreviews_config_' . md5(cmsFramework::getConfig('secret'));
         $Config = S2Cache::read($cache_file);
     }
     $facebook_xfbml = Sanitize::getBool($Config, 'facebook_opengraph') && Sanitize::getBool($Config, 'facebook_appid');
     // Make sure FB is enabled and we have an FB App Id
     if (!$facebook_xfbml) {
         return;
     }
     extract($meta);
     $title == '' and $title = $listing['Listing']['title'];
     $description == '' and $description = Sanitize::htmlClean(Sanitize::stripAll($listing['Listing'], 'summary'));
     $image = isset($listing['Listing']['images'][0]) ? cmsFramework::makeAbsUrl(_DS . _JR_WWW_IMAGES . $listing['Listing']['images'][0]['path']) : null;
     if (!$image) {
         $img_src = '/<img[^>]+src[\\s=\'"]+([^"\'>\\s]+(jpg)+)/is';
         preg_match($img_src, $listing['Listing']['summary'], $matches);
         if (isset($matches[1])) {
             $image = $matches[1];
         }
     }
     $url = cmsFramework::makeAbsUrl($listing['Listing']['url'], array('sef' => true, 'ampreplace' => true));
     $fields = $listing['Field']['pairs'];
     // You can add other Open Graph meta tags by adding the attribute, custom field pair to the array below
     $tags = array('title' => $title, 'url' => $url, 'image' => $image, 'site_name' => cmsFramework::getConfig('sitename'), 'description' => $description, 'type' => Sanitize::getString($listing['ListingType']['config'], 'facebook_opengraph_type'), 'latitude' => Sanitize::getString($Config, 'geomaps.latitude'), 'longitude' => Sanitize::getString($Config, 'geomaps.longitude'), 'street-address' => Sanitize::getString($Config, 'geomaps.address1'), 'locality' => Sanitize::getString($Config, 'geomaps.city'), 'region' => Sanitize::getString($Config, 'geomaps.state'), 'postal-code' => Sanitize::getString($Config, 'geomaps.postal_code'), 'country-name' => Sanitize::getString($Config, 'geomaps.country', Sanitize::getString($Config, 'geomaps.default_country')));
     cmsFramework::addScript('<meta property="fb:app_id" content="' . Sanitize::getString($Config, 'facebook_appid') . '"/>');
     Sanitize::getString($Config, 'facebook_admins') != '' and cmsFramework::addScript('<meta property="fb:admins" content="' . str_replace(' ', '', $Config->facebook_admins) . '"/>');
     //        cmsFramework::addScript('<meta property="fb:admins" content="YOUR-ADMIN-ID"/>'); // It's app_id or this, not both
     # Loop through the tags array to add the additional FB meta tags
     foreach ($tags as $attr => $fname) {
         $content = '';
         if (substr($fname, 0, 3) == 'jr_') {
             // It's a custom field
             $content = isset($fields[$fname]) ? htmlspecialchars($fields[$fname]['text'][0], ENT_QUOTES, 'utf-8') : '';
         } elseif ($fname != '') {
             // It's a static text, not a custom field
             $content = htmlspecialchars($fname);
         }
         $content != '' and cmsFramework::addScript('<meta property="og:' . $attr . '" content="' . $content . '"/>');
     }
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:57,代码来源:jreviews.php

示例2: listings


//.........这里部分代码省略.........
             $count = $this->Listing->findCount($queryData, $this->action == 'search' && in_array('reviews', $scope) ? 'DISTINCT Listing.id' : '*');
         } else {
             $count = $this->Listing->count;
         }
         if ($total_special > 0 && $total_special < $count) {
             $count = Sanitize::getInt($this->data, 'total_special');
         }
     }
     # Get directory info for breadcrumb if dir id is a url parameter
     $directory = array();
     if (is_numeric($dir_id)) {
         $directory = $this->Directory->findRow(array('fields' => array('Directory.id AS `Directory.dir_id`', 'Directory.title AS `Directory.slug`', 'Directory.desc AS `Directory.title`'), 'conditions' => array('Directory.id = ' . $dir_id)));
     }
     /******************************************************************
      * Process page title and description
      *******************************************************************/
     $name_choice = $this->Config->name_choice == 'alias' ? 'username' : 'name';
     $page['show_title'] = 1;
     $page['show_description'] = 1;
     switch ($action) {
         case 'section':
             $menuParams = $this->Menu->getMenuParams($menu_id);
             $page = $section['Section'];
             $page['title'] = trim(Sanitize::getString($menuParams, 'title')) != '' ? Sanitize::getString($menuParams, 'title') : $section['Section']['title'];
             $page['show_title'] = Sanitize::getInt($this->data, 'dirtitle', 1);
             $page['show_description'] = 1;
             break;
         case 'category':
             $menuParams = $this->Menu->getMenuParams($menu_id);
             $page = $category['Category'];
             $page['title'] = trim(Sanitize::getString($menuParams, 'title')) != '' ? Sanitize::getString($menuParams, 'title') : $category['Category']['title'];
             $page['show_title'] = Sanitize::getInt($this->data, 'dirtitle', 1);
             $page['show_description'] = 1;
             Sanitize::getString($category['Category'], 'metadesc') == '' and $page['metadesc'] = Sanitize::htmlClean($category['Category']['description']);
             # Check if this is a listing submit category or disable listing submissions
             if (Sanitize::getInt($category['Category'], 'criteria_id') == 0) {
                 $this->Config->list_show_addnew = 0;
             }
             break;
         case 'custom':
             $menuParams = $this->Menu->getMenuParams($menu_id);
             $page['top_description'] = Sanitize::getString($menuParams, 'custom_description');
             $page['top_description'] = str_replace('\\n', '', $page['top_description']);
             $page['show_description'] = $page['top_description'] != '';
             $page['show_title'] = Sanitize::getInt($menuParams, 'dirtitle');
             $page['title'] = Sanitize::getString($menuParams, 'title');
             if (!$page['title']) {
                 $page['title'] = $this->Menu->getMenuName($menu_id);
             }
             break;
         case 'alphaindex':
             $title = isset($directory['Directory']) ? Sanitize::getString($directory['Directory'], 'title', '') : '';
             $page['title'] = $title != '' ? $title . ' - ' . ($index == '0' ? '0-9' : $index) : ($index == '0' ? '0-9' : $index);
             break;
         case 'mylistings':
             if ($user_id > 0) {
                 $user_name = $this->User->findOne(array('fields' => array('User.' . $name_choice . ' AS `User.name`'), 'conditions' => array('User.id = ' . $user_id)));
             } elseif ($this->_user->id > 0) {
                 $user_name = $this->_user->{$name_choice};
             }
             $page['title'] = sprintf(__t("Listings by %s", true), $user_name);
             break;
         case 'favorites':
             // Not running from CB Plugin so we change the page title
             if (!isset($this->Config->in_cb)) {
                 if ($user_id > 0) {
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:67,代码来源:categories_controller.php

示例3: clean

 /**
  * Sanitizes given array or value for safe input. Use the options to specify
  * the connection to use, and what filters should be applied (with a boolean
  * value). Valid filters: odd_spaces, encode, dollar, carriage, unicode,
  * escape, backslash.
  *
  * @param mixed $data Data to sanitize
  * @param mixed $options If string, DB connection being used, otherwise set of options
  * @return mixed Sanitized data
  * @access public
  * @static
  */
 function clean($data, $options = array())
 {
     if (empty($data) || is_object($data)) {
         return $data;
     }
     if (is_string($options)) {
         $options = array('connection' => $options);
     } elseif (!is_array($options)) {
         $options = array();
     }
     $options = array_merge(array('connection' => 'default', 'odd_spaces' => true, 'html' => true, 'dollar' => true, 'carriage' => true, 'unicode' => true, 'escape' => false, 'backslash' => true), $options);
     if (is_array($data)) {
         foreach ($data as $key => $val) {
             $data[$key] = Sanitize::clean($val, $options);
         }
         return $data;
     } else {
         if ($options['odd_spaces']) {
             $data = str_replace(chr(0xca), '', str_replace(' ', ' ', $data));
         }
         if ($options['html']) {
             $data = Sanitize::htmlClean($data);
         }
         if ($options['dollar']) {
             $data = str_replace("\\\$", "\$", $data);
         }
         if ($options['carriage']) {
             $data = str_replace("\r", "", $data);
         }
         $data = str_replace("'", "'", str_replace("!", "!", $data));
         if ($options['unicode']) {
             $data = preg_replace("/&amp;#([0-9]+);/s", "&#\\1;", $data);
         }
         if ($options['escape']) {
             $data = mysql_real_escape_string($data);
         }
         if ($options['backslash']) {
             $data = preg_replace("/\\\\(?!&amp;#|\\?#)/", "\\", $data);
         }
         return $data;
     }
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:54,代码来源:sanitize.php


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