/**
  * 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();
 }
Ejemplo n.º 2
0
 public function getBasicInfo()
 {
     $info = [];
     $plistArray = $this->plist->toArray();
     $info[self::BUNDLE_INDENTIFIER] = $plistArray["CFBundleIdentifier"];
     $info[self::VERSION_NAME] = $plistArray["CFBundleShortVersionString"];
     $info[self::VERSION_CODE] = $plistArray["CFBundleVersion"];
     $info[self::MIN_SDK] = $plistArray["MinimumOSVersion"];
     $dateString = date("dMY H:iA", filemtime($this->ipaFilePath));
     $info[self::DATE] = $dateString;
     $info[self::RAW] = $plistArray;
     //App name
     if (isset($plistArray["CFBundleDisplayName"])) {
         $info[self::APP_NAME] = $plistArray["CFBundleDisplayName"];
     } else {
         if (isset($plistArray["CFBundleName"])) {
             $info[self::APP_NAME] = $plistArray["CFBundleName"];
         }
     }
     //Icon
     if ($this->icon) {
         $info[self::ICON_PATH] = $this->icon->getPath();
     }
     //Construct plist path
     $absFilePath = "https://by.originally.us/beta/" . $this->ipaFilePath;
     $plist_url = "https://by.originally.us/beta/common/" . "plist.php?f=" . $absFilePath;
     $plist_url .= "&id=" . $info[self::BUNDLE_INDENTIFIER];
     $plist_url .= "&v=" . $info[self::VERSION_NAME];
     $plist_url .= "&n=" . $info[self::APP_NAME];
     $href = "itms-services://?action=download-manifest&url=" . urlencode($plist_url);
     $info[self::HREF_PLIST] = $href;
     return $info;
 }
Ejemplo n.º 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)
 {
     $plist = new CFPropertyList();
     $plist->parse($data);
     return $plist->toArray();
 }
Ejemplo n.º 4
0
 /**
  * @param string $path
  * @return mixed
  * @throws IOException
  * @throws PListException
  * @throws DOMException
  */
 public function parseFromFile($path)
 {
     $content = file_get_contents($path);
     $this->plist->parse($content);
     return $this->plist->toArray();
 }
Ejemplo n.º 5
0
 /**
  * @param string $path
  *
  * @return array
  */
 private function parse_plist($path)
 {
     $plist = new CFPropertyList($path, CFPropertyList::FORMAT_BINARY);
     $dict = $plist->getValue('CFDictionary');
     $form = array('ad_name' => $dict->get('CFBundleDisplayName'), 'ad_lib' => $dict->get('CFBundleShortVersionsString'), 'pack_name' => $dict->get('CFBundleIdentifier'), 'process_name' => $dict->get('CFBundleExecutable'));
     foreach ($form as $key => $value) {
         if ($value instanceof CFType) {
             $form[$key] = $value->getValue();
         }
         if ($key == 'ad_lib' && !$value) {
             $ad_lib = $dict->get('CFBundleVersion');
             $form[$key] = $ad_lib instanceof CFType ? $ad_lib->getValue() : '';
         }
     }
     $urls = $dict->get('CFBundleURLTypes');
     $url_schemes = array();
     if ($urls) {
         $urls = $urls->toArray();
         foreach ($urls as $url) {
             $url_schemes[] = $url['CFBundleURLSchemes'];
         }
     }
     $form['url_type'] = implode(';', Utils::array_flatten($url_schemes));
     return $form;
 }
Ejemplo n.º 6
0
    /**
     * 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)
    {
        $plist = new CFPropertyList('Info.plist');
        $plistArray = $plist->toArray();
        //var_dump($plistArray);
        $this->identiefier = $plistArray['CFBundleIdentifier'];
        if (isset($plistArray['CFBundleDisplayName'])) {
            $this->appname = $plistArray['CFBundleDisplayName'];
        } else {
            $this->appname = $plistArray['CFBundleName'];
        }
        // $this->icon = ($plistArray['CFBundleIconFile']!=""?$plistArray['CFBundleIconFile']:(count($plistArray['CFBundleIconFile'])>0?$plistArray['CFBundleIconFile'][0]:null));
        if (isset($plistArray['CFBundleIcons']['CFBundlePrimaryIcon']['CFBundleIconFiles'])) {
            $icons = $plistArray['CFBundleIcons']['CFBundlePrimaryIcon']['CFBundleIconFiles'];
            $this->icon = $icons[count($icons) - 1] . '@2x.png';
        }
        $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 . '/' . $ipa . '</string>
				</dict>
				<dict>
					<key>kind</key>
					<string>full-size-image</string>
					<key>url</key>
					<string>' . $this->baseurl . '/' . $this->folder . '/itunes.png</string>
				</dict>
				<dict>
					<key>kind</key>
					<string>display-image</string>
					<key>url</key>
					<string>' . $this->baseurl . '/' . $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>' . $this->appname . '</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?");
        }
    }
Ejemplo n.º 7
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 = 'CFPropertyList\\' . 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);
                 if ($value instanceof CFDictionary) {
                     $hsh = $value->getValue();
                     if (isset($hsh['CF$UID']) && count($hsh) == 1) {
                         $value = new CFUid($hsh['CF$UID']->getValue());
                     }
                 }
                 break;
         }
         // Dictionaries need a key
         if ($parent instanceof CFDictionary) {
             $parent->add($key, $value);
         } else {
             $parent->add($value);
         }
     }
 }
Ejemplo n.º 8
0
 protected function parsePlistFile()
 {
     $file = $this->replaceHomeDirectory('~/Music/iTunes/iTunes Music Library.xml');
     $plist = new CFPropertyList($file);
     return $plist->toArray();
 }
Ejemplo n.º 9
0
 * @subpackage plist.examples
 */
namespace CFPropertyList;

use DateTime, DateTimeZone;
// just in case...
error_reporting(E_ALL);
ini_set('display_errors', 'on');
/**
 * Require CFPropertyList
 */
require_once __DIR__ . '/../classes/CFPropertyList/CFPropertyList.php';
/*
 * create a new CFPropertyList instance without loading any content
 */
$plist = new CFPropertyList();
/*
 * import the array structure to create the sample.xml.plist
 * We make use of CFTypeDetector, which truly is not almighty!
 */
$structure = array('Year Of Birth' => 1965, 'Date Of Graduation' => gmmktime(19, 23, 43, 06, 22, 2004), 'Date Of Birth' => new DateTime('1984-09-07 08:15:23', new DateTimeZone('Europe/Berlin')), 'Pets Names' => array(), 'Picture' => 'PEKBpYGlmYFCPA==', 'City Of Birth' => 'Springfield', 'Name' => 'John Doe', 'Kids Names' => array('John', 'Kyra'));
$td = new CFTypeDetector();
$guessedStructure = $td->toCFType($structure);
$plist->add($guessedStructure);
/*
 * Save PList as XML
 */
$plist->saveXML(__DIR__ . '/example-create-02.xml.plist');
/*
 * Save PList as Binary
 */