public function testWriteFile() { $expected = '<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"><dict><key>string</key><string/><key>number</key><integer>0</integer><key>double</key><real>0</real></dict></plist> '; $plist = new CFPropertyList(); $dict = new CFDictionary(); $dict->add('string', new CFString('')); $dict->add('number', new CFNumber(0)); $dict->add('double', new CFNumber(0.0)); $plist->add($dict); $this->assertEquals($expected, $plist->toXML()); }
public function encode($data, $human_readable = false) { require_once 'CFPropertyList.php'; if (!PlistFormat::$binary_mode) { PlistFormat::$binary_mode = !$human_readable; } else { $human_readable = false; } $plist = new CFPropertyList(); $td = new CFTypeDetector(); $guessedStructure = $td->toCFType(object_to_array($data)); $plist->add($guessedStructure); return $human_readable ? $plist->toXML(true) : $plist->toBinary(); }
public function testWriteString() { $plist = new CFPropertyList(); $dict = new CFDictionary(); $names = new CFDictionary(); $names->add('given-name', new CFString('John')); $names->add('surname', new CFString('Dow')); $dict->add('names', $names); $pets = new CFArray(); $pets->add(new CFString('Jonny')); $pets->add(new CFString('Bello')); $dict->add('pets', $pets); $dict->add('age', new CFNumber(28)); $dict->add('birth-date', new CFDate(412035803)); $plist->add($dict); $content = $plist->toXML(); $plist->parse($content); }
public function frontendOutputPostGenerate($context) { if (!array_key_exists('plist', $_GET)) { return; } require_once "lib/CFPropertyList/CFPropertyList.php"; $xmlIterator = new SimpleXMLIterator($context['output']); $xmlArray = $this->sxiToArray($xmlIterator); $plist = new CFPropertyList(); $td = new CFTypeDetector(); $guessedStructure = $td->toCFType($xmlArray); $plist->add($guessedStructure); if ($_GET['plist'] == "binary") { echo $plist->toBinary(); } else { echo $plist->toXML(); } die; }
function profile_service_payload($challenge) { $payload = general_payload(); $payload['PayloadType'] = "Profile Service"; // do not modify $payload['PayloadIdentifier'] = "com.runthisapp.mobileconfig.profile-service"; // strings that show up in UI, customisable $payload['PayloadDisplayName'] = "RunThisApp Profile Service"; $payload['PayloadDescription'] = "Install this profile to allow applications deployement from RunThisApp"; $payload_content = array(); $payload_content['URL'] = Tools::rel2abs('/profile.php?key=' . $_GET['key'], Tools::current_url()); $payload_content['DeviceAttributes'] = array('UDID', 'VERSION', 'PRODUCT', 'MAC_ADDRESS_EN0', 'DEVICE_NAME', 'IMEI', 'ICCID'); if (!empty($challenge)) { $payload_content['Challenge'] = $challenge; } $payload['PayloadContent'] = $payload_content; $plist = new CFPropertyList(); $td = new CFTypeDetector(); $cfPayload = $td->toCFType($payload); $plist->add($cfPayload); return $plist->toXML(true); }
/** * Download distribution certificate * * if $result['resultCode'] equal 0 have your result * else you can print the error $result['resultString'] * * @param string $team_id * @return array $result */ public static function downloadDistributionCert($team_id) { // Create Web Service URL $url = self::$base_url_services . 'downloadDistributionCert.action?clientId=' . self::$client_id; // Generating content $payload = array(); $payload['clientId'] = self::$client_id; $payload['protocolVersion'] = self::$protocol_version_connect1; $payload['requestId'] = Tools::randomAppleRequestId(); $payload['teamId'] = $team_id; $user_locale = array(); $user_locale[0] = self::$user_locale; $payload['userLocale'] = $user_locale; $plist = new CFPropertyList(); $type_detector = new CFTypeDetector(); $plist->add($type_detector->toCFType($payload)); $contents = $plist->toXML(true); // Create a new cURL resource $ch = curl_init(); // Set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $contents); curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent: Xcode', 'Content-Type: text/x-xml-plist', 'Accept: text/x-xml-plist', 'Accept-Language: en-us', 'Connection: keep-alive')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate'); curl_setopt($ch, CURLOPT_COOKIE, self::$cookie); // Execute and close cURL $data = curl_exec($ch); curl_close($ch); $plist = new CFPropertyList(); $plist->parse($data, CFPropertyList::FORMAT_AUTO); $plistData = $plist->toArray(); return $plistData; }
function plist_render($structure) { if ($_GET['test'] == 1) { echo '<pre>' . print_r($structure, true) . '</pre>'; return; } require_once ROOT_PATH . '/lib/cfpropertylist/CFPropertyList.php'; /* * create a new CFPropertyList instance without loading any content */ $plist = new CFPropertyList(); $td = new CFTypeDetector(); $guessedStructure = $td->toCFType($structure); $plist->add($guessedStructure); echo $plist->toXML(true); }
function generateDownloadPlistFile($version) { $payload_assets_content = array(); $payload_assets_content['kind'] = 'software-package'; $payload_assets_content['url'] = Tools::rel2abs(UPLOAD_PATH . $version->getToken() . '/app_bundle.ipa', Tools::current_url()); $payload_content = array(); $payload_content['assets'] = array($payload_assets_content); $payload_metadata_content = array(); $payload_metadata_content['bundle-identifier'] = $version->getApplication()->getBundleId(); $payload_metadata_content['kind'] = 'software'; $payload_metadata_content['title'] = $version->getName(); $payload_content['metadata'] = $payload_metadata_content; $payload = array(); $payload['items'] = array($payload_content); $plist = new CFPropertyList(); $td = new CFTypeDetector(); $cfPayload = $td->toCFType($payload); $plist->add($cfPayload); $data = $plist->toXML(true); $my_file = __DIR__ . '/' . UPLOAD_PATH . $version->getToken() . '.plist'; $handle = fopen($my_file, 'w') or die('Cannot open file: ' . $my_file); fwrite($handle, $data); }