FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Converters » Some fixes for phpBB converter
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Some fixes for phpBB converter [message #29611] Tue, 03 January 2006 17:39 Go to next message
melink is currently offline  melink   Hong Kong
Messages: 6
Registered: January 2006
Karma: 0
Junior Member
Fixed attach mob bug (table names, column names are wrong)
Fixed private message mess up (pmsg_opt need masked with 32 by default), added logic to detect reply message

Could admin verify it? Hope it would help someone need to escape from painful phpBB like me Very Happy
  • Attachment: phpBB2.php
    (Size: 28.13KB, Downloaded 1536 times)

[Updated on: Tue, 03 January 2006 17:40]

Report message to a moderator

Re: Some fixes for phpBB converter [message #29612 is a reply to message #29611] Tue, 03 January 2006 19:58 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Compared to the current version of the converter script there is only a single change that i see:

- $obj->user_id = $hack_id = q_singleval("SELECT MAX(user_id) FROM {$bb2}users") + 1;
+ $obj->user_id = $hack_id = q_singleval("SELECT MAX(id) FROM {$bb2}users") + 1;


I am not sure this is correct, since as I recall user_id was the column name used to reference the identity of a user on phpBB


FUDforum Core Developer
Re: Some fixes for phpBB converter [message #29616 is a reply to message #29612] Wed, 04 January 2006 01:28 Go to previous message
melink is currently offline  melink   Germany
Messages: 6
Registered: January 2006
Karma: 0
Junior Member
Sorry, maybe you diff with a wrong version. Here is my major change:

/* Import phpBB private messages */
	q("DELETE FROM ".$DBHOST_TBL_PREFIX."pmsg");

	$r = bbq("SELECT p.*, pt.privmsgs_text, u.username FROM {$bb2}privmsgs p INNER JOIN {$bb2}privmsgs_text pt ON p.privmsgs_id=pt.privmsgs_text_id INNER JOIN {$bb2}users u ON u.user_id=p.privmsgs_to_userid");
	print_msg('Importing Private Messages '.db_count($r));
	while ($obj = db_rowobj($r)) {
		if ($obj->privmsgs_type != PRIVMSGS_READ_MAIL && $obj->privmsgs_type != PRIVMSGS_NEW_MAIL && $obj->privmsgs_type != PRIVMSGS_SENT_MAIL) {
			continue;
		}

		list($off, $len) = write_pmsg_body(bbcode2fudcode($obj->privmsgs_text));
		$pmsg_opt = ($obj->privmsgs_attach_sig ? 1 : 0) | ($obj->privmsgs_enable_smilies ? 0 : 2);
		if (strncasecmp($obj->privmsgs_subject, "re:", 3) == 0) {
			$pmsg_opt = $pmsg_opt | 64;
		} else {
			$pmsg_opt = $pmsg_opt | 32;
		}
		$read_stamp = $obj->privmsgs_type != PRIVMSGS_NEW_MAIL ? $obj->privmsgs_date : 0;
		if ($obj->privmsgs_type == PRIVMSGS_SENT_MAIL) {
			$folder = 3;
			$duser_id = $obj->privmsgs_from_userid;
			$pdest = $obj->privmsgs_to_userid;
		} else {
			$folder = 1;
			$duser_id = $obj->privmsgs_to_userid;
			$pdest = 0;
		}

		q("INSERT INTO ".$DBHOST_TBL_PREFIX."pmsg 
			(ouser_id, duser_id, pdest, ip_addr, post_stamp, read_stamp, fldr, subject, pmsg_opt, foff, length, to_list)
			VALUES(
				".(int)$obj->privmsgs_from_userid.",
				".(int)$duser_id.",
				".(int)$pdest.",
				'".phpbb_decode_ip($obj->privmsgs_ip)."',
				".(int)$obj->privmsgs_date.",
				".$read_stamp.",
				".$folder.",
				'".addslashes($obj->privmsgs_subject)."',
				".$pmsg_opt.",
				".$off.",
				".$len.",
				'".addslashes($obj->username)."')"
		);
	}
	unset($r);
	print_msg('Finished Importing Private Messages');


/* Import phpBB file attachments (if person has applied phpbb file attachment mod) */
	$ENABLED_FILE_ATTACHMENTS = 0;
	if (@db_rowarr(bbq("SELECT * FROM {$bb2}attachments_desc LIMIT 1", 1))) {
		$ENABLED_FILE_ATTACHMENTS = 1;

		q("DELETE FROM ".$DBHOST_TBL_PREFIX."attach");

		list($phpbb_storage) = db_rowarr(bbq("SELECT config_value FROM {$bb2}attachments_config WHERE config_name='upload_dir'"));
		$phpbb_storage = $phpbb_storage."/";

		$old_umask = umask(0111);
		$r = bbq("SELECT a.physical_filename attach_filename, a.real_filename filename, b.user_id_1 user_id, b.post_id, a.download_count FROM {$bb2}attachments_desc a INNER JOIN {$bb2}attachments b on a.attach_id = b.attach_id");
		print_msg('Importing File Attachments '.db_count($r));
		while ($obj = db_rowobj($r)) {
			if (!@file_exists($PHPBB_INSTALL_ROOT.$phpbb_storage.$obj->attach_filename)) {
				print_msg("\tWARNING: file attachment ".$PHPBB_INSTALL_ROOT.$phpbb_storage.$obj->attach_filename." doesn't exist");
				continue;
			}

			$mime = q_singleval("SELECT id FROM ".$DBHOST_TBL_PREFIX."mime WHERE fl_ext='".substr(strrchr($obj->filename, '.'), 1)."'");

			$attach_id = db_qid("INSERT INTO ".$DBHOST_TBL_PREFIX."attach 
				(original_name, owner, message_id, dlcount, mime_type, fsize)
				VALUES (
					'".addslashes($obj->filename)."',
					".(int)$obj->user_id.",
					".(int)$obj->post_id.",
					".(int)$obj->download_count.",
					".(int)$mime.",
					".(int)filesize($PHPBB_INSTALL_ROOT.$phpbb_storage.$obj->attach_filename).")"
				);

			if (!copy($PHPBB_INSTALL_ROOT.$phpbb_storage.$obj->attach_filename, $FILE_STORE.$attach_id.'.atch')) {
				print_msg("Couldn't copy file attachment (".$PHPBB_INSTALL_ROOT.$phpbb_storage.$obj->attach_filename.") to (".$FILE_STORE.$attach_id.'.atch'.")");
				exit;
			}
			q("UPDATE ".$DBHOST_TBL_PREFIX."attach SET location='".$FILE_STORE.$attach_id.'.atch'."' WHERE id=".$attach_id);
		}
		unset($r);
		umask($old_umask);
		print_msg('Finished Importing File Attachments');
	}
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: phBB2 converter
Next Topic: WBB Converter?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Dec 02 17:09:53 GMT 2024

Total time taken to generate the page: 0.02171 seconds