PDA

View Full Version : php parse attachments, parsing bbcode works


KaitenV
06-28-2013, 03:30 PM
I have this code to parse the bbcode into html, and it works perfectly, except attached images are made into links. How can I get the bbcode parser to make the images display with the <img /> tag and not links?


$forumpath = SRD."forums"; // path to your forum
//echo $forumpath;
$that_cwd = @getcwd(); // absolute path to this script
chdir($forumpath);
$phrasegroups = array();
$globaltemplates = array();
$actiontemplates = array();
$specialtemplates = array();
require_once('./global.php');
require_once('./includes/class_bbcode.php');
@chdir($that_cwd);
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list(), true);
//$my_text = $bbcode_parser->do_parse("Parse",false,true,true,true,true,false);
//echo $my_text;

kh99
06-28-2013, 04:59 PM
In Settings > Options > Message Attachment Options, what do you have selected for "View Attached Images Inline" and "Thumbnail Creation"?

KaitenV
06-28-2013, 06:29 PM
"View Attached Images Inline" is set to "Yes, full size" - when it was set to "Yes, display thumbnails" only a link was displayed as well.
"Thumbnail Creation" is set to "Yes"

When I go to: Maintenance -> General Update Tools -> Rebuild Attachment Thumbnails
Building Attachment ThumbnailsIf you receive a fatal error or if the process seems to hang, you will need to delete the last attachment listed on the screen then refresh this window.
Processing: Attachment : 1 (jpg) Error
Processing: Attachment : 2 (jpg) Error
Processing: Attachment : 3 (jpg) Error
Processing: Attachment : 4 (jpg) Error
Processing: Attachment : 5 (jpg) Error
Processing: Attachment : 6 (jpg) Error
Processing: Attachment : 7 (jpg) Error
Processing: Attachment : 8 (jpg) Error
Processing: Attachment : 9 (jpg) Error
Processing: Attachment : 10 (jpg) Error
Processing: Attachment : 11 (jpg) Error
Processing: Attachment : 12 (jpg) Error
Processing: Attachment : 13 (jpg) Error
Processing: Attachment : 14 (jpg) Error
Processing: Attachment : 18 (jpg) Error
Processing: Attachment : 19 (jpg) Error
Processing: Attachment : 20 (jpg) Error
Processing: Attachment : 21 (jpg) Error
Processing: Attachment : 23 (jpg) Error
Processing: Attachment : 24 (jpg) Error
Processing: Attachment : 25 (jpg) Error
Processing: Attachment : 28 (jpg) Error
Processing: Attachment : 29 (jpg) Error
Processing: Attachment : 30 (jpg) Error
Processing: Attachment : 31 (jpg) Error

kh99
06-28-2013, 10:02 PM
OK. I don't know if that's a problem or not, I was just looking at the parsing code and noticed that it doesn't try to show the images unless those settings allow it (and the way you have them set is OK).

Oh, I should have asked: what does your call to $bbcode_parser->parse() look like? The code you posted has a commented out call to do_parse().

KaitenV
06-29-2013, 12:56 AM
I'm not using $bbcode_parser->parse(); I am using this:
$News['pagetext'] = $GLOBALS['bbcode_parser']->do_parse(unhtmlspecialchars($News['pagetext']),false,true,true,true,true,false);

If I should be using $bbcode_parser->parse(); please give an example.

kh99
06-29-2013, 09:29 AM
No, that's OK, you can call do_parse(). I just assumed (incorrectly) that the commented out call to do_parse() was an experiment or something.

I'm not sure what the problem is, I'd probably have to have it set up so I could debug it. I guess it could be the errors you're getting when you try to build the thumbnails. Do you have the image processing options set up correctly? Does it work for normal forum posts?

KaitenV
06-29-2013, 12:14 PM
Where are the image processing functions? On normal form posts the thumbnails don't work, but I have it set up so full size images do work (http://otakuhelpers.com:8080/forums/showthread.php/71892-Naruto-chapter-535-Review!), if I try to use thumbnails it only displays a link.

kh99
06-29-2013, 05:52 PM
I meant the options under Settings > Options > Image Settings.

I'm guessing it has something to do with the missing thumbnail images, but I can't follow all the logic (I'm looking at handle_bbcode_img() in includes/class_bbcode.php).

KaitenV
06-29-2013, 06:49 PM
I have Image Processing Library > GD is checked. That is all that is installed.

kh99
06-29-2013, 07:32 PM
OK, that sounds good. I'm looking at the "rebuild attachments" code to see what could cause errors. Do you have attachments stored in the database or the file system? If you have them stored in the database, you need a valid writable temp path, either in the php settings, or possibly in the vb settings if you are using open basedir restrictions (although I think if you didn't have a writable temp path you wouldn't be able to upload anything).

If you have attachments stored in the file system, those directories have to be writable (but again, if they weren't you wouldn't be able to attach anything).

I guess if you've been using the same server for a long time but just upgraded vb, then it's probably not the directory permissions (unless maybe you moved them).

KaitenV
06-29-2013, 08:46 PM
They are stored and the database, I can upload them just fine. It's just the issue with thumbnails. I tried switching it to directory storage and it did not help, now it's back to database.

Thanks for all of your hard work, please keep assisting me. It's probably on the tip of your mind.

kh99
06-30-2013, 03:35 PM
Sorry, I can't figure it out just by looking at the code. It does seem like if you have it working in the normal thread display then you should be able to get it to work. Maybe you should try calling $bbcode_parser->parse(unhtmlspecialchars($News['pagetext'])) and see what happens. Also the second parameter is a forumid that is used to apply the forum settings, if you have the thread's forumid maybe you could pass that as well (or at least make it some valid forumid). Without a forumid it might apply options for a "non forum" area.

KaitenV
07-01-2013, 03:31 AM
If I use $bbcode_parser->parse(); only a "1" is rendered.