Esempio n. 1
0
/**
 * This function will check if an upgrade of the database scheme is needed.
 * It is generic for all database layers.
 */
function event_logging_db_install()
{
    $PHORUM = $GLOBALS["PHORUM"];
    $version = isset($PHORUM["mod_event_logging_installed"]) ? $PHORUM["mod_event_logging_installed"] : 0;
    while ($version < EVENT_LOGGING_DB_VERSION) {
        // Initialize the settings array that we will be saving.
        $version++;
        $settings = array("mod_event_logging_installed" => $version);
        $sqlfile = "./mods/event_logging/db/" . $PHORUM["DBCONFIG"]["type"] . "/{$version}.php";
        if (!file_exists($sqlfile)) {
            print "<b>Unexpected situation on installing " . "the Event Logging module</b>: " . "unable to find the database schema setup script " . htmlspecialchars($sqlfile);
            return false;
        }
        $sqlqueries = array();
        include $sqlfile;
        if (count($sqlqueries) == 0) {
            print "<b>Unexpected situation on installing " . "the Event Logging module</b>: could not read any SQL " . "queries from file " . htmlspecialchars($sqlfile);
            return false;
        }
        $err = phorum_db_run_queries($sqlqueries);
        if ($err) {
            print "<b>Unexpected situation on installing " . "the Event Logging module</b>: running the " . "install queries from file " . htmlspecialchars($sqlfile) . " failed. The error was " . htmlspecialchars($err);
            return false;
        }
        // Save our settings.
        if (!phorum_db_update_settings($settings)) {
            print "<b>Unexpected situation on installing " . "the Event Logging module</b>: updating the " . "mod_event_logging_installed setting failed";
            return false;
        }
    }
    return true;
}
Esempio n. 2
0
function spamhurdles_db_install()
{
    $version = isset($GLOBALS["PHORUM"]["mod_spamhurdles_installed"]) ? $GLOBALS["PHORUM"]["mod_spamhurdles_installed"] : 0;
    while ($version < SPAMHURDLES_DB_VERSION) {
        // Initialize the settings array that we will be saving.
        $version++;
        $settings = array("mod_spamhurdles_installed" => $version);
        $sqlfile = "./mods/spamhurdles/db/" . $GLOBALS["PHORUM"]["DBCONFIG"]["type"] . "/{$version}.php";
        if (!file_exists($sqlfile)) {
            print "<b>Unexpected situation on installing " . "the Spam Hurdles module</b>: unable to find the database " . "scheme setup script " . htmlspecialchars($sqlfile);
            return false;
        }
        $sqlqueries = array();
        include $sqlfile;
        if (count($sqlqueries) == 0) {
            print "<b>Unexpected situation on installing " . "the Spam Hurdles module</b>: could not read any SQL " . "queries from file " . htmlspecialchars($sqlfile);
            return false;
        }
        $err = phorum_db_run_queries($sqlqueries);
        if ($err) {
            print "<b>Unexpected situation on installing " . "the Spam Hurdles module</b>: running the " . "install queries from file " . htmlspecialchars($sqlfile) . " failed: " . htmlspecialchars($err);
            return false;
        }
        // Save our settings.
        if (!phorum_db_update_settings($settings)) {
            print "<b>Unexpected situation on installing " . "the Spam Hurdles module</b>: updating the " . "mod_spamhurdles_installed setting failed";
            return false;
        }
    }
    return true;
}
Esempio n. 3
0
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;
}
Esempio n. 4
0
function spamhurdles_db_init()
{
    global $PHORUM;
    $layerpath = "./mods/spamhurdles/db/{$PHORUM["DBCONFIG"]["type"]}";
    // Allow db layers to provide an initialization script of their own.
    // The main goal for this script is to allow a db layer to override the
    // $PHORUM['spamhurdles_table'] variable.
    if (file_exists("{$layerpath}/db.php")) {
        require_once "{$layerpath}/db.php";
    }
    $version = isset($PHORUM["mod_spamhurdles_installed"]) ? $PHORUM["mod_spamhurdles_installed"] : 0;
    while ($version < SPAMHURDLES_DB_VERSION) {
        // Initialize the settings array that we will be saving.
        $version++;
        $settings = array("mod_spamhurdles_installed" => $version);
        $sqlfile = "{$layerpath}/{$version}.php";
        if (!file_exists($sqlfile)) {
            print "<b>Unexpected situation on installing " . "the Spam Hurdles module</b>: unable to find the database " . "scheme setup script " . htmlspecialchars($sqlfile);
            return false;
        }
        $sqlqueries = array();
        include $sqlfile;
        if (count($sqlqueries) == 0) {
            print "<b>Unexpected situation on installing " . "the Spam Hurdles module</b>: could not read any SQL " . "queries from file " . htmlspecialchars($sqlfile);
            return false;
        }
        $err = phorum_db_run_queries($sqlqueries);
        if ($err) {
            print "<b>Unexpected situation on installing " . "the Spam Hurdles module</b>: running the " . "install queries from file " . htmlspecialchars($sqlfile) . " failed: " . htmlspecialchars($err);
            return false;
        }
        // Save our settings.
        if (!phorum_db_update_settings($settings)) {
            print "<b>Unexpected situation on installing " . "the Spam Hurdles module</b>: updating the " . "mod_spamhurdles_installed setting failed";
            return false;
        }
    }
    return true;
}
Esempio n. 5
0
/**
 * Check if there are modules for which the module information is updated.
 *
 * @param boolean $do_reset
 *     If this parameter has a true value, then the active status for
 *     the module information is stored in the database.
 *
 * @return array
 *     An array of module names for which the module information was updated.
 */
