Example #1
0
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("&amp;", "&lt;", "&gt;"), $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;
}
Example #2
0
    return;
}
// wow doing it all by hand this time :(
// adding the new field
phorum_db_interact(DB_RETURN_RES, "ALTER TABLE {$PHORUM['user_newflags_table']}\n     ADD   message_id INT UNSIGNED NOT NULL DEFAULT '0'", NULL, DB_MASTERQUERY);
// removing old primary-key
phorum_db_interact(DB_RETURN_RES, "ALTER TABLE {$PHORUM['user_newflags_table']}\n     DROP PRIMARY KEY", NULL, DB_MASTERQUERY);
// adding new primary-key
phorum_db_interact(DB_RETURN_RES, "ALTER TABLE {$PHORUM['user_newflags_table']}\n     ADD PRIMARY KEY (user_id , forum_id , message_id)", NULL, DB_MASTERQUERY);
// converting the newflags
$rows = phorum_db_interact(DB_RETURN_ASSOCS, "SELECT *\n     FROM {$PHORUM['user_newflags_table']}\n     WHERE message_id=0", NULL, DB_MASTERQUERY);
$olduser = $GLOBALS['PHORUM']['user']['user_id'];
foreach ($rows as $row) {
    $forum = $row['forum_id'];
    $data = unserialize($row['newflags']);
    $GLOBALS['PHORUM']['user']['user_id'] = $row['user_id'];
    $newdata = array();
    foreach ($data as $mid1 => $mid2) {
        if (is_int($mid1)) {
            $newdata[] = array("id" => $mid1, "forum" => $forum);
        }
    }
    phorum_db_newflag_add_read($newdata);
    unset($data);
    unset($newdata);
}
$GLOBALS['PHORUM']['user']['user_id'] = $olduser;
phorum_db_interact(DB_RETURN_RES, "DELETE FROM {$PHORUM['user_newflags_table']}\n     WHERE message_id=0", NULL, DB_MASTERQUERY);
// remove old column
phorum_db_interact(DB_RETURN_RES, "ALTER TABLE {$PHORUM['user_newflags_table']}\n     DROP newflags", NULL, DB_MASTERQUERY);
Example #3
0
function phorum_mod_b8_spam_handle_spam($data, $score)
{
    // Try to insert a new spamhurdles record.
    $res = phorum_db_interact(DB_RETURN_RES, "INSERT INTO b8_log\n                (message_id, score)\n         VALUES (" . "'" . phorum_db_interact(DB_RETURN_QUOTED, $data['message_id']) . "', " . "'" . phorum_db_interact(DB_RETURN_QUOTED, $score) . "')", NULL, DB_DUPKEYOK | DB_MASTERQUERY);
}
Example #4
0
/**
 * This function is used by the sanity checking system to let the
 * database layer do sanity checks of its own. This function can
 * be used by every database layer to implement specific checks.
 *
 * The return value for this function should be exactly the same
 * as the return value expected for regular sanity checking
 * function (see include/admin/sanity_checks.php for information).
 *
 * There's no need to load the sanity_check.php file for the needed
 * constants, because this function should only be called from the
 * sanity checking system.
 *
 * @return array
 *     A return value as expected by Phorum's sanity checking system.
 */
