thanks, I have succesfully convert attachments las night. Had to install "Store files to disk" Phorum module and change some code in it to store files in one dir. Also some changes for converter required.
Here is 2 string I changed:
Code: Select all
array('physical_filename', 'files.file_id', 'import_attachment'),
array('real_filename', 'files.filename', ''),
Attachments are shown in the end of each post/ But i also wnat them to be shown among some text. I made changes for every post_text with regular expresions. Now bbcode for attachments looks like
filename.jpg
.
Here is a sample code for it:
Code: Select all
<?php
require_once 'MDB2.php'; //PEAR MDB2 used here
$dsn = 'mysqli://user:password@host/dbName';
$options = array(
'debug' => 2,
'result_buffering' => false,
);
$mdb2 =& MDB2::factory($dsn, $options);
if (PEAR::isError($mdb2)) {
die($mdb2->getMessage());
}
$sql="SELECT post_id,post_text from phpbb_posts";
$res =& $mdb2->query($sql);
if (PEAR::isError($res)) {
die($res->getMessage());
}
$done=0;
while (($row = $res->fetchRow())) {
$count=0;
$updated_text=preg_replace('/\[attachment \d+ (\S+\.\S+)\]/i', '[attachment=0]$1\[/attachment]', $row[1],-1,$count);
if($count>0){
$update="UPDATE phpbb_posts set post_text='$updated_text',post_attachment=1 where post_id=$row[0]";
$affected =& $mdb2->exec($update);
$done++;
}
echo $done.'\n';
}
$mdb2->disconnect();
?>