當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CHtmlPurifier類代碼示例

本文整理匯總了PHP中CHtmlPurifier的典型用法代碼示例。如果您正苦於以下問題:PHP CHtmlPurifier類的具體用法?PHP CHtmlPurifier怎麽用?PHP CHtmlPurifier使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CHtmlPurifier類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的CHtmlPurifier類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。