function phorum_db_sanitychecks()
{
    $PHORUM = $GLOBALS['PHORUM'];
    // Retrieve the MySQL server version.
    $version = phorum_db_interact(DB_RETURN_VALUE, 'SELECT @@global.version', NULL, DB_MASTERQUERY);
    if (!$version) {
        return array(PHORUM_SANITY_WARN, "The database layer could not retrieve the version of the\n         running MySQL server", "This probably means that you are running a really old MySQL\n         server, which does not support \"SELECT @@global.version\"\n         as a SQL command. If you are not running a MySQL server\n         with version 4.0.18 or higher, then please upgrade your\n         MySQL server. Else, contact the Phorum developers to see\n         where this warning is coming from");
    }
    $verstr = preg_replace('/-.*$/', '', $version);
    $ver = explode('.', $verstr);
    // Version numbering format which is not recognized.
    if (count($ver) != 3) {
        return array(PHORUM_SANITY_WARN, "The database layer was unable to recognize the MySQL server's\n         version number \"" . htmlspecialchars($version) . "\". Therefore,\n         checking if the right version of MySQL is used is not possible.", "Contact the Phorum developers and report this specific\n         version number, so the checking scripts can be updated.");
    }
    settype($ver[0], 'int');
    settype($ver[1], 'int');
    settype($ver[2], 'int');
    // MySQL before version 4.
    if ($ver[0] < 4) {
        return array(PHORUM_SANITY_CRIT, "The MySQL database server that is used is too old. The\n         running version is \"" . htmlspecialchars($row[0]) . "\",\n         while MySQL version 4.0.18 or higher is recommended.", "Upgrade your MySQL server to a newer version. If your\n         website is hosted with a service provider, please contact\n         the service provider to upgrade your MySQL database.");
    }
    // MySQL before version 4.0.18, with full text search enabled.
    if (isset($PHORUM['DBCONFIG']['mysql_use_ft']) && $PHORUM['DBCONFIG']['mysql_use_ft'] && $ver[0] == 4 && $ver[1] == 0 && $ver[2] < 18) {
        return array(PHORUM_SANITY_WARN, "The MySQL database server that is used does not\n         support all Phorum features. The running version is\n         \"" . htmlspecialchars($version) . "\", while MySQL version\n         4.0.18 or higher is recommended.", "Upgrade your MySQL server to a newer version. If your\n         website is hosted with a service provider, please contact\n         the service provider to upgrade your MySQL database.");
    }
    // MySQL before version 5.0
    if ($ver[0] < 5) {
        return array(PHORUM_SANITY_WARN, "The MySQL database server that is used does not\n         support all Phorum features. The running version is\n         \"" . htmlspecialchars($version) . "\", while MySQL version\n         5.0 or higher is recommended. MySQL has discontinued active development \n         for all versions below 5.0. The Phorum teams uses 5.0 for all \n         development. Phorum has been known to work with MySQL 4.1 and some \n         later 4.0 versions. However, there is no testing with these versions. \n         It is recommended that all users upgrade to 5.0 as soon as possible \n         to get the most out of MySQL and Phorum.", "Upgrade your MySQL server to a newer version. If your\n         website is hosted with a service provider, please contact\n         the service provider to upgrade your MySQL database.");
    }
    // All checks are okay.
    return array(PHORUM_SANITY_OK, NULL);
}
Example #5
0
         $search_operators[] = '()';
     }
 }
 if (!empty($_REQUEST["forum_permissions"]) && !empty($_REQUEST["forum_permissions_forums"])) {
     $forum_permissions = explode(",", $_REQUEST["forum_permissions"]);
     $or_forum_permissions = "";
     foreach ($forum_permissions as $forum_permission) {
         if (isset($forum_permissions_first)) {
             $or_forum_permissions .= " OR ";
         } else {
             $forum_permissions_first = 1;
         }
         $or_forum_permissions .= "(perm.permission>={$forum_permission} AND\n                      (perm.permission & {$forum_permission}>0))";
     }
     phorum_db_sanitize_mixed($_REQUEST["forum_permissions_forums"], "string");
     $db_forum_permissions_users = phorum_db_interact(DB_RETURN_ROWS, "SELECT DISTINCT user.user_id AS user_id\n             FROM   {$PHORUM['user_table']} AS user\n                    LEFT JOIN {$PHORUM['user_permissions_table']} AS perm\n                    ON perm.user_id = user.user_id\n             WHERE  ({$or_forum_permissions}) AND perm.forum_id IN ({$_REQUEST['forum_permissions_forums']})");
     $forum_permissions_users = array();
     foreach ($db_forum_permissions_users as $user) {
         $forum_permissions_users[] = $user[0];
     }
     $search_fields[] = 'user_id';
     $search_values[] = $forum_permissions_users;
     $search_operators[] = '()';
 }
 // Find a list of all matching user_ids.
 $total = phorum_api_user_search($search_fields, $search_values, $search_operators, TRUE, 'AND', NULL, 0, 0, true);
 $default_pagelength = 30;
 settype($_REQUEST["page"], "integer");
 settype($_REQUEST["pagelength"], "integer");
 // The available page lengths.
 $pagelengths = array(10 => "10 users per page", 20 => "20 users per page", 30 => "30 users per page", 50 => "50 users per page", 100 => "100 users per page", 250 => "250 users per page");
