public static function parseInfoPlist($ipafile) { $plist_name = self::unzipInfoPlistFileName($ipafile); if (!$plist_name) { throw new UnexpectedValueException(__METHOD__ . ": Info.plist file not found."); } $info_plist = self::unzipFile($ipafile, $plist_name); $plutil = new CFPropertyList\CFPropertyList(); $plutil->parse($info_plist); return $plutil->toArray(); }
function getWorkflowSettings() { global $workflow; try { # workflows.php does not handle property lists with anything other than # single-line string data. Therefore it is necessary to use CFPropertyList # which will retrieve values from the settings list in the proper data # type. $plist = new \CFPropertyList\CFPropertyList($workflow->data() . '/settings.plist', \CFPropertyList\CFPropertyList::FORMAT_XML); return $plist->toArray(); } catch (Exception $e) { return array(); } }
syslog(LOG_DEBUG, $body); $plist = new \CFPropertyList\CFPropertyList(); $plist->parse($body); $message = $plist->toArray(); $message_type = $message["MessageType"]; if ($message_type == "Authenticate") { // TODO: authentication // grab our UUID and create/update our data $udid = $message["UDID"]; $device = array(); $device["udid"] = $udid; // we just return an 'OK' here create_device($device); // now, send back a response $res_plist = new \CFPropertyList\CFPropertyList(); $res_plist->add($dict = new \CFPropertyList\CFDictionary()); echo $res_plist->toXML(); } elseif ($message_type == "TokenUpdate") { update_device_token($message); $res_plist = new \CFPropertyList\CFPropertyList(); $res_plist->add($dict = new \CFPropertyList\CFDictionary()); echo $res_plist->toXML(); } elseif ($message_type == "CheckOut") { check_out_device($message); // the device is leaving our MDM zone, so we need to set the values for // this in the correct place } } // $slim->render('index.php'); }); $slim->run();
/** * Create new Library from a path * * @param string $path path to the .photolibrary directory (with or without trailing /) */ public function __construct($path) { $path = rtrim($path, DIRECTORY_SEPARATOR); $plistPath = $path . DIRECTORY_SEPARATOR . 'AlbumData.xml'; if (!is_dir($path) || !is_file($plistPath)) { throw new \InvalidArgumentException('Given path does not seem to be an iPhoto library package'); } // Since loading/parsing the plist can be quite heavy, caching was added here $cacheKey = preg_replace('/[^A-Za-z0-9_+-]/', '--', realpath($path)); $data = self::loadFromCache($cacheKey, filemtime($plistPath)); if ($data === false) { // These next 2 lines can take a while, depending on the size of the plist / your library $plist = new \CFPropertyList\CFPropertyList($plistPath); $data = $plist->toArray(); // Get rid of this large data asap unset($plist); self::storeInCache($cacheKey, $data); } $this->path = $path; $this->data =& $data; }
function getValueFromSmbios($key, $default = null) { global $workPath; $file = $workPath . '/smbios.plist'; if (file_exists($file)) { $plist = new CFPropertyList\CFPropertyList($file, CFPropertyList\CFPropertyList::FORMAT_XML); $dict = $plist->toArray(); if (array_key_exists($key, $dict)) { return $dict[$key]; } } return $default; }