Location: PHPKode > projects > phpSyncML > phpsyncml/index2.php
<?
// Let's parse the config file and get our settings
$config = simplexml_load_file('config/config.xml');
$compression =$config->config->compression;
$base_dir = $config->config->base_dir;
$dbuser = $config->config->database->dbuser;
$dbpass = $config->config->database->dbpass;
$dbtype = $config->config->database->dbtype;

// Import our external resources
include("get_response.php");
require($base_dir.'/wbxml/WBXML/Encoder.php');
require($base_dir.'/wbxml/WBXML/Decoder.php');

// Make sure its a syncml request (comment for testing)
//if (@@$_SERVER["CONTENT_TYPE"] != "application/vnd.syncml+wbxml") { 
//	echo "<html>I only speak SyncML.</html>";
//	exit();
//}

function MBUInt32ToInt($in, &$pos)
    {
        $val = 0;

        do {
            $b = ord($in[$pos++]);
            echo $b;
            $val <<= 7; // Bitshift left 7 bits.
            $val += ($b & 127);
        } while (($b & 128) != 0);

        return $val;
    }


//Lets open our log file for debugging purposes
$handler = fopen("progress.xml", "a+");

// assign POST data to variable
//$post_data = $HTTP_RAW_POST_DATA;

// For debugging purposes use predefined wbxml file
if ($hand = fopen($base_dir.'/wbxml/docs/examples/syncml_client_packet_3.wbxml', 'a+')) {
	echo "opened\n";
} else {
	echo "error";
}
$post_data = fread($hand,filesize($base_dir.'/wbxml/docs/examples/syncml_client_packet_3.wbxml'));
$post_data = MBUInt32ToInt($post_data, $post_data->_strpos);


echo $post_data."\n";

// Extract data
if ($compression == 'xml') {
	$xmlsh = $post_data;
	fwrite($handler,$post_data);
} else {
	//$decoder = &new XML_WBXML_Decoder();
	//$xmlsh = $decoder->decode($post_data);
	print_r($xmlsh);
	fwrite($handler, $xmlsh);
}

// Load our response into a simplexml object
$xmls = simplexml_load_string($xmlsh);

?>
Return current item: phpSyncML