<?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");

global $database;
global $oids;
global $REFSETTINGS_URL;
global $REFSETTINGS_PREFIX;

$oids = getPOST("oids");
$tableName = getPOST("tableName");

$httpString = "";
$httpString = $httpString . "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
$httpString = $httpString . "\n<HTTP_SERVICE>";

$database = new Database("iCTI");

$SETTINGS_file = rootDir() . "settings/settings.XML";
$SETTINGS_xml = simplexml_load_file($SETTINGS_file);
$REFSETTINGS_URL = getProperty($SETTINGS_xml, "REFSETTINGS", 'URL');
$REFSETTINGS_PREFIX = getProperty($SETTINGS_xml, "REFSETTINGS", 'PREFIX');

if ($REFSETTINGS_URL != "" && extension_loaded('curl')) {

		// Recherche script SQL depuis environnement de référence
		$REFSETTINGS_table_url = "$REFSETTINGS_URL/modules/activite/php/httpService_ACTI_tableManager_getSqlScript.php";
		WebAppLog("","DEBUG",$REFSETTINGS_table_url);
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $REFSETTINGS_table_url);
		curl_setopt($ch, CURLOPT_POST, 2);
		curl_setopt($ch, CURLOPT_POSTFIELDS, "tableName=$tableName&oids=$oids");
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
		$REFSETTINGS_script = @curl_exec($ch);
		curl_close($ch);

		if ($REFSETTINGS_script) {
			$sqlcmd = $REFSETTINGS_script;
			$result  =  $database->exec($sqlcmd);
		}
	
}

$httpString = $httpString . "\n</HTTP_SERVICE>";
 

$httpString = gzcompress($httpString,9);
$httpString = "_c_" . base64_encode($httpString); 

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


    
?>