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); }
public function testWriteFile() { $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); $plist->saveXML(WRITE_XML_DATA_FILE); $this->assertTrue(is_file(WRITE_XML_DATA_FILE)); $plist->load(WRITE_XML_DATA_FILE); unlink(WRITE_XML_DATA_FILE); }
$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"; }
$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); }
$plist->saveXML(__DIR__ . '/example-create-04.xml.plist'); $plist->saveBinary(__DIR__ . '/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(array('suppressExceptions' => true)); $guessedStructure = $td->toCFType($structure); $plist->add($guessedStructure); $plist->saveXML(__DIR__ . '/example-create-04.xml.plist'); $plist->saveBinary(__DIR__ . '/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(__DIR__ . '/example-create-04.xml.plist'); $plist->saveBinary(__DIR__ . '/example-create-04.binary.plist'); } catch (PListException $e) { echo 'User defined detection: ', $e->getMessage(), "\n"; }
<?php require_once 'cfpropertylist-1.1.2/CFPropertyList.php'; // Get the varibles passed by the enroll script $hostname = $_GET["hostname"]; $identifier1 = $_GET["identifier1"]; // Check if manifest already exists for this machine if (file_exists('../manifests/' . $hostname)) { echo "Computer manifest already exists."; } else { echo "Computer manifest does not exist. Will create."; // Create the new manifest plist $plist = new CFPropertyList(); $plist->add($dict = new CFDictionary()); // Add manifest to release catalog by default $dict->add('catalogs', $array = new CFArray()); $array->add(new CFString('release')); // Add manifests $dict->add('included_manifests', $array = new CFArray()); $array->add(new CFString('__Core')); if ($identifier1 != "") { $array->add(new CFString($identifier1)); } // Save the newly created plist $plist->saveXML('../manifests/' . $hostname); }
function plist_create_file($structure, $dest) { require_once ROOT_PATH . '/lib/cfpropertylist/CFPropertyList.php'; /* * create a new CFPropertyList instance without loading any content */ $plist = new CFPropertyList(); $td = new CFTypeDetector(); $guessedStructure = $td->toCFType($structure); $plist->add($guessedStructure); $plist->saveXML($dest); }
public function writeToFile($aPath) { $plist = new CFPropertyList(); $td = new CFTypeDetector(); $struct = $td->toCFType($this->phpArray()); $plist->add($struct); $plist->saveXML($aPath); }