vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.6 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=194)
-   -   Show Thread Enhancements - Download Thread as PDF (https://vborg.vbsupport.ru/showthread.php?t=151637)

magnus 07-08-2007 01:57 PM

Quote:

Originally Posted by Quantnet.org (Post 1285548)
i'm on a VPS so i have full control over my server. Here is the step i used

wget http://user.it.uu.se/~jan/html2ps-1.0b5.tar.gz
tar xvfz html2ps-1.0b5.tar.gz
cd html2ps-1.0b5
./install

Click yes and set directory..it get installed in /usr/local/bin/

cd /usr/local/bin/
chmod 755 html2p*


Still the same error...did i chmod correctly ? What do i miss ?

The developer states that error is:
Quote:

that is a problem of not having html2ps on your server (or it being in a different path). You'll need to install it in your home directory most likely if you do not have root access on the server
So, that being said.. can you execute html2ps from your shell?
Quote:

# whereis html2ps
html2ps: /usr/bin/html2ps /usr/X11R6/bin/html2ps /usr/bin/X11/html2ps /usr/share/man/man1/html2ps.1.gz
Quote:

# html2ps -v
html2ps version 1.0 beta5
Also, this was mentioned on the same topic by the author:
Quote:

There is PHPs open_basedir, if "/usr/local/bin/" is not within the allowed path, then php scripts won't be able to access the file.

Also check your php.ini file to see if anything has been defined in the directive 'disable_functions'
You may want to try locating html2ps within your webroot, seeing if that will work.

Paul M 07-08-2007 02:01 PM

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.

Paul M 07-08-2007 05:29 PM

Quote:

Originally Posted by Paul M (Post 1285813)
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.

JFYI - I've changed the following in threadtopdf.php

PHP Code:

    $htmlFile $vbulletin->options['bburl'] . '/threadtopdf.php?t=' $threadid '&amp;pdf=1'

to

PHP Code:

    $htmlFile $vbulletin->options['bburl'] . '/threadtopdf.php?t=' $threadid

and

PHP Code:

$forumperms fetch_permissions($threadinfo['forumid']);
if (!(
$forumperms $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms $vbulletin->bf_ugp_forumpermissions['canviewthreads']))
{
    
print_no_permission();
}
if (!(
$forumperms $vbulletin->bf_ugp_forumpermissions['canviewothers']) AND ($threadinfo['postuserid'] != $vbulletin->userinfo['userid'] OR $vbulletin->userinfo['userid'] == 0))
{
    
print_no_permission();
}

if (
$threadinfo['open'] == 10)
{
    
exec_header_redirect('threadtopdf.php?' $vbulletin->session->vars['sessionurl_js'] . "t=$threadinfo[pollid]");
}

// check if there is a forum password and if so, ensure the user has it set
verify_forum_password($foruminfo['forumid'], $foruminfo['password']); 

to

PHP Code:

if ($threadinfo['open'] == 10)
{
    
exec_header_redirect('threadtopdf.php?' $vbulletin->session->vars['sessionurl_js'] . "t=$threadinfo[pollid]");
}

if (
$_SERVER['SERVER_ADDR'] != IPADDRESS
{
    
$forumperms fetch_permissions($threadinfo['forumid']);
    if (!(
$forumperms $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms $vbulletin->bf_ugp_forumpermissions['canviewthreads']))
    {
        
print_no_permission();    
    }
    if (!(
$forumperms $vbulletin->bf_ugp_forumpermissions['canviewothers']) AND ($threadinfo['postuserid'] != $vbulletin->userinfo['userid'] OR $vbulletin->userinfo['userid'] == 0))
    {
        
print_no_permission();
    }

// check if there is a forum password and if so, ensure the user has it set
    
verify_forum_password($foruminfo['forumid'], $foruminfo['password']);


Apart from the missing images, I now have a fully operational Thread > PDF (on my test forum). :)

If I decide to make this live I will probably do custom templates instead of using the printthread templates. :cool:

theFAILURE 07-08-2007 05:42 PM

Some of the threads on my site are between 50 to 300 pages long, and are basically stories you read from beginning till end. Mostly all of them have audio and photos as well.

It's nice to have the members logged in and reading the stories, instead of downloading the PDF file then getting logging out.

While reading the threads, it also entices members to post in the thread. While logged out reading PDF files this may not happen.

rjmjr69 07-08-2007 07:11 PM

I get this error when trying am I missing something?

http://www.isosdcftp.com/forums/thre...hp?t=370&pdf=1

If I'm missing those files you posted a link to where do I install those?

nebu 07-08-2007 07:16 PM

pdf convertion is fine, but i have no pics ...
neither avatars nor images/smilies :(

magnus 07-08-2007 07:21 PM

Quote:

Originally Posted by nebu (Post 1286057)
pdf convertion is fine, but i have no pics ...
neither avatars nor images/smilies :(

You're not supposed to. It's a PDF of the "View Printable Version" output.

nebu 07-08-2007 07:23 PM

i overwrited my "old" version (2 days old) with the new one.
it works fine with the old one, but now i get this error message with the new one
"HTML_ToPDF Error: html2ps [/usr/bin/html2ps] not executable"

i have no root access and i dont know what to do :(

nebu 07-10-2007 05:38 AM

can u upload the old version again plz?
the old works .....

Tralala 07-10-2007 02:21 PM

Quote:

Originally Posted by theFAILURE (Post 1285988)
Some of the threads on my site are between 50 to 300 pages long, and are basically stories you read from beginning till end. Mostly all of them have audio and photos as well.

It's nice to have the members logged in and reading the stories, instead of downloading the PDF file then getting logging out.

While reading the threads, it also entices members to post in the thread. While logged out reading PDF files this may not happen.


And yet, on the other hand, there are forums with lots of technical information and support shared. Admins might wish to allow their users to be able to locally archive and search this information. Users might feel "safer" knowing they're able to save a long, informative thread to their own computers... should the forum be down or the thread get removed.

Think of vb.org, for example. There have been instances where a hack author leaves, or a mod is removed... in that case, the support thread with all he answers go "poof!" as well. As a forum admin who might be running one of those mods, the ability to save the thread for my own reference later on would be VERY much appreciated.


That said... I, for one, am appreciative that magnus has coded this and is sharing it with us all. Looking forward to seeing improvements, if they are planned. I would like to see the option for images (inline as well as smilies) to be included, if that's possible.


All times are GMT. The time now is 05:08 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.01228 seconds
  • Memory Usage 1,816KB
  • 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
  • (7)bbcode_php_printable
  • (8)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete