public function testBase64Uri() { /* Provision Request for version 12.1 */ $url = 'eRQJBBCuTs0Z9ZK6Vldwb/dM8JusBHx8TOgDUFBD'; $results = Horde_ActiveSync_Utils::decodeBase64($url); $fixture = array('ProtVer' => '12.1', 'Cmd' => 'Provision', 'Locale' => 1033, 'DeviceId' => 'ae4ecd19f592ba5657706ff74cf09bac', 'PolicyKey' => 3897326716.0, 'DeviceType' => 'PPC'); $this->assertEquals($fixture, $results); /* Smart Forward */ $url = 'eQIJBBCuTs0Z9ZK6Vldwb/dM8JusBHVeHIQDUFBDBwEBAwYxMTkyODEBBUlOQk9Y'; $results = Horde_ActiveSync_Utils::decodeBase64($url); // This is binary data, test it separately. $fixture = array('ProtVer' => '12.1', 'Cmd' => 'SmartForward', 'Locale' => 1033, 'DeviceId' => 'ae4ecd19f592ba5657706ff74cf09bac', 'PolicyKey' => 2216451701.0, 'DeviceType' => 'PPC', 'ItemId' => '119281', 'CollectionId' => 'INBOX', 'AcceptMultiPart' => false, 'SaveInSent' => true); $this->assertEquals($fixture, $results); }
public function testBase64Uri() { /* Settings Request for versions >= 12.1 */ $url = 'oBEJBBBOaW5lMkVDN0VDMEJCNTREBAGJpmIHQW5kcm9pZAcBAA=='; $results = Horde_ActiveSync_Utils::decodeBase64($url); $fixture = array('ProtVer' => '16.0', 'Cmd' => 'Settings', 'Locale' => 1033, 'DeviceId' => '4e696e65324543374543304242353444', 'PolicyKey' => 1655081217, 'DeviceType' => 'Android', 'SaveInSent' => false, 'AcceptMultiPart' => false); $this->assertEquals($fixture, $results); /* Smart Forward */ $url = 'eQIJBBCuTs0Z9ZK6Vldwb/dM8JusBHVeHIQDUFBDBwEBAwYxMTkyODEBBUlOQk9Y'; $results = Horde_ActiveSync_Utils::decodeBase64($url); $results['PolicyKey'] = sprintf('%u', $results['PolicyKey']); // This is binary data, test it separately. $fixture = array('ProtVer' => '12.1', 'Cmd' => 'SmartForward', 'Locale' => 1033, 'DeviceId' => 'ae4ecd19f592ba5657706ff74cf09bac', 'PolicyKey' => '2216451701', 'DeviceType' => 'PPC', 'ItemId' => '119281', 'CollectionId' => 'INBOX', 'AcceptMultiPart' => false, 'SaveInSent' => true); $this->assertEquals($fixture, $results); }
/** * Return the GET variables passed from the device, decoding from * base64 if needed. * * @return array A hash of get variables => values. */ public function getGetVars() { if (!empty($this->_get)) { return $this->_get; } $results = array(); $get = $this->_request->getGetVars(); // Do we need to decode the request parameters? if (!isset($get['Cmd']) && !isset($get['DeviceId']) && !isset($get['DeviceType'])) { $serverVars = $this->_request->getServerVars(); if (isset($serverVars['QUERY_STRING']) && strlen($serverVars['QUERY_STRING']) >= 10) { $results = Horde_ActiveSync_Utils::decodeBase64($serverVars['QUERY_STRING']); // Normalize values. switch ($results['DeviceType']) { case 'PPC': $results['DeviceType'] = 'PocketPC'; break; case 'SP': $results['DeviceType'] = 'SmartPhone'; break; case 'WP': case 'WP8': $results['DeviceType'] = 'WindowsPhone'; break; case 'android': case 'android40': $results['DeviceType'] = 'android'; } $this->_get = $results; } } else { $this->_get = $get; } return $this->_get; }