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

PHP CHtmlPurifier类代码示例

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

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



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

示例1: actionSearch

 function actionSearch($q = null, $page = 1)
 {
     $pages = new CPagination();
     $pages->pageSize = 50;
     $pages->currentPage = $page;
     $p = new CHtmlPurifier();
     $q = CHtml::encode($p->purify($q));
     $searchCriteria = new stdClass();
     $searchCriteria->select = 'id';
     $searchCriteria->query = $q . '*';
     $searchCriteria->paginator = $pages;
     $searchCriteria->from = join(",", $this->indexes);
     // Получаем данные в виде массива
     $resArray = Yii::App()->search->searchRaw($searchCriteria);
     $news = null;
     if (is_array($resArray['matches'])) {
         $c = new CDbCriteria();
         $c->order = 'FIELD(id,' . join(",", array_keys($resArray['matches'])) . ')';
         $news = News::model()->findAllByPk(array_keys($resArray['matches']), $c);
     }
     $this->render("search_results", array('news' => $news));
 }
开发者ID:porem,项目名称:yupe-ext,代码行数:22,代码来源:SearchController.php


示例2: htmlPurifier

 /**
  * 对内容进行过滤  未使用
  */
 public static function htmlPurifier($content)
 {
     $p = new CHtmlPurifier();
     //过滤规则
     $p->options = array('URI.Disable' => true);
     return $p->purify($content);
 }
开发者ID:jvlstudio,项目名称:ask,代码行数:10,代码来源:Help.php


示例3: Purify

 public function Purify($value)
 {
     $p = new CHtmlPurifier();
     $p->options = array('HTML.Allowed' => 'strong,em,u,h1,h2,h3,h4');
     $cleanHtml = $p->purify($value);
     return $cleanHtml;
 }
开发者ID:cooltheo,项目名称:fircms,代码行数:7,代码来源:FActiveRecord.php


示例4: ergebnisse2FeedData

 /**
  * @param \Solarium\QueryType\Select\Result\Result $ergebnisse
  * @return array();
  */
 public static function ergebnisse2FeedData($ergebnisse)
 {
     $data = array();
     $dokumente = $ergebnisse->getDocuments();
     $highlighting = $ergebnisse->getHighlighting();
     $purifier = new CHtmlPurifier();
     $purifier->options = array('URI.AllowedSchemes' => array('http' => true, 'https' => true));
     foreach ($dokumente as $dokument) {
         $model = Dokument::getDocumentBySolrId($dokument->id);
         $risitem = $model->getRISItem();
         if (!$risitem) {
             continue;
         }
         $link = $risitem->getLink();
         $highlightedDoc = $highlighting->getResult($dokument->id);
         $item = array("title" => $model->name . " (zu " . $risitem->getTypName() . " \"" . $risitem->getName() . "\"", "link" => $link, "content" => "", "dateCreated" => RISTools::date_iso2timestamp(str_replace("T", " ", str_replace("Z", "", $dokument->sort_datum))), "aenderung_guid" => $link);
         if ($highlightedDoc && count($highlightedDoc) > 0) {
             foreach ($highlightedDoc as $highlight) {
                 $item["content"] .= $purifier->purify(implode(' (...) ', $highlight)) . '<br/>';
             }
         }
         $data[] = $item;
     }
     return $data;
 }
开发者ID:CatoTH,项目名称:Muenchen-Transparent,代码行数:29,代码来源:RISSolrHelper.php


示例5: safehtml

 public function safehtml($attr, $params)
 {
     $p = new CHtmlPurifier();
     $p->options = Yii::app()->params["HTMLPurifierOptions"];
     $p->options["HTML.Allowed"] = "a[href],b,strong,i,em,u,small,sub,sup";
     $this->{$attr} = trim($p->purify($this->{$attr}));
 }
开发者ID:norayr,项目名称:notabenoid,代码行数:7,代码来源:Announce.php


示例6: safeTransform

 public function safeTransform($content)
 {
     $content = $this->transform($content);
     $purifier = new CHtmlPurifier();
     $purifier->options = $this->purifierOptions;
     return $purifier->purify($content);
 }
开发者ID:Saltly,项目名称:SourceBans,代码行数:7,代码来源:MarkdownParser.php


示例7: purifyText

 public function purifyText($attribute, $params)
 {
     $module = Yii::app()->getModule('comment');
     $p = new CHtmlPurifier();
     $p->options = ['HTML.Allowed' => $module->allowedTags];
     $this->{$attribute} = $p->purify($this->{$attribute});
 }
开发者ID:RonLab1987,项目名称:43berega,代码行数:7,代码来源:Comment.php


示例8: beforeSave

 /**
  * Manage the created fields
  */
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->created = time();
     }
     $p = new CHtmlPurifier();
     $this->subject = $p->purify($this->subject);
     return parent::beforeSave();
 }
