title: getting iPhone UDID from .mobileconfig
body: <p>I'm having problem with getting device info from .mobileconfig. 
  Here is the steps i've done:</p>
  
  <p><strong>device.mobileconfig:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
  &lt;plist version="1.0"&gt;
  &lt;dict&gt;
      &lt;key&gt;PayloadContent&lt;/key&gt;
      &lt;dict&gt;
          &lt;key&gt;URL&lt;/key&gt;
          &lt;string&gt;http://mywebsite.ir/retrieve/get.php&lt;/string&gt;
      &lt;key&gt;DeviceAttributes&lt;/key&gt;
      &lt;array&gt;
          &lt;string&gt;UDID&lt;/string&gt;
          &lt;string&gt;VERSION&lt;/string&gt;
          &lt;string&gt;PRODUCT&lt;/string&gt;
      &lt;/array&gt;
  &lt;/dict&gt;
  &lt;key&gt;PayloadOrganization&lt;/key&gt;
  &lt;string&gt;MyWebsite.ir&lt;/string&gt;
  &lt;key&gt;PayloadDisplayName&lt;/key&gt;
  &lt;string&gt;Device Information&lt;/string&gt;
  &lt;key&gt;PayloadVersion&lt;/key&gt;
  &lt;integer&gt;1&lt;/integer&gt;
  &lt;key&gt;PayloadUUID&lt;/key&gt;
  &lt;string&gt;fab376e5-b5bc-4d8c-829e-e90865f990c9&lt;/string&gt;
  &lt;key&gt;PayloadIdentifier&lt;/key&gt;
  &lt;string&gt;com.MyWebsite.mobileconfig.device-information&lt;/string&gt;
  &lt;key&gt;PayloadDescription&lt;/key&gt;
  &lt;string&gt;Device information&lt;/string&gt;
  &lt;key&gt;PayloadType&lt;/key&gt;
  &lt;string&gt;Profile Service&lt;/string&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>
  
  <p>when I install the profile on my iOS device, it will be installed and redirected to mywebsite.ir/retrieve/get.php</p>
  
  <p><strong>The content of get.php is:</strong></p>
  
  <pre><code>$data = file_get_contents('php://input');
  file_put_contents("data.txt", $data);
  
  $plistBegin   = '&lt;?xml version="1.0"';
  $plistEnd   = '&lt;/plist&gt;';
  
  $pos1 = strpos($data, $plistBegin);
  $pos2 = strpos($data, $plistEnd);
  
  $data2 = substr ($data,$pos1,$pos2-$pos1);
  
  $xml = xml_parser_create();
  
  xml_parse_into_struct($xml, $data2, $vs);
  xml_parser_free($xml);
  
  $UDID = "";
  $DEVICE_PRODUCT = "";
  $DEVICE_VERSION = "";
  $iterator = 0;
  
  $arrayCleaned = array();
  
  foreach($vs as $v){
  
      if($v['level'] == 3 &amp;&amp; $v['type'] == 'complete'){
          $arrayCleaned[]= $v;
      }
      $iterator++;
  }
  
  $data = "";
  
  $iterator = 0;
  
  foreach($arrayCleaned as $elem){
      $data .= "\n==".$elem['tag']." -&gt; ".$elem['value']."&lt;br/&gt;";
      switch ($elem['value']) {
          case "DEVICE_NAME":
              $DEVICE_NAME = $arrayCleaned[$iterator+1]['value'];
              break;
          case "PRODUCT":
              $DEVICE_PRODUCT = $arrayCleaned[$iterator+1]['value'];
              break;
          case "UDID":
              $UDID = $arrayCleaned[$iterator+1]['value'];
              break;
          case "VERSION":
              $DEVICE_VERSION = $arrayCleaned[$iterator+1]['value'];
              break;
      }
      $iterator++;
  }
  
  $params = "UDID: ".$UDID."\n"."DEVICE_PRODUCT: ".$DEVICE_PRODUCT."\n"."DEVICE_VERSION: ".$DEVICE_VERSION;
  file_put_contents("data2.txt", $params);
  
  header("Location: http://mywebsite.ir/retrieve/msg?params=done");
  </code></pre>
  
  <p>At the end, two files(data.txt and data2.txt) are being stored on /retrive but both are empty. It seems that no any data is being sent to the script from iOS device because data.txt is empty whereas it must contains some data for parsing. However, the profile is being installed with no error and being redirected to the script.</p>
  
  <p>Any ideas?</p>
  
  <hr>
  
  <p>I' just found out what the problem is.
  my server has disabled some php functions due to security matters. i have this code and would like to change it to "Curl" and "readfile" functions. can anyone help me please?</p>
  
  <pre><code>&lt;?php
      $data = file_get_contents('php://input');
      file_put_contents("dat.txt", $data);
  ?&gt;
  </code></pre>