ajax.php 1.35 KB
<?php

require_once dirname(__FILE__) . '/../config.php';
require_once LIBDIR . 'c_personAdmin.php';
require_once LIBDIR . 'c_xmlify.php';

/*$personAdmin = new c_personAdmin ();
$persons = xmlify ($personAdmin->getPersons ());
$p = deXmlify ($persons);
*/

class dummy extends c_xmlify
{
	protected $var1;
	protected $var2;
	protected $var3;
	protected $var4;

	function __construct ($xr = NULL, $v1, $v2, $v3, $v4)
	{
		if ($xr !== NULL)
			parent::__construct ($xr);

		$this->var1 = $v1;
		$this->var2 = $v2;
		$this->var3 = $v3;
		$this->var4 = $v4;
	}
};

$_data = new dummy (
		NULL, array ('var1'=>0.53, 'var2'=>1.1), array (12, 13), "Hallo",
		new dummy (NULL, "Das", "ist", "ein", "test"));

//$_data = array (array ('var1'=>0.53, 'var2'=>1.1), array (12, 13), "Hallo");

$data = xmlify ($_data);
unset ($_data);

$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/xml');

$result = FALSE;
if ($encoding !== FALSE)
	$result = gzcompress ($data);

if ($result !== FALSE)
{
	header ('Content-Encoding: ' . $encoding);

	print ("\x1f\x8b\x08\x00\x00\x00\x00\x00");
	print ($result);
}
else
	print ($data);

?>