<?php 
	require_once("../../base/php/startSession.php");
	require_once("../../base/php//classDatabase.php");
	require_once("../../base/php/Functions.php");
	require_once("../../base/php/WebAppLog.php");

	$query = @$_POST["query"];
	if ($query == "") {
		$query = @$_GET["query"];
	}
	
	$httpString = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
	$httpString .= "\n<HTTP_SERVICE>";

	$database = new Database("iCTI");
	$result = $database->exec($query);
	
	if ($result != false) {
		
		$ok = true;
		
		while ($ok == true) {
		
			$ok = false;
			$record = $database->nextRecordInto();
			
			if ($record != false) {
			
				$ok = true;
				$oid = $record[0];
				$code = toHTML(trim($record[1]));
				$texte = toHTML(trim($record[2]));
				
				$httpString .= "\r\n<RECORD ";
				$httpString .= "oid=\"$oid\" ";
				$httpString .= "code=\"$code\" ";
				$httpString .= "texte=\"$texte\" ";
				$httpString .= " />";
			}
		}
	}
	
	@pg_close($iCTI_connexion);
	
	$httpString .= "\n</HTTP_SERVICE>";
	$httpString = compress64($httpString);

	echo "<CTICONTENT>$httpString</CTICONTENT>";

?> 