Example #6
0
<?php

// Find all private messages.
$res = phorum_db_interact(DB_RETURN_RES, "SELECT pm_message_id, user_id, meta\n     FROM   {$PHORUM["pm_messages_table"]}");
// Update the meta author + rcpt info for each private message.
while ($row = phorum_db_fetch_row($res, DB_RETURN_ASSOC)) {
    // Update the PM author.
    $m = $row["pm_message_id"];
    $u = $row["user_id"];
    $user = phorum_db_user_get($u);
    if ($user) {
        $author = phorum_db_interact(DB_RETURN_QUOTED, $user["display_name"]);
        phorum_db_interact(DB_RETURN_RES, "UPDATE {$PHORUM["pm_messages_table"]}\n            SET    author = '{$author}'\n            WHERE  user_id = {$u}", NULL, DB_MASTERQUERY);
    }
    // Update the PM recipients.
    $meta = unserialize($row["meta"]);
    $userids = array_keys($meta["recipients"]);
    $users = phorum_db_user_get($userids);
    foreach ($users as $user) {
        unset($meta["recipients"][$user["user_id"]]["username"]);
        $meta["recipients"][$user["user_id"]]["display_name"] = $user["display_name"];
    }
    $meta = phorum_db_interact(DB_RETURN_QUOTED, serialize($meta));
    phorum_db_interact(DB_RETURN_RES, "UPDATE {$PHORUM["pm_messages_table"]}\n         SET    meta = '{$meta}'\n         WHERE  pm_message_id = {$m}", NULL, DB_MASTERQUERY);
}
Example #7
0
/**
 * This function is used by the sanity checking system to let the
 * database layer do sanity checks of its own. This function can
 * be used by every database layer to implement specific checks.
 *
 * The return value for this function should be exactly the same
 * as the return value expected for regular sanity checking
 * function (see include/admin/sanity_checks.php for information).
 *
 * There's no need to load the sanity_check.php file for the needed
 * constants, because this function should only be called from the
 * sanity checking system.
 *
 * @return array
 *     A return value as expected by Phorum's sanity checking system.
 */
function phorum_db_sanitychecks()
{
    global $PHORUM;
    // For Phorum 5.2+, we need the "charset" option to be set
    // in the config.php.
    if (!isset($PHORUM['DBCONFIG']['charset'])) {
        return array(PHORUM_SANITY_CRIT, "Database configuration parameter \"charset\" missing.", "The option \"charset\" is missing in your database configuration.\n         This might indicate that you are using a config.php from an\n         older Phorum version, which does not yet contain this option.\n         Please, copy include/db/config.php.sample to\n         include/db/config.php and edit this new config.php. Read\n         Phorum's install.txt for installation instructions.");
    }
    // Retrieve the MySQL server version.
    $version = phorum_db_interact(DB_RETURN_VALUE, 'SELECT @@global.version', NULL, DB_MASTERQUERY);
    if (!$version) {
        return array(PHORUM_SANITY_WARN, "The database layer could not retrieve the version of the\n         running MySQL server", "This probably means that you are running a really old MySQL\n         server, which does not support \"SELECT @@global.version\"\n         as a SQL command. If you are not running a MySQL server\n         with version 4.0.18 or higher, then please upgrade your\n         MySQL server. Else, contact the Phorum developers to see\n         where this warning is coming from");
    }
    // See if we recognize the version numbering.
    if (!preg_match('/^(\\d+)\\.(\\d+)\\.(\\d+)/', $version, $ver)) {
        return array(PHORUM_SANITY_WARN, "The database layer was unable to recognize the MySQL server's\n         version number \"" . htmlspecialchars($version) . "\". Therefore,\n         checking if the right version of MySQL is used is not possible.", "Contact the Phorum developers and report this specific\n         version number, so the checking scripts can be updated.");
    }
    // MySQL before version 4.
    if ($ver[1] < 5) {
        return array(PHORUM_SANITY_CRIT, "The MySQL database server that is used is too old. The\n         running version is \"" . htmlspecialchars($version) . "\",\n         while MySQL version 5.0.x or higher is required.", "Upgrade your MySQL server to a newer version. If your\n         website is hosted with a service provider, please contact\n         the service provider to upgrade your MySQL database.");
    }
    // THE FOLLOWING TWO CHECKS ARE NO LONGER NEEDED WITH THE ABOVE CHECK
    // MAKING MYSQL5 A REQUIREMENT
    // MySQL before version 4.0.18, with full text search enabled.
    /*
    if (isset($PHORUM['DBCONFIG']['mysql_use_ft']) &&
        $PHORUM['DBCONFIG']['mysql_use_ft'] &&
        $ver[2] == 4 && $ver[2] == 0 && $ver[3] < 18) return array(
        PHORUM_SANITY_WARN,
        "The MySQL database server that is used does not
         support all Phorum features. The running version is
         \"" . htmlspecialchars($version) . "\", while MySQL version
         4.0.18 or higher is recommended.",
        "Upgrade your MySQL server to a newer version. If your
         website is hosted with a service provider, please contact
         the service provider to upgrade your MySQL database."
    );
    
    // MySQL before version 5.0
    if ($ver[1] < 5) return array(
        PHORUM_SANITY_WARN,
        "The MySQL database server that is used does not
         support all Phorum features. The running version is
         \"" . htmlspecialchars($version) . "\", while MySQL version
         5.0 or higher is recommended. MySQL has discontinued active development
         for all versions below 5.0. The Phorum teams uses 5.0 for all
         development. Phorum has been known to work with MySQL 4.1 and some
         later 4.0 versions. However, there is no testing with these versions.
         It is recommended that all users upgrade to 5.0 as soon as possible
         to get the most out of MySQL and Phorum.",
        "Upgrade your MySQL server to a newer version. If your
         website is hosted with a service provider, please contact
         the service provider to upgrade your MySQL database."
    );
    */
    // All checks are okay.
    return array(PHORUM_SANITY_OK, NULL);
}
Example #8
0
<?php

