ajax.php
1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
class dummy
{
// nur public member werden via json verschickt.
public $german;
public $english;
public $french;
function __construct ($english, $german, $french)
{
$this->german = $german;
$this->english = $english;
$this->french["val1"] = $french;
$this->french["val2"] = "jokus";
}
}
$encoding = FALSE;
if (isset ($_SERVER['HTTP_ACCEPT_ENCODING']) &&
strpos ($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip') !== FALSE)
$encoding = "x-gzip";
if (isset ($_SERVER['HTTP_ACCEPT_ENCODING']) &&
strpos ($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE)
$encoding = "gzip";
header ('Content-type: text/plain');
$result = FALSE;
if ($encoding !== FALSE)
$result = gzcompress (json_encode (new dummy (
'doing gzip', 'gezipedte Daten', 'la zippo')));
if ($result !== FALSE)
{
header ('Content-Encoding: ' . $encoding);
print ("\x1f\x8b\x08\x00\x00\x00\x00\x00");
print ($result);
}
else
{
$result = json_encode (new dummy (
'doing no gzip', 'nicht gezipedte Daten', 'no la zippo'));
print ($result);
}
?>