/**
  * 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();
         }
     }
 }
Example #3
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();
 }
Example #4
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;
 }
Example #5
0
 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!');
 }
 protected function generatePlistFromData()
 {
     $plist = new CFPropertyList();
     $plist->add($array = new CFArray());
     while ($entry = $this->getData()->next()) {
         $array->add($this->formatEntryAsPlist($entry));
     }
     return $plist;
 }
Example #7
0
 public function testWriteUid()
 {
     $plist = new CFPropertyList();
     $dict = new CFDictionary();
     $dict->add('test', new CFUid(1));
     $plist->add($dict);
     $plist1 = new CFPropertyList(TEST_UID_XML_PLIST);
     $this->assertEquals($plist1->toXml(), $plist->toXml());
 }
    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());
    }
Example #9
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();
 }
Example #10
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();
 }
 /**
  * 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();
     }
 }
Example #13
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;
}
Example #14
0
 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);
 }
 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();
 }
Example #16
0
function generateManifest($manifest_path, $parent, $catalog)
{
    $plist = new CFPropertyList();
    $plist->add($dict = new CFDictionary());
    if ($catalog != '') {
        // Add manifest to production catalog by default
        $dict->add('catalogs', $array = new CFArray());
        $array->add(new CFString($catalog));
    }
    // Add parent manifest to included_manifests to achieve waterfall effect
    $dict->add('included_manifests', $array = new CFArray());
    $array->add(new CFString($parent));
    $tmp = explode('/', $manifest_path);
    $manifest = end($tmp);
    logToFile("Generating manifest '{$manifest}'...");
    // Save the newly created plist
    $plist->saveXML($manifest_path);
}
 /**
  * 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();
     }
 }
Example #19
0
 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;
 }
Example #20
0
 public function testInvalidString()
 {
     $catched = false;
     try {
         $plist = new CFPropertyList();
         $plist->parseBinary('lalala');
     } catch (PListException $e) {
         $catched = true;
     }
     if ($catched == false) {
         $this->fail('No exception thrown for invalid string!');
     }
     $catched = false;
     try {
         $plist = new CFPropertyList();
         $plist->parseBinary('bplist00dfwefwefwef');
     } catch (PListException $e) {
         return;
     }
     $this->fail('No exception thrown for invalid string!');
 }
 /**
  * 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();
 }
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);
}
 /**
  * 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();
             }
         }
     }
 }
 public function addBundle()
 {
     if (!Input::hasFile('ipa')) {
         exit(0);
     } else {
         $ipa = Input::file('ipa');
     }
     $payload = exec("unzip -l " . $ipa->getRealPath() . " | sed -e 's/ /\\n/g' | grep app/Info.plist | sed -e 's/Info.plist//g'");
     $default_icon = public_path() . "/images/default_icon.png";
     $fileSystem = new Filesystem();
     if (!$fileSystem->exists('/tmp/bundle')) {
         $fileSystem->makeDirectory('/tmp/bundle');
     }
     if (!$fileSystem->exists('/tmp/bundle/tmp')) {
         $fileSystem->makeDirectory('/tmp/bundle/tmp');
     }
     $path = "/tmp/bundle" . $ipa->getRealPath();
     if ($fileSystem->exists($path)) {
         $fileSystem->deleteDirectory($path);
     }
     $fileSystem->makeDirectory($path);
     $zip = new ZipArchive();
     $res = $zip->open($ipa->getRealPath());
     if ($res === TRUE) {
         $zip->extractTo($path);
         $zip->close();
     }
     $dirs = scandir($path);
     array_shift($dirs);
     array_shift($dirs);
     $APP_PATH = $path . "/" . $dirs[0];
     $dirs = scandir($APP_PATH);
     array_shift($dirs);
     array_shift($dirs);
     $APP_PATH = $APP_PATH . "/" . $dirs[0];
     $plist = CFPropertyList::getInstance();
     $plist->setFile($APP_PATH . "/Info.plist");
     $plist->load();
     $info = $plist->toArray();
     $name = $info['CFBundleName'];
     $build = isset($info['CFBundleVersion']) && array_key_exists("CFBundleVersion", $info) ? $info['CFBundleVersion'] : 1;
     $version = isset($info['CFBundleShortVersionString']) && array_key_exists("CFBundleShortVersionString", $info) ? $info['CFBundleShortVersionString'] : 0;
     if (array_key_exists("CFBundleIconFiles", $info)) {
         $icons = $info['CFBundleIconFiles'];
     } else {
         if (array_key_exists("CFBundleIcons", $info)) {
             $icons = $info["CFBundleIcons"]["CFBundlePrimaryIcon"]["CFBundleIconFiles"];
         } else {
             $icons = array();
         }
     }
     $bundle = $info['CFBundleIdentifier'];
     $label = $_POST['label'];
     if (!$fileSystem->exists(public_path() . '/builds')) {
         $fileSystem->makeDirectory(public_path() . '/builds');
     }
     if (!$fileSystem->exists(public_path() . '/builds/ios')) {
         $fileSystem->makeDirectory(public_path() . '/builds/ios');
     }
     if (!$fileSystem->exists(public_path() . '/builds/ios/' . $label)) {
         $fileSystem->makeDirectory(public_path() . '/builds/ios/' . $label);
     }
     if (!$fileSystem->exists(public_path() . '/builds/ios/' . $label . '/' . $version)) {
         $fileSystem->makeDirectory(public_path() . '/builds/ios/' . $label . '/' . $version);
     }
     $icons_ready = array();
     foreach ($icons as $icon) {
         $img = "{$path}/tmp5646431.png";
         $icon = str_replace(".png", "", $icon) . ".png";
         $processor = PPngUncrush::getInstance();
         if (is_file("{$APP_PATH}/{$icon}")) {
             $processor->setFilePath("{$APP_PATH}/{$icon}");
             try {
                 $processor->decode($img . $icon);
             } catch (ErrorException $e) {
                 $img = $default_icon;
                 $icon = "";
             }
             $sz = getimagesize($img . $icon);
             $icons_ready[] = array("image" => $img . $icon, "size" => $sz);
         }
         //            $fileSystem->copy($img.$icon ,public_path().'/builds/ios/'.$label.'/'.$version.'/'.$bundle.$sz[0].'x'.$sz[1].'.png');
     }
     $label_model = Label::where('label_name', '=', $label)->where('build_type_id', '=', self::BUILD_IOS_TYPE_ID)->first();
     if ($label_model != null) {
         $version_model = $label_model->versions()->where('version', '=', $version)->first();
         if ($version_model != null) {
             $build_version_count = Build::where('version_id', '=', $version_model->id)->count();
             $build = Build::create(array('bundle' => $bundle, 'name' => $name, 'version_id' => $version_model->id, 'build' => $build_version_count + 1));
         } else {
             $version_model = Version::create(array('version' => $version, 'label_id' => $label_model->id));
             $build = Build::create(array('bundle' => $bundle, 'name' => $name, 'version_id' => $version_model->id, 'build' => 1));
         }
     } else {
         $label_model = Label::create(array('label_name' => $label, 'build_type_id' => self::BUILD_IOS_TYPE_ID));
         $version_model = Version::create(array('version' => $version, 'label_id' => $label_model->id));
         $build = Build::create(array('bundle' => $bundle, 'name' => $name, 'version_id' => $version_model->id, 'build' => 1));
     }
     $fn = public_path() . '/builds/ios/' . $label . '/' . $version . '/' . $build->build . '/' . $bundle . '.ipa';
     if (!$fileSystem->exists(public_path() . '/builds/ios/' . $label . '/' . $version . '/' . $build->build)) {
         $fileSystem->makeDirectory(public_path() . '/builds/ios/' . $label . '/' . $version . '/' . $build->build);
     }
     $fileSystem->move($ipa->getRealPath(), $fn);
     $max_size = 0;
     foreach ($icons_ready as $icon) {
         if ($icon["size"][0] > $max_size) {
             $max_size = $icon["size"][0];
         }
     }
     foreach ($icons_ready as $icon) {
         if ($icon["size"][0] == $max_size) {
             $fileSystem->copy($icon["image"], public_path() . '/builds/ios/' . $label . '/' . $version . '/' . $build->build . '/' . $bundle . '.png');
         }
     }
     if (empty($icons_ready)) {
         $fileSystem->copy($default_icon, public_path() . '/builds/ios/' . $label . '/' . $version . '/' . $build->build . '/' . $bundle . '.png');
     }
     $fileSystem->deleteDirectory('/tmp/bundle/tmp');
     echo Config::get("app.domain") . "/ios/builds/{$label}/{$version}/{$build->build}\n";
     return "";
 }
Example #25
0
    $plist->saveXML(dirname(__FILE__) . '/example-create-04.xml.plist');
    $plist->saveBinary(dirname(__FILE__) . '/example-create-04.binary.plist');
} catch (PListException $e) {
    echo 'Normal detection: ', $e->getMessage(), "\n";
}
/*
 * Try detection by omitting exceptions
 */