function phorum_api_modules_check_updated_info($do_reset = FALSE)
{
    global $PHORUM;
    $existing = empty($PHORUM['mod_info_timestamps']) ? array() : $PHORUM['mod_info_timestamps'];
    $new = array();
    $need_update = array();
    if (!empty($PHORUM['mods'])) {
        foreach ($PHORUM['mods'] as $mod => $active) {
            if (!$active) {
                continue;
            }
            $info = "./mods/{$mod}/info.txt";
            $filemod = "./mods/{$mod}.php";
            if (file_exists($info)) {
                $time = @filemtime($info);
            } elseif (file_exists($filemod)) {
                $time = @filemtime($filemod);
            } else {
                continue;
            }
            if (!isset($existing[$mod]) || $existing[$mod] != $time) {
                $need_update[] = $mod;
            }
            $new[$mod] = $time;
        }
    }
    $PHORUM['mod_info_timestamps'] = $new;
    // Store the settings in the database if a reset is requested.
    if ($do_reset) {
        phorum_db_update_settings(array("mod_info_timestamps" => $new));
    }
    return $need_update;
}
Esempio n. 6
0
                }
                $_POST[$field] = $private_key;
                break;
            case "display_name_source":
                if ($_POST[$field] != $PHORUM["display_name_source"]) {
                    $need_display_name_updates = TRUE;
                }
                break;
        }
        if ($error) {
            break;
        }
    }
    if (empty($error)) {
        unset($_POST["module"]);
        if (phorum_db_update_settings($_POST)) {
            $redir = $PHORUM["admin_http_path"];
            if ($need_display_name_updates) {
                $redir .= "?module=update_display_names";
            }
            phorum_redirect_by_url($redir);
            exit;
        } else {
            $error = "Database error while updating settings.";
        }
    }
}
if ($error) {
    phorum_admin_error($error);
}
// create the time zone drop down array
Esempio n. 7
0

    $upgradefile=$upgradepath.$file;

    if(file_exists($upgradefile)) {
        echo "Upgrading from db-version $fromversion to $pure_version ... \n";
        flush();

        if (! is_readable($upgradefile))
        die("$upgradefile is not readable. Make sure the file has got the neccessary permissions and try again.");


        $upgrade_queries=array();
        include($upgradefile);
        $err=phorum_db_run_queries($upgrade_queries);
        if($err){
            echo "an error occured: $err ... try to continue.\n";
        } else {
            echo "done.\n";
        }
        $GLOBALS["PHORUM"]["internal_version"]=$pure_version;
        phorum_db_update_settings(array("internal_version"=>$pure_version));
    } else {
        echo "Ooops, the upgradefile is missing. How could this happen?\n";
    }

    $fromversion=$pure_version;

}
?>
Esempio n. 8
0
//   but WITHOUT ANY WARRANTY, without even the implied warranty of           //
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     //
//                                                                            //
//   You should have received a copy of the Phorum License                    //
//   along with this program.                                                 //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
if (!defined("PHORUM_ADMIN")) {
    return;
}
$error = "";
if (count($_POST)) {
    // some sanity checking would be nice ;)
    $PHORUM["smtp_mail"] = array('host' => $_POST['host'], 'port' => empty($_POST['port']) ? "25" : $_POST['port'], 'auth' => $_POST['auth'], 'username' => $_POST['auth_username'], 'password' => $_POST['auth_password'], 'conn' => $_POST['conn'], 'log_successful' => $_POST['log_successful'], 'show_errors' => $_POST['show_errors']);
    if (empty($error)) {
        phorum_db_update_settings(array("smtp_mail" => $PHORUM["smtp_mail"]));
        phorum_admin_okmsg("Settings updated");
    }
}
include_once "./include/admin/PhorumInputForm.php";
$frm = new PhorumInputForm("", "post", "Save");
$frm->hidden("module", "modsettings");
$frm->hidden("mod", "smtp_mail");
$frm->addbreak("Settings for the SMTP Mail Module");
$frm->addrow("Hostname of mailserver", $frm->text_box("host", $PHORUM['smtp_mail']['host'], 50));
$frm->addrow("Port of mailserver", $frm->text_box("port", $PHORUM['smtp_mail']['port'], 5) . " (Default Port is 25, unencrypted. Encrypted Port is usually 465)");
$frm->addrow("Connection Type", $frm->select_tag("conn", array('plain' => 'Plain Connection', 'ssl' => 'SSL-Encryption', 'tls' => 'TLS-Encryption'), $PHORUM['smtp_mail']['conn']) . " (e.g. Google-Mail connection needs TLS)");
$frm->addrow("Use SMTP Auth", $frm->select_tag("auth", array(1 => 'Yes', 0 => 'No'), $PHORUM['smtp_mail']['auth']));
$frm->addrow("SMTP Auth Username", $frm->text_box("auth_username", $PHORUM['smtp_mail']['username'], 50));
$frm->addrow("SMTP Auth Password", $frm->text_box("auth_password", $PHORUM['smtp_mail']['password'], 50, 0, true));
$frm->addsubbreak("Logging / Errorhandling");
Esempio n. 9
0
<?php

if (!defined("PHORUM_ADMIN")) {
    return;
}
// initialize the "allow_pm_email_notify" setting
if (!isset($PHORUM["allow_pm_email_notify"])) {
    phorum_db_update_settings(array("allow_pm_email_notify" => 1));
}
Esempio n. 10
0
<?php

if(!defined("PHORUM_ADMIN")) return;

// save settings
if(count($_POST)){
    $PHORUM["fsattachments"]["path"]=$_POST["path"];

    if(!phorum_db_update_settings(array("fsattachments"=>$PHORUM["fsattachments"]))){
        $error="Database error while updating settings.";
    }
    else {
        echo "Settings Updated<br />";
    }
}

include_once "./include/admin/PhorumInputForm.php";

$frm = new PhorumInputForm ("", "post", "Save");

$frm->hidden("module", "modsettings");
$frm->hidden("mod", "fsattachments"); // this is the directory name that the Settings file lives in

if (!empty($error)){
    echo "$error<br />";
}

$frm->addbreak("Edit settings for the Filesystem Attachment Storage module");

$frm->addmessage("This is the directory where files will be stored on disk.  You need to enter a full path to the directory.  It is up to you to ensure that the web server daemon can write to this directory.");
Esempio n. 11
0
<?php

