Thread: Show Thread Enhancements - Download Thread as PDF
View Single Post
  #23  
Old 07-08-2007, 02:01 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I now have this working but several problems needed to be overcome;

The required ghostscript and html2ps were not installed on my server so I had to get them and install them (without 'jasper', whatever that is).

Once installed I got the execution errors and noticed that default path in the class file was wrong - they installed to /usr/local/bin/ (not /usr/bin/) so I had to edit the class file.

Despite fixing this I still got the "not executable" errors, this was quickly traced to php open_basdir kicking in and preventing apache from accessing the binaries - so I had to update php settings.

Once all this was done, the pdf conversion started to work - however, I was only getting one page, not the whole thread. This took a bit of degugging, during which I found some unnecessary code in the threadtopdf.php file. Having removed the unnecessary perpage stuff from the file, I found that even though the code was building the whole thread, once I used it properly, the pdf file was still only one page, with the perpage stuff I had removed.

After much head scratching about how this was impossible I did some packet tracing to see what was going on and found the culprit - VBSEO. I had Rewrite Printthread URLs set to 'Yes' and this was somehow interferring with the way the this mod works, causing the pdf output to be built from printthread.php, and not threadtopdf.php - once I disabled the url rewrite on print threads, the mod started outputting the pdf correctly.

I still have one minor issue - the header image is missing from the threads, but this is not important.


FYI; I removed the following code in threadtopdf.php as perpage stuff is not needed ;
PHP Code:
$vbulletin->input->clean_array_gpc('r', array(
    
'perpage'    => TYPE_UINT,
    
'pagenumber'=> TYPE_UINT
)); 
PHP Code:
    // split thread over pages if necessary
    
$countposts $db->query_first_slave("
        SELECT COUNT(*) AS total
        FROM " 
TABLE_PREFIX "post AS post
        WHERE threadid=
$threadinfo[threadid] AND visible=1
    "
);
    
$totalposts $countposts['total'];

    
$vbulletin->GPC['perpage'] = sanitize_maxposts($totalposts);
    
$maxperpage sanitize_maxposts(-1);

    if (
$vbulletin->GPC['pagenumber'] < 1)
    {
        
$vbulletin->GPC['pagenumber'] = 1;
    }

    
$startat = ($vbulletin->GPC['pagenumber'] - 1) * $vbulletin->GPC['perpage'];

    
$pagenav construct_page_nav($vbulletin->GPC['pagenumber'], $vbulletin->GPC['perpage'], $totalposts'threadtopdf.php?' $vbulletin->session->vars['sessionurl'] . "t=$threadinfo[threadid]"'&amp;pp=' $vbulletin->GPC['perpage']);
    
// end page splitter 
I also edited the SQL to this ;
PHP Code:
    $posts $db->query_read_slave("
        SELECT post.*,post.username AS postusername,user.username
        FROM " 
TABLE_PREFIX "post AS post
        LEFT JOIN " 
TABLE_PREFIX "user AS user USING(userid)
        WHERE post.threadid=
$threadid AND post.visible=1
        ORDER BY dateline 
$postorder
    "
); 

There is also a premissions problem - you cannot pdf threads unless they are viewable by guests, and also a slight error in the url build as well.

I think I have fixed these problems locally, but need to test them, and I have to go out now for a few hours.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02264 seconds
  • Memory Usage 1,796KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete