This tool is used to migrate users' digest settings from a phpBB 2.x Digests Installation to phpBB 3.x. You only need to run it once. However, it doesn't hurt if you run it more than once.
Important caveats:
All fields must be filled in. If the field is blank or not filled in in your config.php file, use the default shown.
MySQL is not supported. Cannot migrate digest settings.'; exit; } // Next, try to connect to the phpBB 2 host $phpBB2_hostname = htmlspecialchars($_POST['phpBB2_hostname']); $phpBB2_hostname = (trim($phpBB2_hostname) == '') ? 'localhost': $phpBB2_hostname; $phpBB2_port = htmlspecialchars($_POST['phpBB2_port']); $phpBB2_port = (trim($phpBB2_port) == '') ? '80': $phpBB2_port; $phpBB2_db_name = htmlspecialchars($_POST['phpBB2_db_name']); $phpBB2_db_user = htmlspecialchars($_POST['phpBB2_db_user']); $phpBB2_db_pwd = htmlspecialchars($_POST['phpBB2_db_pwd']); $phpBB2_prefix = htmlspecialchars($_POST['phpBB2_prefix']); $phpBB2 = mysql_connect(trim($phpBB2_hostname) . ':' . trim($phpBB2_db_port), trim($phpBB2_db_user), trim($phpBB2_db_pwd)); if ($phpBB2 == false) { echo 'Cannot connect to phpBB2 database with information supplied. Cannot migrate digest settings.
'; exit; } // Next, try to connect to the phpBB 2 database if (!mysql_select_db($phpBB2_db_name, $phpBB2)) { echo sprintf('Could not connect to phpBB2 database %s. Cannot migrate digest settings.', $phpBB2_db_name); exit; } // Next, try to connect to the phpBB 3 host $phpBB3_hostname = htmlspecialchars($_POST['phpBB3_hostname']); $phpBB3_hostname = (trim($phpBB3_hostname) == '') ? 'localhost': $phpBB3_hostname; $phpBB3_port = htmlspecialchars($_POST['phpBB3_port']); $phpBB3_port = (trim($phpBB3_port) == '') ? '80': $phpBB3_port; $phpBB3_db_name = htmlspecialchars($_POST['phpBB3_db_name']); $phpBB3_db_user = htmlspecialchars($_POST['phpBB3_db_user']); $phpBB3_db_pwd = htmlspecialchars($_POST['phpBB3_db_pwd']); $phpBB3_prefix = htmlspecialchars($_POST['phpBB3_prefix']); $phpBB3 = mysql_connect(trim($phpBB3_hostname) . ':' . trim($phpBB3_db_port), trim($phpBB3_db_user), trim($phpBB3_db_pwd), true); if ($phpBB3 == false) { echo 'Cannot connect to phpBB3 database with information supplied. Cannot migrate digest settings.
'; exit; } // Next, try to connect to the phpBB 3 database if (!mysql_select_db($phpBB3_db_name, $phpBB3)) { echo sprintf('Could not connect to phpBB3 database %s. Cannot migrate digest settings.', $phpBB3_db_name); exit; } echo 'Processing...
'; // Fetch the existing digest subscribers from the phpBB2 database $phpBB2_sql = 'SELECT u.*, d.* FROM ' . $phpBB2_prefix . 'users u, ' . $phpBB2_prefix . 'mod_subscriptions d WHERE u.user_id = d.user_id AND u.user_active = 1 ORDER BY u.username'; $result_phpBB2 = mysql_query($phpBB2_sql, $phpBB2); if (!$result_phpBB2) { echo 'Cannot run query: ' . $phpBB2_sql . ', error is: ' . mysql_error() . ' Cannot migrate digest settings.
'; exit; } // When converting digest send time, in phpBB2 digest send hour is set for server time, in phpBB3 in GMT, so we need to know the offset in // hours between server time and GMT. $timezone_offset = date('Z')/3600; // Here begins the main logic. We need to convert the user's digest settings and the forum subscriptions, if any exist while ($row = mysql_fetch_assoc($result_phpBB2)) { // Does this username exist in the phpBB3 database? $phpBB3_sql = 'SELECT * FROM ' . $phpBB3_prefix . "users u WHERE username = '" . $row['username'] . "'"; $result_phpBB3 = mysql_query($phpBB3_sql, $phpBB3); if (mysql_num_rows($result_phpBB3) == 0) { echo 'Username ' . $row['username'] . ' does not exist in phpBB3 database, skipping...Cannot run query: ' . $phpBB2_sql_2 . ', error is: ' . mysql_error() . '. Cannot continue to migrate digest settings.
'; exit; } if (mysql_num_rows($result_phpBB2_2) > 0) // This user has forum subscriptions { while ($row2 = mysql_fetch_assoc($result_phpBB2_2)) { // echo $row2['username'] . ' has a subscription to a forum named ' . $row2['forum_name'] . 'Cannot run query: ' . $phpBB3_sql_2 . ', error is: ' . mysql_error() . '. Cannot continue to migrate digest settings.
'; exit; } if (mysql_num_rows($result_phpBB3_2) == 0) // There are no forum subscriptions in the phpBB3 database for this forum { // Create the forum subscription // Find the associated forum_id in the phpBB3 database $phpBB3_sql_3 = 'SELECT forum_id FROM ' . $phpBB3_prefix. "forums f WHERE forum_name = '" . $row2['forum_name'] . "'"; $result_phpBB3_3 = mysql_query($phpBB3_sql_3, $phpBB3); $row3 = mysql_fetch_assoc($result_phpBB3_3); // Perform the insert to replicate the forum subscription $phpBB3_sql_4 = 'INSERT INTO ' . $phpBB3_prefix . 'digests_subscribed_forums (user_id, forum_id) VALUES (' . $row2['user_id'] . ', ' . $row3['forum_id'] . ')'; //echo $phpBB3_sql_4 . 'Cannot run query: ' . $phpBB3_sql_4 . ', error is: ' . mysql_error() . '. Cannot continue to migrate digest settings.
'; exit; } echo sprintf("Subscribed user %s to forum \"%s\" in the phpBB3 database.Migration complete!
'; } ?>