示例#1
1
 /**
  * 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();
 }
 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();
         }
     }
 }
示例#3
0
 public function parse($ipaFile, $infoFile = self::INFO_PLIST)
 {
     $zipObj = new ZipArchive();
     if ($zipObj->open($ipaFile) !== true) {
         throw new PListException("unable to open {$ipaFile} file!");
     }
     //scan plist file
     $plistFile = null;
     for ($i = 0; $i < $zipObj->numFiles; $i++) {
         $name = $zipObj->getNameIndex($i);
         if (preg_match('/Payload\\/(.+)?\\.app\\/' . preg_quote($infoFile) . '$/i', $name)) {
             $plistFile = $name;
             break;
         }
     }
     //parse plist file
     if (!$plistFile) {
         throw new PListException("unable to parse plist file!");
     }
     //deal in memory
     $plistHandle = fopen('php://memory', 'wb');
     fwrite($plistHandle, $zipObj->getFromName($plistFile));
     rewind($plistHandle);
     $zipObj->close();
     $plist = new CFPropertyList($plistHandle, CFPropertyList::FORMAT_AUTO);
     $this->plistContent = $plist->toArray();
     return true;
 }
示例#4
0
 /**
  * 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();
 }
示例#5
0
 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('EnabledDate', 'EnabledUser', 'LVGUUID', 'LVUUID', 'PVUUID', 'RecoveryKey', 'HddSerial') as $item) {
         if (isset($plist[$item])) {
             $this->{$item} = $plist[$item];
         } else {
             $this->{$item} = '';
         }
     }
     $this->save();
 }
示例#7
0
 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();
 }
示例#8
0
 public function testParseStream()
 {
     $plist = new CFPropertyList();
     if (($fd = fopen(TEST_BINARY_DATA_FILE, "rb")) == NULL) {
         throw new IOException("Error opening test data file for reading!");
     }
     $plist->readBinaryStream($fd);
     $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);
 }
 /**
  * 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();
     }
 }
示例#10
0
/**
 * Sanitizes plist before import. To be called before the new Workflow is installed.
 *
 * @param string  $plist Location of the plist file
 * @return bool          Return true on success and false otherwise.
 */
function importSanitize($plist)
{
    $wflow = new CFPropertyList($plist);
    $tmp = $wflow->toArray();
    if (!isset($tmp['objects'])) {
        // This is a blank Workflow. Why are you updating it?
        return true;
    }
    foreach ($tmp['objects'] as $key => $object) {
        if ($object['type'] == 'alfred.workflow.trigger.hotkey') {
            // We've found a hotkey, so let's strip it.
            $location = ":objects:{$key}:config";
            stripHotkey($location, $plist);
        }
    }
    return true;
}
 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();
 }
示例#12
0
 /**
  * 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();
 }
示例#13
0
 /**
  * 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();
             }
         }
     }
 }
示例#17
0
/**
 * Migrates the hotkeys and keywords from the current plist to the new version. It alters the actual files.
 * @param  string $current The current plist file
 * @param  string $new     The new plist file
 * @return mixed           Either "true" or an error code
 */
