View source
<?php
function htmlpurifier_install() {
_htmlpurifier_version_check();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {cache_htmlpurifier} (\n cid varchar(255) NOT NULL default '',\n data longblob,\n expire int NOT NULL default '0',\n created int NOT NULL default '0',\n headers text,\n PRIMARY KEY (cid),\n INDEX expire (expire)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
break;
case 'pgsql':
db_query("CREATE TABLE {cache_htmlpurifier} (\n cid varchar(255) NOT NULL default '',\n data bytea,\n expire int NOT NULL default '0',\n created int NOT NULL default '0',\n headers text,\n PRIMARY KEY (cid)\n )");
db_query("CREATE INDEX {cache_htmlpurifier}_expire_idx ON {cache_htmlpurifier} (expire)");
break;
}
}
function htmlpurifier_uninstall() {
db_query('DROP TABLE {cache_htmlpurifier}');
}
function _htmlpurifier_version_check() {
static $req_version = '2.1.0';
$module_path = dirname(__FILE__);
$s = DIRECTORY_SEPARATOR;
if (!file_exists("{$module_path}/library/HTMLPurifier.auto.php")) {
echo "<strong>Fatal error:</strong> Could not find HTML Purifier\n installation in {$module_path}{$s}library. Please copy contents\n of library to this folder or ensure HTMLPurifier.auto.php exists.\n You can download HTML Purifier at\n <a href=\"http://htmlpurifier.org/download.html\">htmlpurifier.org</a>.\n After you have done so, reload this page.";
exit;
}
require_once "{$module_path}/library/HTMLPurifier.auto.php";
$purifier = new HTMLPurifier();
if (version_compare($purifier->version, $req_version, '<')) {
echo "<strong>Fatal error:</strong> HTML Purifier {$old} is not compatible\n with this module: HTML Purifier <strong>{$req_version}</strong> or later is required.\n You can download the latest version of HTML Purifier at\n <a href=\"http://htmlpurifier.org/download.html\">htmlpurifier.org</a>.";
exit;
}
return true;
}
function htmlpurifier_update_1() {
_htmlpurifier_version_check();
$ret = array();
$result = db_query("SHOW TABLES LIKE '{cache_htmlpurifier}'");
if (!db_fetch_array($result)) {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("CREATE TABLE {cache_htmlpurifier} (\n cid varchar(255) NOT NULL default '',\n data longblob,\n expire int NOT NULL default '0',\n created int NOT NULL default '0',\n headers text,\n PRIMARY KEY (cid),\n INDEX expire (expire)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
break;
case 'pgsql':
$ret[] = update_sql("CREATE TABLE {cache_htmlpurifier} (\n cid varchar(255) NOT NULL default '',\n data bytea,\n expire int NOT NULL default '0',\n created int NOT NULL default '0',\n headers text,\n PRIMARY KEY (cid)\n )");
$ret[] = update_sql("CREATE INDEX {cache_htmlpurifier}_expire_idx ON {cache_htmlpurifier} (expire)");
break;
}
}
return $ret;
}