<?php if(!defined("PHORUM_ADMIN")) return; $cid=phorum_db_mysql_connect(); // converting the custom-fields $res=mysql_query("SELECT user_id,user_data FROM {$PHORUM['user_table']}",$cid); while($row=mysql_fetch_assoc($res)) { $userdata=array('user_id'=>$row['user_id']); $user_data_new=array(); $user_data_old=unserialize($row['user_data']); // converting meta-data to fields if(isset($user_data_old['show_signature']) && !empty($user_data_old['show_signature'])) $userdata['show_signature']=$user_data_old['show_signature']; if(isset($user_data_old['email_notify']) && !empty($user_data_old['email_notify'])) $userdata['email_notify']=$user_data_old['email_notify']; if(isset($user_data_old['tz_offset']) && !empty($user_data_old['tz_offset'])) $userdata['tz_offset']=$user_data_old['tz_offset']; if(isset($user_data_old['is_dst']) && !empty($user_data_old['is_dst'])) $userdata['is_dst']=$user_data_old['is_dst']; if(isset($user_data_old['user_language']) && !empty($user_data_old['user_language'])) $userdata['user_language']=$user_data_old['user_language']; if(isset($user_data_old['user_template']) && !empty($user_data_old['user_template'])) $userdata['user_template']=$user_data_old['user_template'];
in the end, nothing more. Depending on the number of messages and users, it may take some time. */ // we try to disable the execution timeout // that command doesn't work in safe_mode :( set_time_limit(0); require './common.php'; // no need to change anything below this line $sql="select user_id, count(*) as postcnt from ".$PHORUM["message_table"]." group by user_id"; $conn = phorum_db_mysql_connect(); $res = mysql_query($sql, $conn); if ($err = mysql_error()) phorum_db_mysql_error("$err: $sql"); if(mysql_num_rows($res)) { $usercnt=0; while($row = mysql_fetch_row($res)) { $user=array("user_id"=>$row[0],"posts"=>$row[1]); phorum_user_save_simple($user); $usercnt++; } } print "$usercnt Users updated with their current postcounts. Done!<br>\n"; ?>
/** * Return TRUE if any one of the given username, email, or IP address * is banned. * * @param string $p_username * @param string $p_email */ public static function IsBanned($p_username, $p_email) { global $PHORUM; $conn = phorum_db_mysql_connect(); // Check if username is banned. $sql = "SELECT COUNT(*) as matches FROM ".$PHORUM['banlist_table'] ." WHERE type=".PHORUM_BAD_NAMES ." AND string='".mysql_escape_string($p_username)."'"; $result = mysql_query($sql, $conn); $row = mysql_fetch_assoc($result); if ($row['matches'] > 0) { return true; } // Check if email is banned. $sql = "SELECT COUNT(*) as matches FROM ".$PHORUM['banlist_table'] ." WHERE type=".PHORUM_BAD_EMAILS ." AND string='".mysql_escape_string($p_email)."'"; $result = mysql_query($sql, $conn); $row = mysql_fetch_assoc($result); if ($row['matches'] > 0) { return true; } // Check if IP address is banned. $ipaddr = $_SERVER['REMOTE_ADDR']; // Fetch the settings and pretend they were returned to // us instead of setting a global variable. phorum_db_load_settings(); $settings = $PHORUM['SETTINGS']; if ($settings["dns_lookup"]) { $resolved = @gethostbyaddr($_SERVER["REMOTE_ADDR"]); if (!empty($resolved) && $resolved != $_SERVER["REMOTE_ADDR"]) { $ipaddr = $resolved; } } $sql = "SELECT COUNT(*) as matches FROM ".$PHORUM['banlist_table'] ." WHERE type=".PHORUM_BAD_IPS ." AND string='".mysql_escape_string($ipaddr)."'"; $result = mysql_query($sql, $conn); $row = mysql_fetch_assoc($result); if ($row['matches'] > 0) { return true; } return false; } // fn IsBanned
function phorum_htmlpurifier_migrate_sigs($offset) { global $PHORUM; if (!$offset) { return; } // bail out quick of $offset == 0 @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_user_save($user)) { exit('Error while saving user data'); } } unset($userinfos); // free up memory // query for highest ID in database $type = $PHORUM['DBCONFIG']['type']; if ($type == 'mysql') { $conn = phorum_db_mysql_connect(); $sql = "select MAX(user_id) from {$PHORUM['user_table']}"; $res = mysql_query($sql, $conn); $row = mysql_fetch_row($res); $top_id = (int) $row[0]; } elseif ($type == 'mysqli') { $conn = phorum_db_mysqli_connect(); $sql = "select MAX(user_id) from {$PHORUM['user_table']}"; $res = mysqli_query($conn, $sql); $row = mysqli_fetch_row($res); $top_id = (int) $row[0]; } else { exit('Unrecognized database!'); } $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; }
/** * 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 */ function phorum_db_sanitychecks() { $PHORUM = $GLOBALS["PHORUM"]; // Retrieve the MySQL server version. $conn = phorum_db_mysql_connect(); $res = mysql_query("SELECT @@global.version",$conn); if (!$res) return array( PHORUM_SANITY_WARN, "The database layer could not retrieve the version of the running MySQL server", "This probably means that you are running a really old MySQL server, which does not support \"SELECT @@global.version\" as an SQL command. If you are not running a MySQL server with version 4.0.18 or higher, then please upgrade your MySQL server. Else, contact the Phorum developers to see where this warning is coming from" ); if (mysql_num_rows($res)) { $row = mysql_fetch_array($res); $ver = explode(".", $row[0]); // 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 version number \"" . htmlspecialchars($row[0]) . "\". Therefore, checking if the right version of MySQL is used is not possible.", "Contact the Phorum developers and report this specific 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 running version is \"" . htmlspecialchars($row[0]) . "\", 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 4.0.18, with full text search enabled. if ($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 support all Phorum features. The running version is \"" . htmlspecialchars($row[0]) . "\", 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." ); // All checks are okay. return array (PHORUM_SANITY_OK, NULL); } return array( PHORUM_SANITY_CRIT, "An unexpected problem was found in running the sanity check function phorum_db_sanitychecks().", "Contact the Phorum developers to find out what the problem is." ); }