////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//   Copyright (C) 2007  Phorum Development Team                              //
//   http://www.phorum.org                                                    //
//                                                                            //
//   This program is free software. You can redistribute it and/or modify     //
//   it under the terms of either the current Phorum License (viewable at     //
//   phorum.org) or the Phorum License that was distributed with this file    //
//                                                                            //
//   This program is distributed in the hope that it will be useful,          //
//   but WITHOUT ANY WARRANTY, without even the implied warranty of           //
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     //
//                                                                            //
//   You should have received a copy of the Phorum License                    //
//   along with this program.                                                 //
////////////////////////////////////////////////////////////////////////////////
if (!defined("PHORUM_ADMIN")) {
    return;
}
phorum_db_update_settings(array("status" => $_POST["status"]));
phorum_redirect_by_url($PHORUM["admin_http_path"]);
exit;
Esempio n. 12
0
         $_POST["inherit_id"] = "NULL";
         unset($_POST["pub_perms"]);
         unset($_POST["reg_perms"]);
     }
 }
 if (defined("PHORUM_EDIT_FORUM") || defined("PHORUM_DEFAULT_OPTIONS")) {
     $forum_settings = $_POST;
     if (defined("PHORUM_DEFAULT_OPTIONS")) {
         // these two will not be set if no options were checked
         if (empty($forum_settings["pub_perms"])) {
             $forum_settings["pub_perms"] = 0;
         }
         if (empty($forum_settings["reg_perms"])) {
             $forum_settings["reg_perms"] = 0;
         }
         $res = phorum_db_update_settings(array("default_forum_options" => $forum_settings));
     } else {
         $res = phorum_db_update_forum($forum_settings);
         // set/build the forum_path
         $cur_forum_id = $forum_settings['forum_id'];
         $built_paths = phorum_admin_build_path_array($cur_forum_id);
         phorum_db_update_forum(array('forum_id' => $cur_forum_id, 'forum_path' => $built_paths[$cur_forum_id]));
     }
     // setting the current settings to all forums/folders inheriting from this forum/default settings
     $forum_inherit_settings = phorum_db_get_forums(false, false, false, intval($_POST["forum_id"]));
     foreach ($forum_inherit_settings as $inherit_setting) {
         $forum_settings["forum_id"] = $inherit_setting["forum_id"];
         // We don't need to inherit this settings
         unset($forum_settings["name"]);
         unset($forum_settings["description"]);
         unset($forum_settings["active"]);
Esempio n. 13
0
<?php

if (!defined("PHORUM_ADMIN")) {
    return;
}
// For shorter writing.
$settings =& $GLOBALS["PHORUM"]["mod_event_logging"];
$eventtypes =& $GLOBALS["PHORUM"]["DATA"]["MOD_EVENT_LOGGING"]["EVENT_TYPES"];
if (count($_POST)) {
    $settings["resolve_hostnames"] = isset($_POST["resolve_hostnames"]) ? 1 : 0;
    $settings["max_log_entries"] = (int) $_POST["max_log_entries"];
    $settings["min_log_level"] = (int) $_POST["min_log_level"];
    foreach ($eventtypes as $type => $desc) {
        $settings["do_log_{$type}"] = isset($_POST["do_log_{$type}"]) ? 1 : 0;
    }
    phorum_db_update_settings(array("mod_event_logging" => $settings));
    phorum_admin_okmsg("The settings were successfully saved.");
}
// Create the settings form.
include_once "./include/admin/PhorumInputForm.php";
$frm = new PhorumInputForm("", "post", "Save settings");
$frm->hidden("module", "modsettings");
$frm->hidden("mod", "event_logging");
$frm->hidden("el_action", "settings");
$frm->addbreak("General Settings");
$row = $frm->addrow("Minimum log level", $frm->select_tag("min_log_level", $GLOBALS["PHORUM"]["DATA"]["MOD_EVENT_LOGGING"]["LOGLEVELS"], $settings["min_log_level"]));
$frm->addhelp($row, "Minimum log level", "This option configures the minimum log level for which log messages are written to the event log. Events with a lower log level will not be written.<br/><br/>\"Debug\" is the lowest log level and \"Alert\" the highest, so to log all events, set this option to \"Debug\".");
$row = $frm->addrow("Maximum amount of stored event logs (0 = unlimited)", $frm->text_box("max_log_entries", $settings["max_log_entries"], 5));
$frm->addhelp($row, "Maximum amount of stored event logs", "This option configures the maximum amount of event logs that can be stored in the database at a given time. If the amount of event logs grows larger than this configured maximum, then old entries will be automatically cleaned up.<br/><br/>If you do not want a limit on the number of event logs, then set this option to 0 (zero).");
$row = $frm->addrow("Resolve IP addresses to host names when writing the event log", $frm->checkbox("resolve_hostnames", "1", "", $settings["resolve_hostnames"]));
$frm->addhelp($row, "Resolve IP addresses", "If this option is enabled, the IP address of the visitor will immediately be resolved into its hostname. Enabling this option can result in delays for the user, in case hostname lookups are slow for some reason.<br/><br/><b>Because of the performance penalty, we do not recommend enabling this option, unless you really need it and know what you are doing.</b>");
Esempio n. 14
0
$curr = "NEW";
$ban_types = array(PHORUM_BAD_IPS => "IP Address/Hostname", PHORUM_BAD_NAMES => "Name/User Name", PHORUM_BAD_EMAILS => "Email Address", PHORUM_BAD_USERID => "User-Id (registered User)", PHORUM_BAD_SPAM_WORDS => "Illegal Words (SPAM)");
$match_types = array("String", "PCRE");
$forum_list = phorum_get_forum_info(2);
$forum_list[0] = "GLOBAL";
if (count($_POST) && $_POST["string"] != "") {
    if ($_POST["curr"] != "NEW") {
        $ret = phorum_db_mod_banlists($_POST['type'], $_POST['pcre'], $_POST['string'], $_POST['forum_id'], $_POST['comments'], $_POST['curr']);
        if (isset($PHORUM['cache_banlists']) && $PHORUM['cache_banlists']) {
            // we need to increase the version in that case to
            // invalidate them all in the cache.
            // TODO: I think I have to work out a way to make the same
            // work with vroots
            if ($_POST['forum_id'] == 0) {
                $PHORUM['banlist_version'] = $PHORUM['banlist_version'] + 1;
                phorum_db_update_settings(array('banlist_version' => $PHORUM['banlist_version']));
            } else {
                // remove the one for that forum
                phorum_cache_remove('banlist', $_POST['forum_id']);
            }
        }
    } else {
        $ret = phorum_db_mod_banlists($_POST['type'], $_POST['pcre'], $_POST['string'], $_POST['forum_id'], $_POST['comments'], 0);
    }
    if (!$ret) {
        $error = "Database error while updating settings.";
    } else {
        phorum_admin_okmsg("Ban Item Updated");
    }
}
if (isset($_POST["curr"]) && isset($_POST["delete"]) && $_POST["confirm"] == "Yes") {
Esempio n. 15
0
/**
 * This function can perform multiple banlist checks at once and will
 * automatically generate an appropriate error message when a banlist
 * match is found.
 * @param bans - an array of bans to check. Each element in this array is an
 *               array itself with two elements: the value to check and the
 *               type of banlist to check against. One special case:
 *               if the type if PHORUM_BAD_IPS, the value may be NULL.
 *               In that case the IP/hostname of the client will be checked.
 * @return - An error message in case a banlist match was found or NULL
 *           if no match was found.
 */
function phorum_check_bans($bans)
{
    $PHORUM = $GLOBALS["PHORUM"];
    // A mapping from bantype -> error message to return on match.
    $phorum_bantype2error = array(PHORUM_BAD_NAMES => "ErrBannedName", PHORUM_BAD_EMAILS => "ErrBannedEmail", PHORUM_BAD_USERID => "ErrBannedUser", PHORUM_BAD_IPS => "ErrBannedIP", PHORUM_BAD_SPAM_WORDS => "ErrBannedContent");
    // These language strings are set dynamically, so the language
    // tool won't recognize them automatically. Therefore they are
    // mentioned here.
    // $PHORUM["DATA"]["LANG"]["ErrBannedName"]
    // $PHORUM["DATA"]["LANG"]["ErrBannedEmail"]
    // $PHORUM["DATA"]["LANG"]["ErrBannedUser"]
    // $PHORUM["DATA"]["LANG"]["ErrBannedIP"]
    // $PHORUM["DATA"]["LANG"]["ErrBannedContent"]
    $cache_key = $PHORUM['forum_id'];
    // Load the ban lists.
    if (!isset($GLOBALS["PHORUM"]["banlists"])) {
        if (!empty($PHORUM['cache_banlists']) && !empty($PHORUM['banlist_version'])) {
            $GLOBALS["PHORUM"]["banlists"] = phorum_cache_get('banlist', $cache_key, $PHORUM['banlist_version']);
            if (!is_array($GLOBALS["PHORUM"]["banlists"]) || !count($GLOBALS["PHORUM"]["banlists"])) {
                unset($GLOBALS["PHORUM"]["banlists"]);
            }
        }
        // not found or no caching enabled
        if (!isset($GLOBALS["PHORUM"]["banlists"])) {
            $GLOBALS["PHORUM"]["banlists"] = phorum_db_get_banlists();
            if (isset($GLOBALS["PHORUM"]["banlists"]) && isset($PHORUM['cache_banlists']) && $PHORUM['cache_banlists']) {
                if (!isset($PHORUM['banlist_version'])) {
                    $PHORUM['banlist_version'] = 1;
                    phorum_db_update_settings(array('banlist_version' => 1));
                }
                phorum_cache_put('banlist', $cache_key, $GLOBALS["PHORUM"]["banlists"], 7200, $PHORUM['banlist_version']);
            }
        }
    }
    if (!isset($GLOBALS['PHORUM']['banlists'])) {
        return NULL;
    }
    // Run the checks.
    for (;;) {
        // An array for adding ban checks on the fly.
        $add_bans = array();
        foreach ($bans as $ban) {
            // Checking IP/hostname, but no value set? Then add the IP-address
            // and hostname (if DNS lookups are enabled) to the end of the checking
            // queue and continue with the next check.
            if ($ban[1] == PHORUM_BAD_IPS && $ban[0] == NULL) {
                $add_bans[] = array($_SERVER["REMOTE_ADDR"], PHORUM_BAD_IPS);
                if ($PHORUM["dns_lookup"]) {
                    $resolved = @gethostbyaddr($_SERVER["REMOTE_ADDR"]);
                    if (!empty($resolved) && $resolved != $_SERVER["REMOTE_ADDR"]) {
                        $add_bans[] = array($resolved, PHORUM_BAD_IPS);
                    }
                }
                continue;
            }
            // Do a single banlist check. Return an error if we find a match.
            if (!phorum_check_ban_lists($ban[0], $ban[1])) {
                $msg = $PHORUM["DATA"]["LANG"][$phorum_bantype2error[$ban[1]]];
                // Replace %name% with the blocked string.
                $msg = str_replace('%name%', htmlspecialchars($ban[0]), $msg);
                return $msg;
            }
        }
        // Bans added on the fly? Then restart the loop.
        if (count($add_bans) == 0) {
            break;
        } else {
            $bans = $add_bans;
        }
    }
    return NULL;
}
Esempio n. 16
0
/**
 * Check and fix the custom profile field configuration.
 *
 * This function has mainly been implemented for fixing problems that
 * are introduced by modules that create custom profile fields on their
 * own. Besides that, it was also written to upgrade the profile field
 * configuration, because Phorum 5.2 introduced some new fields in
 * the config.
 */
function phorum_api_custom_profile_field_checkconfig()
{
    global $PHORUM;
    // Used to find the real maximum used field id.
    $max_id = isset($PHORUM['PROFILE_FIELDS']['num_fields']) ? (int) $PHORUM['PROFILE_FIELDS']['num_fields'] : 0;
    foreach ($PHORUM['PROFILE_FIELDS'] as $id => $config) {
        // Keep track of the highest id that we see.
        if ($id > $max_id) {
            $max_id = $id;
        }
        // The least that should be in the config, is the name of the
        // field. If there is no name, then we don't bother at all.
        if (!isset($config['name']) || $config['name'] == '') {
            continue;
        }
        // 5.2 includes the id in the field configuration.
        if (empty($config['id'])) {
            $PHORUM['PROFILE_FIELDS'][$id]['id'] = $id;
        }
        // Some default values.
        if (!array_key_exists('length', $config)) {
            $PHORUM['PROFILE_FIELDS'][$id]['length'] = 255;
        }
        if (!array_key_exists('html_disabled', $config)) {
            $PHORUM['PROFILE_FIELDS'][$id]['html_disabled'] = TRUE;
        }
        if (!array_key_exists('show_in_admin', $config)) {
            $PHORUM['PROFILE_FIELDS'][$id]['show_in_admin'] = FALSE;
        }
        // Some typecasting won't hurt.
        settype($PHORUM['PROFILE_FIELDS'][$id]['id'], 'int');
        settype($PHORUM['PROFILE_FIELDS'][$id]['name'], 'string');
        settype($PHORUM['PROFILE_FIELDS'][$id]['length'], 'int');
        settype($PHORUM['PROFILE_FIELDS'][$id]['html_disabled'], 'bool');
        settype($PHORUM['PROFILE_FIELDS'][$id]['show_in_admin'], 'bool');
    }
    // Set the maximum field id that we've seen.
    $PHORUM['PROFILE_FIELDS']['num_fields'] = $max_id;
    // Save the custom profile field settings to the database.
    phorum_db_update_settings(array('PROFILE_FIELDS' => $PHORUM['PROFILE_FIELDS']));
}
Esempio n. 17
0
    $error="";
    $curr="NEW";

    // retrieving the forum-info
    $forum_list=phorum_get_forum_info(2);

    $forum_list[0]="GLOBAL";

    // conversion of old data if existing
    if(isset($PHORUM["bad_words"]) && count($PHORUM['bad_words'])) {
    print "upgrading badwords<br>";
        foreach($PHORUM['bad_words'] as $key => $data) {
            phorum_db_mod_banlists(PHORUM_BAD_WORDS ,0 ,$data ,0 ,0);
            unset($PHORUM["bad_words"][$key]);
        }
        phorum_db_update_settings(array("bad_words"=>$PHORUM["bad_words"]));
    }

    if(count($_POST) && $_POST["string"]!=""){
        if($_POST["curr"]!="NEW"){
            $ret=phorum_db_mod_banlists(PHORUM_BAD_WORDS ,0 ,$_POST["string"] ,$_POST['forumid'] ,$_POST['curr']);
        } else {
            $ret=phorum_db_mod_banlists(PHORUM_BAD_WORDS ,0 ,$_POST["string"] ,$_POST['forumid'] ,0);
        }

        if(!$ret){
            $error="Database error while updating badwords.";
        } else {
            echo "Bad Word Added<br />";
        }
    }
Esempio n. 18
0
    function phorum_upgrade_tables($fromversion,$toversion) {

          $PHORUM=$GLOBALS['PHORUM'];

          if(empty($fromversion) || empty($toversion)){
              die("Something is wrong with the upgrade script.  Please contact the Phorum Dev Team. ($fromversion,$toversion)");
          }

          $msg="";
          $upgradepath="./include/db/upgrade/{$PHORUM['DBCONFIG']['type']}/";

          // read in all existing files
          $dh=opendir($upgradepath);
          $upgradefiles=array();
          while ($file = readdir ($dh)) {
              if (substr($file,-4,4) == ".php") {
                  $upgradefiles[]=$file;
              }
          }
          unset($file);
          closedir($dh);

          // sorting by number
          sort($upgradefiles,SORT_NUMERIC);
          reset($upgradefiles);

          // advance to current version
          while(list($key,$val)=each($upgradefiles)) {
              if($val == $fromversion.".php")
              break;
          }



          // get the file for the next version (which we will upgrade to)
          list($dump,$file) = each($upgradefiles);

          // extract the pure version, needed as internal version
          $pure_version = basename($file,".php");

          if(empty($pure_version)){
              die("Something is wrong with the upgrade script.  Please contact the Phorum Dev Team. ($fromversion,$toversion)");
          }


          $upgradefile=$upgradepath.$file;

          if(file_exists($upgradefile)) {
              if (! is_readable($upgradefile))
                die("$upgradefile is not readable. Make sure the file has got the neccessary permissions and try again.");

              $msg.="Upgrading from db-version $fromversion to $pure_version ... ";
              $upgrade_queries=array();
              include($upgradefile);
              $err=phorum_db_run_queries($upgrade_queries);
              if($err){
                  $msg.= "an error occured: $err ... try to continue.<br />\n";
              } else {
                  $msg.= "done.<br />\n";
              }
              $GLOBALS["PHORUM"]["internal_version"]=$pure_version;
              phorum_db_update_settings(array("internal_version"=>$pure_version));
          } else {
              $msg="Ooops, the upgradefile is missing. How could this happen?";
          }

          return $msg;
    }
Esempio n. 19
0
/**
 * Perform the upgrade for a single upgrade file.
 *
 * @param $upgrades - An upgrade description. One element from the array
 *                    as returned by phorum_dbupgrade_getupgrades().
 * @param $update_internal_version - whether to update the internal version
 *                    for Phorum or not. This one is TRUE by default.
 *                    It can be used by scripts that have to re-run an old
 *                    single upgrade file and for which the internal version
 *                    should not be put back to an old value.
 * @return $msg - Describes the results of the upgrade.
 */
function phorum_dbupgrade_run($upgrade, $update_internal_version = TRUE)
{
    $PHORUM = $GLOBALS["PHORUM"];
    $version = $upgrade["version"];
    $type = $upgrade["type"];
    $upgradefile = $upgrade["file"];
    $versionvar = $type == 'patch' ? 'internal_patchlevel' : 'internal_version';
    // Find the version from which we're upgrading.
    $fromversion = $PHORUM[$versionvar];
    // Executing large, long running scripts can result in problems,
    // in case the script hits PHP resource boundaries. Here we try
    // to prepare the PHP environment for the upgrade. Unfortunately,
    // if the server is running with safe_mode enabled, we cannot
    // change the execution time and memory limits.
    if (!ini_get('safe_mode')) {
        set_time_limit(0);
        ini_set("memory_limit", "64M");
    }
    // Check if the upgradefile is readable.
    if (file_exists($upgradefile) && is_readable($upgradefile)) {
        // Initialize the return message.
        if (!$update_internal_version) {
            $msg = "Installing patch {$version} ...<br/>\n";
        } elseif ($fromversion == '1111111111') {
            $msg = "Upgrading to patch level {$version} ...<br/>\n";
        } else {
            $msg = "Upgrading from " . ($type == "patch" ? "patch level " : "database version ") . "{$fromversion} to {$version} ...<br/>\n";
        }
        // Load the upgrade file. The upgrade file should fill the
        // $upgrade_queries array with the necessary queries to run.
        $upgrade_queries = array();
        include $upgradefile;
        // Run the upgrade queries.
        $err = phorum_db_run_queries($upgrade_queries);
        if ($err !== NULL) {
            $msg .= "An error occured during this upgrade:<br/><br/>\n" . "<span style=\"color:red\">{$err}</span><br/><br/>\n" . "Please make note of this error and contact the " . "Phorum Dev Team for help.\nYou can try to continue " . "with the rest of the upgrade.<br/>\n";
        } else {
            $msg .= "The upgrade was successful.<br/>\n";
        }
        // Update the upgrade version info.
        if ($update_internal_version) {
            $GLOBALS["PHORUM"][$versionvar] = $version;
            phorum_db_update_settings(array($versionvar => $version));
        }
        return $msg;
    } else {
        return "The upgrade file " . htmlspecialchars($upgradefile) . " " . "cannot be opened by Phorum for reading. Please check " . "the file permissions for this file and try again.";
    }
}
Esempio n. 20
0
            }

            if(!phorum_db_update_settings(array("PROFILE_FIELDS"=>$PHORUM["PROFILE_FIELDS"]))){
                $error="Database error while updating settings.";
            } else {
                echo "Profile Field Updated<br />";
            }

        }

    }

    if(isset($_GET["curr"])){
        if(isset($_GET["delete"])){
            unset($PHORUM["PROFILE_FIELDS"][$_GET["curr"]]);
            phorum_db_update_settings(array("PROFILE_FIELDS"=>$PHORUM["PROFILE_FIELDS"]));
            echo "Profile Field Deleted<br />";
        } else {
            $curr = $_GET["curr"];
        }
    }


    if($curr!="NEW"){
        $string=$PHORUM["PROFILE_FIELDS"][$curr]['name'];
        $length=$PHORUM["PROFILE_FIELDS"][$curr]['length'];
        $html_disabled=$PHORUM["PROFILE_FIELDS"][$curr]['html_disabled'];
        $title="Edit Profile Field";
        $submit="Update";
    } else {
        settype($string, "string");
Esempio n. 21
0
<?php

// Initialize some default setting values.
if (!defined('PHORUM_ADMIN')) {
    return;
}
$update_settings = array();
if (!isset($PHORUM['default_feed'])) {
    $update_settings['default_feed'] = 'rss';
}
if (!isset($PHORUM['cache_newflags'])) {
    $update_settings['cache_newflags'] = 0;
}
if (!isset($PHORUM['cache_messages'])) {
    $update_settings['cache_messages'] = 0;
}
if (!isset($PHORUM['track_edits'])) {
    $update_settings['track_edits'] = 0;
}
if (!empty($update_settings)) {
    phorum_db_update_settings($update_settings);
}
Esempio n. 22
0
<?php

if (!defined("PHORUM_ADMIN")) {
    return;
}
// Apply default settings.
require_once "./mods/editor_tools/defaults.php";
// Save the settings to the database.
if (count($_POST)) {
    $PHORUM["mod_editor_tools"] = array("enable_help" => $_POST["enable_help"] ? 1 : 0);
    phorum_db_update_settings(array("mod_editor_tools" => $PHORUM["mod_editor_tools"]));
    phorum_admin_okmsg("The settings were successfully saved.");
}
// Build the settings form.
include_once "./include/admin/PhorumInputForm.php";
$frm = new PhorumInputForm("", "post", "Save");
$frm->hidden("module", "modsettings");
$frm->hidden("mod", "editor_tools");
$frm->addbreak("Edit settings for the Editor Tools module");
$row = $frm->addrow("Enable Help tool", $frm->checkbox("enable_help", "1", "", $PHORUM["mod_editor_tools"]["enable_help"]) . ' Yes');
$frm->addhelp($row, "Enable Help tool", "If you enable this option, then a help button will be added to\n         the tool bar. This help button can be used to open help pages\n         that are registered by other modules (e.g. to show a list of\n         smileys or available BBcode tags).");
$frm->show();
Esempio n. 23
0
            $PHORUM["mod_replace"][]=$item;
        }

        if(empty($error)){
            if(!phorum_db_update_settings(array("mod_replace"=>$PHORUM["mod_replace"]))){
                $error="Database error while updating settings.";
            } else {
                echo "Replacement Updated<br />";
            }
        }
    }

    if(isset($_GET["curr"])){
        if(isset($_GET["delete"])){
            unset($PHORUM["mod_replace"][$_GET["curr"]]);
            phorum_db_update_settings(array("mod_replace"=>$PHORUM["mod_replace"]));
            echo "Replacement Deleted<br />";
        } else {
            $curr = $_GET["curr"];
        }
    }


    if($curr!="NEW"){
        extract($PHORUM["mod_replace"][$curr]);
        $title="Edit Replacement";
        $submit="Update";
    } else {
        settype($string, "string");
        settype($type, "int");
        settype($pcre, "int");
Esempio n. 24
0
    // Add options to the settings array.
    $PHORUM["mod_bbcode"] = array("links_in_new_window" => empty($_POST["links_in_new_window"]) ? 0 : 1, "rel_no_follow" => empty($_POST["rel_no_follow"]) ? 0 : 1, "quote_hook" => empty($_POST["quote_hook"]) ? 0 : 1, "show_full_urls" => empty($_POST["show_full_urls"]) ? 0 : 1, "process_bare_urls" => empty($_POST["process_bare_urls"]) ? 0 : 1, "process_bare_email" => empty($_POST["process_bare_email"]) ? 0 : 1, "allow_disable_per_post" => empty($_POST["allow_disable_per_post"]) ? 0 : 1, "enable_bbcode_escape" => empty($_POST["enable_bbcode_escape"]) ? 0 : 1);
    // Add enable / disable status for individual tags.
    $nr_of_enabled_tags = 0;
    $PHORUM['mod_bbcode']['enabled'] = array();
    foreach ($GLOBALS['PHORUM']['MOD_BBCODE']['BUILTIN'] as $tagname => $tag) {
        if (isset($_POST['enabled'][$tagname])) {
            $value = (int) $_POST['enabled'][$tagname];
            $PHORUM['mod_bbcode']['enabled'][$tagname] = $value;
            if ($value == 2) {
                $nr_of_enabled_tags++;
            }
        }
    }
    // Store the new settings array.
    phorum_db_update_settings(array('mod_bbcode' => $PHORUM['mod_bbcode']));
    phorum_admin_okmsg("The settings were successfully saved.");
    if ($nr_of_enabled_tags > 0 && empty($PHORUM['mods']['editor_tools'])) {
        phorum_admin_error("<b>Notice:</b> You have configured one or more BBcode tags to add a button to the editor tool bar. However, you have not enabled the Editor Tools module. If you want to use the tool buttons, then remember to activate the Editor Tools module.");
    }
}
require_once './include/admin/PhorumInputForm.php';
$frm = new PhorumInputForm("", "post", "Save settings");
$frm->hidden("module", "modsettings");
$frm->hidden("mod", "bbcode");
$frm->addbreak("General settings for the BBcode module");
$row = $frm->addrow("Open links in new window", $frm->checkbox("links_in_new_window", "1", "Yes", $PHORUM["mod_bbcode"]["links_in_new_window"]));
$frm->addhelp($row, "Open links in new window", "When users post links on your forum, you can choose whether to open these in a new window or not.");
$row = $frm->addrow("Turn bare URLs into clickable links", $frm->checkbox("process_bare_urls", "1", "Yes", $PHORUM["mod_bbcode"]["process_bare_urls"]));
$frm->addhelp($row, "Turn bare URLs into clickable links", "If you enable this option, then the BBcode module will try to detect bare URLs in the message (URLs that are not surrounded by [url]...[/url] BBcode tags) and turn those into clickable links (as if they were surrounded by [url]...[/url]).");
$row = $frm->addrow("Turn bare email addresses into clickable links", $frm->checkbox("process_bare_email", "1", "Yes", $PHORUM["mod_bbcode"]["process_bare_email"]));
Esempio n. 25
0
    $settings = array();
    $settings["max_length"] = (int) $_POST["max_length"];
    $settings["min_length"] = (int) $_POST["min_length"];
    $settings["only_lowercase"] = isset($_POST["only_lowercase"]) ? 1 : 0;
    // Valid chars is a bit special.
    $settings["valid_chars"] = isset($_POST["valid_chars"]) ? implode("", array_keys($_POST["valid_chars"])) : "";
    // Take care of applying sane settings.
    if ($settings["min_length"] < 0) {
        $settings["min_length"] = 0;
    }
    if ($settings["max_length"] < $settings["min_length"] && $settings["max_length"] != 0) {
        $settings["max_length"] = $settings["min_length"];
    }
    // Save settings array.
    $PHORUM["mod_username_restrictions"] = $settings;
    phorum_db_update_settings(array("mod_username_restrictions" => $settings));
    phorum_admin_okmsg("The module settings were successfully saved.");
}
include_once "./include/admin/PhorumInputForm.php";
$frm = new PhorumInputForm("", "post", "Save");
$frm->hidden("module", "modsettings");
$frm->hidden("mod", "username_restrictions");
$frm->addbreak("Edit settings for the username restrictions module");
$frm->addrow("Minimum username length (0 = no restriction)", $frm->text_box('min_length', $PHORUM["mod_username_restrictions"]["min_length"], 6));
$frm->addrow("Maximum username length (0 = no restriction)", $frm->text_box('max_length', $PHORUM["mod_username_restrictions"]["max_length"], 6));
$checkboxes = '';
foreach ($valid_chars_options as $k => $v) {
    $enabled = strpos($PHORUM["mod_username_restrictions"]["valid_chars"], $k) === FALSE ? 0 : 1;
    $checkboxes .= $frm->checkbox("valid_chars[{$k}]", "1", "", $enabled) . " {$v}<br/>";
}
$frm->addrow("Valid username characters (check none for no restrictions)", $checkboxes);
Esempio n. 26
0
    // Sanity check.
    if ((int) $_POST["number_to_show"] == 0) {
        $_POST["number_to_show"] = 5;
    }
    if (isset($_POST['vroot_forum_id']) && is_array($_POST['vroot_forum_id'])) {
        foreach ($_POST['vroot_forum_id'] as $vroot_id => $vroot_forum_id) {
            $PHORUM["mod_announcements"]["vroot"][$vroot_id] = (int) $vroot_forum_id;
        }
    }
    $PHORUM["mod_announcements"]["forum_id"] = (int) $_POST["forum_id"];
    $PHORUM["mod_announcements"]["pages"] = $_POST["pages"];
    $PHORUM["mod_announcements"]["disable_autodisplay"] = isset($_POST["disable_autodisplay"]) ? 1 : 0;
    $PHORUM["mod_announcements"]["only_show_unread"] = isset($_POST["only_show_unread"]) ? 1 : 0;
    $PHORUM["mod_announcements"]["number_to_show"] = (int) $_POST["number_to_show"];
    $PHORUM["mod_announcements"]["days_to_show"] = (int) $_POST["days_to_show"];
    phorum_db_update_settings(array("mod_announcements" => $PHORUM["mod_announcements"]));
    phorum_admin_okmsg("Announcement settings updated");
}
include_once "./include/admin/PhorumInputForm.php";
$frm = new PhorumInputForm("", "post", "Save");
$frm->hidden("module", "modsettings");
$frm->hidden("mod", "announcements");
$frm->addbreak("Announcement Settings");
$page_list = $frm->checkbox("pages[home]", 1, "Home page, root level forum list (index.php)", $PHORUM["mod_announcements"]["pages"]["home"]) . "<br/>" . $frm->checkbox("pages[index]", 1, "Any forum List (index.php)", $PHORUM["mod_announcements"]["pages"]["index"]) . "<br/>" . $frm->checkbox("pages[list]", 1, "Message List (list.php)", $PHORUM["mod_announcements"]["pages"]["list"]) . "<br/>" . $frm->checkbox("pages[read]", 1, "Read Message (read.php)", $PHORUM["mod_announcements"]["pages"]["read"]);
$frm->addrow("Announcements Appear On", $page_list);
$row = $frm->addrow("Disable automatic displaying of announcements?", $frm->checkbox("disable_autodisplay", 1, "Disable automatic displaying", $PHORUM["mod_announcements"]["disable_autodisplay"]));
$frm->addhelp($row, "Disable automatic displaying", "By default, the announcements will be displayed after the page header automatically. If you need more control over the exact placement, then enable this option. Then you can specify where you want the announcements to appear yourself by placing the code {MOD_ANNOUNCEMENTS} in your templates.");
$frm->addrow("Show only unread messages to the user?", $frm->checkbox("only_show_unread", 1, "Show only unread", $PHORUM["mod_announcements"]["only_show_unread"]));
$frm->addrow("Number To Show", $frm->text_box("number_to_show", $PHORUM["mod_announcements"]["number_to_show"], 10));
$frm->addrow("Maximum Days To Show", $frm->text_box("days_to_show", $PHORUM["mod_announcements"]["days_to_show"], 10) . " (0 = forever)");
$forum_list_global = phorum_get_forum_info(1, 0);
Esempio n. 27
0
            break;

        case 6:
            // try to figure out if we can write to the cache directory
            $message = "";
            error_reporting(0);
            $err = false;
            if ($fp = fopen($PHORUM["cache"] . "/phorum-install-test", "w+")) {
                unlink($PHORUM["cache"] . "/phorum-install-test");
            }
            else {
                // in this case the normal setting is wrong, so try ./cache
                $PHORUM["cache"] = "./cache";
                $settings = array("cache" => $PHORUM["cache"]);
                if (!phorum_db_update_settings($settings)) {
                    $message .= "Database error updating settings.<br />";
                    $err = true;
                }
                elseif ($fp = fopen($PHORUM["cache"] . "/phorum-install-test", "w+")) {
                    unlink($PHORUM["cache"] . "/phorum-install-test");
                }
                else {
                    $err = true;
                }

            }
            error_reporting(E_WARN);
            if ($message == "") {
                if($err){
                    $message.="Your cache directory is not writable. Please change the permissions on '/cache' inside the Phorum directory to allow writing. In Unix, you may have to use this command: chmod 777 cache<br /><br />If you want to continue anyway and set a cache directory manually, press continue. Note that you must do this, Phorum will not work without a valid cache.";
Esempio n. 28
0
<?php

if (!defined("PHORUM_ADMIN")) {
    return;
}
require_once 'defaults.php';
// save settings
if (count($_POST)) {
    $PHORUM['mod_sphinx_search'] = array('hostname' => $_POST['hostname'], 'port' => $_POST['port']);
    if (!phorum_db_update_settings(array('mod_sphinx_search' => $PHORUM['mod_sphinx_search']))) {
        phorum_admin_error("Updating the settings in the database failed.");
    } else {
        phorum_admin_okmsg("Settings updated");
    }
}
?>
<div style="font-size: xx-large; font-weight: bold">Sphinx Search Module</div>
 This module uses the sphinx fulltext search engine to gather the results of the phorum-search.<br />
 On this page you can set the hostname and port of your sphinx search daemon.

<br style="clear:both" />
<?php 
include_once PHORUM_INCLUDES_DIR . '/admin/PhorumInputForm.php';
$frm = new PhorumInputForm("", "post", "Save");
$frm->hidden("module", "modsettings");
$frm->hidden("mod", "sphinx_search");
$frm->addbreak("Hostname and port");
$row = $frm->addrow("What is the hostname of the sphinx daemon? (e.g. 127.0.0.1){$warn}", $frm->text_box("hostname", $PHORUM["mod_sphinx_search"]["hostname"], 30));
$row = $frm->addrow("What is the port of the sphinx daemon? (e.g. 9312){$warn}", $frm->text_box("port", $PHORUM["mod_sphinx_search"]["port"], 30));
$frm->show();
Esempio n. 29
0
            } else {
                print "Error in message: " . $CONVERT['lbr'];
                print_var($newmessage);
                print $CONVERT['lbr'];
            }
        }
        echo "{$CONVERT['lbr']}Updating forum-statistics: {$CONVERT['lbr']}";
        flush();
        phorum_db_update_forum_stats(true);
        echo $CONVERT['lbr'];
        flush();
    }
}
unset($forums);
// storing the offsets of the forums
phorum_db_update_settings(array("conversion_offsets" => $offsets));
if ($CONVERT['do_groups'] && count($CONVERT['groups'])) {
    // here we set the group-permissions
    echo "Writing group-permissions ... {$CONVERT['lbr']}";
    foreach ($CONVERT['groups'] as $groupid => $groupdata) {
        phorum_db_update_group($groupdata);
    }
}
if ($CONVERT['do_users']) {
    echo "migrating users ...{$CONVERT['lbr']}";
    flush();
    $group_perms = phorum_convert_getUserGroups($oldlink);
    $res = phorum_convert_selectUsers($oldlink);
    if (!$res) {
        echo "No users found, All done now.{$CONVERT['lbr']}";
        flush();
Esempio n. 30
0
function phorum_htmlpurifier_commit_settings()
{
    global $PHORUM;
    return phorum_db_update_settings(array("mod_htmlpurifier" => $PHORUM["mod_htmlpurifier"]));
}