Changes

Jump to: navigation, search

ITunes

1,484 bytes added, 10:21, 11 March 2015
Pre-Setup Process - automation
* Open the file with 7zip or another file archiver
* Extract iTunes.msi, AppleApplicationSupport.msi and AppleMobileDeviceSupport.msi
 
<pre>
<?php
# simple script for download and extract iTunes MSI packages
 
$url = 'https://www.apple.com/itunes/download/';
libxml_use_internal_errors(true);
 
$dom = new DOMDocument();
$dom->loadHTML(stahni($url));
$xpath = new DOMXPath($dom);
$iframe = $xpath->query("//iframe");
$iframe_url = $iframe->item(0)->getAttribute('src');
 
$dom->loadHTML(stahni($iframe_url));
$xpath = new DOMXPath($dom);
$downloads = $xpath->query("//input[@type='hidden']");
 
foreach ($downloads as $link) {
$foo = $link->getAttribute("value");
if(preg_match('/\.exe$/', $foo)){
$filename = basename($foo);
system("wget --no-check-certificate -O $filename $foo");
$dirname = preg_replace('/\.exe$/', '', $filename);
if(!is_dir($dirname)){
mkdir($dirname);
}
system("7z e -o$dirname $filename");
}
}
 
function stahni($url){
$ch = curl_init();
$timeout = 10;
$useragent = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.65 Safari/537.36';
$proxy = 'proxy.example.com:3128';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch,CURLOPT_ENCODING, '');
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
</pre>
== Notes ==
18
edits

Navigation menu