function migratePlist($current, $new)
{
    if (!file_exists($current)) {
        return 1;
        // Error Code #1 is original file doesn't exist
    }
    if (!file_exists($new)) {
        return 2;
        // Error Code #2 is new file doesn't exist
    }
    // Construct the workflow plist objects
    $workflow = new CFPropertyList($current);
    $import = new CFPropertyList($new);
    // Declare an array to store the data about the original plist in.
    $original = array();
    // Convert plist object to usable array for processing
    $tmp = $workflow->toArray();
    /**
     * Load the objects array, scan through it to get everything migratable.
     * Store the values as an array with the UIDs as the keys.
     * @var array
     */
    foreach ($tmp['objects'] as $o) {
        if (isset($o['config'])) {
            $original[$o['uid']]['type'] = $o['type'];
            switch ($o['type']) {
                case 'alfred.workflow.trigger.hotkey':
                    $value = array();
                    if (isset($o['config']['hotkey'])) {
                        $value['hotkey'] = $o['config']['hotkey'];
                    }
                    if (isset($o['config']['hotmod'])) {
                        $value['hotmod'] = $o['config']['hotmod'];
                    }
                    if (isset($o['config']['hotstring'])) {
                        $value['hotstring'] = $o['config']['hotstring'];
                    }
                    $original[$o['uid']]['config'] = $value;
                    break;
                case 'alfred.workflow.input.filefilter':
                case 'alfred.workflow.input.scriptfilter':
                case 'alfred.workflow.input.keyword':
                    $value = array('keyword' => $o['config']['keyword']);
                    $original[$o['uid']]['config'] = $value;
                    break;
            }
        }
    }
    $tmp = $import->toArray();
    // The uids are stored as the keys of the $original array,
    // so let's grab them to check if we need to migrate anything.
    $uids = array_keys($original);
    // These are the only types of objects that we need to migrate
    $objects = array('alfred.workflow.trigger.hotkey', 'alfred.workflow.input.filefilter', 'alfred.workflow.input.scriptfilter', 'alfred.workflow.input.keyword');
    // We need the key(order) so that we can set things properly
    foreach ($tmp['objects'] as $key => $o) {
        // Use only the things in the types above
        if (in_array($o['type'], $objects)) {
            // Check to see if the objects is one of the original objects with a uid.
            if (in_array($o['uid'], $uids)) {
                echo $o['uid'] . "<br >";
                echo $o['type'] . "<br> ";
                if ($o['type'] == 'alfred.workflow.trigger.hotkey') {
                    // We're not really going to bother to check to see if the values match;
                    // we'll just migrate them instead.
                    //setPlistValue( $location, $value, $plist)
                    setPlistValue(":objects:{$key}:config:hotmod", $original[$o['uid']]['config']['hotmod'], $new);
                    setPlistValue(":objects:{$key}:config:hotkey", $original[$o['uid']]['config']['hotkey'], $new);
                    setPlistValue(":objects:{$key}:config:hotstring", $original[$o['uid']]['config']['hotstring'], $new);
                } else {
                    // At this point, the only other thing to migrate is the keyword
                    // Check to see if they match; if they don't, then set them to the new one
                    if ($o['config']['keyword'] != $original[$o['uid']]['config']['keyword']) {
                        setPlistValue(":objects:{$key}:config:keyword", $original[$o['uid']]['config']['keyword'], $new);
                    }
                }
            }
        }
    }
    return TRUE;
    /**
     *
     * Todo:
     * 		-- add in error checking for correct plist syntax.
     * 		-- expand migration for desired but non-essential settings
     *
     */
}
 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;
 }
示例#19
0
 * @package plist
 * @subpackage plist.examples
 */
// just in case...
error_reporting(E_ALL);
ini_set('display_errors', 'on');
/**
 * Require CFPropertyList
 */
require_once dirname(__FILE__) . '/../CFPropertyList.php';
/*
 * create a new CFPropertyList instance which loads the sample.plist on construct.
 * since we know it's an XML file, we can skip format-determination
 */
$plist = new CFPropertyList(dirname(__FILE__) . '/clients', CFPropertyList::FORMAT_XML);
$customerarray = $plist->toArray();
$customerarray = $customerarray['clients'];
/*
 * retrieve the array structure of sample.plist and dump to stdout
 */
