public function __construct($output, $multipart = false) { $this->log = ZLog::WbxmlDebug(); $this->_out = $output; // reverse-map the DTD foreach ($this->dtd["namespaces"] as $nsid => $nsname) { $this->_dtd["namespaces"][$nsname] = $nsid; } foreach ($this->dtd["codes"] as $cp => $value) { $this->_dtd["codes"][$cp] = array(); foreach ($this->dtd["codes"][$cp] as $tagid => $tagname) { $this->_dtd["codes"][$cp][$tagname] = $tagid; } } $this->_stack = array(); $this->multipart = $multipart; $this->bodyparts = array(); }
/** * Loads the command handler and processes a command sent from the mobile * * @access public * @return boolean */ public static function HandleRequest() { $handler = ZPush::GetRequestHandlerForCommand(Request::GetCommandCode()); // if there is an error decoding wbxml, consume remaining data and include it in the WBXMLException try { if (!$handler->Handle(Request::GetCommandCode())) { throw new WBXMLException(sprintf("Unknown error in %s->Handle()", get_class($handler))); } } catch (Exception $ex) { ZLog::Write(LOGLEVEL_FATAL, "WBXML debug data: " . Request::GetInputAsBase64(), false); throw $ex; } // also log WBXML in happy case if (ZLog::WbxmlDebug()) { ZLog::Write(LOGLEVEL_WBXML, "WBXML-IN : " . Request::GetInputAsBase64(), false); } }
/** * WBXML Decode Constructor * We only handle ActiveSync WBXML, which is a subset of WBXML * * @param stream $input the incoming data stream * * @access public */ public function __construct($input) { $this->log = ZLog::WbxmlDebug(); $this->in = $input; $version = $this->getByte(); if ($version != self::VERSION) { $this->inputBuffer .= chr($version); $this->isWBXML = false; return; } $publicid = $this->getMBUInt(); if ($publicid !== 1) { throw new WBXMLException("Wrong publicid : " . $publicid); } $charsetid = $this->getMBUInt(); if ($charsetid !== 106) { throw new WBXMLException("Wrong charset : " . $charsetid); } $stringtablesize = $this->getMBUInt(); if ($stringtablesize !== 0) { throw new WBXMLException("Wrong string table size : " . $stringtablesize); } }