Welcome!
Log In
Create A New Profile
Home
>
Outdated forums
>
Phorum 5.1/5.0
>
5.1 Phorum Modules / Add-Ons
>
Topic
WeBBs to phorum5 conversion
Posted by Thomas Seifert
All files from this thread
| File Name | File Size | Posted by | Date | ||
|---|---|---|---|---|---|
| webbs2phorum5convert-20051001.zip | 3.8 KB | open | download | Thomas Seifert | 02/12/2006 | Read message |
|
February 12, 2006 09:28AM |
Admin Registered: 7 years ago Posts: 7,734 |
This script allows you to convert the data from webbs to phorum5.
Short usage:
---
- webbs_in.php needs to be put in <phorum-dir>/scripts
- webbs2phorum5.php needs to be put in the phorum-directory
- edit the path and forum-id in the top of webbs2phorum5.php
(the forum where the data should be imported should be created before)
- the path is meant to contain multiple directories
Please move all directories which don't contain
messages directly out of it.
---
Some remarks on it:
I have no knowledge of the webbs datastructure at all. I just rewrote a script built for an ancient phorum-version to work with phorum5.
As far as I know the importer worked for webbbs 5.x, not sure about other versions it might work on.
Please post any comments, enhancements and not too much bugs ;) in this thread.
Thomas Seifert
Phorum Development Team / Phorum-Support.de
Custom Phorum Development
Personal Blog
Short usage:
---
- webbs_in.php needs to be put in <phorum-dir>/scripts
- webbs2phorum5.php needs to be put in the phorum-directory
- edit the path and forum-id in the top of webbs2phorum5.php
(the forum where the data should be imported should be created before)
- the path is meant to contain multiple directories
Please move all directories which don't contain
messages directly out of it.
---
Some remarks on it:
I have no knowledge of the webbs datastructure at all. I just rewrote a script built for an ancient phorum-version to work with phorum5.
As far as I know the importer worked for webbbs 5.x, not sure about other versions it might work on.
Please post any comments, enhancements and not too much bugs ;) in this thread.
Thomas Seifert
Phorum Development Team / Phorum-Support.de
Custom Phorum Development
Personal Blog
|
Thank you very much! February 13, 2006 12:24PM |
Registered: 4 years ago Posts: 117 |
|
Re: WeBBs to phorum5 conversion February 13, 2006 03:01PM |
Registered: 4 years ago Posts: 117 |
The conversion script work very well on Webbbs 5.12, which is the latest version. I added a little code to post the image to the end of the body (if an image is attached).
The only thing I wanted to do was update the attachment indicator if a picture is attached. I am running the icon message mod but could not understand the rhyme and reason of the meta tag where the attachment indicator is stored.
Help???
The only thing I wanted to do was update the attachment indicator if a picture is attached. I am running the icon message mod but could not understand the rhyme and reason of the meta tag where the attachment indicator is stored.
Help???
|
February 13, 2006 03:03PM |
Admin Registered: 7 years ago Posts: 7,734 |
how do you add the attachment to the post?
Thomas Seifert
Phorum Development Team / Phorum-Support.de
Custom Phorum Development
Personal Blog
Thomas Seifert
Phorum Development Team / Phorum-Support.de
Custom Phorum Development
Personal Blog
|
Re: WeBBs to phorum5 conversion February 13, 2006 03:11PM |
Registered: 4 years ago Posts: 117 |
Your code parsed out the IMAGE> tag from the Webbbs data file but you never did anything with it. In 5.12 the post page has a single image upload field which stores the URL of the picture.
I added the <img src> tagging to the URL then appended this to the end of the $body variable. Webbbs' upload field is specific to images only so you don't hvae to worry about any other type of attachment.
If the image was added to the post via bbcode img tags then it has already been converted to html by webbbs and store in this format in the message.
Here is the relavent part of webbs_in.php starting about line 58...
I added the <img src> tagging to the URL then appended this to the end of the $body variable. Webbbs' upload field is specific to images only so you don't hvae to worry about any other type of attachment.
If the image was added to the post via bbcode img tags then it has already been converted to html by webbbs and store in this format in the message.
Here is the relavent part of webbs_in.php starting about line 58...
for ($a = 0; $a < count($aryCurrFile); $a++ ) {
$strLine = $aryCurrFile[$a];
// pull lines into either specified tags or the body
if ( ereg ("^SUBJECT>",$strLine) ||
ereg ("^POSTER>",$strLine) ||
ereg ("^EMAIL>",$strLine) ||
ereg ("^DATE>",$strLine) ||
ereg ("^EMAILNOTICES>",$strLine) ||
ereg ("^IP_ADDRESS>",$strLine) ||
ereg ("^NEXT>",$strLine) ||
ereg ("^IMAGE>",$strLine) ||
ereg ("^LINKNAME>",$strLine) ||
ereg ("^LINKURL>",$strLine) ||
ereg ("^PASSWORD>",$strLine) ) {
$tag = strtolower(trim(substr($strLine,0,strpos($strLine,">"))));
$value = trim(substr($strLine,strpos($strLine,">") + 1,strlen($strLine) - 1));
$$tag = $value;
} elseif ( ereg ("^PREVIOUS>",$strLine) ) {
$value = trim(substr($strLine,strpos($strLine,">") + 1,strlen($strLine) - 1));
$aryInput[$strFile]['PREVIOUS'] = $value;
} else {
$body .= trim($strLine);
}
}
// clean up body to format used by phorum
$body = trim(ereg_replace('<P>',"\n",ereg_replace('<BR>',"\n",$body)));
// attempt to assign threads
if (empty ($aryInput[$strFile]['PREVIOUS'])) {
$aryInput[$strFile]['THREAD'] = $aryInput[$strFile]['ID'];
} else {
$aryInput[$strFile]['THREAD'] = $aryInput[($aryInput[$strFile]['PREVIOUS'])]['THREAD'] ;
$aryInput[$strFile]['PREVIOUS'] = $aryInput[($aryInput[$strFile]['PREVIOUS'])]['ID'] ;
}
// trim IP_ADDRESS to actual IP_ADDRESS.
$ip_address = trim(substr($ip_address,strrpos($ip_address,":")+1,strlen($ip_address)));
// If you care about host names (and don't mind the slowdown) comment this line in:
// $ip_address = gethostbyaddress($ip_address);
$image = "<img src=".$image.">";
// set up and write insert commands to sql files
$id = $aryInput[$strFile]['ID'];
$thread = $aryInput[$strFile]['THREAD'];
if (empty ($thread)) { $thread = $id; }
$parent = $aryInput[$strFile]['PREVIOUS'];
$body = stripslashes($body);
$body = $body . $image;
// email-replies currently ignored!
if (empty ($emailnotices) || $emailnotices == "no") {
$email_reply = 'N';
} else {
$email_reply = 'N';
}
$max_id= $CONVERT['max_id'];
$mdata['id']=$id;
$closed=0;
$post_status=PHORUM_STATUS_APPROVED;
$post_sort=PHORUM_SORT_DEFAULT;
$parentid=($parent>0)?($parent+$max_id):0;
$mdata['author'] =$poster;
$mdata['subject']=preg_replace("/<img.*?>/i","",$subject);
$mdata['body'] =$body;
$mdata['email'] =$email;
$mdata['unixtime']=$date;
$mdata['thread'] =$thread;
$mdata['parent'] =$parent;
$mdata['host'] =$ip_address;
$mdata['msgid'] ="";
|
February 13, 2006 03:14PM |
Admin Registered: 7 years ago Posts: 7,734 |
pardon, phorum-attachments are real attachments to the message. not images referenced by an img-tag. thats why no module will see those "attached" images as attachments ;).
Thomas Seifert
Phorum Development Team / Phorum-Support.de
Custom Phorum Development
Personal Blog
Thomas Seifert
Phorum Development Team / Phorum-Support.de
Custom Phorum Development
Personal Blog
|
Re: WeBBs to phorum5 conversion February 13, 2006 03:19PM |
Registered: 4 years ago Posts: 117 |
|
February 13, 2006 03:32PM |
Admin Registered: 7 years ago Posts: 7,734 |
I would store that info in the meta-data for a message.
taken from docs/creating_mods.txt (www.phorum.org/cgi-bin/trac.cgi/browser/phorum5/trunk/docs/creating_mods.txt)
Thomas Seifert
Phorum Development Team / Phorum-Support.de
Custom Phorum Development
Personal Blog
taken from docs/creating_mods.txt (www.phorum.org/cgi-bin/trac.cgi/browser/phorum5/trunk/docs/creating_mods.txt)
2.4 Storing message data ------------------------ If your module needs to store data along with a Phorum message, you can make use of the meta information array that is attached to each message ($message["meta"]). This array is a regular PHP array, which is stored in the database as serialized data (see [www.php.net]). Because Phorum and other modules make use of this meta data as well, you should not squash it, neither access the meta data in the database directly. Instead use the methods described in this section. Remark: because the meta data is stored as serialized data in the database, it is not possible to include data you store in there in SQL queries. When storing information in the meta data from a hook function, you can encounter two different situations, which both need a different way of handling. 2.4.1 From hooks that are run before saving a message to the database --------------------------------------------------------------------- There are some hooks that send a full message structure to the hook functions, so these can change the message data before storing the message in the database. Examples are the hooks "pre_post" and "pre_edit". In this case you can simply update the meta information directly. Here's an example of how this would look in your hook function: function phorum_mod_foo_pre_post ($message) { $message["meta"]["mod_foo"]["foodata"] = "Some data"; $message["meta"]["mod_foo"]["bardata"] = "Some more data"; return $message; } Phorum will take care of storing the updated meta data in the database. 2.4.2 From other hooks ---------------------- For other hooks, the proper way to store information in the meta data is to retrieve the current meta data using phorum_db_get_message(), copy the meta data to a new message structure, make changes as needed and use phorum_db_update_message() to update the message in the database. Here is an example of how this could look in your hook function: function phorum_mod_foo_some_hook ($data) { // Somehow you get the id for the message. Here we asume // that it is stored in the $data parameter. $message_id = $data["message_id"]; // Retrieve the current message data. $message = phorum_db_get_message ($message_id); // Create updated meta data. $new_message = array("meta" => $message["meta"]); $new_message["meta"]["mod_foo"]["foodata"] = "Some data"; $new_message["meta"]["mod_foo"]["bardata"] = "Some more data"; // Store the updated data in the database. phorum_db_update_message($message_id, $new_message); return $data; } Changing meta data for a message this way will ensure that the existing meta data is kept intact.
Thomas Seifert
Phorum Development Team / Phorum-Support.de
Custom Phorum Development
Personal Blog
|
Re: WeBBs to phorum5 conversion February 13, 2006 10:24PM |
Registered: 4 years ago Posts: 117 |
Ok, I give up. I tried for hours to make this work but I really need some help. I understand that the embedded img src tags are now really attachments but I need to indicate to my users with post have images and which don't.
If possible, could you (or someone) help me with code that I can add to the conversion routine that does the following.
If the converted message body contains "<img src=" then mark the post as having an attachment so that the attachment icon will show up.
I think I can take it from there but I just could not figure out how to update the meta data.
Thanks.
If possible, could you (or someone) help me with code that I can add to the conversion routine that does the following.
If the converted message body contains "<img src=" then mark the post as having an attachment so that the attachment icon will show up.
I think I can take it from there but I just could not figure out how to update the meta data.
Thanks.
|
February 14, 2006 02:35AM |
Admin Registered: 5 years ago Posts: 7,803 |
There's no mark for "has an attachment" in the standard data. There is only a list of attachments in the meta data of the message. You cannot fool this system into showing an attachment icon. You could put something in the attachment list, but that would result in the message to really show attachments. That's not what you want, because you seem to want to show a camera icon once the message has whatever image embedded.
What would be needed for doing this can be found in this thread. There I've outlined the things the software should do. Now wait till I or somebody else gets around to typing it in ;)
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
What would be needed for doing this can be found in this thread. There I've outlined the things the software should do. Now wait till I or somebody else gets around to typing it in ;)
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
Sorry, only registered users may post in this forum.
