Welcome! » Log In » Create A New Profile

HTML Purifer - Codeigniter Plugin

Posted by Chamyto 
HTML Purifer - Codeigniter Plugin
February 28, 2009 09:33AM

I was thinking that since the Codeigniter Plugin link on the home page doesn't work (Page not Found), I'd write one.

This plugin was created due to a need to use a wysiwyg and I didn’t trust it to validate.

First, you will need download the HTMLPurifier class. Extract and and rename the folder, ‘library’ which contain the main files to htmlpurifier.

Create a file. Name it htmlpurifier_pi.php and insert the code below.

<pre><![CDATA[ function purify($dirty_html) { if (is_array($dirty_html)) { foreach ($dirty_html as $key => $val) { $dirty_html[$key] = purify($val); }

return $dirty_html; } // to prevent further processing of 'nothing'... if (trim($dirty_html) === '') { return $dirty_html; }

require_once(APPPATH."plugins/htmlpurifier/HTMLPurifier.auto.php"); require_once(APPPATH."plugins/htmlpurifier/HTMLPurifier.func.php");

$config = HTMLPurifier_Config::createDefault();

$config->set('HTML', 'Doctype', 'XHTML 1.0 Strict');

return HTMLPurifier($dirty_html, $config);

} ]]></pre>

Save the file in your plugins folder located in the application folder ('application/plugins/'). If it doesn't exist. Create one. Save htmlpurifier_pi.php in that folder.

Now, to use the plugin, you will need to load it using the controller.

<pre><![CDATA[ function save() { $this->load->plugin(’htmlpurifier’); $clean_html = purify($this->input->post(’html_content’)); $this->content_model->save($clean_html); } ]]></pre>

Happy coding :P

From: <a href="http://codeigniter.com/wiki/htmlpurifier/"> HTMLPurifier Plugin for CodeIgniter</a> by <a href="http://pinoytech.org/">Thorpe Obazee</a>

<strong>Edit: </strong> Added support for arrays.

Re: HTML Purifer - Codeigniter Plugin
February 28, 2009 04:09PM

Good catch. I probably should update the link.

ci newbie
Re: HTML Purifer - Codeigniter Plugin
October 09, 2009 09:17AM

In version 4.0 user:

$config->set('HTML.Doctype', 'XHTML 1.0 Strict');

in stead of:

$config->set('HTML', 'Doctype', 'XHTML 1.0 Strict');
Re: HTML Purifer - Codeigniter Plugin
November 12, 2009 10:16PM

@ ci newbie. Nice catch. I sure hope the link an updated tutorial is updated on the homepage though..

aaasasas
Re: HTML Purifer - Codeigniter Plugin
July 06, 2017 03:02AM
Top 10 Mens Watches from Amazon, Flipkart and Myntra By dharma teja On Jul 06, 2017

 

1. Timex Analog Silver Dial Men's Watch

An Elegant Quartz watch made from Brass and vivaciously designed to complement your style and to fit all occasions. Timex is a symbol for fashion, this watch comes with a black leather strap, and the silver dial color highlights its grandeur.

 M.R.P.: 1,995.00 Rs.      Offer-Price: 599.00 Rs.    Click here to buy from Amazon. 

2. Skmei Analogue-Digital Black Dial Men's Watch

Silver outlined Black dial with black strap accentuates its glamor. This sports watch is really good and weighs as low as 180 grams. Features include: Stop Watch, Back Light, Chronograph, Multiple Time Zone, Water Resistant, and Alarm. 

M.R.P.: 1,799.00 Rs.        Offer Price: 510.00 Rs.       Click here to buy from Amazon.

3. Carson Analogue Blue Dial Men’s Watch

There's a well-proportioned way to dress, give a boost to your casual outfit, give your casual outlook a spark with this classy Carson analog men's watch. Specially engineered to fit all the special occasions, the watch's blue dial with its matching blue leather strap gives it a special attraction. 

