I've been using PDF class produced by R&OS successfully in a number of recent developments. I'd like to use it in a page that performs a database query before generating a PDF (it's basically a summary of the session, so I'm using session_id() as part of the query)
All is fine if I run this in Firefox - not fine in IE. I think the loading of session_start() is doing something with headers that's upsetting IE as it appears unable to load the page (comment off session_start and the page loads fine).
I'm getting a little concerned as, on further investigation, it appears that R&OS is not supported ... bad newbie learning experience and I really don't want to have to try adopt another class system this late in the day.
Have you any thoughts as to what I could try next?
Thankx
G
session_start() does indeed send some headers when it is used. However, you can control this particular functionality using the session_cache_limiter() function.
From browsing through the manual comments, it sounds like IE has some particular idiosyncrasies when dealing with binary content. One of the suggested solutions is to set a must-validate header before calling session_start() when you are trying to force a file download on the same page:
session_cache_limiter("must-revalidate");
session_start();
Maybe that will work for you. There are other headers that might work as well... give the comments section on that manual page a read, it looks like there's a variety of tricks you might be able to use.
Related
Im using wkhtmltopdf --header-html option, but it seems, that it really works only with html code. Is there any way I can add some PHP and force it to working somehow? I need to display Date and userĀ“s e-mail on every page... Thanks for any advice ;)
You can feed --header-html almost anything :) Try the following to see my point:
wkhtmltopdf.exe --margin-top 30mm --header-html isitchristmas.com google.fi x.pdf
So isitchristmas.com could be www.yoursite.com/magical/ponies.php
Just to add, you cant run the php files locally so you need a webserver to serve them. If you need 100% local dynamic headers you could try some fake dynamic with javascript; use --header-html myheader.html?date=12345&usermail=derp and then process the URL with javacript (I havent tried it).
To add extra query string parameters for your header/footer html you need to use the command line switch 'replace'.
The wording of the help/manual is a little misleading (i.e. better wording would have cleared up the issue), as it lead me on the wrong path (tried using the 'post' switch). I found the solution after digging through the code on github.
I am pretty new to php so bear with me :)
I am trying to create a web page that can use the get_user_browser function in php to then direct the user to a separate HTML page.
My website is http://www.danabohne.com and I just realized it is barely visible in IE. Unless there's a different way to go around this I want to make a separate static HTML site that can be seen by IE users.
Any feedback would be extremely helpful!
<?php
$useragent = $_SERVER['HTTP_USER_AGENT'];
if( strpos($useragent,"MSIE 6.0") ) {
header("Location: http://google.com");
}
?>
You can add more if conditions as needed.
However , Like John mentioned in the comments. I would advise you to create a separate stylesheet and create a fallback design rather than redirecting to another page.
Firstly, it's important to note that browser detection on the server is not recommended, because it is possible for browsers to provide false user agent details, or none at all. (I know of some firewall products that routinely strip out this kind of data from the http headers).
Secondly, the get_user_browser function only works if you have a valid browsecap.ini file. If you're having trouble getting the function to work, check that you have this ini file and that it is up-to-date. (also note that you will need to keep it updated whenever new browsers or browser versions are released).
Finally, most (virtually all) IE-specific display issues can be resolved without having to create a separate page for IE.
Specifically in your case, I can see what the problem is straight away when looking at the HTML source code for your page:
The problem is the <pre></pre> that is in the first line of your code immediately before the <!DOCTYPE>. I assume this is the left-overs from some debugging code that hasn't been removed properly.
This <pre></pre> is going to cause IE to fall into "quirks mode", because IE sees the <pre> and assumes it doesn't have a doctype. Without a doctype, IE assumes the page should be in quirks mode.
Quirks mode makes IE's rendering engine display the page completely differently (it's basically an IE5-backward-compatibility mode), so it's no wonder your page looks rubbish in IE.
This behaviour is the same in all versions of IE.
If you have other IE-specific problems, it would be better to try to fix them on the page, as there are a lot of tools and hacks available to make IE work better.
Hope that helps.
I have a very strange problem and i don't know what to do about it. My site seems to work just fine all browsers other than internet explorer, so i've been trying to figure out why.
I've narrowed it down to the a file that I'm including in my site, this file is a php class that has a number of different functions like login getters and setters and so on.
I took all the php code out of my pages and it renders fine, so i added the php back in line by line and released that it stopped working when i used this:
require_once 'classes/Membership2.php';
Does anyone know why some php code will be messing with the style of my website.
For more detail on the matter, i have a number of divs that are centered, they all have curved edges as well as shadows. So by taking away the php i can see that IE is loading the page properly, no incompatibilities or anything like that.
Has anyone had a problem like this before? While i'm waiting for an aswesome or two i'll be removing functions and part of the code till i can narrow it down. (I would give code, but the file has a lot of lines of code.)
Thanks for the help.
Oh yeah and I'm testing on Internet Explorer 9 and every other browser is the latest version or close enough.
Okay so i've done some more digging into this, i've found that if i delete all the code in the class (All the functions) and leave just and empty class in the include file it still doesn't work. Okay, so in my view that means the functions aren't whats making this problem. So i deleted EVERYTHING, so now the include points to a blank php file. This worked and the page rendered as it should but obviously there is no functionality, i can't login or anything like that. I decided to add a constructor instead of leaving it as default, this function does nothing but return true; and it made the site mess up again.
Does this info change anything? Also i'm reiterating the fact that i do not get this error or any other browser but Internet Explorer 9 (Haven't tried any other IE version).
Thanks again for the help.
Okay, so i've solved the problem. At the start of my PHP class i have used
<!-- blah blah blah -->
forgetting that there is only PHP in this document and no HTML. So when i include the file it just outputs that into my source code and and messes things up, should have used the PHP commenting style.
Still strange that EVERY browser other than IE just ignores this and goes about its business, even the site that #blankabout suggested didn't give me any error (Although i assure thats because its part of the included PHP file and not the HTML itself).
as #fajran says to you, save both outputs with "view source code" on the browser and compare them to find the diference. To compare outputs use winmerge or similar tool. Once you now which text it generating the trouble, modify it inside the include file.
Given that your php, because it runs on the server, should never actually reach the browser, it may very well be some unterminated HTML or similar that is causing the problem. Perhaps the PHP is causing a break in the HTML that is unexpected.
Is there a way to redirect using PHP without using header("Location: http://www.google.com")? I put that at the top, right after a PHP script (which has no output), but it doesn't work. I use the PHP to check something in the database, and it will redirect depending on the contents.
"Right after a PHP script"? Well, it's going to have to be in a PHP script to work.
If that's not it, please consider showing your previous code. Remember, don't post a question asking how to implement your solution, but rather the question itself...
Your code should always work as long as the header is called before any echo or print statements that send output to the browser. Another possibility is your webserver sending out additional output or headers that are causing the redirect to not work.
One way to test would be to telnet to your webserver and send GET /myscript.php. Then view the result and see if it is what you expect.
Per the PHP documentation:
Remember that header() must be called before any actual output is
sent, either by normal HTML tags, blank lines in a file, or from PHP.
It is a very common error to read code with include(), or require(),
functions, or another file access function, and have spaces or empty
lines that are output before header() is called. The same problem
exists when using a single PHP/HTML file.
Without seeing the actual code that the redirect resides in it will be difficult to assist. Perhaps if you could provide more details then someone may be able to suggest another technology to help but the header method is the only one that I've came across.
I need to have the output of a PHP snippet in a Plone site. It was delivered to be a small library that has a display() function, in PHP, that outputs a line of text. But I need to put it in a Plone site. Do you have any recommendations?
I was thinking a long the lines of having a display.php that just runs display() and from the Plone template to download that URL and output the content. Do you think it might work? What methods of hitting a URL, retrieve the content and outputting can I use from inside a Plone template?
One important and critical constraint is that the output should be directly on the HTML and not an an iframe. This is a constraint coming from the outside, nothing technical.
Another option is to run the PHP script on the server using os.popen, then just printing the output. Quick and dirty example:
import os
print os.popen('php YourScript.php').read()
Well, use AJAX to call the PHP script (yes, you will need apache) and display the output. Adding a custom JS to plone is trivial and this abstract the technology issue.
Just be sure this is not a critical feature. Some users still deactivate JS and the web page should therefor degrade itself nicely.
Probably the easiest way: install windowz inside your site. That way you get a page with an iframe in your plone layout. Make sure the php script outputs a regular html page and configure your windowz page with that url. Done.
Works great for existing in-company phonebook applications and so.