开发者ID:CrystReal,项目名称:Site_frontend,代码行数:12,代码来源:Thread.php


示例9: actionHtmlFilter

	public function actionHtmlFilter()
	{
		$str = "fd'<script><b>fdsafds</b>alert('good')</script>d%#sds/ds\gs<a href='fdsa'>fdas</a>a@fd<b>fdsa<?php echo 'fdsad'; ?>fds</b>sa0";
		
		$p = new CHtmlPurifier();

		echo $p->processOutput($str);
		/* echo $p->purify($str); */
	}
开发者ID:noikiy,项目名称:letstravel,代码行数:9,代码来源:TestController.php


示例10: process

 /**
  * Process a string with markup
  *
  * @abstract
  * @param string $input
  * @return string $output
  */
 public function process($input)
 {
     $out = $this->processMarkup($input);
     if ($this->purify) {
         $purifier = new CHtmlPurifier();
         $out = $purifier->purify($out);
     }
     return $out;
 }
开发者ID:sherifflight,项目名称:yupe,代码行数:16,代码来源:AbstractMarkup.php


示例11: processOutput

 /**
  * Processes the captured output.
  * This method converts the content in markdown syntax to HTML code.
  * If {@link purifyOutput} is true, the HTML code will also be purified.
  * @param string $output the captured output to be processed
  * @see convert
  */
 public function processOutput($output)
 {
     $output = $this->transform($output);
     if ($this->purifyOutput) {
         $purifier = new CHtmlPurifier();
         $output = $purifier->purify($output);
     }
     parent::processOutput($output);
 }
开发者ID:arduanov,项目名称:eco,代码行数:16,代码来源:CMarkdown.php


示例12: rules

 /**
  * @return array validation rules for model attributes.
  * @internal you should only define rules for those attributes that will receive user inputs
  */
 public function rules()
 {
     // On ajoute un filtre CHtmlPurifier avant l'enregistrement des données. Il sert ici moins à la protection contre
     // les attaques XSS qu'à s'assurer que le code HTML de l'actualité est valide.
     // Cette condition est indispensable pour que la classe DOMHelper puisse tronquer correctement
     // le texte pour construire des résumés (en page d'accueil par exemple)
     $htmlPurifier = new CHtmlPurifier();
     $htmlPurifier->setOptions(array('HTML.SafeIframe' => true, 'URI.SafeIframeRegexp' => '%www.youtube.com/embed/%'));
     return array(array('news_id, language_id, title', 'required'), array('title, description, keywords', 'length', 'max' => 255), array('language_id', 'exist', 'attributeName' => 'id', 'className' => 'Language'), array('news_id', 'exist', 'attributeName' => 'id', 'className' => 'News'), array('content', 'filter', 'filter' => array($htmlPurifier, 'purify')), array('tagsString', 'length', 'max' => 255), array('created_at, updated_at', 'safe'), array('news_id, language_id, title, slug, description, keywords, content, tagsString, tagIdFilter, enabled, eventDate', 'safe', 'on' => 'search'));
 }
开发者ID:ChristopheBrun,项目名称:hLib,代码行数:14,代码来源:TranslatedNews.php


示例13: filterString

 public static function filterString($string)
 {
     $string = strip_tags($string);
     $string = stripcslashes($string);
     $string = htmlspecialchars($string);
     $p = new CHtmlPurifier();
     $string = $p->purify($string);
     $string = addslashes($string);
     $string = str_replace("\r\n", "\n", $string);
     return $string;
 }
开发者ID:huynt57,项目名称:uet_messenger,代码行数:11,代码来源:StringHelper.php


示例14: run

 public function run()
 {
     $this->markdown = CHtml::encode($this->markdown);
     $parserClass = $this->parserClass;
     $parser = new $parserClass();
     $html = $parser->parse($this->markdown);
     if ($this->purifyOutput) {
         $purifier = new CHtmlPurifier();
         $html = $purifier->purify($html);
     }
     $this->render('markdownView', array('content' => $html));
 }
开发者ID:skapl,项目名称:design,代码行数:12,代码来源:MarkdownViewWidget.php


示例15: actionHtmlPurifier

 public function actionHtmlPurifier()
 {
     $user_input = null;
     if (isset($_POST['user_input'])) {
         $user_input = $_POST['user_input'];
     }
     $parser = new CHtmlPurifier();
     //create instance of CHtmlPurifier
     $user_input = $parser->purify($user_input);
     //we purify the $user_input
     $this->render("htmlpurifier", array('user_input' => $user_input));
 }
开发者ID:TianJinRong,项目名称:yiiplayground,代码行数:12,代码来源:XssController.php


