HTMLPurifier Plugin for CodeIgniter

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.

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

return $dirty_html;
}

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);
}
?>

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

function save()
{
$this->load->plugin(’htmlpurifier’);
$clean_html = purify($this->input->post(’html_content’));
$this->content_model->save($clean_html);
}
?>

Happy coding :P

I have also posted this on the codeigniter wiki: HTMLPurifier plugin for Codeigniter

Leave a Comment

What’s the Difference between CHAR and VARCHAR

The main difference between a CHAR data type and a VARCHAR data type is how they are stored. CHAR data is right-padded when stored in a table while VARCHAR isn’t.

However, when CHAR data is retrieved, the added padding is removed.

Leave a Comment

New 7 Wonders of Nature 2009

New 7 Wonders have now lots of entries for 2009. Here is a list of entries for Asia.

Mesopotamian Marshes, Wetlands - Iraq
Ein Gedi, Oasis - Israel
Wadi Rum, Desert - Jordan
Singing Dunes - Kazakhstan
Liwa Oasis and Empty Quarter - Oman
Al-hasa Oasis - Saudi Arabia
Coral Triangle - Philippines, Malaysia, Papua New Guinea, Timor
Musandam Peninsula - Oman
Ha Long Bay - Vietnam

More of them are found here

Leave a Comment

Philippine Holiday Schedule for 2009

This is a list of Philippine holidays for 2009.

  • Araw ng Kagitingan - April 6 - Regular Holiday
  • Maundy Thursday - April 9 - Regular Holiday
  • Good Friday - April 10 - Regular Holiday
  • Labor Day - May 1 - Regular Holiday
  • Independence Day - June 12 - Regular Holiday
  • Ninoy Aquino Day - August 21 - Special Non-Working Day
  • National Heroes Day - August 31 - Regular Holiday
  • November 1 - All Saints Day - Special Non-Working Day
  • November 2 - All Souls Day - Special Non-Working Day
  • Bonifacio Day - November 30 - Regular Holiday
  • Christmas Eve - December 24 - Special Non-Working Day
  • Christmas Day - December 25 - Regular Holiday
  • Rizal Day - December 30 - Regular Holiday
  • New Year’s Eve - December 31 - Special Non-Working Day

Holiday schedules are very important for those who plan their vacations in advance. Make sure to plan out your transportation and food well.

Leave a Comment

What are the long weekends in the Philippines 2009

It’s been a tradition for office workers to look into the calender and recognize the long weekends for planning vacations. There are just a few long weekends this year but Filipinos are sure to make the best out of them.

Here is the list of long weekends in the Philippines:

  • April 4 - 6
  • April 9 - 12
  • May 1 - 3
  • June 12 - 14
  • August 21 - 23
  • August 29 - 31
  • October 31 - November 2
  • November 28 - 30
  • December 24 - 27
  • December 30 - January 3, 2010

Leave a Comment

Who is the Philippine’s National Hero?

The Philippine’s National Hero is Jose Protacio Rizal. Born on June 19, 1861, he was the most prominent advocate for changes in the Philippines during the Spanish colonization.

Jose Rizal is the seventh child of Francisco Mercado. He studied at Ateneo Municipal de Manila, UST and traveled throughout Europe to study.

He also wrote the famous Noli me Tangere and El Filibusterismo which became an inspiration to reformists back then.

He died on December 30, 1896 at where is known to be his last resting place. Inscribe there are the words, I want to show to those who deprive people the right to love of country, that when we know how to sacrifice ourselves for our duties and convictions, death does not matter if one dies for those one loves – for his country and for others dear to him.”

Leave a Comment

How do CSS Conditional Comments work?

CSS Conditional statements are comments in html that will be read only by the particular browser set to read it. Below, is a statement that will only be read by Internet Explorer.

<!--[if IE]>
rules here
<![endif]-->

Conditional statements can be set for a particular Internet Explorer version. Below is for Internet Explorer version 6.

 <!--[if IE 6]>
rules here
<![endif]-->

Below is a statement for Internet Explorer version 5

<!--[if IE 5]>
rules here
<![endif]-->

Below is a statement for Internet Explorer version 5 and up

<!--[if gte IE 5]>
rules here
<![endif]-->

Below is a statement for Internet Explorer version 6 and below

<!--[if lte IE 6]>
rules here
<![endif]-->

Leave a Comment

How to SELECT a Random row in MySQL

To select a random row in MySQL, you will need to use the ORDER BY function to retrieve the database result ordered by any field, ascending and descending. This would generate a random sorting.

SELECT * users ORDER BY RAND()

Leave a Comment