Passwortschutz auf Verzieichnis /faq

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

Post Reply
Spolti
Posts: 9
Joined: Wed Sep 26, 2012 2:52 pm
Location: 48703 Stadtlohn
Contact:

Passwortschutz auf Verzieichnis /faq

Post by Spolti »

Hallo
Ich habe die phpMyFAQ Installation in einem Verzeichnis mit Passwortschutz Installiert damit nur eine bestimmte Personengruppe darauf zugreifen kann.(Mein Chef möchte das (noch) nicht wegen Betriebsinterna!).
Jetzt habe ich natürlich schon Beiträge erstellt und dabei festgestellt das der pdf.EXPORT unterschiedlich auf Bilder/Fotos reagiert.
Wenn ich die Bilder aus dem Verzeichnis /faq/images in Beiträge verwende dann bekomme ich bei einem pdf.EXPORT folgende Fehlermeldung:
TCPDF ERROR: [Image] Unable to get image: http://faq.meineseite.de/images/562435623.jpg

Wenn ich die Bilder von externen Internetseiten (http://www.andere-internetseite.de/images/562435623.jpg) in einem Beitrag verwende dann bekomme ich bei einem pdf.EXPORT, in dem die Bilder richtig angezeigt werden.

Kann man das irgendwie ändern?
Gruß
Guido
phpMyFAQ Version 2.8.8
Server Software Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7
phpMyFAQ installation path C:/xampp/htdocs/phpmyfaq
PHP Version 5.4.7
Database Server mysql
Database Server Version 5.5.27 / mysqlnd 5.0.10
Thorsten
Posts: 15729
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Passwortschutz auf Verzieichnis /faq

Post by Thorsten »

Hi,

geht das ohne dem Schutz auf http://faq.meineseite.de/images/562435623.jpg? Wenn nein, dann nimm den Ordner images/ raus aus dem Schutz.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
tamere22
Posts: 5
Joined: Thu Feb 07, 2013 4:34 pm

Re: Passwortschutz auf Verzieichnis /faq

Post by tamere22 »

Hi,

I have similar error, but as I don't understand german I can't read your solution Thorsten so I registred and I post here.

When I try export, if I have image included in the body of text (ctrl c / ctrl v inside wysiwyg editor), I get the following pdf export error :

Code: Select all

TCPDF ERROR: [Image] Unable to get image: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ4AAAEFCAI........................................................................ characters goes on
If I remove intext images, it works.

I digged a bit and found this that is related : https://github.com/thorsten/phpMyFAQ/issues/359

So could it be possible for you to remove base64 images from the export? Then TCPDF will work whatever happens.


Also when I use tcpdf export, is it supposed to display attached images inside the pdf ? Because I attached .gif files to my KB articles, and they don't display in the pdf.


Thanks for your help.


Edit : Found out that editing

Commenting out this line (phpmyfaq/inc/libs/tcpdf/tcpdf.php 7549):

Code: Select all

# $this->Error('[Image] Unable to get image: '.$file);
Removes the error, the pdf gets generated and is ok (but without the in-text image, but eh, it's better than nothing)

Any luck that this will work in the future ?
Thorsten
Posts: 15729
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Passwortschutz auf Verzieichnis /faq

Post by Thorsten »

HI,

well, this depends on the TCPDF library, if it'll support base64 encoded images we'll do, too.

Sorry for that!

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
tamere22
Posts: 5
Joined: Thu Feb 07, 2013 4:34 pm

Re: Passwortschutz auf Verzieichnis /faq

Post by tamere22 »

Hi,

I digged a bit ...

In fact tcpdf doesn't need to support base64, all you have to do is base64_decode() the img data to make it understand it.

But somehow, phpmyfaq code replace '+' symbols by ' ' so it make base64_decode crash.

I don't have the time to search where in the phpmyfaq's code it act like this, since the mysql database contains the correct '+' symbols.

Anyway, here is a proof of concept that I used to make a correct pdf including an embedded image :

Just after the function Image() declaration :

Code: Select all

 public function Image($file, $x='', $y='', $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0, $fitbox=false, $hidden=false, $fitonpage=false, $alt=false, $altimgs=array()) {
Add the following code :

Code: Select all

if (!strpos($file, 'data:image/png;base64,' === false)) {
        $file='@'.base64_decode(chunk_split(str_replace(' ', '+', str_replace('data:image/png;base64,', '', $file))));
}
(I added chunk_split as an user suggested at php.net/base64_decode, because it should work better with large base64 encoded content)

It works, but it's ugly :)

Maybe you could include this into the phpmyfaq code instead of tcpdf class as I did ? (I would have done it, but don't know where).



What I'm not understanding is attached files to faq are not included in pdf file. I attached a 50kb jpg file to a sample faq article, and it doesn't get included into the pdf (with or without my modification to the code).
Any idea why ?
Thorsten
Posts: 15729
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Passwortschutz auf Verzieichnis /faq

Post by Thorsten »

Hi,

I will do some testing on this, thanks a lot for the hint.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Thorsten
Posts: 15729
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Passwortschutz auf Verzieichnis /faq

Post by Thorsten »

Hi,

I added this code for phpMyFAQ 2.8.0-RC2:

https://github.com/thorsten/phpMyFAQ/co ... d4a1981021

Please check it.

Attached images are not display in PDF exports, only embedded images. If you need that, please add a feature request here: https://github.com/thorsten/phpMyFAQ/issues

Thanks!

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Post Reply