// Find orphaned messages in newflags
$res = phorum_db_interact(DB_RETURN_RES, "SELECT    distinct {$PHORUM['user_newflags_table']}.message_id\n     FROM      {$PHORUM['user_newflags_table']}\n     LEFT JOIN {$PHORUM['message_table']} using (message_id)\n     WHERE     {$PHORUM['message_table']}.message_id is null");
$ids = array();
// delete rows from newflags table that have not matching messages row
$done = false;
while (!$done) {
    if ($row = phorum_db_fetch_row($res, DB_RETURN_ROW)) {
        $ids[] = $row[0];
    } else {
        $done = true;
    }
    if (count($ids) > 1000 || $done && count($ids) > 0) {
        phorum_db_interact(DB_RETURN_RES, "DELETE\n             FROM      {$PHORUM['user_newflags_table']}\n             WHERE     message_id in (" . implode(",", $ids) . ")", NULL, DB_MASTERQUERY);
        $ids = array();
    }
}
// fix messages in newflags table with the wrong forum_id
$upgrade_queries[] = "delete\n                     from {$PHORUM["user_newflags_table"]}\n                     using {$PHORUM["user_newflags_table"]},\n                           {$PHORUM["message_table"]}\n                     where\n                        {$PHORUM["user_newflags_table"]}.message_id={$PHORUM["message_table"]}.message_id\n                        and {$PHORUM["user_newflags_table"]}.forum_id<>{$PHORUM["message_table"]}.forum_id";
// fix messages in the messages table with the wrong
// forum_id except move notices
$upgrade_queries[] = "UPDATE IGNORE\n                     {$PHORUM["message_table"]} as msg,\n                     {$PHORUM["message_table"]} as thd\n                     SET msg.forum_id=thd.forum_id\n                     where msg.thread=thd.message_id and\n                           msg.forum_id<>thd.forum_id\n                           and msg.moved=0";
Example #9
0
function spamhurdles_db_remove_expired()
{
    global $PHORUM;
    phorum_db_interact(DB_RETURN_RES, "DELETE FROM {$PHORUM['spamhurdles_table']}\n         WHERE  expire_time < " . time(), NULL, DB_MASTERQUERY);
}
foreach ($forums as $forum) {
    if ($forum["vroot"] == $forum["forum_id"] && $forum["folder_flag"]) {
        $vroots[] = $forum["forum_id"];
    }
}
foreach ($vroots as $vroot) {
    // alter the template to work for this vroot
    $template["vroot"] = $vroot;
    $template["parent_id"] = $vroot;
    // add the new announcement forum for this vroot
    $forum_id = phorum_db_add_forum($template);
    // activate the forum in the announcements module
    $PHORUM["mod_announcements"]["vroot"][$vroot] = $forum_id;
    // update messages to the new forum_id
    $sql = "update {$PHORUM['message_table']} set forum_id={$forum_id}, sort=2 where forum_id={$vroot}";
    phorum_db_interact(DB_RETURN_RES, $sql);
    // update the new forums stats
    $PHORUM["forum_id"] = $forum_id;
    phorum_db_update_forum_stats(true);
}
// add the hooks and functions to the module
if (!in_array("announcements", $PHORUM["hooks"]["common"]["mods"])) {
    $PHORUM["hooks"]["common"]["mods"][] = "announcements";
}
if (!in_array("phorum_setup_announcements", $PHORUM["hooks"]["common"]["funcs"])) {
    $PHORUM["hooks"]["common"]["funcs"][] = "phorum_setup_announcements";
}
if (!in_array("announcements", $PHORUM["hooks"]["after_header"]["mods"])) {
    $PHORUM["hooks"]["after_header"]["mods"][] = "announcements";
}
if (!in_array("phorum_show_announcements", $PHORUM["hooks"]["after_header"]["funcs"])) {
Example #11
0
<?php

if (!defined("PHORUM_ADMIN")) {
    return;
}
// Create tables for the new PM system.
$upgrade_queries[] = "CREATE TABLE {$PHORUM["pm_messages_table"]} (\n    pm_message_id int(10) unsigned NOT NULL auto_increment,\n    from_user_id int(10) unsigned NOT NULL default '0',\n    from_username varchar(50) NOT NULL default '',\n    subject varchar(100) NOT NULL default '',\n    message text NOT NULL,\n    datestamp int(10) unsigned NOT NULL default '0',\n    meta mediumtext NOT NULL,\n    PRIMARY KEY (pm_message_id)\n) TYPE=MyISAM";
$upgrade_queries[] = "CREATE TABLE {$PHORUM["pm_folders_table"]} (\n    pm_folder_id int(10) unsigned NOT NULL auto_increment,\n    user_id int(10) unsigned NOT NULL default '0',\n    foldername varchar(20) NOT NULL default '',\n    KEY user_id (user_id),\n    PRIMARY KEY (pm_folder_id)\n) TYPE=MyISAM";
$upgrade_queries[] = "CREATE TABLE {$PHORUM["pm_xref_table"]} (\n    pm_xref_id int(10) unsigned NOT NULL auto_increment,\n    user_id int(10) unsigned NOT NULL default '0',\n    pm_folder_id int(10) unsigned NOT NULL default '0',\n    special_folder varchar(10),\n    pm_message_id int(10) unsigned NOT NULL default '0',\n    read_flag tinyint(1) NOT NULL default '0',\n    reply_flag tinyint(1) NOT NULL default '0',\n    PRIMARY KEY (pm_xref_id),\n    KEY xref (user_id,pm_folder_id,pm_message_id),\n    KEY read_flag (read_flag)\n) TYPE=MyISAM";
// converting the old PM system to the new one.
$old_table = "{$PHORUM['DBCONFIG']['table_prefix']}_private_messages";
$res = phorum_db_interact(DB_RETURN_RES, "SELECT *\n     FROM   {$old_table}", NULL, DB_MASTERQUERY);
while ($row = phorum_db_fetch_row($res, DB_RETURN_ASSOC)) {
    // Put the message in the message table.
    $meta = serialize(array('recipients' => array($row["to_user_id"] => array('user_id' => $row["to_user_id"], 'username' => $row["to_username"], 'read_flag' => $row["read_flag"]))));
    $sql = "INSERT INTO {$PHORUM["pm_messages_table"]} SET " . "pm_message_id = {$row["private_message_id"]}, " . "from_user_id = {$row["from_user_id"]}, " . "from_username = '******', " . "subject = '" . addslashes($row['subject']) . "', " . "message = '" . addslashes($row['message']) . "', " . "datestamp = {$row["datestamp"]}, " . "meta = '" . addslashes($meta) . "'";
    $upgrade_queries[] = $sql;
    // Link message to recipient inbox.
    if (!$row["to_del_flag"]) {
        $sql = "INSERT INTO {$PHORUM["pm_xref_table"]} SET " . "user_id = {$row["to_user_id"]}, " . "pm_folder_id = 0, " . "special_folder = '" . PHORUM_PM_INBOX . "', " . "pm_message_id = {$row["private_message_id"]}, " . "read_flag = {$row["read_flag"]}, " . "reply_flag = {$row["reply_flag"]}";
        $upgrade_queries[] = $sql;
    }
    // Link message to sender outbox.
    if (!$row["from_del_flag"]) {
        $sql = "INSERT INTO {$PHORUM["pm_xref_table"]} SET " . "user_id = {$row["from_user_id"]}, " . "pm_folder_id = 0, " . "special_folder = '" . PHORUM_PM_OUTBOX . "', " . "pm_message_id = {$row["private_message_id"]}, " . "read_flag = 1, " . "reply_flag = 0";
        $upgrade_queries[] = $sql;
    }
}
Example #12
0
            $type = -1;
            // find out which ID that custom-field has
            foreach ($PHORUM['PROFILE_FIELDS'] as $ctype => $cdata) {
                if ($cdata['name'] == $old_key) {
                    $type = $ctype;
                    break;
                }
            }
            if ($type != -1) {
                // store it only if we found it
                if ($old_val !== "") {
                    if (!is_array($old_val)) {
                        $user_data_new[$type] = substr($old_val, 0, $PHORUM['PROFILE_FIELDS'][$type]['length']);
                    } else {
                        $user_data_new[$type] = $old_val;
                    }
                }
            }
        }
    }
    $userdata['user_data'] = serialize($user_data_new);
    // Prepare the user table fields.
    $values = array();
    foreach ($userdata as $key => $value) {
        $value = phorum_db_interact(DB_RETURN_QUOTED, $value);
        $values[] = "{$key} = '{$value}'";
    }
    $user_id = $userdata['user_id'];
    unset($userdata['user_id']);
    phorum_db_interact(DB_RETURN_RES, "UPDATE {$PHORUM['user_table']}\n         SET    " . implode(', ', $values) . "\n         WHERE  user_id = {$user_id}", NULL, DB_MASTERQUERY);
}
Example #13
0
/**
 * Update the forum info for a certain message_id.
 */
