Server IP : 213.176.29.180 / Your IP : 18.118.164.100 Web Server : Apache System : Linux 213.176.29.180.hostiran.name 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64 User : webtaragh ( 1001) PHP Version : 8.3.14 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0750) : /home/webtaragh/public_html/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
PK j�$Z���i i htmlpurifier/update-for-releasenu �[��� <?php // release script // PHP 5.0 only if (php_sapi_name() != 'cli') { echo 'Release script cannot be called from web-browser.'; exit; } if (!isset($argv[1])) { echo 'php release.php [version] HTML Purifier release script '; exit; } $version = trim($argv[1]); // Bump version numbers: // ...in VERSION file_put_contents('VERSION', $version); // ...in NEWS if ($is_dev = (strpos($version, 'dev') === false)) { $date = date('Y-m-d'); $news_c = str_replace( $l = "$version, unknown release date", "$version, released $date", file_get_contents('NEWS'), $c ); if (!$c) { echo 'Could not update NEWS, missing ' . $l . PHP_EOL; exit; } elseif ($c > 1) { echo 'More than one release declaration in NEWS replaced' . PHP_EOL; exit; } file_put_contents('NEWS', $news_c); } // ...in Doxyfile $doxyfile_c = preg_replace( '/(?<=PROJECT_NUMBER {9}= )[^\s]+/m', // brittle $version, file_get_contents('Doxyfile'), 1, $c ); if (!$c) { echo 'Could not update Doxyfile, missing PROJECT_NUMBER.' . PHP_EOL; exit; } file_put_contents('Doxyfile', $doxyfile_c); // ...in HTMLPurifier.php $htmlpurifier_c = file_get_contents('library/HTMLPurifier.php'); $htmlpurifier_c = preg_replace( '/HTML Purifier .+? - /', "HTML Purifier $version - ", $htmlpurifier_c, 1, $c ); if (!$c) { echo 'Could not update HTMLPurifier.php, missing HTML Purifier [version] header.' . PHP_EOL; exit; } $htmlpurifier_c = preg_replace( '/public \$version = \'.+?\';/', "public \$version = '$version';", $htmlpurifier_c, 1, $c ); if (!$c) { echo 'Could not update HTMLPurifier.php, missing public $version.' . PHP_EOL; exit; } $htmlpurifier_c = preg_replace( '/const VERSION = \'.+?\';/', "const VERSION = '$version';", $htmlpurifier_c, 1, $c ); if (!$c) { echo 'Could not update HTMLPurifier.php, missing const $version.' . PHP_EOL; exit; } file_put_contents('library/HTMLPurifier.php', $htmlpurifier_c); $config_c = file_get_contents('library/HTMLPurifier/Config.php'); $config_c = preg_replace( '/public \$version = \'.+?\';/', "public \$version = '$version';", $config_c, 1, $c ); if (!$c) { echo 'Could not update Config.php, missing public $version.' . PHP_EOL; exit; } file_put_contents('library/HTMLPurifier/Config.php', $config_c); passthru('maintenance/flush.sh'); if ($is_dev) echo "Review changes, write something in WHATSNEW and FOCUS, and then commit with log 'Release $version.'" . PHP_EOL; else echo "Numbers updated to dev, no other modifications necessary!"; // vim: et sw=4 sts=4 PK j�$Z}���� � htmlpurifier/package.phpnu �[��� <?php set_time_limit(0); require_once 'PEAR/PackageFileManager2.php'; require_once 'PEAR/PackageFileManager/File.php'; PEAR::setErrorHandling(PEAR_ERROR_PRINT); $pkg = new PEAR_PackageFileManager2; $pkg->setOptions( array( 'baseinstalldir' => '/', 'packagefile' => 'package.xml', 'packagedirectory' => realpath(dirname(__FILE__) . '/library'), 'filelistgenerator' => 'file', 'include' => array('*'), 'dir_roles' => array('/' => 'php'), // hack to put *.ser files in the right place 'ignore' => array( 'HTMLPurifier.standalone.php', 'HTMLPurifier.path.php', '*.tar.gz', '*.tgz', 'standalone/' ), ) ); $pkg->setPackage('HTMLPurifier'); $pkg->setLicense('LGPL', 'http://www.gnu.org/licenses/lgpl.html'); $pkg->setSummary('Standards-compliant HTML filter'); $pkg->setDescription( 'HTML Purifier is an HTML filter that will remove all malicious code (better known as XSS) with a thoroughly audited, secure yet permissive whitelist and will also make sure your documents are standards compliant.' ); $pkg->addMaintainer('lead', 'ezyang', 'Edward Z. Yang', 'admin@htmlpurifier.org', 'yes'); $version = trim(file_get_contents('VERSION')); $api_version = substr($version, 0, strrpos($version, '.')); $pkg->setChannel('htmlpurifier.org'); $pkg->setAPIVersion($api_version); $pkg->setAPIStability('stable'); $pkg->setReleaseVersion($version); $pkg->setReleaseStability('stable'); $pkg->addRelease(); $pkg->setNotes(file_get_contents('WHATSNEW')); $pkg->setPackageType('php'); $pkg->setPhpDep('5.0.0'); $pkg->setPearinstallerDep('1.4.3'); $pkg->generateContents(); $pkg->writePackageFile(); // vim: et sw=4 sts=4 PK j�$Z���1 1 htmlpurifier/INSTALLnu �[��� Install How to install HTML Purifier HTML Purifier is designed to run out of the box, so actually using the library is extremely easy. (Although... if you were looking for a step-by-step installation GUI, you've downloaded the wrong software!) While the impatient can get going immediately with some of the sample code at the bottom of this library, it's well worth reading this entire document--most of the other documentation assumes that you are familiar with these contents. --------------------------------------------------------------------------- 1. Compatibility HTML Purifier is PHP 5 and PHP 7, and is actively tested from PHP 5.3 and up. It has no core dependencies with other libraries. These optional extensions can enhance the capabilities of HTML Purifier: * iconv : Converts text to and from non-UTF-8 encodings * bcmath : Used for unit conversion and imagecrash protection * tidy : Used for pretty-printing HTML These optional libraries can enhance the capabilities of HTML Purifier: * CSSTidy : Clean CSS stylesheets using %Core.ExtractStyleBlocks Note: You should use the modernized fork of CSSTidy available at https://github.com/Cerdic/CSSTidy * Net_IDNA2 (PEAR) : IRI support using %Core.EnableIDNA Note: This is not necessary for PHP 5.3 or later --------------------------------------------------------------------------- 2. Reconnaissance A big plus of HTML Purifier is its inerrant support of standards, so your web-pages should be standards-compliant. (They should also use semantic markup, but that's another issue altogether, one HTML Purifier cannot fix without reading your mind.) HTML Purifier can process these doctypes: * XHTML 1.0 Transitional (default) * XHTML 1.0 Strict * HTML 4.01 Transitional * HTML 4.01 Strict * XHTML 1.1 ...and these character encodings: * UTF-8 (default) * Any encoding iconv supports (with crippled internationalization support) These defaults reflect what my choices would be if I were authoring an HTML document, however, what you choose depends on the nature of your codebase. If you don't know what doctype you are using, you can determine the doctype from this identifier at the top of your source code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> ...and the character encoding from this code: <meta http-equiv="Content-type" content="text/html;charset=ENCODING"> If the character encoding declaration is missing, STOP NOW, and read 'docs/enduser-utf8.html' (web accessible at http://htmlpurifier.org/docs/enduser-utf8.html). In fact, even if it is present, read this document anyway, as many websites specify their document's character encoding incorrectly. --------------------------------------------------------------------------- 3. Including the library The procedure is quite simple: require_once '/path/to/library/HTMLPurifier.auto.php'; This will setup an autoloader, so the library's files are only included when you use them. Only the contents in the library/ folder are necessary, so you can remove everything else when using HTML Purifier in a production environment. If you installed HTML Purifier via PEAR, all you need to do is: require_once 'HTMLPurifier.auto.php'; Please note that the usual PEAR practice of including just the classes you want will not work with HTML Purifier's autoloading scheme. Advanced users, read on; other users can skip to section 4. Autoload compatibility ---------------------- HTML Purifier attempts to be as smart as possible when registering an autoloader, but there are some cases where you will need to change your own code to accomodate HTML Purifier. These are those cases: AN __autoload FUNCTION IS DECLARED AFTER OUR AUTOLOADER IS REGISTERED spl_autoload_register() has the curious behavior of disabling the existing __autoload() handler. Users need to explicitly spl_autoload_register('__autoload'). Because we use SPL when it is available, __autoload() will ALWAYS be disabled. If __autoload() is declared before HTML Purifier is loaded, this is not a problem: HTML Purifier will register the function for you. But if it is declared afterwards, it will mysteriously not work. This snippet of code (after your autoloader is defined) will fix it: spl_autoload_register('__autoload') For better performance ---------------------- Opcode caches, which greatly speed up PHP initialization for scripts with large amounts of code (HTML Purifier included), don't like autoloaders. We offer an include file that includes all of HTML Purifier's files in one go in an opcode cache friendly manner: // If /path/to/library isn't already in your include path, uncomment // the below line: // require '/path/to/library/HTMLPurifier.path.php'; require 'HTMLPurifier.includes.php'; Optional components still need to be included--you'll know if you try to use a feature and you get a class doesn't exists error! The autoloader can be used in conjunction with this approach to catch classes that are missing. Simply add this afterwards: require 'HTMLPurifier.autoload.php'; Standalone version ------------------ HTML Purifier has a standalone distribution; you can also generate a standalone file from the full version by running the script maintenance/generate-standalone.php . The standalone version has the benefit of having most of its code in one file, so parsing is much faster and the library is easier to manage. If HTMLPurifier.standalone.php exists in the library directory, you can use it like this: require '/path/to/HTMLPurifier.standalone.php'; This is equivalent to including HTMLPurifier.includes.php, except that the contents of standalone/ will be added to your path. To override this behavior, specify a new HTMLPURIFIER_PREFIX where standalone files can be found (usually, this will be one directory up, the "true" library directory in full distributions). Don't forget to set your path too! The autoloader can be added to the end to ensure the classes are loaded when necessary; otherwise you can manually include them. To use the autoloader, use this: require 'HTMLPurifier.autoload.php'; For advanced users ------------------ HTMLPurifier.auto.php performs a number of operations that can be done individually. These are: HTMLPurifier.path.php Puts /path/to/library in the include path. For high performance, this should be done in php.ini. HTMLPurifier.autoload.php Registers our autoload handler HTMLPurifier_Bootstrap::autoload($class). You can do these operations by yourself, if you like. --------------------------------------------------------------------------- 4. Configuration HTML Purifier is designed to run out-of-the-box, but occasionally HTML Purifier needs to be told what to do. If you answer no to any of these questions, read on; otherwise, you can skip to the next section (or, if you're into configuring things just for the heck of it, skip to 4.3). * Am I using UTF-8? * Am I using XHTML 1.0 Transitional? If you answered no to any of these questions, instantiate a configuration object and read on: $config = HTMLPurifier_Config::createDefault(); 4.1. Setting a different character encoding You really shouldn't use any other encoding except UTF-8, especially if you plan to support multilingual websites (read section three for more details). However, switching to UTF-8 is not always immediately feasible, so we can adapt. HTML Purifier uses iconv to support other character encodings, as such, any encoding that iconv supports <http://www.gnu.org/software/libiconv/> HTML Purifier supports with this code: $config->set('Core.Encoding', /* put your encoding here */); An example usage for Latin-1 websites (the most common encoding for English websites): $config->set('Core.Encoding', 'ISO-8859-1'); Note that HTML Purifier's support for non-Unicode encodings is crippled by the fact that any character not supported by that encoding will be silently dropped, EVEN if it is ampersand escaped. If you want to work around this, you are welcome to read docs/enduser-utf8.html for a fix, but please be cognizant of the issues the "solution" creates (for this reason, I do not include the solution in this document). 4.2. Setting a different doctype For those of you using HTML 4.01 Transitional, you can disable XHTML output like this: $config->set('HTML.Doctype', 'HTML 4.01 Transitional'); Other supported doctypes include: * HTML 4.01 Strict * HTML 4.01 Transitional * XHTML 1.0 Strict * XHTML 1.0 Transitional * XHTML 1.1 4.3. Other settings There are more configuration directives which can be read about here: <http://htmlpurifier.org/live/configdoc/plain.html> They're a bit boring, but they can help out for those of you who like to exert maximum control over your code. Some of the more interesting ones are configurable at the demo <http://htmlpurifier.org/demo.php> and are well worth looking into for your own system. For example, you can fine tune allowed elements and attributes, convert relative URLs to absolute ones, and even autoparagraph input text! These are, respectively, %HTML.Allowed, %URI.MakeAbsolute and %URI.Base, and %AutoFormat.AutoParagraph. The %Namespace.Directive naming convention translates to: $config->set('Namespace.Directive', $value); E.g. $config->set('HTML.Allowed', 'p,b,a[href],i'); $config->set('URI.Base', 'http://www.example.com'); $config->set('URI.MakeAbsolute', true); $config->set('AutoFormat.AutoParagraph', true); --------------------------------------------------------------------------- 5. Caching HTML Purifier generates some cache files (generally one or two) to speed up its execution. For maximum performance, make sure that library/HTMLPurifier/DefinitionCache/Serializer is writeable by the webserver. If you are in the library/ folder of HTML Purifier, you can set the appropriate permissions using: chmod -R 0755 HTMLPurifier/DefinitionCache/Serializer If the above command doesn't work, you may need to assign write permissions to group: chmod -R 0775 HTMLPurifier/DefinitionCache/Serializer You can also chmod files via your FTP client; this option is usually accessible by right clicking the corresponding directory and then selecting "chmod" or "file permissions". Starting with 2.0.1, HTML Purifier will generate friendly error messages that will tell you exactly what you have to chmod the directory to, if in doubt, follow its advice. If you are unable or unwilling to give write permissions to the cache directory, you can either disable the cache (and suffer a performance hit): $config->set('Core.DefinitionCache', null); Or move the cache directory somewhere else (no trailing slash): $config->set('Cache.SerializerPath', '/home/user/absolute/path'); --------------------------------------------------------------------------- 6. Using the code The interface is mind-numbingly simple: $purifier = new HTMLPurifier($config); $clean_html = $purifier->purify( $dirty_html ); That's it! For more examples, check out docs/examples/ (they aren't very different though). Also, docs/enduser-slow.html gives advice on what to do if HTML Purifier is slowing down your application. --------------------------------------------------------------------------- 7. Quick install First, make sure library/HTMLPurifier/DefinitionCache/Serializer is writable by the webserver (see Section 5: Caching above for details). If your website is in UTF-8 and XHTML Transitional, use this code: <?php require_once '/path/to/htmlpurifier/library/HTMLPurifier.auto.php'; $config = HTMLPurifier_Config::createDefault(); $purifier = new HTMLPurifier($config); $clean_html = $purifier->purify($dirty_html); ?> If your website is in a different encoding or doctype, use this code: <?php require_once '/path/to/htmlpurifier/library/HTMLPurifier.auto.php'; $config = HTMLPurifier_Config::createDefault(); $config->set('Core.Encoding', 'ISO-8859-1'); // replace with your encoding $config->set('HTML.Doctype', 'HTML 4.01 Transitional'); // replace with your doctype $purifier = new HTMLPurifier($config); $clean_html = $purifier->purify($dirty_html); ?> vim: et sw=4 sts=4 PK j�$Zc4�Z� � $ htmlpurifier/plugins/phorum/info.txtnu �[��� title: HTML Purifier Phorum Mod desc: This module enables standards-compliant HTML filtering on Phorum. Please check migrate.bbcode.php before enabling this mod. author: Edward Z. Yang url: http://htmlpurifier.org/ version: 4.0.0 hook: format|phorum_htmlpurifier_format hook: quote|phorum_htmlpurifier_quote hook: posting_custom_action|phorum_htmlpurifier_posting hook: common|phorum_htmlpurifier_common hook: before_editor|phorum_htmlpurifier_before_editor hook: tpl_editor_after_subject|phorum_htmlpurifier_editor_after_subject # This module is meant to be a drop-in for bbcode, so make it run last. priority: run module after * priority: run hook format after * vim: et sw=4 sts=4 PK j�$Z�9S� � # htmlpurifier/plugins/phorum/INSTALLnu �[��� Install How to install the Phorum HTML Purifier plugin 0. PREREQUISITES ---------------- This Phorum module only works on PHP5 and with HTML Purifier 4.0.0 or later. 1. UNZIP -------- Unzip phorum-htmlpurifier-x.y.z, producing an htmlpurifier folder. You've already done this step if you're reading this! 2. MOVE ------- Move the htmlpurifier folder to the mods/ folder of your Phorum installation, so the directory structure looks like: phorum/ mods/ htmlpurifier/ INSTALL - this install file info.txt, ... - the module files htmlpurifier/ 3. INSTALL HTML PURIFIER ------------------------ Download and unzip HTML Purifier <htmlpurifier.org>. Place the contents of the library/ folder in the htmlpurifier/htmlpurifier folder. Your directory structure will look like: phorum/ mods/ htmlpurifier/ htmlpurifier/ HTMLPurifier.auto.php ... - other files HTMLPurifier/ Advanced users: If you have HTML Purifier installed elsewhere on your server, all you need is an HTMLPurifier.auto.php file in the library folder which includes the HTMLPurifier.auto.php file in your install. 4. MIGRATE ---------- If you're setting up a new Phorum installation, all you need to do is create a blank migrate.php file in the htmlpurifier module folder (NOT the library folder. If you have an old Phorum installation and was using BBCode, copy migrate.bbcode.php to migrate.php. If you were using a different input format, follow the instructions in migrate.bbcode.php to create your own custom migrate.php file. Your directory structure should now look like this: phorum/ mods/ htmlpurifier/ migrate.php 5. ENABLE --------- Navigate to your Phorum admin panel at http://example.com/phorum/admin.php, click on Global Settings > Modules, scroll to "HTML Purifier Phorum Mod" and turn it On. 6. MIGRATE SIGNATURES --------------------- If you're setting up a new Phorum installation, skip this step. If you allowed your users to make signatures, navigate to the module settings page of HTML Purifier (Global Settings > Modules > HTML Purifier Phorum Mod > Configure), type in "yes" in the "Confirm" box, and press "Migrate." ONLY DO THIS ONCE! BE SURE TO BACK UP YOUR DATABASE! 7. CONFIGURE ------------ Configure using Edit settings. See that page for more information. vim: et sw=4 sts=4 PK j�$Z'$��� � + htmlpurifier/plugins/phorum/init-config.phpnu �[��� <?php /** * Initializes the appropriate configuration from either a PHP file * or a module configuration value * @return Instance of HTMLPurifier_Config */ function phorum_htmlpurifier_get_config($default = false) { global $PHORUM; $config_exists = phorum_htmlpurifier_config_file_exists(); if ($default || $config_exists || !isset($PHORUM['mod_htmlpurifier']['config'])) { $config = HTMLPurifier_Config::createDefault(); include(dirname(__FILE__) . '/config.default.php'); if ($config_exists) { include(dirname(__FILE__) . '/config.php'); } unset($PHORUM['mod_htmlpurifier']['config']); // unnecessary } else { $config = HTMLPurifier_Config::create($PHORUM['mod_htmlpurifier']['config']); } return $config; } function phorum_htmlpurifier_config_file_exists() { return file_exists(dirname(__FILE__) . '/config.php'); } // vim: et sw=4 sts=4 PK j�$Z�c�(� � : htmlpurifier/plugins/phorum/settings/migrate-sigs-form.phpnu �[��� <?php function phorum_htmlpurifier_show_migrate_sigs_form() { $frm = new PhorumInputForm ('', "post", "Migrate"); $frm->hidden("module", "modsettings"); $frm->hidden("mod", "htmlpurifier"); $frm->hidden("migrate-sigs", "1"); $frm->addbreak("Migrate user signatures to HTML"); $frm->addMessage('This operation will migrate your users signatures to HTML. <strong>This process is irreversible and must only be performed once.</strong> Type in yes in the confirmation field to migrate.'); if (!file_exists(dirname(__FILE__) . '/../migrate.php')) { $frm->addMessage('Migration file does not exist, cannot migrate signatures. Please check <tt>migrate.bbcode.php</tt> on how to create an appropriate file.'); } else { $frm->addrow('Confirm:', $frm->text_box("confirmation", "")); } $frm->show(); } // vim: et sw=4 sts=4 PK j�$Z��O�} } 5 htmlpurifier/plugins/phorum/settings/migrate-sigs.phpnu �[��� <?php function phorum_htmlpurifier_migrate_sigs_check() { global $PHORUM; $offset = 0; if (!empty($_POST['migrate-sigs'])) { if (!isset($_POST['confirmation']) || strtolower($_POST['confirmation']) !== 'yes') { echo 'Invalid confirmation code.'; exit; } $PHORUM['mod_htmlpurifier']['migrate-sigs'] = true; phorum_db_update_settings(array("mod_htmlpurifier"=>$PHORUM["mod_htmlpurifier"])); $offset = 1; } elseif (!empty($_GET['migrate-sigs']) && $PHORUM['mod_htmlpurifier']['migrate-sigs']) { $offset = (int) $_GET['migrate-sigs']; } return $offset; } function phorum_htmlpurifier_migrate_sigs($offset) { global $PHORUM; if(!$offset) return; // bail out quick if $offset == 0 // theoretically, we could get rid of this multi-request // doo-hickery if safe mode is off @set_time_limit(0); // attempt to let this run $increment = $PHORUM['mod_htmlpurifier']['migrate-sigs-increment']; require_once(dirname(__FILE__) . '/../migrate.php'); // migrate signatures // do this in batches so we don't run out of time/space $end = $offset + $increment; $user_ids = array(); for ($i = $offset; $i < $end; $i++) { $user_ids[] = $i; } $userinfos = phorum_db_user_get_fields($user_ids, 'signature'); foreach ($userinfos as $i => $user) { if (empty($user['signature'])) continue; $sig = $user['signature']; // perform standard Phorum processing on the sig $sig = str_replace(array("&","<",">"), array("&","<",">"), $sig); $sig = preg_replace("/<((http|https|ftp):\/\/[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),~%]+?)>/i", "$1", $sig); // prepare fake data to pass to migration function $fake_data = array(array("author"=>"", "email"=>"", "subject"=>"", 'body' => $sig)); list($fake_message) = phorum_htmlpurifier_migrate($fake_data); $user['signature'] = $fake_message['body']; if (!phorum_api_user_save($user)) { exit('Error while saving user data'); } } unset($userinfos); // free up memory // query for highest ID in database $type = $PHORUM['DBCONFIG']['type']; $sql = "select MAX(user_id) from {$PHORUM['user_table']}"; $row = phorum_db_interact(DB_RETURN_ROW, $sql); $top_id = (int) $row[0]; $offset += $increment; if ($offset > $top_id) { // test for end condition echo 'Migration finished'; $PHORUM['mod_htmlpurifier']['migrate-sigs'] = false; phorum_htmlpurifier_commit_settings(); return true; } $host = $_SERVER['HTTP_HOST']; $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); $extra = 'admin.php?module=modsettings&mod=htmlpurifier&migrate-sigs=' . $offset; // relies on output buffering to work header("Location: http://$host$uri/$extra"); exit; } // vim: et sw=4 sts=4 PK j�$Z@RXNK K - htmlpurifier/plugins/phorum/settings/save.phpnu �[��� <?php function phorum_htmlpurifier_save_settings() { global $PHORUM; if (phorum_htmlpurifier_config_file_exists()) { echo "Cannot update settings, <code>mods/htmlpurifier/config.php</code> already exists. To change settings, edit that file. To use the web form, delete that file.<br />"; } else { $config = phorum_htmlpurifier_get_config(true); if (!isset($_POST['reset'])) $config->mergeArrayFromForm($_POST, 'config', $PHORUM['mod_htmlpurifier']['directives']); $PHORUM['mod_htmlpurifier']['config'] = $config->getAll(); } $PHORUM['mod_htmlpurifier']['wysiwyg'] = !empty($_POST['wysiwyg']); $PHORUM['mod_htmlpurifier']['suppress_message'] = !empty($_POST['suppress_message']); if(!phorum_htmlpurifier_commit_settings()){ $error="Database error while updating settings."; } else { echo "Settings Updated<br />"; } } function phorum_htmlpurifier_commit_settings() { global $PHORUM; return phorum_db_update_settings(array("mod_htmlpurifier"=>$PHORUM["mod_htmlpurifier"])); } // vim: et sw=4 sts=4 PK j�$Z���c) ) - htmlpurifier/plugins/phorum/settings/form.phpnu �[��� <?php function phorum_htmlpurifier_show_form() { if (phorum_htmlpurifier_config_file_exists()) { phorum_htmlpurifier_show_config_info(); return; } global $PHORUM; $config = phorum_htmlpurifier_get_config(); $frm = new PhorumInputForm ("", "post", "Save"); $frm->hidden("module", "modsettings"); $frm->hidden("mod", "htmlpurifier"); // this is the directory name that the Settings file lives in if (!empty($error)){ echo "$error<br />"; } $frm->addbreak("Edit settings for the HTML Purifier module"); $frm->addMessage('<p>The box below sets <code>$PHORUM[\'mod_htmlpurifier\'][\'wysiwyg\']</code>. When checked, contents sent for edit are now purified and the informative message is disabled. If your WYSIWYG editor is disabled for admin edits, you can safely keep this unchecked.</p>'); $frm->addRow('Use WYSIWYG?', $frm->checkbox('wysiwyg', '1', '', $PHORUM['mod_htmlpurifier']['wysiwyg'])); $frm->addMessage('<p>The box below sets <code>$PHORUM[\'mod_htmlpurifier\'][\'suppress_message\']</code>, which removes the big how-to use HTML Purifier message.</p>'); $frm->addRow('Suppress information?', $frm->checkbox('suppress_message', '1', '', $PHORUM['mod_htmlpurifier']['suppress_message'])); $frm->addMessage('<p>Click on directive links to read what each option does (links do not open in new windows).</p> <p>For more flexibility (for instance, you want to edit the full range of configuration directives), you can create a <tt>config.php</tt> file in your <tt>mods/htmlpurifier/</tt> directory. Doing so will, however, make the web configuration interface unavailable.</p>'); require_once 'HTMLPurifier/Printer/ConfigForm.php'; $htmlpurifier_form = new HTMLPurifier_Printer_ConfigForm('config', 'http://htmlpurifier.org/live/configdoc/plain.html#%s'); $htmlpurifier_form->setTextareaDimensions(23, 7); // widen a little, since we have space $frm->addMessage($htmlpurifier_form->render( $config, $PHORUM['mod_htmlpurifier']['directives'], false)); $frm->addMessage("<strong>Warning: Changing HTML Purifier's configuration will invalidate the cache. Expect to see a flurry of database activity after you change any of these settings.</strong>"); $frm->addrow('Reset to defaults:', $frm->checkbox("reset", "1", "", false)); // hack to include extra styling echo '<style type="text/css">' . $htmlpurifier_form->getCSS() . ' .hp-config {margin-left:auto;margin-right:auto;} </style>'; $js = $htmlpurifier_form->getJavaScript(); echo '<script type="text/javascript">'."<!--\n$js\n//-->".'</script>'; $frm->show(); } function phorum_htmlpurifier_show_config_info() { global $PHORUM; // update mod_htmlpurifier for housekeeping phorum_htmlpurifier_commit_settings(); // politely tell user how to edit settings manually ?> <div class="input-form-td-break">How to edit settings for HTML Purifier module</div> <p> A <tt>config.php</tt> file exists in your <tt>mods/htmlpurifier/</tt> directory. This file contains your custom configuration: in order to change it, please navigate to that file and edit it accordingly. You can also set <code>$GLOBALS['PHORUM']['mod_htmlpurifier']['wysiwyg']</code> or <code>$GLOBALS['PHORUM']['mod_htmlpurifier']['suppress_message']</code> </p> <p> To use the web interface, delete <tt>config.php</tt> (or rename it to <tt>config.php.bak</tt>). </p> <p> <strong>Warning: Changing HTML Purifier's configuration will invalidate the cache. Expect to see a flurry of database activity after you change any of these settings.</strong> </p> <?php } // vim: et sw=4 sts=4 PK j�$Z��dY Y . htmlpurifier/plugins/phorum/config.default.phpnu �[��� <?php if(!defined("PHORUM")) exit; // default HTML Purifier configuration settings $config->set('HTML.Allowed', // alphabetically sorted 'a[href|title] abbr[title] acronym[title] b blockquote[cite] br caption cite code dd del dfn div dl dt em i img[src|alt|title|class] ins kbd li ol p pre s strike strong sub sup table tbody td tfoot th thead tr tt u ul var'); $config->set('AutoFormat.AutoParagraph', true); $config->set('AutoFormat.Linkify', true); $config->set('HTML.Doctype', 'XHTML 1.0 Transitional'); $config->set('Core.AggressivelyFixLt', true); $config->set('Core.Encoding', $GLOBALS['PHORUM']['DATA']['CHARSET']); // we'll change this eventually if (strtolower($GLOBALS['PHORUM']['DATA']['CHARSET']) !== 'utf-8') { $config->set('Core.EscapeNonASCIICharacters', true); } $config->set('Core.AllowParseManyTags', false); // vim: et sw=4 sts=4 PK j�$Z��?) ) . htmlpurifier/plugins/phorum/migrate.bbcode.phpnu �[��� <?php /** * This file is responsible for migrating from a specific markup language * like BBCode or Markdown to HTML. WARNING: THIS PROCESS IS NOT REVERSIBLE * * Copy this file to 'migrate.php' and it will automatically work for * BBCode; you may need to tweak this a little to get it to work for other * languages (usually, just replace the include name and the function name). * * If you do NOT want to have any migration performed (for instance, you * are installing the module on a new forum with no posts), simply remove * phorum_htmlpurifier_migrate() function. You still need migrate.php * present, otherwise the module won't work. This ensures that the user * explicitly says, "No, I do not need to migrate." */ if(!defined("PHORUM")) exit; require_once(dirname(__FILE__) . "/../bbcode/bbcode.php"); /** * 'format' hook style function that will be called to convert * legacy markup into HTML. */ function phorum_htmlpurifier_migrate($data) { return phorum_mod_bbcode_format($data); // bbcode's 'format' hook } // vim: et sw=4 sts=4 PK j�$ZT}�� � ( htmlpurifier/plugins/phorum/settings.phpnu �[��� <?php // based off of BBCode's settings file /** * HTML Purifier Phorum mod settings configuration. This provides * a convenient web-interface for editing the most common HTML Purifier * configuration directives. You can also specify custom configuration * by creating a 'config.php' file. */ if(!defined("PHORUM_ADMIN")) exit; // error reporting is good! error_reporting(E_ALL ^ E_NOTICE); // load library and other paraphenalia require_once './include/admin/PhorumInputForm.php'; require_once (dirname(__FILE__) . '/htmlpurifier/HTMLPurifier.auto.php'); require_once (dirname(__FILE__) . '/init-config.php'); require_once (dirname(__FILE__) . '/settings/migrate-sigs-form.php'); require_once (dirname(__FILE__) . '/settings/migrate-sigs.php'); require_once (dirname(__FILE__) . '/settings/form.php'); require_once (dirname(__FILE__) . '/settings/save.php'); // define friendly configuration directives. you can expand this array // to get more web-definable directives $PHORUM['mod_htmlpurifier']['directives'] = array( 'URI.Host', // auto-detectable 'URI.DisableExternal', 'URI.DisableExternalResources', 'URI.DisableResources', 'URI.Munge', 'URI.HostBlacklist', 'URI.Disable', 'HTML.TidyLevel', 'HTML.Doctype', // auto-detectable 'HTML.Allowed', 'AutoFormat', '-AutoFormat.Custom', 'AutoFormatParam', 'Output.TidyFormat', ); // lower this setting if you're getting time outs/out of memory $PHORUM['mod_htmlpurifier']['migrate-sigs-increment'] = 100; if (isset($_POST['reset'])) { unset($PHORUM['mod_htmlpurifier']['config']); } if ($offset = phorum_htmlpurifier_migrate_sigs_check()) { // migrate signatures phorum_htmlpurifier_migrate_sigs($offset); } elseif(!empty($_POST)){ // save settings phorum_htmlpurifier_save_settings(); } phorum_htmlpurifier_show_migrate_sigs_form(); echo '<br />'; phorum_htmlpurifier_show_form(); // vim: et sw=4 sts=4 PK j�$Z�x�U/ U/ , htmlpurifier/plugins/phorum/htmlpurifier.phpnu �[��� <?php /** * HTML Purifier Phorum Mod. Filter your HTML the Standards-Compliant Way! * * This Phorum mod enables users to post raw HTML into Phorum. But never * fear: with the help of HTML Purifier, this HTML will be beat into * de-XSSed and standards-compliant form, safe for general consumption. * It is not recommended, but possible to run this mod in parallel * with other formatters (in short, please DISABLE the BBcode mod). * * For help migrating from your previous markup language to pure HTML * please check the migrate.bbcode.php file. * * If you'd like to use this with a WYSIWYG editor, make sure that * editor sets $PHORUM['mod_htmlpurifier']['wysiwyg'] to true. Otherwise, * administrators who need to edit other people's comments may be at * risk for some nasty attacks. * * Tested with Phorum 5.2.11. */ // Note: Cache data is base64 encoded because Phorum insists on flinging // to the user and expecting it to come back unharmed, newlines and // all, which ain't happening. It's slower, it takes up more space, but // at least it won't get mutilated /** * Purifies a data array */ function phorum_htmlpurifier_format($data) { $PHORUM = $GLOBALS["PHORUM"]; $purifier =& HTMLPurifier::getInstance(); $cache_serial = $PHORUM['mod_htmlpurifier']['body_cache_serial']; foreach($data as $message_id => $message){ if(isset($message['body'])) { if ($message_id) { // we're dealing with a real message, not a fake, so // there a number of shortcuts that can be taken if (isset($message['meta']['htmlpurifier_light'])) { // format hook was called outside of Phorum's normal // functions, do the abridged purification $data[$message_id]['body'] = $purifier->purify($message['body']); continue; } if (!empty($PHORUM['args']['purge'])) { // purge the cache, must be below the following if unset($message['meta']['body_cache']); } if ( isset($message['meta']['body_cache']) && isset($message['meta']['body_cache_serial']) && $message['meta']['body_cache_serial'] == $cache_serial ) { // cached version is present, bail out early $data[$message_id]['body'] = base64_decode($message['meta']['body_cache']); continue; } } // migration might edit this array, that's why it's defined // so early $updated_message = array(); // create the $body variable if ( $message_id && // message must be real to migrate !isset($message['meta']['body_cache_serial']) ) { // perform migration $fake_data = array(); list($signature, $edit_message) = phorum_htmlpurifier_remove_sig_and_editmessage($message); $fake_data[$message_id] = $message; $fake_data = phorum_htmlpurifier_migrate($fake_data); $body = $fake_data[$message_id]['body']; $body = str_replace("<phorum break>\n", "\n", $body); $updated_message['body'] = $body; // save it in $body .= $signature . $edit_message; // add it back in } else { // reverse Phorum's pre-processing $body = $message['body']; // order is important $body = str_replace("<phorum break>\n", "\n", $body); $body = str_replace(array('<','>','&', '"'), array('<','>','&','"'), $body); if (!$message_id && defined('PHORUM_CONTROL_CENTER')) { // we're in control.php, so it was double-escaped $body = str_replace(array('<','>','&', '"'), array('<','>','&','"'), $body); } } $body = $purifier->purify($body); // dynamically update the cache (MUST BE DONE HERE!) // this is inefficient because it's one db call per // cache miss, but once the cache is in place things are // a lot zippier. if ($message_id) { // make sure it's not a fake id $updated_message['meta'] = $message['meta']; $updated_message['meta']['body_cache'] = base64_encode($body); $updated_message['meta']['body_cache_serial'] = $cache_serial; phorum_db_update_message($message_id, $updated_message); } // must not get overloaded until after we cache it, otherwise // we'll inadvertently change the original text $data[$message_id]['body'] = $body; } } return $data; } // ----------------------------------------------------------------------- // This is fragile code, copied from read.php:596 (Phorum 5.2.6). Please // keep this code in-sync with Phorum /** * Generates a signature based on a message array */ function phorum_htmlpurifier_generate_sig($row) { $phorum_sig = ''; if(isset($row["user"]["signature"]) && isset($row['meta']['show_signature']) && $row['meta']['show_signature']==1){ $phorum_sig=trim($row["user"]["signature"]); if(!empty($phorum_sig)){ $phorum_sig="\n\n$phorum_sig"; } } return $phorum_sig; } /** * Generates an edit message based on a message array */ function phorum_htmlpurifier_generate_editmessage($row) { $PHORUM = $GLOBALS['PHORUM']; $editmessage = ''; if(isset($row['meta']['edit_count']) && $row['meta']['edit_count'] > 0) { $editmessage = str_replace ("%count%", $row['meta']['edit_count'], $PHORUM["DATA"]["LANG"]["EditedMessage"]); $editmessage = str_replace ("%lastedit%", phorum_date($PHORUM["short_date_time"],$row['meta']['edit_date']), $editmessage); $editmessage = str_replace ("%lastuser%", $row['meta']['edit_username'], $editmessage); $editmessage = "\n\n\n\n$editmessage"; } return $editmessage; } // End fragile code // ----------------------------------------------------------------------- /** * Removes the signature and edit message from a message * @param $row Message passed by reference */ function phorum_htmlpurifier_remove_sig_and_editmessage(&$row) { $signature = phorum_htmlpurifier_generate_sig($row); $editmessage = phorum_htmlpurifier_generate_editmessage($row); $replacements = array(); // we need to remove add <phorum break> as that is the form these // extra bits are in. if ($signature) $replacements[str_replace("\n", "<phorum break>\n", $signature)] = ''; if ($editmessage) $replacements[str_replace("\n", "<phorum break>\n", $editmessage)] = ''; $row['body'] = strtr($row['body'], $replacements); return array($signature, $editmessage); } /** * Indicate that data is fully HTML and not from migration, invalidate * previous caches * @note This function could generate the actual cache entries, but * since there's data missing that must be deferred to the first read */ function phorum_htmlpurifier_posting($message) { $PHORUM = $GLOBALS["PHORUM"]; unset($message['meta']['body_cache']); // invalidate the cache $message['meta']['body_cache_serial'] = $PHORUM['mod_htmlpurifier']['body_cache_serial']; return $message; } /** * Overload quoting mechanism to prevent default, mail-style quote from happening */ function phorum_htmlpurifier_quote($array) { $PHORUM = $GLOBALS["PHORUM"]; $purifier =& HTMLPurifier::getInstance(); $text = $purifier->purify($array[1]); $source = htmlspecialchars($array[0]); return "<blockquote cite=\"$source\">\n$text\n</blockquote>"; } /** * Ensure that our format hook is processed last. Also, loads the library. * @credits <http://secretsauce.phorum.org/snippets/make_bbcode_last_formatter.php.txt> */ function phorum_htmlpurifier_common() { require_once(dirname(__FILE__).'/htmlpurifier/HTMLPurifier.auto.php'); require(dirname(__FILE__).'/init-config.php'); $config = phorum_htmlpurifier_get_config(); HTMLPurifier::getInstance($config); // increment revision.txt if you want to invalidate the cache $GLOBALS['PHORUM']['mod_htmlpurifier']['body_cache_serial'] = $config->getSerial(); // load migration if (file_exists(dirname(__FILE__) . '/migrate.php')) { include(dirname(__FILE__) . '/migrate.php'); } else { echo '<strong>Error:</strong> No migration path specified for HTML Purifier, please check <tt>modes/htmlpurifier/migrate.bbcode.php</tt> for instructions on how to migrate from your previous markup language.'; exit; } if (!function_exists('phorum_htmlpurifier_migrate')) { // Dummy function function phorum_htmlpurifier_migrate($data) {return $data;} } } /** * Pre-emptively performs purification if it looks like a WYSIWYG editor * is being used */ function phorum_htmlpurifier_before_editor($message) { if (!empty($GLOBALS['PHORUM']['mod_htmlpurifier']['wysiwyg'])) { if (!empty($message['body'])) { $body = $message['body']; // de-entity-ize contents $body = str_replace(array('<','>','&'), array('<','>','&'), $body); $purifier =& HTMLPurifier::getInstance(); $body = $purifier->purify($body); // re-entity-ize contents $body = htmlspecialchars($body, ENT_QUOTES, $GLOBALS['PHORUM']['DATA']['CHARSET']); $message['body'] = $body; } } return $message; } function phorum_htmlpurifier_editor_after_subject() { // don't show this message if it's a WYSIWYG editor, since it will // then be handled automatically if (!empty($GLOBALS['PHORUM']['mod_htmlpurifier']['wysiwyg'])) { $i = $GLOBALS['PHORUM']['DATA']['MODE']; if ($i == 'quote' || $i == 'edit' || $i == 'moderation') { ?> <div> <p> <strong>Notice:</strong> HTML has been scrubbed for your safety. If you would like to see the original, turn off WYSIWYG mode (consult your administrator for details.) </p> </div> <?php } return; } if (!empty($GLOBALS['PHORUM']['mod_htmlpurifier']['suppress_message'])) return; ?><div class="htmlpurifier-help"> <p> <strong>HTML input</strong> is enabled. Make sure you escape all HTML and angled brackets with <code>&lt;</code> and <code>&gt;</code>. </p><?php $purifier =& HTMLPurifier::getInstance(); $config = $purifier->config; if ($config->get('AutoFormat.AutoParagraph')) { ?><p> <strong>Auto-paragraphing</strong> is enabled. Double newlines will be converted to paragraphs; for single newlines, use the <code>pre</code> tag. </p><?php } $html_definition = $config->getDefinition('HTML'); $allowed = array(); foreach ($html_definition->info as $name => $x) $allowed[] = "<code>$name</code>"; sort($allowed); $allowed_text = implode(', ', $allowed); ?><p><strong>Allowed tags:</strong> <?php echo $allowed_text; ?>.</p><?php ?> </p> <p> For inputting literal code such as HTML and PHP for display, use CDATA tags to auto-escape your angled brackets, and <code>pre</code> to preserve newlines: </p> <pre><pre><![CDATA[ <em>Place code here</em> ]]></pre></pre> <p> Power users, you can hide this notice with: <pre>.htmlpurifier-help {display:none;}</pre> </p> </div><?php } // vim: et sw=4 sts=4 PK j�$Z�R�A� � "