try {
    $plist = new CFPropertyList();
    $td = new CFTypeDetector(false, true);
    $guessedStructure = $td->toCFType($structure);
    $plist->add($guessedStructure);
    $plist->saveXML(dirname(__FILE__) . '/example-create-04.xml.plist');
    $plist->saveBinary(dirname(__FILE__) . '/example-create-04.binary.plist');
} catch (PListException $e) {
    echo 'Silent detection: ', $e->getMessage(), "\n";
}
/*
 * Try detection with an extended version of CFTypeDetector
 */
try {
    $plist = new CFPropertyList();
    $td = new DemoDetector();
    $guessedStructure = $td->toCFType($structure);
    $plist->add($guessedStructure);
    $plist->saveXML(dirname(__FILE__) . '/example-create-04.xml.plist');
    $plist->saveBinary(dirname(__FILE__) . '/example-create-04.binary.plist');
} catch (PListException $e) {
    echo 'User defined detection: ', $e->getMessage(), "\n";
}
Example #26
0
$identifier = $_GET["identifier"];
$hostname = $_GET["hostname"];
// Split the manifest path up to determine directory structure
$directories = explode("/", $identifier, -1);
$total = count($directories);
$n = 0;
$identifier_path = "";
while ($n < $total) {
    $identifier_path .= $directories[$n] . '/';
    $n++;
}
// Check if manifest already exists for this machine
if (file_exists('../manifests/' . $identifier_path . '/clients/' . $hostname)) {
    echo "Computer manifest already exists.";
} else {
    echo "Computer manifest does not exist. Will create.";
    if (!is_dir('../manifests/' . $identifier_path . 'clients/')) {
        mkdir('../manifests/' . $identifier_path . 'clients/', 0755, true);
    }
    // Create the new manifest plist
    $plist = new CFPropertyList();
    $plist->add($dict = new CFDictionary());
    // Add manifest to production catalog by default
    $dict->add('catalogs', $array = new CFArray());
    $array->add(new CFString('production'));
    // Add parent manifest to included_manifests to achieve waterfall effect
    $dict->add('included_manifests', $array = new CFArray());
    $array->add(new CFString($identifier));
    // Save the newly created plist
    $plist->saveXML('../manifests/' . $identifier_path . 'clients/' . $hostname);
}
Example #27
0
 /**
  * Convert a DOMNode into a CFType.
  * @param DOMNode $node Node to import children of
  * @param CFDictionary|CFArray|CFPropertyList $parent 
  * @return void
  */
 protected function import(DOMNode $node, $parent)
 {
     // abort if there are no children
     if (!$node->childNodes->length) {
         return;
     }
     foreach ($node->childNodes as $n) {
         // skip if we can't handle the element
         if (!isset(self::$types[$n->nodeName])) {
             continue;
         }
         $class = self::$types[$n->nodeName];
         $key = null;
         // find previous <key> if possible
         $ps = $n->previousSibling;
         while ($ps && $ps->nodeName == '#text' && $ps->previousSibling) {
             $ps = $ps->previousSibling;
         }
         // read <key> if possible
         if ($ps && $ps->nodeName == 'key') {
             $key = $ps->firstChild->nodeValue;
         }
         switch ($n->nodeName) {
             case 'date':
                 $value = new $class(CFDate::dateValue($n->nodeValue));
                 break;
             case 'data':
                 $value = new $class($n->nodeValue, true);
                 break;
             case 'string':
                 $value = new $class($n->nodeValue);
                 break;
             case 'real':
             case 'integer':
                 $value = new $class($n->nodeName == 'real' ? floatval($n->nodeValue) : intval($n->nodeValue));
                 break;
             case 'true':
             case 'false':
                 $value = new $class($n->nodeName == 'true');
                 break;
             case 'array':
             case 'dict':
                 $value = new $class();
                 $this->import($n, $value);
                 break;
         }
         // Dictionaries need a key
         if ($parent instanceof CFDictionary) {
             $parent->add($key, $value);
         } else {
             $parent->add($value);
         }
     }
 }
 * Read an XML 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 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);
	/**
    * 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!");
	}
Example #30
0
    $user_is_on_this_host = in_array($host['id'], $our_host_ids, true);
} 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);