Closed Caberhagen closed 7 years ago
Hello,
perhaps are you using Chrome as browser? I noticed the same signs some times ago while using that browser. I think it could be something related the page of compression (all the output is sent compressed). It's strange that signs are not displayed with other browsers.
Hi i see it on opera and android smartphone. New edge browser don't show it.
i search around, i hope i find some hints on the web.
Hello,
I've tested the game with the following browsers and the strange chars doesn't come up: Mac OS X Yosemite 10.10.4
Nexus 5 (Android 5.1.1)
Windows 7 Ultimate
I'm downloading Chrome and Firefox on Windows to test also that browsers.
Hi
that is verry ugly. I have opera 31 on windows 10 pro and see the signs. Windows 10 edge browser is ok.
so it looks as the same opera on different win shows not the same.
hmmm...
Hi,
this is really, really strange. I've just tested the game with Opera 31 on Windows 10 Pro (x64) and the signs are not displayed (it's a VM but I don't think it could matter).
Hi @kirirur are you testing it on stfc.it? Or in a private server? I can help you to troubleshoot this issue :)
Hi @Dax89 I'm testing it on stfc.it and AI don't see any trouble. How's the mystery solved? :)
Mmmmh It can be an encoding issue or the browser's cache needs to be deleted.
If the issue is present in Opera only, it can be the page compression feature that leaves some junk at the bottom of the page.
Hi it's not the browser cache. truncatet them and no change. hmm
Here there's the code in file UI/game/index.php for output compression. It's seems fine to me:
// #############################################################################
// Output compression
$gzip_contents = ob_get_contents();
ob_end_clean();
if( (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) && (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ) {
$start_gtime = (microtime() + time());
$compression=1;
if ($game->player['user_id']<12 && isset($_GET['compression']))
$compression=$_GET['compression'];
$gzip_size = strlen($gzip_contents);
$gzip_crc = crc32($gzip_contents);
$gzip_contents = gzcompress($gzip_contents, $compression);
$gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4);
$total_gtime = (time() + microtime()) - $start_gtime;
header('Content-Encoding: gzip');
echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
echo $gzip_contents;
echo pack('V', $gzip_crc);
echo pack('V', $gzip_size);
if ($game->player['user_id']<12)
{
// Calculate size of the file before / after the compression:
$gzip_result=floor($gzip_size/1024).'kb / '.floor(strlen($gzip_contents)/1024).'kb<br>'.($total_gtime*1000).' msecs';
$gzip_size = strlen($gzip_result);
$gzip_crc = crc32($gzip_result);
$gzip_result = gzcompress($gzip_result, $compression);
$gzip_result = substr($gzip_result, 0, strlen($gzip_result) - 4);
header('Content-Encoding: gzip');
echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
echo $gzip_result;
echo pack('V', $gzip_crc);
echo pack('V', $gzip_size);
}
}
else {
echo $gzip_contents;
}
@kirirur That's tricky, it seems that, for some reason @Caberhagen receives a different header (or longer than expected), you can make this addition to the code, if possible.
Add a console.log() that prints compressed and uncompressed data's length, so it is possible to check if he receives a different length OR (I don't know if this is useful), you can specify Content-Length in the header, as specified in RFC, maybe some browser take care of it:
The Content-Length entity-header field indicates the size
of the entity-body, in decimal number of OCTETs, sent to the recipient or,
in the case of the HEAD method, the size of the entity-body that would have
been sent had the request been a GET.
Content-Length = "Content-Length" ":" 1*DIGIT
An example is
Content-Length: 3495
Edit: RFC Link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13
at witch poin i have to add the content-length? so i can make a test...
I think you need to add it after the first header() call. Something like:
header('Content-Encoding: gzip');
header('Content-length: '.$content_length);
I think.
tried now. seem nothing change. with header('Content-length: .$content_lengt'); the building times have long to loand and display. with header('Content-length: 3495'); just the bakground from page is showing.
Hi,
the variable $content_length does not exists. It was only an example. I think you need to use one of $gzip_size or something used in this line:
$gzip_result = substr($gzip_result, 0, strlen($gzip_result) - 4);
I don't know if could be
$gzip_contents = gzcompress($gzip_contents, $compression);
$content_length = strlen($gzip_result);
You need to make some tests, I'm sorry I cannot help more you. :(
@Caberhagen:
Yes, Content-Length specifies the amount of data that you are sending to the browser, in this case, the compressed data.
If this doesn't work, try to print the value of $content_length variable (the initialization is explained by @kirirur in the previous post!):
In PHP...
echo $content_length;
...and it is displayed in the webpage, somewhere.
tried like this:
// Output compression $gzip_contents = ob_get_contents(); ob_end_clean();
if( (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) && (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ) { $start_gtime = (microtime() + time());
$compression=1;
if ($game->player['user_id']<12 && isset($_GET['compression']))
$compression=$_GET['compression'];
$gzip_size = strlen($gzip_contents);
$gzip_crc = crc32($gzip_contents);
$gzip_contents = gzcompress($gzip_contents, $compression);
$gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4);
$total_gtime = (time() + microtime()) - $start_gtime;
header('Content-Encoding: gzip');
header('Content-length: '.$content_length);
echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
echo $gzip_contents;
echo pack('V', $gzip_crc);
echo pack('V', $gzip_size);
if ($game->player['user_id']<12)
{
// Calculate size of the file before / after the compression:
$gzip_result=floor($gzip_size/1024).'kb / '.floor(strlen($gzip_contents)/1024).'kb<br>'.($total_gtime*1000).' msecs';
$gzip_size = strlen($gzip_result);
$gzip_crc = crc32($gzip_result);
$gzip_result = gzcompress($gzip_result, $compression);
$gzip_result = substr($gzip_result, 0, strlen($gzip_result) - 4);
$content_length = strlen($gzip_result);
header('Content-Encoding: gzip');
echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
echo $gzip_result;
echo pack('V', $gzip_crc);
echo pack('V', $gzip_size);
}
}
only cange is the building times have long to show. browser chache truncated. singes still there.
Hello,
if you used that code, I don't see variable $content_length initialization.
I think you need to modify it something like this:
$gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4);
$content_length = strlen($gzip_contents);
$total_gtime = (time() + microtime()) - $start_gtime;
header('Content-Encoding: gzip');
header('Content-length: '.$content_length);
echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
echo $gzip_contents;
echo pack('V', $gzip_crc);
echo pack('V', $gzip_size);
if ($game->player['user_id']<12)
{
// Calculate size of the file before / after the compression:
$gzip_result=floor($gzip_size/1024).'kb / '.floor(strlen($gzip_contents)/1024).'kb<br>'.($total_gtime*1000).' msecs';
$gzip_size = strlen($gzip_result);
$gzip_crc = crc32($gzip_result);
$gzip_result = gzcompress($gzip_result, $compression);
$gzip_result = substr($gzip_result, 0, strlen($gzip_result) - 4);
$content_length = strlen($gzip_result);
header('Content-Encoding: gzip');
header('Content-length: '.$content_length);
echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
echo $gzip_result;
echo pack('V', $gzip_crc);
echo pack('V', $gzip_size);
}
Please also read the documentation of involved functions, I don't know them and I don't know if there's something more fitting to obtain the length of compressed data.
Yeah, on the most pages the sings are away. Only on some pages a rest of the sings like this: </ And the rest is fast like ever.
Good do know!
On which pages are you seeing the signs?
Hmm that sign </ seems a truncated HTML tag...
Update: surfing the web I've found this function:
header('Content-Length: '.ob_get_length());
Could you test it and see if it works?
portal spacedock ship-templates and more.
but i see now at searching the pages. It's not showing an any page open. klick more times the same page, and the sings are most there but not on all klicks. some times no sings on the same page...
wired...
I've found an interesting thread here:
http://stackoverflow.com/questions/3202218/how-does-gzcompress-work
Try to modify:
$content_length = strlen($gzip_result);
into:
$content_length = strlen($gzip_result - 4);
Oh, and please, check if using ob_get_length works better.
Update: found this code example:
<?php
function print_gzipped_output()
{
$HTTP_ACCEPT_ENCODING = $_SERVER["HTTP_ACCEPT_ENCODING"];
if( headers_sent() )
$encoding = false;
else if( strpos($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false )
$encoding = 'x-gzip';
else if( strpos($HTTP_ACCEPT_ENCODING,'gzip') !== false )
$encoding = 'gzip';
else
$encoding = false;
if( $encoding )
{
$contents = ob_get_clean();
$_temp1 = strlen($contents);
if ($_temp1 < 2048) // no need to waste resources in compressing very little data
print($contents);
else
{
header('Content-Encoding: '.$encoding);
print("\x1f\x8b\x08\x00\x00\x00\x00\x00");
$contents = gzcompress($contents, 9);
$contents = substr($contents, 0, $_temp1);
print($contents);
}
}
else
ob_end_flush();
}
?>
hi i think we can cloes this. because i dont find the solution for the last two signs. but its not realy needet. on most systems the signs are not to see.
Hi @ all
i the new install from master branch, i found some special signs at bottom of some pages. not on all!
Anyone knows from where it comes?
CU