Post your guild_image.php here.
<?php
if(!defined('INITIALIZED'))
exit;
$guild_id = (int) $_REQUEST['id'];
$guild = new Guild($guild_id);
$guildLogo = $guild->getGuildLogo();
$guildLogoInfo = explode(';', $guildLogo, 3);
$image = array();
$image['content_mtime'] = $guildLogoInfo[0];
if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime(preg_replace('/;.*$/','',$_SERVER["HTTP_IF_MODIFIED_SINCE"])) == $image['content_mtime'])
{
header('HTTP/1.0 304 Not Modified');
/* PHP/webserver by default can return 'no-cache', so we must modify it */
header('Cache-Control: public');
header('Pragma: cache');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $image['content_mtime']) . ' GMT');
}
else
{
$image['content_type'] = substr($guildLogoInfo[1], 5);
$image['content'] = base64_decode(substr($guildLogoInfo[2], 7));
header('Content-Type: ' . $image['content_type']);
header('Cache-Control: public');
header('Pragma: cache');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $image['content_mtime']) . ' GMT');
echo $image['content'];
}
there are rights there and image file is in http://albaniaot.com/images/default_guild_logo.gif in new gesior images are stored in database tho.Either set rights to www/images folder or make sure you have the default_guild.jpg or smth image file.
Also check if you have any queries of that image in your database.
there are rights there and image file is in http://albaniaot.com/images/default_guild_logo.gif in new gesior images are stored in database tho.
seems like nginx issue maybe it's because im using latest stable version and it has a bug like that?I spent 10 minutes with Wireshark to find it, because I don't like bugs in version 2012!
Somehow your server adds 'new line' character before image code. It sends image 'bytes' and 'new line' before them. When I removed 'new line' I could open it on windows image explorer.
You server answer:
HTTP/1.1 200 OK
Server: nginx/1.6.1
Date: Wed, 27 Aug 2014 14:14:22 GMT
Content-Type: image/gif
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/5.5.16-1~dotdeb.1
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: public
Pragma: cache
Last-Modified: Wed, 27 Aug 2014 03:35:38 GMT
<one new line, it's HTTP protocol, good>
b27 <what the hell is that 'b27 and new line'? >
<what? another new line?>
GIF89a@...<rest of image>
If you click 'view source' on any page in 'Chrome' you will see that server adds 'new line' at start of every answer. For HTML it's fine (just skip it), but for binary transfer like image it's big problem.
(about HTTP protocol.. it should be: HTTP HEADERS , ONE EMPTY LINE , CONTENT OF FILE/SITE)
I got no idea what is wrong in nginx/php and how to fix it. I just found out what is wrong.
// I think that change to old images system won't help, as old images were also served by PHP script. Old system -> get images from files, new system -> get images from database, rest of it is almost the same.
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
server {
root /var/www;
listen 80;
server_name albaniaot.com www.albaniaot.com;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
index index.html index.php;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 1y;
log_not_found off;
}
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
<?php
// if we set ONLY_PAGE, then it will not login / connect to MySQL until we use SQL query in our script
define('ONLY_PAGE', true);
$_GET['subtopic'] = 'guild_image';
$_REQUEST['subtopic'] = 'guild_image';
include('index.php');
<?php
// TRICK: start buffering
ob_start();
// if we set ONLY_PAGE, then it will not login / connect to MySQL until we use SQL query in our script
define('ONLY_PAGE', true);
$_GET['subtopic'] = 'guild_image';
$_REQUEST['subtopic'] = 'guild_image';
include('index.php');
// TRICK: output buffer without first character, substring from character nr '1' to end (first character is nr 0)
echo substr(ob_get_clean(), 1);