示例16: purifyHtml

 protected function purifyHtml($html)
 {
     // remove bad parsing
     $html = preg_replace('#\\\\r\\\\n|\\\\r|\\\\n|\\\\#sui', '', $html);
     $p = new CHtmlPurifier();
     $p->options = array('HTML.Allowed' => 'img[src],p,br,b,strong,i');
     $html = $p->purify($html);
     $p->options = array('HTML.Allowed' => '');
     $text = $p->purify($html);
     if (mb_strlen($text, 'UTF-8') === mb_strlen($html, 'UTF-8')) {
         return '<pre>' . $text . '</pre>';
     }
     return $html;
 }
开发者ID:maduhu,项目名称:openbay,代码行数:14,代码来源:MainController.php


示例17: purify

 public function purify($value)
 {
     $p = new CHtmlPurifier();
     $p->options = array('HTML.Allowed' => 'b,p,br');
     $cleanHtml = $p->purify($value);
     return $cleanHtml;
 }
开发者ID:cooltheo,项目名称:fircms,代码行数:7,代码来源:Upload.php


示例18: savePage

 /**
  * @param $action
  */
 private function savePage($action)
 {
     //var_dump($_POST); die;
     Yii::log("Function SavePage DesignController called", "trace", self::LOG_CAT);
     $model = DocPages::model()->findByPk($_POST['pageId']);
     if (isset($_POST['desContent'])) {
         $purifier = new CHtmlPurifier();
         $model->docData = $purifier->purify($_POST['desContent']);
         if ($model->update()) {
             Yii::app()->user->setFlash('success', 'The page was updated successfully');
             $this->redirect($action);
             return;
         }
     }
     Yii::app()->user->setFlash('error', 'The page was not updated successfully, contact your administrator');
     $this->redirect($action);
     return;
 }
开发者ID:schrapps,项目名称:risksur,代码行数:21,代码来源:DesignController.php


示例19: preFilter

 protected function preFilter($filterChain)
 {
     // logic being applied before the action is executed
     if (isset($_POST) && count($_POST) > 0) {
         $obj = new CHtmlPurifier();
         $obj->options = array('HTML.Allowed' => 'p,b,u,a[href|title],i,img[src|alt|title],em,strong,strike,ul,ol,li,div[align],br', 'CSS.AllowedProperties' => array('text-decoration' => true, 'font-family' => true, 'font-size' => true, 'text-align' => true, 'padding-left' => true, 'padding-right' => true, 'padding-top' => true, 'padding-bottom' => true, 'color' => true, 'background-color' => true), 'AutoFormat.RemoveEmpty' => true);
         foreach ($_POST as $key => $val) {
             if (is_array($val)) {
                 $val = $obj->purify($val);
                 //$_POST[$key] = Yii::app()->input->xssClean($val);
                 $_POST[$key] = Yii::app()->input->xssClean($this->filterSubElement($val, $obj));
             } else {
                 $_POST[$key] = $obj->purify($val);
             }
         }
     }
     $filterChain->run();
     // return true; // false if the action should not be executed
 }
开发者ID:jayant06,项目名称:lukurug,代码行数:19,代码来源:StringFilter.php


示例20: actionRoom

 public function actionRoom($room_id)
 {
     $since = intval(isset($_POST["since"]) ? $_POST["since"] : $_GET["since"]);
     $room_id = (int) $room_id;
     $key = "chat{$room_id}";
     $room = Yii::app()->cache->get($key);
     if (!is_array($room)) {
         $room = [];
     }
     if (Yii::app()->request->isPostRequest) {
         $msg = trim($_POST["msg"]);
         $h = date("h");
         $m = date("i");
         if ($h == 4 && $m >= 20 && $m <= 40) {
             $p = new CHtmlPurifier();
             $p->options = Yii::app()->params["HTMLPurifierOptions"];
             $msg = trim($p->purify($msg));
         } else {
             $msg = strip_tags($msg);
         }
         if ($msg != "") {
             $msg = mb_substr($msg, 0, 2048);
             $msg = Yii::app()->parser->parse($msg);
             $line = ["u" => Yii::app()->user->login, "i" => Yii::app()->user->id, "t" => time(), "m" => $msg];
             array_push($room, $line);
             if (count($room) > 50) {
                 array_shift($room);
             }
         }
         Yii::app()->cache->set($key, $room, 60 * 60 * 24 * 3);
     }
     if ($since > 0) {
         $roomGood = [];
         foreach ($room as $k => $v) {
             $room["m"] .= " <small>(after {$since})</small>";
             if ($v["t"] > $since) {
                 $roomGood[] = $room[$k];
             }
         }
         $room = $roomGood;
     }
     echo json_encode(["room" => $room, "servertime" => time()]);
 }
开发者ID:norayr,项目名称:notabenoid,代码行数:43,代码来源:ChatController.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP CHttpRequest类代码示例发布时间:2022-05-23
下一篇:
PHP CHtml类代码示例发布时间: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