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


PHP HTMLPurifier_Config::createDefault方法代码示例

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


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

示例1: html_purify

 function html_purify($dirty_html, $config = FALSE)
 {
     require_once APPPATH . 'third_party/htmlpurifier-4.6.0-standalone/HTMLPurifier.standalone.php';
     if (is_array($dirty_html)) {
         foreach ($dirty_html as $key => $val) {
             $clean_html[$key] = html_purify($val, $config);
         }
     } else {
         $ci =& get_instance();
         switch ($config) {
             //settings for rhe WYSIWYG
             case 'comment':
                 $config = HTMLPurifier_Config::createDefault();
                 $config->set('Core.Encoding', $ci->config->item('charset'));
                 $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
                 $config->set('HTML.Allowed', 'a[href|title],img[title|src|alt],em,strong,cite,blockquote,code,ul,ol,li,dl,dt,dd,p,br,h1,h2,h3,h4,h5,h6,span,*[style]');
                 $config->set('AutoFormat.AutoParagraph', TRUE);
                 $config->set('AutoFormat.Linkify', TRUE);
                 $config->set('AutoFormat.RemoveEmpty', TRUE);
                 break;
             case FALSE:
                 $config = HTMLPurifier_Config::createDefault();
                 $config->set('Core.Encoding', $ci->config->item('charset'));
                 $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
                 break;
             default:
                 show_error('The HTMLPurifier configuration labeled "' . htmlentities($config, ENT_QUOTES, 'UTF-8') . '" could not be found.');
         }
         $purifier = new HTMLPurifier($config);
         $clean_html = $purifier->purify($dirty_html);
     }
     return $clean_html;
 }
开发者ID:sanekagr,项目名称:phoneshop,代码行数:33,代码来源:htmlpurifier_helper.php

示例2: sanitize

 /**
  * Value sanitation. Sanitize input and output with ease using one of the sanitation types below.
  * 
  * @param  string $data the string/value you wish to sanitize
  * @param  string $type the type of sanitation you wish to use.
  * @return string       the sanitized string
  */
 public function sanitize($data, $type = '')
 {
     ## Use the HTML Purifier, as it help remove malicious scripts and code. ##
     ##       HTML Purifier 4.4.0 - Standards Compliant HTML Filtering       ##
     require_once 'htmlpurifier/HTMLPurifier.standalone.php';
     $purifier = new HTMLPurifier();
     $config = HTMLPurifier_Config::createDefault();
     $config->set('Core.Encoding', 'UTF-8');
     // If no type if selected, it will simply run it through the HTML purifier only.
     switch ($type) {
         // Remove HTML tags (can have issues with invalid tags, keep that in mind!)
         case 'purestring':
             $data = strip_tags($data);
             break;
             // Only allow a-z (H & L case)
         // Only allow a-z (H & L case)
         case 'atoz':
             $data = preg_replace('/[^a-zA-Z]+/', '', $data);
             break;
             // Integers only - Remove any non 0-9 and use Intval() to make sure it is an integer which comes out.
         // Integers only - Remove any non 0-9 and use Intval() to make sure it is an integer which comes out.
         case 'integer':
             $data = intval(preg_replace('/[^0-9]+/', '', $data));
             break;
     }
     /* HTML purifier to help prevent XSS in case anything slipped through. */
     $data = $purifier->purify($data);
     return $data;
 }
开发者ID:J0ker98,项目名称:Zolid-AJAX-Chat-Admin-Extension,代码行数:36,代码来源:livechat.processor.php

