I recently upgraded one of my servers, and since then I have had a problem with some specific PHP commands (see below). I believe this is a configuration problem, but I have already covered a few things and donโt know anymore. So maybe you have a good idea:
I use the following code to display a standard logo on an intranet site or a user-defined logo:
if(L_HEADER) { $logo = L_HEADER; } else { $logo = 'logo.png'; } $properties = getimagesize(CONFIG_URL . 'images/' . $logo)
L_HEADER and CONFIG_URL are constants with predefined values โโ(another file):
Concatenation works correctly, which is also confirmed by the Apache log file error message:
PHP Warning: getimagesize ( http: //billing.intranet.opb/images/opb_beta.png ) : Could not open stream: HTTP request failed! HTTP / 1.1 404 NOT FOUND in /var/www/billing/templates/header.inc.php on line 42
So, the first obvious conclusion: the path is wrong. But this is not so, believe me. I tested it as 1,000 times. In fact, the first curiosity is that the image is displayed and correctly refers to a couple of lines further in the code of the same file:
echo '<img src="' . CONFIG_URL . 'images/' . $logo . '" width="' . $properties[0] . '" height = "' . $properties[1] . '" />";
As I get the error mentioned above, the height and width are โ0โ, but looking at the source code, the URL is fine, accessing it manually opens the image, and when replacing the width and height with manual values, the image is simply displayed excellent.
More curious though (and also my current finx), when changing getimagesize to the next, it works just fine:
$properties = getimagesize($_SERVER['DOCUMENT_ROOT'] . /public_html/images/' . $logo);
I mentioned that I am using Apache redirection; therefore, in the URL you do not see "public_html", but in the absolute path of the second example you see it.
The same thing happens with "file_exists". URL does not work, absolute local path for the same file.
Another curiosity: in another piece of code, I check online for updates. There I use a "real", public URL with file files and fopen. I look and it works great:
if(file_exists('http://desk.co.cr/df_stable.txt') { if(($handle = fopen('http://desk.co.cr/df_stable.txt', 'r')) !== FALSE) {
Now those things that I already checked:
- File permissions are set correctly for the entire path, with www data being the group and owner of all files, and read and write access for the image file
- allow_url_fopen in the "On" settings.
- open_basedir is set to "no value" and there is no override in the definitions of Apache virtual hosts.
- the file finally exists, and the syntax + path is correct.
Some background information:
- Server runs on Ubuntu 14.04 LTS
- Apache 2.4.7
- PHP 5.5.9
I currently have no ideas.