vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   php parse attachments, parsing bbcode works (https://vborg.vbsupport.ru/showthread.php?t=299604)

KaitenV 06-28-2013 03:30 PM

php parse attachments, parsing bbcode works
 
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?

PHP Code:

$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($vbulletinfetch_tag_list(), true);  
    
//$my_text = $bbcode_parser->do_parse("[b]Parse[/b]",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
Code:

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:
PHP Code:

$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/...ter-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.


All times are GMT. The time now is 05:49 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01001 seconds
  • Memory Usage 1,748KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (13)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete