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 }
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; }
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\r\n settings, edit that file. To use the web form, delete that file.<br />"; } else { $config = phorum_htmlpurifier_get_config(); if (!isset($_POST['reset'])) { $config->mergeArrayFromForm($_POST, 'config', $PHORUM['mod_htmlpurifier']['directives']); } $PHORUM['mod_htmlpurifier']['config'] = $config->getAll(); if (!phorum_htmlpurifier_commit_settings()) { $error = "Database error while updating settings."; } else { echo "Settings Updated<br />"; } } }