MyBB Community Forums

Full Version: Merge System Attachments Not Copied
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11
^ would you like to provide required temporary access and wait for a few days - if you are willing then you can PM me
Thank you for your prompt reply!
I wrote you via PM.
Many thanks in advance for your help!
(2013-11-06, 07:39 AM)barmale Wrote: [ -> ]Hello!
I'm very impressed with this merge system because all conversion passed seamlessly but attachments.
I have latest MyBB installation and old SMF forum 1.1.x
Attachments are assigned to the posts but are non displayed.
When I click on an attachment (say, http://..../forum/attachment.php?aid=4) file blank window appears with the message "Waiting for www......com".
Can anybody help me to get it working?

I have the same problem, please share your fix.

I merged from phpbb3 to mybb 1.6. Whole process worked with no errors but now in forum i can see all attachent but they blank.

Anyone know a solution?
Hi, Superman23.
It seems that no solution exists.
.m. has tried to solve the problem but no success.
After migration I also faced another issue - I can not see attachment thumbs even in newly posted threads. Do you have the same problem too?
(2013-11-18, 06:00 AM)barmale Wrote: [ -> ]Hi, Superman23.
It seems that no solution exists.
.m. has tried to solve the problem but no success.
After migration I also faced another issue - I can not see attachment thumbs even in newly posted threads. Do you have the same problem too?

Ah, that sucks!! was hoping your was sorted and had solution for me.

No i can post and see thumbs for new posts...

Seems like i have dead links, could be something silly.
Have you chaps tried this code from Salvatore? I had the same problem after moving from phpBB3 to MyBB (and since to SMF Big Grin ) . . .

<?php
/* mybb connect */
define("IN_MYBB", 1);
define("NO_ONLINE", 1);
require("global.php");

/* phpBB3 connect */
$username = "phpbb3_username";
$password = "phpbb3_password";
$hostname = "localhost";	
$dbh = mysql_connect($hostname, $username, $password) 
	or die("Unable to connect to MySQL");
mysql_set_charset('utf8',$dbh); 

$selected = mysql_select_db("phpbb3_database",$dbh) 
	or die("Could not select database");

$no_encontrados = 0;

$query=$db->query("SELECT * FROM mybb_attachments");
while($result=$db->fetch_array($query))
{
	$file_phpbb3 = getFileData( $result['filename'] );
	if ( !empty($file_phpbb3) ) {
		echo "MYBB: id: " . $result['aid'] . " name: " .$result['filename'] . "<br/>";
		echo "PHPBB: id: ".$file_phpbb3['attach_id']." physical_filename: ".$file_phpbb3['physical_filename']." <br/>";
		//uncomment this line once you are sure you want to copy files
		//copyFile( $file_phpbb3['physical_filename'], $result['attachname'] );
	} else {
		echo "File id: ".$result['aid']." (".$result['filename'].") was not found in phpbb3<br/>";
		$no_encontrados++;
	}
	echo "<br/>";
}

echo $no_encontrados." files not found in total";

function getFileData( $name ) {
	$sql = "SELECT attach_id, physical_filename
			  FROM phpbb_attachments
				 WHERE real_filename LIKE '".mysql_real_escape_string($name)."'";

	$result = mysql_query($sql);
	if (!$result) {
		return;
	} else {
		$row = mysql_fetch_array($result);
		return $row;
	}
}

function copyFile( $from, $to ) {
	$from_folder = "/home/your_folder/phpbb3/files/";
	$to_folder = "/home/your_folder/mybb/uploads/";
	//echo "copiando archivo ".$from_folder.$from." a ".$to_folder.$to;
	if (!copy($from_folder.$from, $to_folder.$to)) {
		echo "Error copying<br/>";
	} else {
		echo "File copied<br/>";
	}
}
?>  


I deleted the converted attachments (since they are corrupt), then pasted this code into a file called "migrate-attachments.php". Upload it to your MyBB root directory and run it.

You'll need to change your phpBB3 database credentials and the path of both phpBB3 and MyBB attachment folders in the script ($username, $password, $hostname, $from_folder & $to_folder).

Hope it helps, it worked for me.

I then scripted some updates to re-embed them back into the posts since pretty much all of mine were image attachments.
(2013-11-18, 10:07 AM)Dunk Wrote: [ -> ]Have you chaps tried this code from Salvatore? I had the same problem after moving from phpBB3 to MyBB (and since to SMF Big Grin ) . . .

<?php
/* mybb connect */
define("IN_MYBB", 1);
define("NO_ONLINE", 1);
require("global.php");

/* phpBB3 connect */
$username = "phpbb3_username";
$password = "phpbb3_password";
$hostname = "localhost";	
$dbh = mysql_connect($hostname, $username, $password) 
	or die("Unable to connect to MySQL");
mysql_set_charset('utf8',$dbh); 

$selected = mysql_select_db("phpbb3_database",$dbh) 
	or die("Could not select database");

$no_encontrados = 0;

$query=$db->query("SELECT * FROM mybb_attachments");
while($result=$db->fetch_array($query))
{
	$file_phpbb3 = getFileData( $result['filename'] );
	if ( !empty($file_phpbb3) ) {
		echo "MYBB: id: " . $result['aid'] . " name: " .$result['filename'] . "<br/>";
		echo "PHPBB: id: ".$file_phpbb3['attach_id']." physical_filename: ".$file_phpbb3['physical_filename']." <br/>";
		//uncomment this line once you are sure you want to copy files
		//copyFile( $file_phpbb3['physical_filename'], $result['attachname'] );
	} else {
		echo "File id: ".$result['aid']." (".$result['filename'].") was not found in phpbb3<br/>";
		$no_encontrados++;
	}
	echo "<br/>";
}

echo $no_encontrados." files not found in total";

function getFileData( $name ) {
	$sql = "SELECT attach_id, physical_filename
			  FROM phpbb_attachments
				 WHERE real_filename LIKE '".mysql_real_escape_string($name)."'";

	$result = mysql_query($sql);
	if (!$result) {
		return;
	} else {
		$row = mysql_fetch_array($result);
		return $row;
	}
}

function copyFile( $from, $to ) {
	$from_folder = "/home/your_folder/phpbb3/files/";
	$to_folder = "/home/your_folder/mybb/uploads/";
	//echo "copiando archivo ".$from_folder.$from." a ".$to_folder.$to;
	if (!copy($from_folder.$from, $to_folder.$to)) {
		echo "Error copying<br/>";
	} else {
		echo "File copied<br/>";
	}
}
?>  


I deleted the converted attachments (since they are corrupt), then pasted this code into a file called "migrate-attachments.php". Upload it to your MyBB root directory and run it.

You'll need to change your phpBB3 database credentials and the path of both phpBB3 and MyBB attachment folders in the script ($username, $password, $hostname, $from_folder & $to_folder).

Hope it helps, it worked for me.

I then scripted some updates to re-embed them back into the posts since pretty much all of mine were image attachments.

Thanks will give that a try, how can i re-embed them after this update? mine are also 100% images.
Every post had copied across with the code [attachment=0] (then 1, 2 , 3 etc depending on how many attachments are in the post) inserted in it, which is obviously the wrong attachment ID, hence not displaying it correctly.

There must be an easier way, but since I'm no DBA, I ran this to show me the posts with attachments and the correct attachment ID's . . .

SELECT * 
FROM mybb_posts
LEFT JOIN mybb_attachments ON mybb_posts.pid = mybb_attachments.pid
WHERE mybb_posts.message LIKE  "%[attach%"

Exported the results into Excel and created a list of updates like this:

update mybb_posts set message = replace(message, "[attachment=0", "[attachment=19") where pid = "7314";

Where there is more than one attachment in a post you'll need to repeat lines for each one of course:

update mybb_posts set message = replace(message, "[attachment=0", "[attachment=19") where pid = "7314";
update mybb_posts set message = replace(message, "[attachment=1", "[attachment=20") where pid = "7314";

You'll end up with a load of update statements like this:

update mybb_posts set message = replace(message, "[attachment=0", "[attachment=13") where pid = "7288";
update mybb_posts set message = replace(message, "[attachment=0", "[attachment=14") where pid = "7289";
update mybb_posts set message = replace(message, "[attachment=1", "[attachment=15") where pid = "7289";
update mybb_posts set message = replace(message, "[attachment=2", "[attachment=16") where pid = "7289";
update mybb_posts set message = replace(message, "[attachment=3", "[attachment=17") where pid = "7289";
update mybb_posts set message = replace(message, "[attachment=4", "[attachment=18") where pid = "7289";
update mybb_posts set message = replace(message, "[attachment=0", "[attachment=19") where pid = "7314";
update mybb_posts set message = replace(message, "[attachment=1", "[attachment=20") where pid = "7314";
update mybb_posts set message = replace(message, "[attachment=0", "[attachment=21") where pid = "7320";

I copied the code into phpmyadmin and ran it to update the posts and all was well with the world again Big Grin I only had 350 odd attachments to it wasn't too painful to sort out.
(2013-11-18, 10:33 AM)Dunk Wrote: [ -> ]Every post had copied across with the code (then 1, 2 , 3 etc depending on how many attachments are in the post) inserted in it, which is obviously the wrong attachment ID, hence not displaying it correctly.

There must be an easier way, but since I'm no DBA, I ran this to show me the posts with attachments and the correct attachment ID's . . .

SELECT * 
FROM mybb_posts
LEFT JOIN mybb_attachments ON mybb_posts.pid = mybb_attachments.pid
WHERE mybb_posts.message LIKE  "%[attach%"

Exported the results into Excel and created a list of updates like this:

update mybb_posts set message = replace(message, "[attachment=0", "[attachment=19") where pid = "7314";

Where there is more than one attachment in a post you'll need to repeat lines for each one of course:

update mybb_posts set message = replace(message, "[attachment=0", "[attachment=19") where pid = "7314";
update mybb_posts set message = replace(message, "[attachment=1", "[attachment=20") where pid = "7314";

You'll end up with a load of update statements like this:

update mybb_posts set message = replace(message, "[attachment=0", "[attachment=13") where pid = "7288";
update mybb_posts set message = replace(message, "[attachment=0", "[attachment=14") where pid = "7289";
update mybb_posts set message = replace(message, "[attachment=1", "[attachment=15") where pid = "7289";
update mybb_posts set message = replace(message, "[attachment=2", "[attachment=16") where pid = "7289";
update mybb_posts set message = replace(message, "[attachment=3", "[attachment=17") where pid = "7289";
update mybb_posts set message = replace(message, "[attachment=4", "[attachment=18") where pid = "7289";
update mybb_posts set message = replace(message, "[attachment=0", "[attachment=19") where pid = "7314";
update mybb_posts set message = replace(message, "[attachment=1", "[attachment=20") where pid = "7314";
update mybb_posts set message = replace(message, "[attachment=0", "[attachment=21") where pid = "7320";

I copied the code into phpmyadmin and ran it to update the posts and all was well with the world again Big Grin I only had 350 odd attachments to it wasn't too painful to sort out.

Thats really smart but im sure i will mess it up! also have over 3500 attachents so could be painfull to do it.

So irritating that all worked 100% other than attachments! really looking forward to using mybb.

Is there a company which offers mybb support? i dont mind paying a fee.
Did a conversion from a phpBB3 database and everything looks petty good, but for the attachments. In the ../archive directory I had a whole set of files that are html files that all say the same thing, that "I don't have permission to access" followed by the attachment file name. I checked the permissions on the "files" directory in the phpBB3 directory and it is set for everyone to read the directory content and all the files have read access to the world.

Any suggestions?


Ok I just wrote a perl script that looked at the html files which named the attachment it was trying to find and renamed that file with the MyBB attachment file name. Works just fine.
Pages: 1 2 3 4 5 6 7 8 9 10 11