protected function generatePlistFromData()
 {
     $plist = new CFPropertyList();
     $plist->add($array = new CFArray());
     while ($entry = $this->getData()->next()) {
         $array->add($this->formatEntryAsPlist($entry));
     }
     return $plist;
 }
示例#2
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());
    }
示例#4
0
 public function encode($data, $human_readable = false)
 {
     require_once 'CFPropertyList.php';
     if (!PlistFormat::$binary_mode) {
         PlistFormat::$binary_mode = !$human_readable;
     } else {
         $human_readable = false;
     }
     $plist = new CFPropertyList();
     $td = new CFTypeDetector();
     $guessedStructure = $td->toCFType(object_to_array($data));
     $plist->add($guessedStructure);
     return $human_readable ? $plist->toXML(true) : $plist->toBinary();
 }
示例#5
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);
 }
示例#6
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);
}
示例#7
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;
 }
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);
}
示例#9
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";
}
示例#10
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);
}
示例#11
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);
         }
     }
 }
 /**
  * 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;
 }
示例#13
0
function plist_render($structure)
{
    if ($_GET['test'] == 1) {
        echo '<pre>' . print_r($structure, true) . '</pre>';
        return;
    }
    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);
    echo $plist->toXML(true);
}
function generateDownloadPlistFile($version)
{
    $payload_assets_content = array();
    $payload_assets_content['kind'] = 'software-package';
    $payload_assets_content['url'] = Tools::rel2abs(UPLOAD_PATH . $version->getToken() . '/app_bundle.ipa', Tools::current_url());
    $payload_content = array();
    $payload_content['assets'] = array($payload_assets_content);
    $payload_metadata_content = array();
    $payload_metadata_content['bundle-identifier'] = $version->getApplication()->getBundleId();
    $payload_metadata_content['kind'] = 'software';
    $payload_metadata_content['title'] = $version->getName();
    $payload_content['metadata'] = $payload_metadata_content;
    $payload = array();
    $payload['items'] = array($payload_content);
    $plist = new CFPropertyList();
    $td = new CFTypeDetector();
    $cfPayload = $td->toCFType($payload);
    $plist->add($cfPayload);
    $data = $plist->toXML(true);
    $my_file = __DIR__ . '/' . UPLOAD_PATH . $version->getToken() . '.plist';
    $handle = fopen($my_file, 'w') or die('Cannot open file:  ' . $my_file);
    fwrite($handle, $data);
}
示例#15
0
 public function writeToFile($aPath)
 {
     $plist = new CFPropertyList();
     $td = new CFTypeDetector();
     $struct = $td->toCFType($this->phpArray());
     $plist->add($struct);
     $plist->saveXML($aPath);
 }