示例3: clean

 /**
  * clean the comment text field from html, in order to use it as submitted text
  * uses the htmlpurifier library, or a simple strip_tags call, based on the app.yml config file
  *
  * @return String
  * @param  String - the text to be cleaned
  *
  * @author Guglielmo Celata
  * @see    http://htmlpurifier.org/
  **/
 public static function clean($text)
 {
     $allowed_html_tags = sfConfig::get('app_deppPropelActAsCommentableBehaviorPlugin_allowed_tags', array());
     $use_htmlpurifier = sfConfig::get('app_deppPropelActAsCommentableBehaviorPlugin_use_htmlpurifier', false);
     if ($use_htmlpurifier) {
         $htmlpurifier_path = sfConfig::get('app_deppPropelActAsCommentableBehaviorPlugin_htmlpurifier_path', SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'htmlpurifier' . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR);
         require_once $htmlpurifier_path . 'HTMLPurifier.auto.php';
         $config = HTMLPurifier_Config::createDefault();
         $config->set('HTML', 'Doctype', 'XHTML 1.0 Strict');
         $config->set('HTML', 'Allowed', implode(',', array_keys($allowed_html_tags)));
         if (isset($allowed_html_tags['a'])) {
             $config->set('HTML', 'AllowedAttributes', 'a.href');
             $config->set('AutoFormat', 'Linkify', true);
         }
         if (isset($allowed_html_tags['p'])) {
             $config->set('AutoFormat', 'AutoParagraph', true);
         }
         $purifier = new HTMLPurifier($config);
         $clean_text = $purifier->purify($text);
     } else {
         $allowed_html_tags_as_string = "";
         foreach ($allowed_html_tags as $tag) {
             $allowed_html_tags_as_string .= "{$tag}";
         }
         $clean_text = strip_tags($text, $allowed_html_tags_as_string);
     }
     return $clean_text;
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:38,代码来源:deppPropelActAsCommentableToolkit.class.php

示例4: getScheme

 /**
  * Retrieves a scheme validator object
  * @param $scheme String scheme name like http or mailto
  * @param $config HTMLPurifier_Config object
  * @param $config HTMLPurifier_Context object
  */
 public function getScheme($scheme, $config, $context)
 {
     if (!$config) {
         $config = HTMLPurifier_Config::createDefault();
     }
     $null = null;
     // for the sake of passing by reference
     // important, otherwise attacker could include arbitrary file
     $allowed_schemes = $config->get('URI', 'AllowedSchemes');
     if (!$config->get('URI', 'OverrideAllowedSchemes') && !isset($allowed_schemes[$scheme])) {
         return $null;
     }
     if (isset($this->schemes[$scheme])) {
         return $this->schemes[$scheme];
     }
     if (!isset($allowed_schemes[$scheme])) {
         return $null;
     }
     $class = 'HTMLPurifier_URIScheme_' . $scheme;
     if (!class_exists($class)) {
         return $null;
     }
     $this->schemes[$scheme] = new $class();
     return $this->schemes[$scheme];
 }
开发者ID:WorkIdea,项目名称:DVWA,代码行数:31,代码来源:URISchemeRegistry.php

示例5: getConfig

 public function getConfig()
 {
     if ($this->config === null) {
         $this->config = \HTMLPurifier_Config::createDefault();
     }
     return $this->config;
 }
开发者ID:patrova,项目名称:omeka-s,代码行数:7,代码来源:HtmlPurifier.php

示例6: getScheme

 /**
  * Retrieves a scheme validator object
  * @param $scheme String scheme name like http or mailto
  * @param $config HTMLPurifier_Config object
  * @param $config HTMLPurifier_Context object
  */
 public function getScheme($scheme, $config, $context)
 {
     if (!$config) {
         $config = HTMLPurifier_Config::createDefault();
     }
     // important, otherwise attacker could include arbitrary file
     $allowed_schemes = $config->get('URI.AllowedSchemes');
     if (!$config->get('URI.OverrideAllowedSchemes') && !isset($allowed_schemes[$scheme])) {
         return;
     }
     if (isset($this->schemes[$scheme])) {
         return $this->schemes[$scheme];
     }
     if (!isset($allowed_schemes[$scheme])) {
         return;
     }
     $class = 'HTMLPurifier_URIScheme_' . $scheme;
     // Case-sensitive on all non-windows systems
     require_once 'HTMLPurifier/URIScheme/' . $scheme . '.php';
     if (!class_exists($class)) {
         return;
     }
     $this->schemes[$scheme] = new $class();
     return $this->schemes[$scheme];
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:31,代码来源:URISchemeRegistry.php

示例7: html_filter_admin

 function html_filter_admin($html)
 {
     static $purifier;
     if (!isset($purifier)) {
         $ci = get_instance();
         $ci->config->load('html_filter_admin', true, true);
         $config = $ci->config->item('html_filter_admin');
         if (!is_array($config)) {
             $config = array();
         }
         if (!isset($config['allowed_tags'])) {
             $config['allowed_tags'] = '';
         }
         $purifier_config = HTMLPurifier_Config::createDefault();
         $purifier_config->set('Cache.SerializerPath', APPPATH . 'cache_htmlpurifier');
         $purifier_config->set('Core.Encoding', 'utf-8');
         $purifier_config->set('HTML.Doctype', 'XHTML 1.0 Transitional');
         $purifier_config->set('HTML.TidyLevel', 'light');
         $purifier_config->set('Core.ConvertDocumentToFragment', false);
         $purifier_config->set('Core.RemoveProcessingInstructions', true);
         @$purifier_config->set('HTML.Allowed', $config['allowed_tags']);
         $purifier_config->set('HTML.SafeEmbed', true);
         $purifier_config->set('HTML.SafeObject', true);
         $purifier_config->set('HTML.FlashAllowFullScreen', true);
         $purifier_config->set('HTML.SafeIframe', true);
         $purifier_config->set('Attr.EnableID', true);
         $purifier_config->set('CSS.AllowImportant', true);
         $purifier_config->set('CSS.AllowTricky', true);
         $purifier_config->set('CSS.Proprietary', true);
         $purifier_config->set('Core.EnableIDNA', true);
         $purifier = @new HTMLPurifier($purifier_config);
     }
     return @$purifier->purify($html);
 }
开发者ID:aslijiasheng,项目名称:ciFramework,代码行数:34,代码来源:html_filters_helper.php

示例8: loadHttpData

 /**
  * Prebehneme data HTML purifierom
  * @param  array
  * @return void
  */
 public function loadHttpData()
 {
     $data = $this->getForm()->getHttpData();
     $name = $this->getName();
     $value = isset($data[$name]) && is_scalar($data[$name]) ? $data[$name] : NULL;
     $config = HTMLPurifier_Config::createDefault();
     $config->set('Core.Encoding', $this->encoding);
     if (!is_null($this->docType)) {
         $config->set('HTML.Doctype', $this->docType);
     }
     $config->set('HTML.Allowed', 'p,a[href],strong,em,b,i,ul,ol,li,h1,h2,h3,h4,h5,div[class],span[class],br,sup,table[border],tr,td,th,thead,tbody,img[src],img[style]');
     //        $config->set('HTML.Allowed', 'p,a[href],strong,em,ul,ol,li,h1,h2,div[class],span[class],br,sup');
     //        $config->set('HTML.Allowed', 'p,a[href],strong,em,ul,ol,li,h2,h3,h4,h5');
     // povoli lubovolny obsah pre href atribut odkazu - aby sa dali vyuzit latte links
     $config->set('HTML.DefinitionID', 'enduser-customize.html tutorial');
     //        $config->set('HTML.DefinitionRev', 1);
     //        $config->set('Cache.DefinitionImpl', null); // remove this later!
     $def = $config->getHTMLDefinition(true);
     $def->addAttribute('a', 'href*', 'Text');
     $purifier = new HTMLPurifier($config);
     //        var_dump($value);
     //		 kedze CKEDITOR to escapuje a neviem ho prinutit aby to nerobil, tak to tu dam naspat, Purifier to nasledne aj tak spravne zescapuje
     //        $value = html_entity_decode($value);
     //        var_dump($value);
     //        var_dump($purifier->purify($value));die();
     $this->setValue($purifier->purify($value));
 }
开发者ID:radypala,项目名称:maga-website,代码行数:32,代码来源:RichTextArea.php

示例9: scrape

function scrape($url, $path, $parse)
{
    $config = HTMLPurifier_Config::createDefault();
    $config->set('Core.Encoding', 'UTF-8');
    //encoding of output
    $config->set('HTML.Doctype', 'XHTML 1.1');
    //doctype of output
    $purifier = new HTMLPurifier($config);
    $dirty_html = file_get_contents($url);
    $clean_html = $purifier->purify($dirty_html);
    $html = str_get_html($clean_html);
    switch ($parse) {
        case 'tag':
            $ret = $html->find($path)->tag;
            break;
        case 'outertext':
            $ret = $html->find($path)->outertext;
            break;
        case 'innertext':
            $ret = $html->find($path)->innertext;
            break;
        case 'plaintext':
            $ret = $html->find($path)->plaintext;
            break;
        default:
            $ret = $html->find($path);
            break;
    }
    // clean up memory
    $html->clear();
    unset($dirty_html);
    unset($clean_html);
    unset($html);
    return $ret;
}
开发者ID:anubhaBhargava,项目名称:OpenRecommender,代码行数:35,代码来源:index.php

示例10: addpurifierelement

 /**
  * Adds an element to the allowedElements list
  *
  *  Security::addpurifierelement("cms", Array("attributes" => Array("name" => "Text")));
  *
  * @param   elementname elementname to add to the allowedelements
  * @param   elementconfig   array with config options for the new element; currently only 'attributes' are supported
  */
 public static function addpurifierelement($elementname, $elementconfig = array())
 {
     // Create a new configuration object, or load it if there is already one set
     if (Security::$htmlpurifierconfig != False) {
         $config = Security::$htmlpurifierconfig;
     } else {
         $config = HTMLPurifier_Config::createDefault();
         $config->autoFinalize = false;
         // To allow for later changes to the config
         if (is_array($settings = Kohana::config('purifier.settings'))) {
             // Load the settings
             $config->loadArray($settings);
         }
     }
     if (!isset($elementconfig["attributes"]) or !is_array($elementconfig["attributes"])) {
         $elementconfig["attributes"] = array();
     }
     $config->set('Core.Encoding', "UTF-8");
     $config->set('HTML.DefinitionID', 'cms-specific');
     $config->set('Cache.DefinitionImpl', null);
     // Do not use caching
     $def = $config->getHTMLDefinition(true);
     $element = $def->addElement($elementname, 'Inline', 'Flow', 'Common', $elementconfig["attributes"]);
     // Save configuration for later use
     Security::$htmlpurifierconfig = $config;
 }
开发者ID:azuya,项目名称:Wi3,代码行数:34,代码来源:security.php

示例11: text

 public static function text($str)
 {
     $config = HTMLPurifier_Config::createDefault();
     $cache_dir = Tiny::getPath('cache') . "/htmlpurifier/";
     if (!file_exists($cache_dir)) {
         File::mkdir($cache_dir);
     }
     $config = HTMLPurifier_Config::createDefault();
     //配置 缓存目录
     $config->set('Cache.SerializerPath', $cache_dir);
     //设置cache目录
     //配置 允许flash
     $config->set('HTML.SafeEmbed', true);
     $config->set('HTML.SafeObject', true);
     $config->set('Output.FlashCompat', true);
     //$config->set('HTML.Allowed', 'p');
     //$config->set('AutoFormat.AutoParagraph', true);
     //$config->set('AutoFormat.RemoveEmpty', true);
     //允许<a>的target属性
     $def = $config->getHTMLDefinition(true);
     $def->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
     $purifier = new HTMLPurifier($config);
     if (get_magic_quotes_gpc()) {
         $str = stripslashes($str);
         $str = $purifier->purify($str);
         $str = addslashes($str);
     } else {
         $str = $purifier->purify($str);
     }
     return self::sql($str);
 }
开发者ID:sammychan1981,项目名称:quanpin,代码行数:31,代码来源:filter_class.php

示例12: cvtx_init

/**
 * Create custom post types
 */
function cvtx_init()
{
    // Tagesordnungspunkte
    register_post_type('cvtx_top', array('labels' => array('name' => __('Agenda points', 'cvtx'), 'singular_name' => __('Agenda point', 'cvtx'), 'add_new_item' => __('Create agenda point', 'cvtx'), 'edit_item' => __('Edit agenda point', 'cvtx'), 'view_item' => __('View agenda point', 'cvtx'), 'menu_name' => __('agenda points (menu_name)', 'cvtx'), 'new_item' => __('New agenda point', 'cvtx'), 'search_items' => __('Search agenda points', 'cvtx'), 'not_found' => __('No agenda points found', 'cvtx'), 'not_found_in_trash' => __('No agenda points found in trash', 'cvtx')), 'public' => true, '_builtin' => false, 'has_archive' => false, 'menu_icon' => CVTX_PLUGIN_URL . 'images/cvtx_top_small.png', 'rewrite' => array('slug' => __('agenda points (slug)', 'cvtx')), 'supports' => array('title', 'editor')));
    // Anträge
    register_post_type('cvtx_antrag', array('labels' => array('name' => __('Resolutions', 'cvtx'), 'singular_name' => __('Resolution', 'cvtx'), 'add_new_item' => __('Create resolution', 'cvtx'), 'edit_item' => __('Edit resolution', 'cvtx'), 'view_item' => __('View resolution', 'cvtx'), 'menu_name' => __('resolutions (menu_name)', 'cvtx'), 'new_item' => __('New resolution', 'cvtx'), 'search_items' => __('Search resolutions', 'cvtx'), 'not_found' => __('No resolutions found', 'cvtx'), 'not_found_in_trash' => __('No resolutions found in trash', 'cvtx')), 'public' => true, '_builtin' => false, 'has_archive' => false, 'menu_icon' => CVTX_PLUGIN_URL . 'images/cvtx_antrag_small.png', 'rewrite' => array('slug' => __('resolutions (slug)', 'cvtx')), 'supports' => array('title', 'editor')));
    // Änderungsanträge
    register_post_type('cvtx_aeantrag', array('labels' => array('name' => __('Amendments', 'cvtx'), 'singular_name' => __('Amendment', 'cvtx'), 'add_new_item' => __('Create amendment', 'cvtx'), 'edit_item' => __('Edit amendment', 'cvtx'), 'view_item' => __('View amendment', 'cvtx'), 'menu_name' => __('amendments (menu_name)', 'cvtx'), 'new_item' => __('New amendment', 'cvtx'), 'search_items' => __('Search amendment', 'cvtx'), 'not_found' => __('No amendments found', 'cvtx'), 'not_found_in_trash' => __('No amendments found in Trash', 'cvtx')), 'public' => true, '_builtin' => false, 'has_archive' => false, 'menu_icon' => CVTX_PLUGIN_URL . 'images/cvtx_aeantrag_small.png', 'rewrite' => array('slug' => __('amendments (slug)', 'cvtx')), 'supports' => array('editor')));
    // Applications
    register_post_type('cvtx_application', array('labels' => array('name' => __('Applications', 'cvtx'), 'singular_name' => __('Application', 'cvtx'), 'add_new_item' => __('Create application', 'cvtx'), 'edit_item' => __('Edit application', 'cvtx'), 'view_item' => __('View application', 'cvtx'), 'menu_name' => __('Applications', 'cvtx'), 'new_item' => __('New application', 'cvtx'), 'search_items' => __('Search applications', 'cvtx'), 'not_found' => __('No applications found', 'cvtx'), 'not_found_in_trash' => __('No applications found in Trash', 'cvtx')), 'public' => true, '_builtin' => false, 'has_archive' => false, 'rewrite' => array('slug' => __('applications (slug)', 'cvtx')), 'supports' => array('title', 'editor')));
    // Reader
    register_post_type('cvtx_reader', array('labels' => array('name' => __('Readers', 'cvtx'), 'singular_name' => __('Reader', 'cvtx'), 'add_new_item' => __('Create reader', 'cvtx'), 'new_item' => __('New reader', 'cvtx'), 'edit_item' => __('Edit reader', 'cvtx'), 'view_item' => __('View reader', 'cvtx'), 'menu_name' => __('readers (menu_name)', 'cvtx'), 'search_items' => __('Search reader', 'cvtx'), 'not_found' => __('No readers found', 'cvtx'), 'not_found_in_trash' => __('No readers found in trash', 'cvtx')), 'public' => true, '_builtin' => false, 'has_archive' => false, 'menu_icon' => CVTX_PLUGIN_URL . 'images/cvtx_reader_small.png', 'rewrite' => array('slug' => __('readers (slug)', 'cvtx')), 'supports' => array('title')));
    register_post_type('cvtx_event', array('labels' => array('name' => __('Events', 'cvtx'), 'singular_name' => __('Event', 'cvtx'), 'add_new_item' => __('Create event', 'cvtx'), 'new_item' => __('New event', 'cvtx'), 'edit_item' => __('Edit event', 'cvtx'), 'view_item' => __('View event', 'cvtx'), 'menu_name' => __('Events', 'cvtx'), 'search_items' => __('Search event', 'cvtx'), 'not_found' => __('No events found', 'cvtx'), 'not_found_in_trash' => __('No events found in trash', 'cvtx')), 'public' => true, '_builtin' => false, 'has_archive' => false, 'rewrite' => array('slug' => 'veranstaltungen'), 'supports' => array('title', 'editor')));
    // Register reader taxonomy to Anträgen
    register_taxonomy('cvtx_tax_reader', 'cvtx_antrag', array('hierarchical' => true, 'label' => __('Readers', 'cvtx'), 'show_ui' => false, 'query_var' => true, 'rewrite' => false));
    // Register reader taxonomy to amendments
    register_taxonomy('cvtx_tax_reader', 'cvtx_aeantrag', array('hierarchical' => true, 'label' => __('Readers', 'cvtx'), 'show_ui' => false, 'query_var' => true, 'rewrite' => false));
    // Register reader taxonomy to applications
    register_taxonomy('cvtx_tax_reader', 'cvtx_application', array('hierarchical' => true, 'label' => __('Readers', 'cvtx'), 'show_ui' => false, 'query_var' => true, 'rewrite' => false));
    // Register taxonomy of "Überweisen an" to Anträge
    register_taxonomy('cvtx_tax_assign_to', array('cvtx_antrag', 'cvtx_aeantrag'), array('hierarchical' => false, 'label' => 'Überwiesen an', 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => true));
    // Initialize HTML Purifier if plugin activated
    if (is_plugin_active('html-purified/html-purified.php')) {
        global $html_purifier, $cvtx_purifier, $cvtx_purifier_config;
        $cvtx_purifier = $html_purifier->get_purifier();
        $cvtx_purifier_config = HTMLPurifier_Config::createDefault();
        $cvtx_purifier_config->set('HTML.Doctype', 'XHTML 1.1');
        $cvtx_purifier_config->set('HTML.Allowed', 'strong,b,em,i,h1,h2,h3,h4,ul,ol,li,br,p,del,ins,code,span[style|class],a[href],div');
        $cvtx_purifier_config->set('Attr.AllowedClasses', 'color-red,color-lila,color-grau,color-green');
        $cvtx_purifier_config->set('CSS.AllowedProperties', 'text-decoration');
    }
}
开发者ID:alexfecke,项目名称:cvtx,代码行数:35,代码来源:cvtx.php

示例13: filterData

 /**
  * 过滤数据 重组
  * @param array $data
  * @param array $modelfield
  */
 public function filterData($data = array(), $modelfield = array())
 {
     $newmodelfield = $this->parseModelField($modelfield);
     $newdata = $data;
     foreach ($data as $k => $d) {
         if (key_exists($k, $newmodelfield)) {
             switch ($newmodelfield[$k]['type']) {
                 case 'editor':
                     //编辑器过滤XSS
                     Vendor('Htmlpurifier.library.HTMLPurifier#auto');
                     $config = \HTMLPurifier_Config::createDefault();
                     $purifier = new \HTMLPurifier($config);
                     $newdata[$k] = $purifier->purify(htmlspecialchars_decode($d));
                     break;
                 case 'position':
                     //推荐位
                     $newdata[$k] = implode(',', $d);
                     break;
                 case 'checkbox':
                     $newdata[$k] = implode(',', $d);
                     break;
             }
         }
     }
     return $newdata;
 }
开发者ID:liutongju,项目名称:DreamCMSCN,代码行数:31,代码来源:ContentBaseModel.class.php

示例14: _comment

 protected function _comment($params)
 {
     $pageId = (int) $params['page'];
     $itemId = (int) $params['id'];
     $sql = "SELECT * FROM news WHERE page_id = {$pageId} AND id = {$itemId}";
     $query = $this->kobros->db->query($sql);
     $news = array();
     while ($res = $query->fetch(PDO::FETCH_OBJ)) {
         $news[] = $res;
     }
     if (!sizeof($news)) {
         throw new Exception('No news be here');
     }
     $item = $news[0];
     $now = new DateTime();
     $now = $now->format('Y-m-d H:i:s');
     $config = HTMLPurifier_Config::createDefault();
     $purifier = new HTMLPurifier($config);
     $dirty_html = strip_tags($_POST['comment']);
     $clean_html = $purifier->purify($dirty_html);
     $sql = "INSERT INTO news_comments (news_id, comment, created) VALUES(?, ?, ?)";
     $stmt = $this->kobros->db->prepare($sql);
     $stmt->execute(array($item->id, $clean_html, $now));
     header("Location: {$_SERVER['HTTP_REFERER']}");
 }
开发者ID:ristoni,项目名称:kobrocms,代码行数:25,代码来源:News.php

示例15: smarty_modifier_xoops_html_purifier

function smarty_modifier_xoops_html_purifier($html, $ecoding = null, $doctype = null)
{
    require_once XOOPS_LIBRARY_PATH . '/htmlpurifier/library/HTMLPurifier.auto.php';
    $encoding = $encoding ? $encoding : _CHARSET;
    $doctypeArr = array("HTML 4.01 Strict", "HTML 4.01 Transitional", "XHTML 1.0 Strict", "XHTML 1.0 Transitional", "XHTML 1.1");
    $config = HTMLPurifier_Config::createDefault();
    if (in_array($doctype, $doctypeArr)) {
        $config->set('HTML.Doctype', $doctype);
    }
    if ($_conv = $encoding !== 'UTF-8' && function_exists('mb_convert_encoding')) {
        $_substitute = mb_substitute_character();
        mb_substitute_character('none');
        $html = mb_convert_encoding($html, 'UTF-8', $encoding);
        $config->set('Core.Encoding', 'UTF-8');
    } else {
        $config->set('Core.Encoding', $encoding);
    }
    $purifier = new HTMLPurifier($config);
    $html = $purifier->purify($html);
    if ($_conv) {
        $html = mb_convert_encoding($html, $encoding, 'UTF-8');
        mb_substitute_character($_substitute);
    }
    return $html;
}
开发者ID:hiro1173,项目名称:legacy,代码行数:25,代码来源:modifier.xoops_html_purifier.php


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