API 1.5.0

- Faster parsing of information
- Requests are compressed when possible
- Fixed some EnterpriseEval files being shown for Enterprise
- Names of packages for builds 17017 and newer are shorter
This commit is contained in:
mkuba50 2017-10-27 21:38:31 +02:00
parent 29b9672b9b
commit 603b445b24
3 changed files with 49 additions and 34 deletions

74
get.php
View File

@ -31,7 +31,7 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac
} }
foreach($pack as $val) { foreach($pack as $val) {
$temp = preg_grep('/'.$val.'.*\./i', $filesKeys); $temp = preg_grep('/'.$val.'.*/i', $filesKeys);
$filesTemp = array_merge($filesTemp, $temp); $filesTemp = array_merge($filesTemp, $temp);
} }
@ -124,21 +124,12 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac
$out = preg_replace('/<FileLocation>|<\/FileLocation>/', '', $out[0]); $out = preg_replace('/<FileLocation>|<\/FileLocation>/', '', $out[0]);
$files = array(); $files = array();
$removeFiles = array();
foreach($out as $val) { foreach($out as $val) {
preg_match('/<FileDigest>.*<\/FileDigest>/', $val, $sha1); preg_match('/<FileDigest>.*<\/FileDigest>/', $val, $sha1);
$sha1 = preg_replace('/<FileDigest>|<\/FileDigest>/', '', $sha1[0]); $sha1 = preg_replace('/<FileDigest>|<\/FileDigest>/', '', $sha1[0]);
$sha1 = bin2hex(base64_decode($sha1)); $sha1 = bin2hex(base64_decode($sha1));
preg_match('/<Url>.*<\/Url>/', $val, $url); preg_match('/files\/.{8}-.{4}-.{4}-.{4}-.{12}/', $val, $guid);
$url = preg_replace('/<Url>|<\/Url>/', '', $url[0]);
$url = html_entity_decode($url);
preg_match('/P1=.*?&/', $url, $expire);
if(isset($expire[0])) $expire = preg_replace('/P1=|&$/', '', $expire[0]);
preg_match('/files\/.{8}-.{4}-.{4}-.{4}-.{12}/', $url, $guid);
$guid = preg_replace('/files\/|\?$/', '', $guid[0]); $guid = preg_replace('/files\/|\?$/', '', $guid[0]);
if(empty($info[$sha1]['name'])) { if(empty($info[$sha1]['name'])) {
@ -155,33 +146,56 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac
if(!isset($fileSizes[$name])) $fileSizes[$name] = 0; if(!isset($fileSizes[$name])) $fileSizes[$name] = 0;
$temp = array(
'sha1' => $sha1,
'size' => $size,
'url' => $url,
'uuid' => $guid,
'expire' => intval($expire),
);
if(!preg_match('/\.psf$/', $name)) {
if($size > $fileSizes[$name]) { if($size > $fileSizes[$name]) {
preg_match('/<Url>.*<\/Url>/', $val, $url);
$url = preg_replace('/<Url>|<\/Url>/', '', $url[0]);
$url = html_entity_decode($url);
preg_match('/P1=.*?&/', $url, $expire);
if(isset($expire[0])) {
$expire = preg_replace('/P1=|&$/', '', $expire[0]);
}
$fileSizes[$name] = $size; $fileSizes[$name] = $size;
$files = array_merge($files, array($name => $temp));
} $temp = array();
} else { $temp['sha1'] = $sha1;
if(!preg_match('/^Windows10\.0-KB/', $name)) { $temp['size'] = $size;
$name = preg_replace('/\.psf$/', '', $name); $temp['url'] = $url;
$removeFiles = array_merge($removeFiles, array($name)); $temp['uuid'] = $guid;
$temp['expire'] = intval($expire);
$newName = preg_replace('/~31bf3856ad364e35/', '', $name);
$newName = preg_replace('/~~\.|~\./', '.', $newName);
$newName = preg_replace('/~/', '-', $newName);
$files[$newName] = $temp;
} }
} }
$psf = array_keys($files);
$psf = preg_grep('/\.psf$/i', $psf);
$index = 0;
$removeFiles = array();
foreach($psf as $val) {
$name = preg_replace('/\.psf$/i', '', $val);
$removeFiles[$index] = $name;
unset($files[$val]);
$index++;
} }
unset($index, $name);
if(!$uupFix) { if(!$uupFix) {
foreach($removeFiles as $val) { $temp = preg_grep('/'.$updateArch.'_.*|arm64.arm_.*/i', $removeFiles);
if(preg_match('/'.$updateArch.'_.*/i', $val)) {
if(isset($files[$val.'.cab'])) unset($files[$val.'.cab']);
}
foreach($temp as $key => $val) {
if(isset($files[$val.'.cab'])) unset($files[$val.'.cab']);
unset($removeFiles[$key]);
}
unset($temp);
foreach($removeFiles as $val) {
if(isset($files[$val.'.esd'])) { if(isset($files[$val.'.esd'])) {
if(isset($files[$val.'.cab'])) unset($files[$val.'.cab']); if(isset($files[$val.'.cab'])) unset($files[$val.'.cab']);
} }

View File

@ -16,7 +16,7 @@ limitations under the License.
*/ */
function uupApiVersion() { function uupApiVersion() {
return '1.4.1'; return '1.5.0';
} }
function uupApiPrintBrand() { function uupApiPrintBrand() {
@ -44,6 +44,7 @@ function sendWuPostRequest($url, $postData) {
curl_setopt($req, CURLOPT_HEADER, 0); curl_setopt($req, CURLOPT_HEADER, 0);
curl_setopt($req, CURLOPT_POST, 1); curl_setopt($req, CURLOPT_POST, 1);
curl_setopt($req, CURLOPT_RETURNTRANSFER, 1); curl_setopt($req, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($req, CURLOPT_ENCODING, '');
curl_setopt($req, CURLOPT_POSTFIELDS, $postData); curl_setopt($req, CURLOPT_POSTFIELDS, $postData);
curl_setopt($req, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($req, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($req, CURLOPT_HTTPHEADER, array( curl_setopt($req, CURLOPT_HTTPHEADER, array(

View File

@ -77,7 +77,7 @@ $packs = array(
'Microsoft-Windows-EditionSpecific-Enterprise-WOW64-Package', 'Microsoft-Windows-EditionSpecific-Enterprise-WOW64-Package',
'Microsoft-Windows-EditionSpecific-Enterprise-arm64arm-Package', 'Microsoft-Windows-EditionSpecific-Enterprise-arm64arm-Package',
'Microsoft\.ModernApps\.Client\.All', 'Microsoft\.ModernApps\.Client\.All',
'Microsoft\.ModernApps\.Client\.enterprise', 'Microsoft\.ModernApps\.Client\.enterprise\.',
), ),
'PROFESSIONAL' => array( 'PROFESSIONAL' => array(
'Microsoft-Windows-EditionPack-Professional-Package', 'Microsoft-Windows-EditionPack-Professional-Package',