/** * Process data sent by postflight * * @param string data * @author abn290 **/ function process($plist) { require_once APP_PATH . 'lib/CFPropertyList/CFPropertyList.php'; $parser = new CFPropertyList(); $parser->parse($plist, CFPropertyList::FORMAT_XML); $mylist = $parser->toArray(); // Remove serial_number from mylist, use the cleaned serial that was provided in the constructor. unset($mylist['serial_number']); // Set default computer_name if (!isset($mylist['computer_name']) or trim($mylist['computer_name']) == '') { $mylist['computer_name'] = 'No name'; } // Convert memory string (4 GB) to int if (isset($mylist['physical_memory'])) { $mylist['physical_memory'] = intval($mylist['physical_memory']); } // Convert OS version to int if (isset($mylist['os_version'])) { $digits = explode('.', $mylist['os_version']); $mult = 10000; $mylist['os_version'] = 0; foreach ($digits as $digit) { $mylist['os_version'] += $digit * $mult; $mult = $mult / 100; } } $this->timestamp = time(); $this->merge($mylist)->save(); }
/** * Decode the given data from plist format * @param string $data data sent from client to * the api in the given format. * @return array associative array of the parsed data */ public function decode($data) { require_once 'CFPropertyList.php'; $plist = new CFPropertyList(); $plist->parse($data); return $plist->toArray(); }
public function testInvalidString() { $catched = false; try { $plist = new CFPropertyList(); $plist->parse('lalala'); } catch (\DOMException $e) { $catched = true; } catch (\PHPUnit_Framework_Error $e) { $catched = true; } if ($catched == false) { $this->fail('No exception thrown for invalid string!'); } $catched = false; try { $plist = new CFPropertyList(); $plist->parse('<plist>'); } catch (PListException $e) { return; } catch (\PHPUnit_Framework_Error $e) { return; } $this->fail('No exception thrown for invalid string!'); }
function process($data) { //list of bundleids to ignore $bundleid_ignorelist = is_array(conf('bundleid_ignorelist')) ? conf('bundleid_ignorelist') : array(); $regex = '/^' . implode('|', $bundleid_ignorelist) . '$/'; // List of paths to ignore $bundlepath_ignorelist = is_array(conf('bundlepath_ignorelist')) ? conf('bundlepath_ignorelist') : array(); $path_regex = ':^' . implode('|', $bundlepath_ignorelist) . '$:'; require_once APP_PATH . 'lib/CFPropertyList/CFPropertyList.php'; $parser = new CFPropertyList(); $parser->parse($data, CFPropertyList::FORMAT_XML); $inventory_list = $parser->toArray(); if (count($inventory_list)) { // clear existing inventory items $this->delete_set($this->serial); // insert current inventory items foreach ($inventory_list as $item) { if (preg_match($regex, $item['bundleid'])) { continue; } if (preg_match($path_regex, $item['path'])) { continue; } $item['bundlename'] = isset($item['CFBundleName']) ? $item['CFBundleName'] : ''; $this->id = 0; $this->merge($item)->save(); } } }
public function testParseBinaryString() { $content = file_get_contents(TEST_BINARY_DATA_FILE); $plist = new CFPropertyList(); $plist->parse($content); $vals = $plist->toArray(); $this->assertEquals(count($vals), 4); $this->assertEquals($vals['names']['given-name'], 'John'); $this->assertEquals($vals['names']['surname'], 'Dow'); $this->assertEquals($vals['pets'][0], 'Jonny'); $this->assertEquals($vals['pets'][1], 'Bello'); $this->assertEquals($vals['age'], 28); $this->assertEquals($vals['birth-date'], 412035803); }
function process($data) { require_once APP_PATH . 'lib/CFPropertyList/CFPropertyList.php'; $parser = new CFPropertyList(); $parser->parse($data); $plist = $parser->toArray(); echo "Setting: '"; echo $plist['ds_workflow']; echo "' as DeployStudio workflow name.\n"; // TODO Also deprecated, if testing works remove this line //$this->delete_set($this->serial); $this->workflow = ''; $this->workflow = $plist['ds_workflow']; $this->save(); }
function process($data) { require_once APP_PATH . 'lib/CFPropertyList/CFPropertyList.php'; $parser = new CFPropertyList(); $parser->parse($data); $plist = $parser->toArray(); foreach (array('Text1', 'Text2', 'Text3', 'Text4') as $item) { if (isset($plist[$item])) { $this->{$item} = $plist[$item]; } else { $this->{$item} = ''; } } $this->save(); }
function process($data) { require_once APP_PATH . 'lib/CFPropertyList/CFPropertyList.php'; $parser = new CFPropertyList(); $parser->parse($data); $plist = $parser->toArray(); foreach (array('EnabledDate', 'EnabledUser', 'LVGUUID', 'LVUUID', 'PVUUID', 'RecoveryKey', 'HddSerial') as $item) { if (isset($plist[$item])) { $this->{$item} = $plist[$item]; } else { $this->{$item} = ''; } } $this->save(); }
/** * Process data sent by postflight * * @param string data * @author erikng **/ function process($plist) { require_once APP_PATH . 'lib/CFPropertyList/CFPropertyList.php'; $parser = new CFPropertyList(); $parser->parse($plist); $plist = $parser->toArray(); $this->delete_where('serial_number=?', $this->serial_number); $item = array_pop($plist); reset($item); while (list($key, $val) = each($item)) { $this->munkiinfo_key = $key; $this->munkiinfo_value = $val; $this->id = ''; $this->save(); } }
function process($plist) { require_once APP_PATH . 'lib/CFPropertyList/CFPropertyList.php'; $parser = new CFPropertyList(); $parser->parse($plist, CFPropertyList::FORMAT_XML); $mylist = $parser->toArray(); // Remove serial_number from mylist, use the cleaned serial that was provided in the constructor. unset($mylist['serial_number']); // If console_user is empty, retain previous entry if (!$mylist['console_user']) { unset($mylist['console_user']); } // If long_username is empty, retain previous entry if (array_key_exists('long_username', $mylist) && empty($mylist['long_username'])) { unset($mylist['long_username']); } $this->merge($mylist)->register()->save(); }
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); }
/** * Process data sent by postflight * * @param string data * **/ function process($data) { require_once APP_PATH . 'lib/CFPropertyList/CFPropertyList.php'; $parser = new CFPropertyList(); $parser->parse($data); $plist = $parser->toArray(); // Translate location strings to db fields $translate = array('Address' => 'address', 'Altitude' => 'altitude', 'CurrentStatus' => 'currentstatus', 'LS_Enabled' => 'ls_enabled', 'LastLocationRun' => 'lastlocationrun', 'LastRun' => 'lastrun', 'Latitude' => 'latitude', 'LatitudeAccuracy' => 'latitudeaccuracy', 'Longitude' => 'longitude', 'LongitudeAccuracy' => 'longitudeaccuracy', 'StaleLocation' => 'stalelocation'); // Parse data foreach ($translate as $search => $field) { if (isset($plist[$search])) { $this->{$field} = $plist[$search]; } else { $this->{$field} = $this->defaults[$field]; } } $this->save(); }
/** * Process data sent by postflight * * @param string data * @author abn290 **/ function process($plist) { require_once APP_PATH . 'lib/CFPropertyList/CFPropertyList.php'; $parser = new CFPropertyList(); $parser->parse($plist, CFPropertyList::FORMAT_XML); $mylist = $parser->toArray(); if (!$mylist) { throw new Exception("No Disks in report", 1); } // Convert old style reports from not migrated clients if (isset($mylist['DeviceIdentifier'])) { $mylist = array($mylist); } // Delete previous set $this->delete_where('serial_number=?', $this->serial_number); // Copy default values $empty = $this->rs; foreach ($mylist as $disk) { // Reset values $this->rs = $empty; // Calculate percentage if (isset($disk['TotalSize']) && isset($disk['FreeSpace'])) { $disk['Percentage'] = round(($disk['TotalSize'] - $disk['FreeSpace']) / max($disk['TotalSize'], 1) * 100); } // Determine VolumeType $disk['VolumeType'] = "hdd"; if (isset($disk['SolidState']) && $disk['SolidState'] == TRUE) { $disk['VolumeType'] = "ssd"; } if (isset($disk['CoreStorageCompositeDisk']) && $disk['CoreStorageCompositeDisk'] == TRUE) { $disk['VolumeType'] = "fusion"; } if (isset($disk['RAIDMaster']) && $disk['RAIDMaster'] == TRUE) { $disk['VolumeType'] = "raid"; } $this->merge($disk); // Typecast Boolean values $this->Internal = (int) $this->Internal; $this->CoreStorageEncrypted = (int) $this->CoreStorageEncrypted; $this->id = ''; $this->timestamp = time(); $this->create(); } }
function isVersionAppSignedForUdid($udid, $version) { $plistValue = __DIR__ . '/' . UPLOAD_PATH . $version->getToken() . '/app_bundle/Payload/' . $version->getApplication()->getBundleName() . '.app/embedded.mobileprovision'; $plistValue = retreivePlistFromAsn($plistValue); if (empty($plistValue)) { die("unable to read plist from configuration profile challenge."); } $plist = new CFPropertyList(); $plist->parse($plistValue, CFPropertyList::FORMAT_AUTO); $plistData = $plist->toArray(); $provisionedDevices = $plistData['ProvisionedDevices']; $found = false; foreach ($provisionedDevices as $device) { if (strtoupper($device) == strtoupper($udid)) { return true; } } return false; }
/** * Process data sent by postflight * * @param string data * @author abn290 **/ function process($plist) { require_once APP_PATH . 'lib/CFPropertyList/CFPropertyList.php'; $parser = new CFPropertyList(); $parser->parse($plist, CFPropertyList::FORMAT_XML); $mylist = $parser->toArray(); // Reset values $this->SolidState = 0; $this->TotalSize = 0; $this->FreeSpace = 0; $this->Percentage = 0; $this->SMARTStatus = ''; // Calculate percentage if (isset($mylist['TotalSize']) && isset($mylist['FreeSpace'])) { $mylist['Percentage'] = round(($mylist['TotalSize'] - $mylist['FreeSpace']) / max($mylist['TotalSize'], 1) * 100); } $this->merge($mylist); // Set type on SolidState (booleans don't translate well) $this->SolidState = (int) $this->SolidState; $this->save(); }
/** * Process data sent by postflight * * @param string data * @author abn290 **/ function process($plist) { // Delete old data $this->delete_where('serial_number=?', $this->serial_number); // Check if we're passed a plist (10.6 and higher) if (strpos($plist, '<?xml version="1.0" encoding="UTF-8"?>') === 0) { // Strip invalid xml chars $plist = preg_replace('/[^\\x{0009}\\x{000A}\\x{000D}\\x{0020}-\\x{D7FF}\\x{E000}-\\x{FFFD}\\x{10000}-\\x{10FFFF}]/u', '�', $plist); require_once APP_PATH . 'lib/CFPropertyList/CFPropertyList.php'; $parser = new CFPropertyList(); $parser->parse($plist, CFPropertyList::FORMAT_XML); $mylist = $parser->toArray(); foreach ($mylist as $item) { // PackageIdentifiers is an array, so we only retain one // packageidentifier so we can differentiate between // Apple and third party tools if (array_key_exists('packageIdentifiers', $item)) { $item['packageIdentifiers'] = array_pop($item['packageIdentifiers']); } $this->id = 0; $this->merge($item)->save(); } } else { //2007-12-14 12:40:47 +0100: Installed "GarageBand Update" (4.1.1) $pattern = '/^(.*): .*"(.+)"\\s+\\((.+)\\)/m'; if (preg_match_all($pattern, $plist, $result, PREG_SET_ORDER)) { $this->packageIdentifiers = 'com.apple.fake'; $this->processName = 'installer'; foreach ($result as $row) { $this->date = strtotime($row[1]); $this->displayName = $row[2]; $this->displayVersion = $row[3]; $this->id = 0; $this->save(); } } } }
// Upload the file to your specified path. mkdir($upload_path . $folder_token, 0700); $file_path = $upload_path . $folder_token . '/app_bundle.ipa'; if (move_uploaded_file($_FILES['app_file']['tmp_name'], $file_path)) { echo 'Your file upload was successful at: ' . $file_path . '<br />'; $zip = new ZipArchive(); //$res = $zip->open($file_path . $folder_token . '/'); if (unzipApplication($upload_path . $folder_token . '/', 'app_bundle.ipa')) { echo 'Unzip ok.<br>'; // We get the Info.plist of the app if it exists else <app_name>-Info.plist $plistfile = Tools::getInfoPlistPath($folder_token); echo 'Plist file: ' . $plistfile . '<br />'; $plistValue = file_get_contents($plistfile); if (!empty($plistValue)) { $plist = new CFPropertyList(); $plist->parse($plistValue, CFPropertyList::FORMAT_AUTO); $plistData = $plist->toArray(); //TODO connect to apple and be sure a profile exists for this app. //Create an application object and set basic data here $entityManager = initDoctrine(); // Retrieve the developer connected (unique) $developer = $entityManager->getRepository('Entities\\Developer')->find($_SESSION['developerId']); //verify if the application does not already exist (Ask to create an new version if it exists) $application = $entityManager->getRepository('Entities\\Application')->findOneBy(array('bundleId' => $plistData['CFBundleIdentifier'])); if ($application == NULL) { $application = new Application(); $application->setDeveloper($developer); $application->setBundleId($plistData['CFBundleIdentifier']); $application->setBundleName($plistData['CFBundleName']); } //ensure version doesn't already exists.
function process($plist) { // Check if uptime is set to determine this is a new client $new_client = $this->uptime ? FALSE : TRUE; require_once APP_PATH . 'lib/CFPropertyList/CFPropertyList.php'; $parser = new CFPropertyList(); $parser->parse($plist, CFPropertyList::FORMAT_XML); $mylist = $parser->toArray(); // Remove serial_number from mylist, use the cleaned serial that was provided in the constructor. unset($mylist['serial_number']); // If console_user is empty, retain previous entry if (!$mylist['console_user']) { unset($mylist['console_user']); } // If long_username is empty, retain previous entry if (array_key_exists('long_username', $mylist) && empty($mylist['long_username'])) { unset($mylist['long_username']); } $this->merge($mylist)->register()->save(); if ($new_client) { store_event($this->serial_number, 'reportdata', 'info', 'new_client'); } }
/** * Process data sent by postflight * * @param string data * @author abn290 **/ function process($plist) { require_once APP_PATH . 'lib/CFPropertyList/CFPropertyList.php'; $parser = new CFPropertyList(); $parser->parse($plist, CFPropertyList::FORMAT_XML); $mylist = $parser->toArray(); if (!$mylist) { throw new Exception("No Disks in report", 1); } // Convert old style reports from not migrated clients if (isset($mylist['DeviceIdentifier'])) { $mylist = array($mylist); } // Delete previous set $this->delete_where('serial_number=?', $this->serial_number); // Copy default values $empty = $this->rs; foreach ($mylist as $disk) { // Reset values $this->rs = $empty; // Calculate percentage if (isset($disk['TotalSize']) && isset($disk['FreeSpace'])) { $disk['Percentage'] = round(($disk['TotalSize'] - $disk['FreeSpace']) / max($disk['TotalSize'], 1) * 100); } // Determine VolumeType $disk['VolumeType'] = "hdd"; if (isset($disk['SolidState']) && $disk['SolidState'] == TRUE) { $disk['VolumeType'] = "ssd"; } if (isset($disk['CoreStorageCompositeDisk']) && $disk['CoreStorageCompositeDisk'] == TRUE) { $disk['VolumeType'] = "fusion"; } if (isset($disk['RAIDMaster']) && $disk['RAIDMaster'] == TRUE) { $disk['VolumeType'] = "raid"; } if (isset($disk['Content']) && $disk['Content'] == 'Microsoft Basic Data') { $disk['VolumeType'] = "bootcamp"; } $this->merge($disk); // Typecast Boolean values $this->Internal = (int) $this->Internal; $this->CoreStorageEncrypted = (int) $this->CoreStorageEncrypted; $this->id = ''; $this->timestamp = time(); $this->create(); // Fire event when systemdisk hits a threshold if ($this->MountPoint == '/') { $type = 'success'; $msg = ''; $data = ''; $lowvalue = 1000; // Lowest value (GB) // Check SMART Status if ($this->SMARTStatus == 'Failing') { $type = 'danger'; $msg = 'smartstatus_failing'; } foreach (conf('disk_thresholds', array()) as $name => $value) { if ($this->FreeSpace < $value * 1000000000) { if ($value < $lowvalue) { $type = $name; $msg = 'free_disk_space_less_than'; $data = json_encode(array('gb' => $value)); // Store lowest value $lowvalue = $value; } } } if ($type == 'success') { $this->delete_event(); } else { $this->store_event($type, $msg, $data); } } } }
function process($plist) { $this->timestamp = date('Y-m-d H:i:s'); // Todo: why this check? if (!$plist) { $this->errors = 0; $this->warnings = 0; return $this; } require_once APP_PATH . 'lib/CFPropertyList/CFPropertyList.php'; $parser = new CFPropertyList(); $parser->parse($plist, CFPropertyList::FORMAT_XML); $mylist = $parser->toArray(); # Check munki version if (array_key_exists('ManagedInstallVersion', $mylist)) { $this->version = $mylist['ManagedInstallVersion']; } # Copy items $strings = array('ManifestName', 'RunType', 'RunState', 'StartTime', 'EndTime'); foreach ($strings as $str) { if (array_key_exists($str, $mylist)) { $lcname = strtolower($str); $this->rs[$lcname] = $mylist[$str]; unset($mylist[$str]); } } // If there's an error downloading the manifest, we don't get a ManagedInstalls // array. We retain the old ManagedInstalls array and only store the new // Errors, Warnings, StartTime, EndTime if (!array_key_exists('ManagedInstalls', $mylist)) { $strings = array('Errors', 'Warnings'); foreach ($strings as $str) { $lcname = strtolower($str); $this->rs[$lcname] = 0; if (array_key_exists($str, $mylist)) { $this->rs[$lcname] = count($mylist[$str]); // Store errors and warnings $this->rs['report_plist'][$str] = $mylist[$str]; } } $this->save(); return $this; } # Count items $strings = array('Errors', 'Warnings', 'ManagedInstalls', 'InstallResults', 'ItemsToInstall', 'AppleUpdates', 'RemovalResults'); foreach ($strings as $str) { $lcname = strtolower($str); $this->rs[$lcname] = 0; if (array_key_exists($str, $mylist)) { $this->rs[$lcname] = count($mylist[$str]); } } // Install info - used when there is one install to report on $install_info = array(); // Problem installs $this->failedinstalls = 0; if (array_key_exists('ProblemInstalls', $mylist)) { $this->failedinstalls = count($mylist['ProblemInstalls']); if ($this->failedinstalls == 1) { $install_info = array('pkg' => $mylist['ProblemInstalls'][0]['display_name'], 'reason' => $mylist['ProblemInstalls'][0]['note']); } } // Calculate pending installs $this->pendinginstalls = max($this->itemstoinstall + $this->appleupdates - $this->installresults, 0); // Calculate pending removals $removal_items = isset($mylist['ItemsToRemove']) ? count($mylist['ItemsToRemove']) : 0; $this->pendingremovals = max($removal_items - $this->removalresults, 0); // Check results for failed installs if ($this->installresults) { foreach ($mylist['InstallResults'] as $result) { if ($result["status"]) { $this->failedinstalls++; $this->installresults--; $install_info = array('pkg' => $result['display_name'], 'reason' => ''); } else { $install_info_success = array('pkg' => $result['display_name'] . ' ' . $result['version']); } } } # Save plist todo: remove all cruft from plist $this->report_plist = $mylist; $this->save(); // Store apropriate event: if ($this->failedinstalls == 1) { $this->store_event('warning', 'pkg_failed_to_install', json_encode($install_info)); } elseif ($this->failedinstalls > 1) { $this->store_event('warning', 'pkg_failed_to_install', json_encode(array('count' => $this->failedinstalls))); } elseif ($this->rs['errors'] == 1) { $this->store_event('danger', 'munki.error', json_encode(array('error' => truncate_string($mylist['Errors'][0])))); } elseif ($this->rs['errors'] > 1) { $this->store_event('danger', 'munki.error', json_encode(array('count' => $this->rs['errors']))); } elseif ($this->warnings == 1) { $this->store_event('warning', 'munki.warning', json_encode(array('warning' => truncate_string($mylist['Warnings'][0])))); } elseif ($this->warnings > 1) { $this->store_event('warning', 'munki.warning', json_encode(array('count' => $this->warnings))); } elseif ($this->installresults == 1) { $this->store_event('success', 'munki.package_installed', json_encode($install_info_success)); } elseif ($this->installresults > 1) { $this->store_event('success', 'munki.package_installed', json_encode(array('count' => $this->installresults))); } else { // Delete event $this->delete_event(); } return $this; }
/** * 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 process($plist) { $this->timestamp = date('Y-m-d H:i:s'); // Todo: why this check? if (!$plist) { $this->errors = 0; $this->warnings = 0; return $this; } require_once APP_PATH . 'lib/CFPropertyList/CFPropertyList.php'; $parser = new CFPropertyList(); $parser->parse($plist, CFPropertyList::FORMAT_XML); $mylist = $parser->toArray(); # Check munki version if (array_key_exists('ManagedInstallVersion', $mylist)) { $this->version = $mylist['ManagedInstallVersion']; } # Copy items $strings = array('ManifestName', 'RunType', 'RunState', 'StartTime', 'EndTime'); foreach ($strings as $str) { if (array_key_exists($str, $mylist)) { $lcname = strtolower($str); $this->rs[$lcname] = $mylist[$str]; unset($mylist[$str]); } } // If there's an error downloading the manifest, we don't get a ManagedInstalls // array. We retain the old ManagedInstalls array and only store the new // Errors, Warnings, StartTime, EndTime if (!array_key_exists('ManagedInstalls', $mylist)) { $strings = array('Errors', 'Warnings'); foreach ($strings as $str) { $lcname = strtolower($str); $this->rs[$lcname] = 0; if (array_key_exists($str, $mylist)) { $this->rs[$lcname] = count($mylist[$str]); // Store errors and warnings $this->rs['report_plist'][$str] = $mylist[$str]; } } $this->save(); return $this; } # Count items $strings = array('Errors', 'Warnings', 'ManagedInstalls', 'InstallResults', 'ItemsToInstall', 'AppleUpdates', 'RemovalResults'); foreach ($strings as $str) { $lcname = strtolower($str); $this->rs[$lcname] = 0; if (array_key_exists($str, $mylist)) { $this->rs[$lcname] = count($mylist[$str]); } } // Calculate pending installs $this->pendinginstalls = max($this->itemstoinstall + $this->appleupdates - $this->installresults, 0); // Calculate pending removals $removal_items = isset($mylist['ItemsToRemove']) ? count($mylist['ItemsToRemove']) : 0; $this->pendingremovals = max($removal_items - $this->removalresults, 0); // Check results for failed installs $this->failedinstalls = 0; if ($this->installresults) { foreach ($mylist['InstallResults'] as $result) { if ($result["status"]) { $this->failedinstalls++; } } } // Adjust installed items $this->installresults -= $this->failed_installs; # Save plist todo: remove all cruft from plist $this->report_plist = $mylist; $this->save(); return $this; }
<?php /** * Examples for how to use CFPropertyList with strings * Read a binary from a string PropertyList * @package plist * @subpackage plist.examples */ namespace CFPropertyList; // just in case... error_reporting(E_ALL); ini_set('display_errors', 'on'); /** * Require CFPropertyList */ require_once __DIR__ . '/../classes/CFPropertyList/CFPropertyList.php'; /* * create a new CFPropertyList instance which loads the sample.plist on construct. * We don't know that it is a binary plist, so we simply call ->parse() */ $content = file_get_contents(__DIR__ . '/sample.binary.plist'); $plist = new CFPropertyList(); $plist->parse($content); /* * retrieve the array structure of sample.plist and dump to stdout */ echo '<pre>'; var_dump($plist->toArray()); echo '</pre>';