function event_logging_update_message_id_info($message_id, $forum_id, $thread_id)
{
    $PHORUM = $GLOBALS["PHORUM"];
    phorum_db_interact(DB_RETURN_RES, "UPDATE {$PHORUM["event_logging_table"]}\n         SET    forum_id = " . (int) $forum_id . ",\n                thread_id = " . (int) $thread_id . "\n         WHERE  message_id = " . (int) $message_id, NULL, DB_MASTERQUERY);
}
Example #14
0
if (!defined("PHORUM_ADMIN")) {
    return;
}
// Load the configuration
require_once './mods/b8_spam/b8/b8.php';
require_once "./mods/b8_spam/config.php";
//if(count($_POST) && $_POST["retrain"]!="")
//{
// Create a new b8 instance
$b8 = new b8($config_b8, $config_storage, $config_lexer, $config_degenerator);
// Reset Word Classification
$rows = phorum_db_interact(DB_RETURN_RES, "TRUNCATE TABLE b8_wordlist");
$rows = phorum_db_interact(DB_RETURN_RES, "INSERT INTO b8_wordlist (token, count_ham) VALUES ('b8*dbversion',3)");
// Build new Word Classification on Training Data
$rows = phorum_db_interact(DB_RETURN_ASSOCS, "SELECT id,text,classification\n             FROM   b8_messages");
foreach ($rows as $row) {
    $classification = b8::SPAM;
    if ($row['classification'] == 'HAM') {
        $classification = b8::HAM;
    }
    $b8->learn($row['text'], $classification);
}
//}
if (count($_POST) && $_POST["search"] != "" && $_POST["replace"] != "") {
    $item = array("search" => $_POST["search"], "replace" => $_POST["replace"], "pcre" => $_POST["pcre"]);
    if ($_POST["curr"] != "NEW") {
        $PHORUM["mod_replace"][$_POST["curr"]] = $item;
    } else {
        $PHORUM["mod_replace"][] = $item;
    }
Example #15
0
if (isset($_SERVER["REMOTE_ADDR"])) {
    echo "This script cannot be run from a browser.";
    return;
}
define("PHORUM_ADMIN", 1);
define('phorum_page', 'rebuild_postcount');
chdir(dirname(__FILE__) . "/..");
require_once './common.php';
// Make sure that the output is not buffered.
phorum_ob_clean();
if (!ini_get('safe_mode')) {
    set_time_limit(0);
    ini_set("memory_limit", "64M");
}
print "\nCounting the posts for all users ...\n";
$postcounts = phorum_db_interact(DB_RETURN_ROWS, "SELECT user_id, count(*) \n     FROM   {$PHORUM["message_table"]}\n     WHERE  user_id != 0\n     GROUP  BY user_id");
print "Updating the post counts ...\n";
$count_total = count($postcounts);
$size = strlen($count_total);
$count = 0;
foreach ($postcounts as $row) {
    phorum_api_user_save_raw(array("user_id" => $row[0], "posts" => $row[1]));
    $count++;
    $perc = floor($count / $count_total * 100);
    $barlen = floor(20 * ($perc / 100));
    $bar = "[";
    $bar .= str_repeat("=", $barlen);
    $bar .= str_repeat(" ", 20 - $barlen);
    $bar .= "]";
    printf("updating %{$size}d / %{$size}d  %s (%d%%)\r", $count, $count_total, $bar, $perc);
}
Example #16
0
<?php

if (!defined("PHORUM_ADMIN")) {
    return;
}
// Check if all the tables from version 2005091400 were created,
// before dropping the old private messages table.
$old_table = "{$PHORUM['DBCONFIG']['table_prefix']}_private_messages";
$check_tables = array($PHORUM["pm_messages_table"] => 1, $PHORUM["pm_folders_table"] => 1, $PHORUM["pm_xref_table"] => 1);
$rows = phorum_db_interact(DB_RETURN_ROWS, "SHOW TABLES", NULL, DB_MASTERQUERY);
foreach ($rows as $row) {
    if (isset($check_tables[$row[0]])) {
        unset($check_tables[$row[0]]);
    }
}
if (count($check_tables)) {
    ?>
    <br/>
    <b>Warning: database upgrade 2005091400 does not seem to have
    completed successfully. The old style private messages table
    <?php 
    print $old_table;
    ?>
 will be kept for backup. <?php 
} else {
    $upgrade_queries[] = "DROP TABLE {$old_table}";
}
Example #17
0
    return;
}
define('phorum_page', 'rebuild_thread_info');
define('PHORUM_ADMIN', 1);
chdir(dirname(__FILE__) . "/..");
require_once './common.php';
include './include/thread_info.php';
// Make sure that the output is not buffered.
phorum_ob_clean();
if (!ini_get('safe_mode')) {
    set_time_limit(0);
    ini_set("memory_limit", "128M");
}
print "\nRebuilding thread info meta data ...\n";
$count_total = phorum_db_interact(DB_RETURN_VALUE, "SELECT count(*)\n     FROM   {$PHORUM["message_table"]}\n     WHERE  parent_id = 0 AND\n            message_id = thread");
$res = phorum_db_interact(DB_RETURN_RES, "SELECT message_id, forum_id\n     FROM   {$PHORUM["message_table"]}\n     WHERE  parent_id = 0 AND\n            message_id = thread");
$size = strlen($count_total);
$count = 0;
while ($row = phorum_db_fetch_row($res, DB_RETURN_ROW)) {
    $PHORUM['forum_id'] = $row[1];
    phorum_update_thread_info($row[0]);
    $count++;
    $perc = floor($count / $count_total * 100);
    $barlen = floor(20 * ($perc / 100));
    $bar = "[";
    $bar .= str_repeat("=", $barlen);
    $bar .= str_repeat(" ", 20 - $barlen);
    $bar .= "]";
    printf("updating %{$size}d / %{$size}d  %s (%d%%)\r", $count, $count_total, $bar, $perc);
}
print "\n\n";
Example #18
0
function spamhurdles_db_remove_expired()
{
    $sql = "DELETE FROM " . SPAMHURDLES_TABLE . " " . "WHERE expire_time < " . time();
    phorum_db_interact(DB_RETURN_RES, $sql, NULL, DB_MASTERQUERY);
}