foreach ($customerarray as $customer) {
    echo $customer['firstName'] . " " . $customer['lastName'];
    foreach ($customer['projectIds'] as $project) {
        $plist = new CFPropertyList(dirname(__FILE__) . '/iBiz/', CFPropertyList::FORMAT_XML);
        echo "<br/>" . $project;
    }
    echo "<br/><br/>";
}
/*echo '<pre>';
var_dump($customerarray);
echo '</pre>';*/
	/**
    * Parse the Plist and get the values for the creating an Manifest and write the Manifest
    *
    * @param String $ipa the location of the IPA file
    */
	function createManifest ($ipa) {
		if (file_exists(dirname(__FILE__).'/cfpropertylist/CFPropertyList.php')) {
			require_once(dirname(__FILE__).'/cfpropertylist/CFPropertyList.php');

			$plist = new CFPropertyList('Info.plist');
			$plistArray = $plist->toArray();
			//var_dump($plistArray);
			$this->identiefier = $plistArray['CFBundleIdentifier'];
			$this->appname = $plistArray['CFBundleDisplayName'];
			$this->icon = ($plistArray['CFBundleIconFile']!=""?$plistArray['CFBundleIconFile']:(count($plistArray['CFBundleIconFile'])>0?$plistArray['CFBundleIconFile'][0]:null));
			
			
			$manifest = '<?xml version="1.0" encoding="UTF-8"?>
			<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
			<plist version="1.0">
			<dict>
				<key>items</key>
				<array>
					<dict>
						<key>assets</key>
						<array>
							<dict>
								<key>kind</key>
								<string>software-package</string>
								<key>url</key>
								<string>'.$this->baseurl.$this->basedir.$ipa.'</string>
							</dict>
							'.(file_exists($this->folder.'/itunes.png')?'<dict>
								<key>kind</key>
								<string>full-size-image</string>
								<key>needs-shine</key>
								<false/>
								<key>url</key>
								<string>'.$this->baseurl.$this->basedir.$this->folder.'/itunes.png</string>
							</dict>':'').'
							'.(file_exists($this->folder.'/icon.png')?'<dict>
								<key>kind</key>
								<string>display-image</string>
								<key>needs-shine</key>
								<false/>
								<key>url</key>
								<string>'.$this->baseurl.$this->basedir.$this->folder.'/'.($this->icon==null?'icon.png':$this->icon).'</string>
							</dict>':'').'
						</array>
						<key>metadata</key>
						<dict>
							<key>bundle-identifier</key>
							<string>'.$plistArray['CFBundleIdentifier'].'</string>
							<key>bundle-version</key>
							<string>'.$plistArray['CFBundleVersion'].'</string>
							<key>kind</key>
							<string>software</string>
							<key>title</key>
							<string>'.$plistArray['CFBundleDisplayName'].'</string>
						</dict>
					</dict>
				</array>
			</dict>
			</plist>';
				
			if (file_put_contents($this->folder."/".basename($ipa, ".ipa").".plist",$manifest)) $this->applink = $this->applink.$this->baseurl.$this->basedir.$this->folder."/".basename($ipa, ".ipa").".plist";
			else die("Wireless manifest file could not be created !?! Is the folder ".$this->folder." writable?");
			
			
		} else die("CFPropertyList class was not found! You need it to create the wireless manifest. Put it in de folder cfpropertylist!");
	}
 /**
  * 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);
             }
         }
     }
 }
示例#22
0
} else {
    $user_is_on_this_host = true;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    switch ($_GET['action']) {
        case 'redirect':
            $tmpfname = tempnam("/tmp", "gs-iphone");
            $handle = fopen($tmpfname, "w");
            $stdin = fopen('php://input', "r");
            while ($chunk = fread($stdin, 1024)) {
                fwrite($handle, $chunk);
            }
            fclose($handle);
            fclose($stdin);
            $plist = new CFPropertyList($tmpfname, CFPropertyList::FORMAT_XML);
            $assoc = $plist->toArray();
            unlink($tmpfname);
            if (!$assoc['timeout']) {
                gs_log(GS_LOG_WARNING, 'could not parse Plist from device');
                header("HTTP/1.0 500 Internal Server Error");
                exit;
            }
            setForward($userinfo, 0, $assoc['sourceAction'][0], $assoc);
            setForward($userinfo, 1, $assoc['sourceAction'][1], $assoc);
            setForward($userinfo, 2, $assoc['sourceAction'][2], $assoc);
            setForward($userinfo, 3, $assoc['sourceAction'][3], $assoc);
            setForward($userinfo, 4, $assoc['sourceAction'][4], $assoc);
            setForward($userinfo, 5, $assoc['sourceAction'][5], $assoc);
            setForward($userinfo, 6, $assoc['sourceAction'][6], $assoc);
            setForward($userinfo, 7, $assoc['sourceAction'][7], $assoc);
            if (GS_BUTTONDAEMON_USE == true) {
示例#23
0
    $db->store_result();
}
$multi_query = '';
// run and flush multi_query
echo "**** END: Importing Projects, Jobs, and Job Estimates **** \n\n";
/* Import Invoices */
echo "**** Importing Invoices **** \n";
/* Open invoices directory */
if ($handle = opendir($pref_ibiz_dir . '/Invoices')) {
    /* For each item in directory */
    while (false !== ($filename = readdir($handle))) {
        /* If this is a file */
        if (substr($filename, 0, 1) != '.') {
            /* Load this invoice into array */
            $plist = new CFPropertyList($pref_ibiz_dir . '/Invoices/' . $filename . '/Attributes', CFPropertyList::FORMAT_XML);
            $invoice = $plist->toArray();
            /* Clean invoice strings */
            if (!empty($invoice['balance'])) {
                $balance = $db->real_escape_string(trim($invoice['balance']));
            } else {
                $balance = NULL;
            }
            if (!empty($invoice['invoiceAmount'])) {
                $invoiceAmount = $db->real_escape_string(trim($invoice['invoiceAmount']));
            } else {
                $invoiceAmount = NULL;
            }
            if (!empty($invoice['clientIdentifier'])) {
                $clientIdentifier = $db->real_escape_string(trim($invoice['clientIdentifier']));
            } else {
                $clientIdentifier = NULL;
示例#24
0
<?php

/**
 * Examples for how to use CFPropertyList
 * Read a Binary PropertyList
 * @package plist
 * @subpackage plist.examples
 */
// just in case...
error_reporting(E_ALL);
ini_set('display_errors', 'on');
/**
 * Require CFPropertyList
 */
require_once dirname(__FILE__) . '/../CFPropertyList.php';
/*
 * create a new CFPropertyList instance which loads the sample.plist on construct.
 * since we know it's a binary file, we can skip format-determination
 */
$plist = new CFPropertyList(dirname(__FILE__) . '/sample.binary.plist', CFPropertyList::FORMAT_BINARY);
/*
 * retrieve the array structure of sample.plist and dump to stdout
 */
echo '<pre>';
var_dump($plist->toArray());
echo '</pre>';
$plist->saveBinary(dirname(__FILE__) . '/sample.binary.plist');
示例#25
0
            }
        } elseif ($matchHistory > 0) {
            if (is_array($value) && isset($value['NS.string']) && preg_match('/^[\\dA-Fa-f]{8}\\-[\\dA-Fa-f]{4}\\-[\\dA-Fa-f]{4}\\-[\\dA-Fa-f]{4}\\-[\\dA-Fa-f]{12}$/', $value['NS.string'])) {
                $excludeResults[$value['NS.string']] = $matchHistory--;
            }
        } else {
            break;
        }
    }
    unlink($fName);
}
// Reading Transmit Metadata files
if (($dp = @opendir($root)) !== false) {
    while ($fName = readdir($dp)) {
        if (is_file($root . $fName) && preg_match($reValidName, $fName) && ($pList = new CFPropertyList($root . $fName))) {
            $data = $pList->toArray();
            $rowQuery = join(' ', array($data['com_panic_transmit_nickname'], $data['com_panic_transmit_username'], $data['com_panic_transmit_server'], $data['com_panic_transmit_remotePath']));
            if (!$excludeResults[$data['com_panic_transmit_uniqueIdentifier']] && preg_match($reRowQuery, $rowQuery)) {
                $results[] = array('uid' => $data['com_panic_transmit_uniqueIdentifier'], 'arg' => $root . $fName, 'title' => $data['com_panic_transmit_nickname'], 'subtitle' => strtolower($data['com_panic_transmit_protocol'] . '://' . ($data['com_panic_transmit_username'] ? $data['com_panic_transmit_username'] . '@' : '') . $data['com_panic_transmit_server'] . ($data['com_panic_transmit_port'] ? ':' . $data['com_panic_transmit_port'] : $defaultPorts[$data['com_panic_transmit_protocol']])) . $data['com_panic_transmit_remotePath'], 'icon' => 'icon.png', 'valid' => true);
            }
        }
    }
} else {
    // Unable to open Transmit folder
    $results[] = array('uid' => 'notfound', 'arg' => 'notfound', 'title' => 'Favorites Folder Not Found', 'subtitle' => 'Unable to locate Transmit favorites folder', 'icon' => 'icon.png', 'valid' => false);
}
// No favorites matched
if (!count($results)) {
    $results[] = array('uid' => 'none', 'arg' => 'none', 'title' => 'No Favorites Found', 'subtitle' => 'No favorites matching your query were found', 'icon' => 'icon.png', 'valid' => false);
}
// Preparing the XML output file
示例#26
0
 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');
     }
 }
示例#27
0
 public function testUidPlist()
 {
     $plist = new CFPropertyList(TEST_UID_BPLIST);
     $val = $plist->toArray();
     $this->assertEquals(array('test' => 1), $val);
     $v = $plist->getValue()->getValue();
     $this->assertTrue($v['test'] instanceof CFUid);
 }
 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;
 }
 /**
  * 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;
 }
 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.
             //TODO version can be unspefied, handle this case.