how can I troubleshoot these new php-pdf font errors? - php

Today our web server started throwing these errors when generating a pdf with php-pdf. Path is wrong but the pdf still generates. Unsure why this path issue started or how to fix it. Also concerned that it just started seemingly on its own.
Warning: fopen(/tmp/cachedTimes-Roman.php) [function.fopen]: failed to open stream: Permission denied in /home/site/public_html/include/pdf-php/src/Cpdf.php on line 2039
Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/site/public_html/include/pdf-php/src/Cpdf.php on line 2040
Warning: fclose() expects parameter 1 to be resource, boolean given in /home/site/public_html/include/pdf-php/src/Cpdf.php on line 2041

Most likely the device where /tmp is may have run out of space, so that new files can not be created there.
df -h in console should get you started.
If you are the system administrator, even rm -rf /tmp/* might help, but may also have consequences if any files currently in use are stored there.

The warnings were caused by the script not being able to find the font files. The problem was solved by explicitly setting the tempPath.
$pdf->tempPath = '../include/pdf-php/src/fonts';

Related

Errors on Opencart website developed n local PC after being uploaded to live server

I have developed an OC store on my local PC using XAMPP. I've uploaded the store to the server, and it's displaying well, BUT there are some irregularities. To cite an example, admin panel isn't functioning properly - I can sign in, but nothing is displayed then. I am almost sure the problem is in the urls, but as I have messed with the site once and had to reupload it, I more than welcome help from others. There are two sections of error messages - one in the header and one in the footer.
Errors in the header:
Warning: fopen(/home/davofvpt/public_html/storage/logs/openbay.log): failed to open stream: No such file or directory in /home/davofvpt/public_html/system/library/log.php on line 22
Warning: fopen(/home/davofvpt/public_html/storage/logs/openbay.log): failed
to open stream: No such file or directory in
/home/davofvpt/public_html/system/library/log.php on line 22
Warning: fclose() expects parameter 1 to be resource, boolean given in
/home/davofvpt/public_html/system/library/log.php on line 39
Warning: Cannot modify header information - headers already sent by (output
started at /home/davofvpt/public_html/system/framework.php:42) in
/home/davofvpt/public_html/catalog/controller/startup/session.php on line
25Warning: Cannot modify header information - headers already sent by
(output started at /home/davofvpt/public_html/system/framework.php:42) in
/home/davofvpt/public_html/catalog/controller/startup/startup.php on line
99Warning: Cannot modify header information - headers already sent by
(output started at /home/davofvpt/public_html/system/framework.php:42) in
/home/davofvpt/public_html/catalog/controller/startup/startup.php on line
157Warning: fopen(/home/davofvpt/public_html/storage/logs/openbay.log):
failed to open stream: No such file or directory in
/home/davofvpt/public_html/system/library/log.php on line 22
Warning: fclose() expects parameter 1 to be resource, boolean given in
/home/davofvpt/public_html/system/library/log.php on line 39
Warning: fopen(/home/davofvpt/public_html/storage/logs/error.log): failed to
open stream: No such file or directory in
/home/davofvpt/public_html/system/library/log.php on line 22
Errors in the footer:
Warning: fclose() expects parameter 1 to be resource, boolean given in
/home/davofvpt/public_html/system/library/log.php on line 39Warning:
fclose()
expects parameter 1 to be resource, boolean given in
/home/davofvpt/public_html/system/library/log.php on line 39Warning:
fclose()
expects parameter 1 to be resource, boolean given in
/home/davofvpt/public_html/system/library/log.php on line 39
Here is my config.php in the public folder
This is my config.php in the admin folder
I managed to resolve this issue by tracing the error message:
I created ($touch storage/logs/error.log) The file name is mentioned in the error message
I applied the permissions (chmod 777 storage/logs/error.log)
Did 1,2 for openbay.log
I noticed that the storage folder the owner _www which I changed to my user name (I dont think this step is required - just 1-3 should do the trick)
Note: I started with deleting the storage folder contents
You have moved your "storage" folder from the main directory (such as system/storage) to other location.
please restore folder to moved location.
or install Opencart using auto installer.
If you are not expert in Opencart, then follow these steps.
Install new opencart(your required version).
Download or copy the config file from admin folder.
Upload your modified admin and catalog folder to server (using FTP).
Re-upload the downloaded config file to admin folder.
Now it works same as on localserver

Warning: failed to open stream and cannot modify header

The site www.bethazore.com is having a couple of error messages come up when trying to login to the admin-
Warning: file_put_contents(/home/content/37/10812537/html/wp-content/themes/novelty/custom-style.css) [function.file-put-contents]: failed to open stream: Permission denied in /home/content/37/10812537/html/wp-content/themes/novelty/functions.php on line 66
Warning: Cannot modify header information - headers already sent by (output started at /home/content/37/10812537/html/wp-content/themes/novelty/functions.php:66) in /home/content/37/10812537/html/wp-includes/pluggable.php on line 875.
I got some help here. I'm not sure how to fix it, it's a bit too complicated for me here but this is what they said Warning: Cannot modify header information - headers already sent by ERROR - can anyone help?
Let's analyze this error word by word:
file_put_contents(/home/content/37/10812537/html/wp-content/themes/novelty/custom-style.css)
Right, so we're running file_put_contents, and it's accessing that file.
failed to open stream: Permission denied
But it's not allowed to do what it wants to do with that file, which is writing for that function.
in /home/content/37/10812537/html/wp-content/themes/novelty/functions.php on line 66
And that's where it was called.
So, you now know where the error was generated, what is causing it, and what it's trying to do. The problem is of course that Apache doesn't have permissions to overwrite that file.
Run the following in your console:
chmod 777 /home/content/37/10812537/html/wp-content/themes/novelty/custom-style.css
Or set it to mode 777 in your control panel, and you should be fine.

PHP from command line

I am trying to use some of the scripts on this site
http://www.tubekit.org/tools.php
As you can see under the Usage section it gives you some arguments to put into the command line
php extractYTVideoURLs.php yturls.txt mylist.txt
I have downloaded the extract php file and made the 2 text files yet I only get this answer in the command line.
c:\php>php C:/Users/extractYTVideoURLs.php yturls.txt my
list.txt
Warning: fopen(yturls.txt): failed to open stream: No such file or directory in
C:\Users\extractYTVideoURLs.php on line 21
Warning: fgets() expects parameter 1 to be resource, boolean given in C:\Users\extractYTVideoURLs.php on line 24
Warning: fclose() expects parameter 1 to be resource, boolean given in C:\Users\
extractYTVideoURLs.php on line 52
The error seems pretty clear. On line 21 of C:\Users\extractYTVideoURLs.php the code calls fopen() on a file called yturls.txt which it can't find. Where is this file? Does it exist at all?
It's generally best practice to reference a file with a fully-qualified path name. Note that you're currently in the directory c:\php so if that file isn't in the current working directory then just referencing it by name isn't going to find it. You'll need to reference the file by where it's located. Potentially something like this:
php C:/Users/extractYTVideoURLs.php C:/Path/to/yturls.txt C:/Path/to/mylist.txt

PHP Cron Problems - using plesk: dynamic library, open_basedir

I entered the following command through plesk (control panel) crontab, to run a php file once an hour:
php httpdocs/cron/script.php
And I am getting the following 2 error messages (once an hour, to my email):
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/http.so' -
/usr/lib/php/modules/http.so: cannot open shared object file: No such file or directory in
Unknown on line 0
PHP Warning: require_once(): open_basedir restriction in effect.
File(../include/functions.php) is not within the allowed path(s):
(/var/www/vhosts/basedomain.com:/tmp) in /var/www/vhosts/example.com/httpdocs/cron/script.php
on line 2
PHP Warning: require_once(../include/functions.php): failed to open stream: Operation not
permitted in /var/www/vhosts/example.com/httpdocs/cron/script.php on line 2
PHP Fatal error: require_once(): Failed opening required '../include/functions.php'
(include_path='.:') in /var/www/vhosts/example.com/httpdocs/cron/script.php on line 2
Note: Line 2 has require_once(../include/functions.php);
I realized these are 2 different issues. I tried solving each separately and they are both still with me. Any help would be appreciated. Thanks
When you run PHP like this, configuration set in Plesk-specific and Apache-specific places like vhost.conf doesn't apply.
Since your script is already inside httpdocs, why don't you just use wget/curl to invoke the script through HTTP? Something like /usr/bin/curl http://yoursite.com/cron/script.php 2>&1. Might want to consider some additional validation (IP limiting, htpasswd auth) to make sure random visitors (script kiddies) can't run it.
Please check below, maybe it will help you.
http://www.geeklog.net/forum/viewtopic.php?showtopic=28107

HTML tables to PDF in PHP - neither DOMPDF nor html2ps/pdf are working

For the longest time now I've been trying to convert HTML pages containing large tables to PHP. These are styled with CSS and can be several pages long.
I first tried DOMPDF. It works great, until a document is more than one page. None of the fixes I've found work. Either it errors out, or any element that would be even partially on the second page gets lumped over the content of page 1. I've tried both the latest release and the SVN copy I checked out today.
I also tried html2ps/pdf, and it gives me "permission denied" errors writing to the cache directory, even though the directory is fully writable. The system requirements test script passes. The server is running PHP 5 under IIS (not my choice heh).
Can either of these be convinced to work, or is there a library that can do it?
Errors from the demo/test scripts:
Warning: file_put_contents(C:\Inetpub\wwwroot\JM\pdf\html2ps\cache/7d888258e9745b3716532ea81342daaf.css.compiled) [function.file-put-contents]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\JM\pdf\html2ps\css.cache.class.php on line 33
Warning: fopen(C:\Inetpub\wwwroot\JM\pdf\html2ps\cache/unicode.lb.classes.dat) [function.fopen]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\JM\pdf\html2ps\inline.content.builder.php on line 991
Warning: flock() expects parameter 1 to be resource, boolean given in C:\Inetpub\wwwroot\JM\pdf\html2ps\inline.content.builder.php on line 992
Warning: fwrite(): supplied argument is not a valid stream resource in C:\Inetpub\wwwroot\JM\pdf\html2ps\inline.content.builder.php on line 1011 (this error repeats several thousand times)
Warning: fopen(C:\Inetpub\wwwroot\JM\pdf\html2ps\cache/times.z) [function.fopen]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\JM\pdf\html2ps\pdf.fpdf.makefont.php on line 318
Can't write to file C:\Inetpub\wwwroot\JM\pdf\html2ps\cache/times.z
A similar problem with html2pdf under IIS has been discussed here.
The solution was quite simple, yet weird. If this doesn't help you, a full error-message and / or a little bit of code would help me to help you.
I personally recommend command line applications instead of any PHP libraries.
Reasons :
PHP libraries need more time and memory (cache) for conversion process.
They need well-formatted HTML pages only, otherwise throw errors or warnings.
No support for external style sheets.
Command Line Tool:
If you run your script on a Linux server then I suggest command line tools.
Reasons :
They are extremely fast compared to PHP libraries.
Support CSS.
Accept non-well-formatted HTML.
Which command line tool to use?
wkhtmltopdf
htmltopdf
html2pdf
For more information refer to Converting HTML to PDF (not PDF to HTML) using PHP.

Categories