Beispiel #1
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();
 }
Beispiel #2
0
 public function toCFType($value)
 {
     if ($value instanceof PListException) {
         return new CFString($value->getMessage());
     }
     return parent::toCFType($value);
 }
Beispiel #3
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);
}
Beispiel #5
0
 /**
  * Create CFType-structure from guessing the data-types.
  * The functionality has been moved to the more flexible {@link CFTypeDetector} facility.
  * @param mixed $value Value to convert to CFType
  * @param boolean $autoDictionary if true {@link CFArray}-detection is bypassed and arrays will be returned as {@link CFDictionary}.
  * @return CFType CFType based on guessed type
  * @uses CFTypeDetector for actual type detection
  * @deprecated
  */
 public static function guess($value, $autoDictionary = false)
 {
     static $t = null;
     if ($t === null) {
         $t = new CFTypeDetector($autoDictionary);
     }
     return $t->toCFType($value);
 }
 * Create the PropertyList sample.xml.plist by using {@link CFTypeDetector}.
 * @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 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(dirname(__FILE__) . '/example-create-02.xml.plist');
/*
 * Save PList as Binary
 */
$plist->saveBinary(dirname(__FILE__) . '/example-create-02.binary.plist');
 /**
  * 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;
 }
Beispiel #8
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);
}
Beispiel #10
0
 public function writeToFile($aPath)
 {
     $plist = new CFPropertyList();
     $td = new CFTypeDetector();
     $struct = $td->toCFType($this->phpArray());
     $plist->add($struct);
     $plist->saveXML($aPath);
 }