Example #1
0
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\r\n      the cache. Expect to see a flurry of database activity after you change\r\n      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_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();
}
Example #3
0
            foreach ($usergroups as $group_id => $group) {
                $group_perm = $group['user_status'];
                $group_info = phorum_db_get_groups($group_id);
                $frm->hidden("groups[{$group_id}]", "{$group_id}");
                $frm->addrow($group_info[$group_id]["name"], $frm->select_tag("group_perm[{$group_id}]", $group_options, $group_perm, $extra_opts));
            }
        }
        $frm->show();
    } else {
        echo "User Not Found.";
    }
    //display add user form
} elseif (isset($_REQUEST["add"]) || isset($addUser_error)) {
    $username = isset($user_data["username"]) ? $user_data["username"] : "";
    $real_name = isset($user_data["real_name"]) ? $user_data["real_name"] : "";
    $email = isset($user_data["email"]) ? $user_data["email"] : "";
    $admin = isset($user_data["admin"]) ? $user_data["admin"] : "";
    print "<a href=\"" . htmlspecialchars($referrer) . "\">Back to the user overview</a><br/>";
    $frm = new PhorumInputForm("", "post", "Add User");
    $frm->hidden("module", "users");
    $frm->hidden("referrer", $referrer);
    $frm->hidden("addUser", 1);
    $frm->addbreak("Add User");
    $frm->addrow("User Name", $frm->text_box("username", $username, 50));
    $frm->addrow("Real Name", $frm->text_box("real_name", $real_name, 50));
    $frm->addrow("Email", $frm->text_box("email", $email, 50));
    $frm->addrow("Password", $frm->text_box("password1", "", 0, 0, true));
    $frm->addrow("Password (Confirmation)", $frm->text_box("password2", "", 0, 0, true));
    $frm->addrow("Administrator", $frm->select_tag("admin", array("No", "Yes"), $admin));
    $frm->show();
}
Example #4
0
function phorum_generate_language_file($lang, $displayname, $generate_new)
{
    global $fullfile;
    $basename = preg_replace('/-.*$/', '', $lang);
    $fullfile = $basename . '-' . PHORUM . '.php';
    // Get our default language file.
    $DEFAULT = phorum_get_language(PHORUM_DEFAULT_LANGUAGE);
    // Get the languagefile to update, unless generating a new language.
    $CURRENT = array();
    if (!$generate_new) {
        $CURRENT = phorum_get_language($lang);
    } else {
        $CURRENT['STORE']['language_hide'] = 0;
        $CURRENT['STORE']['language'] = urlencode("'" . addslashes($displayname) . "'");
    }
    // Keep a copy of the languagefile.
    $CURRENT_COPY = $CURRENT;
    // Collect all language strings from the distribution files.
    $language_strings = phorum_extract_language_strings();
    $frm = new PhorumInputForm("", "post", "Download new " . htmlspecialchars($fullfile) . " language file");
    $frm->hidden("module", "manage_languages");
    $frm->hidden("action", "download_lang");
    $frm->hidden("filename", $lang);
    if (!$generate_new) {
        $frm->addmessage("<h2>Update language: " . htmlspecialchars($displayname) . "</h2>" . "Below you will see all the things that have been updated " . "to get to the new version of the language file. At the " . "bottom of the page you will find a download button to download " . "the updated language file. This language file has to be placed " . "in <b>include/lang/" . htmlspecialchars($lang) . ".php</b> to make it " . "available to Phorum (backup your old file first of course!). " . "If new language strings have been added, " . "they will be marked with '***' in the language file, so it's " . "easy for you to find them.");
        $frm->addbreak("Updates for the new language file");
    } else {
        $frm->addmessage("<h2>Generate new language: " . htmlspecialchars($displayname) . "</h2>" . "A new language file has been generated. Below you will find " . "a download button to download the new file. In this file, you " . "can replace all language strings by strings which apply to " . "\"" . htmlspecialchars($displayname) . "\". After updating the new " . "file, you will have to place it in " . "<b>include/lang/" . htmlspecialchars($basename) . ".php</b>, " . "so Phorum can use it (backup your old file first of course!).");
    }
    $notifies = 0;
    // Check for language strings that are missing.
    $missing = array();
    $count_missing = 0;
    foreach ($language_strings as $string => $data) {
        // This one is special.
        if ($string == 'TIME') {
            continue;
        }
        // Multi-dimentional string? That must be a module lang string
        // (cut at PHORUM->LANG->myarray-|>word).
        if (preg_match('/-$/', $string)) {
            continue;
        }
        if (!isset($CURRENT["DATA"]["LANG"][$string])) {
            array_push($missing, $string);
            $translation = urlencode("'" . addslashes($string) . "'");
            if (isset($DEFAULT["DATA"]["LANG"][$string])) {
                $translation = $DEFAULT["DATA"]["LANG"][$string];
            }
            $CURRENT_COPY["DATA"]["LANG"][$string] = urlencode("'***'. " . urldecode($translation));
            $count_missing++;
            if (!$generate_new) {
                $frm->addrow("MISSING ({$count_missing})", $string);
                $notifies++;
            }
        } else {
            unset($CURRENT["DATA"]["LANG"][$string]);
        }
    }
    // Check for language strings that are deprecated.
    $deprecated = array();
    $count_deprecated = 0;
    if (!$generate_new) {
        foreach ($CURRENT["DATA"]["LANG"] as $string => $translation) {
            if ($string == 'TIME') {
                continue;
            }
            // This one is special.
            $count_deprecated++;
            $deprecated[$string] = true;
            // Only notify the deprecation if not already in deprecated state.
            if (!isset($CURRENT['STORE']['DEPRECATED'][$string])) {
                $frm->addrow("DEPRECATED ({$count_deprecated})", htmlspecialchars($string));
                $notifies++;
            }
        }
    }
    $CURRENT_COPY['STORE']['DEPRECATED'] = $deprecated;
    // Restore our full current language data from the copy.
    $CURRENT = $CURRENT_COPY;
    // Copy values from our default language to the current language.
    $copyfields = array('long_date', 'long_date_time', 'short_date', 'short_date_time', 'locale', 'thous_sep', 'dec_sep');
    foreach ($copyfields as $f) {
        if (!isset($CURRENT[$f])) {
            $CURRENT[$f] = $DEFAULT[$f];
            if (!$generate_new) {
                $frm->addrow("MISSING VARIABLE", "{$f} set to default " . htmlspecialchars(urldecode($DEFAULT[$f])));
                $notifies++;
            }
        }
    }
    // Copy default values beneath DATA to the current language.
    $datafields = array('CHARSET', 'HCHARSET', 'MAILENCODING', 'LANG_META');
    foreach ($datafields as $f) {
        if (!isset($CURRENT['DATA'][$f]) || $CURRENT['DATA'][$f] == '') {
            $CURRENT['DATA'][$f] = $DEFAULT['DATA'][$f];
            if (!$generate_new) {
                $frm->addrow("MISSING VARIABLE", "DATA->{$f} set to default " . htmlspecialchars(urldecode($DEFAULT['DATA'][$f])));
                $notifies++;
            }
        }
    }
    // Copy default values for timezone information to the current language.
    foreach ($DEFAULT['DATA']['LANG']['TIME'] as $key => $val) {
        if (!isset($CURRENT['DATA']['LANG']['TIME'][$key])) {
            $CURRENT['DATA']['LANG']['TIME'][$key] = $val;
            if (!$generate_new) {
                $dflt = htmlspecialchars(urldecode($DEFAULT['DATA']['LANG']['TIME'][$key]));
                $frm->addrow("MISSING TZINFO", "TZ {$key} set to default<br/>{$dflt}");
                $notifies++;
            }
        }
    }
    if ($generate_new) {
        $frm->addrow("COMPLETED", "A new language file has been generated for you");
    } elseif (!$notifies) {
        $frm->addrow("NONE", "There were no updates for the current \"{$lang}\" language file");
    }
    $frm->show();
    phorum_write_language_file($lang, $CURRENT);
}