Price: 999.00 Rs        Sale: 449.00 Rs        Click here to grab the deal from Amazon

4. Ferry Rozer Analog Black Dial Men's & Boy's Watch

The name Ferry Rozer itself speaks volumes about its eccentric fashion trends and this Analog Black Dial Men's & Boy's Watch is inclusive. Made out of a rich quality stainless steel, this analog wrist watch is a perfect match for all the gentlemen, the black colored dial in contrast to white colored hand strap gives a rich taste of latest fashion. 

Price: 999.00 Rs.         Sale: 379.00 Rs.        Click here to avail the bestseller.

5. Curren Decker Men’s Analog Watch

Designer Series collection from Curren is not only for time but also to add magnetism to your style. This highly sophisticated modern watch from Curren features a black round dial with contrast hands, the two sub-dials for date and day adds a feather to its cap. The elegant metal strap adds to the charm to this watch. 

Sale: 700.00 Rs.        Price: 1,999.00 Rs.        To grab this awesome watch, click here.

6. Q&Q Men Black Dial Analogue Watch

There’s a way to celebrate any occasion, a way to express your personality. This Black Analogue Watch Q&Q with a stainless steel circular case is a perfect choice to walk around. The Black dial with silver colored hands and markings highlight its opulence. The silver-toned bracelet-styled stainless steel strap secured with a fold-over press clasp makes it look gorgeous.

Price: Rs. 1225.00        Sale: Rs. 918.00 Rs.         Grab this piece from Myntra.

7. RDSTR by Roadster Men Black & Grey Analogue Watch

It has all the features for a watch to be called as a best-seller, this black and white Roadster analog watch has a unique brown synthetic strap, secured with a tang clasp which gives it more glamor. Apart from its strap, the black and gray dial in a circular case with a stainless steel back makes it even more stunning. 

Price Rs. 3499.00       Sale Rs. 2099.00        Click here to grab the piece from Myntra.

8. Skmei Gold Chronograph Men’s Analog-Digital Watch

Here comes the rare combination of Analog and Digital, the Skmei Gold Chronograph Men’s Watch has all the specialties to be called a best one. Its dual-tone with a sporty look is equipped with many features like countdown timer, stopwatch, dual time, auto-date and a back flash. The Gold chronograph gives it a magnificent look. 

Sale: Rs. 525.00        Price: Rs. 3,700.00        Click here to see full specifications and to grab the watch.

9. Curren Analog Watch 

There’s a rhythm that makes it worth buying. The first impression that attracts is its black and light brown combination, this Curren analog watch is built with black round case with white hands and dials. The leather strap in brown color gives it an extra charm. Pair it with any casual wear and make your day great. 

Sale: Rs. 214.00        Price: Rs. 999.00            This watch has got good customer reviews, click here to add it to your wardrobe. 

10. Aveiro Men Silver-Toned Dial Watch 

How do you define a watch to be splendid, yes! If it has got all the styles, features, good looking straps, sub dials etc. This Aveiro Men silver-toned dial watch has got additional three mock sub dials and two mock buttons. The light silver colored tone with dark brown leather strap matches any of the casual styles. 

Price: Rs. 1275.00        Sale: Rs. 446.00        Click here to grab the product.

 

 

Comments

Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a>

Author:
Your Email:

Subject:

HTML input is enabled. Make sure you escape all HTML and angled brackets with &lt; and &gt;.

Auto-paragraphing is enabled. Double newlines will be converted to paragraphs; for single newlines, use the pre tag.

Allowed tags: a, abbr, acronym, b, blockquote, caption, cite, code, dd, del, dfn, div, dl, dt, em, i, ins, kbd, li, ol, p, pre, s, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var.

For inputting literal code such as HTML and PHP for display, use CDATA tags to auto-escape your angled brackets, and pre to preserve newlines:

<pre><![CDATA[
Place code here
]]></pre>

Power users, you can hide this notice with:

.htmlpurifier-help {display:none;}

Message: