From 603b445b249beed17eb470b43affe20a57072010 Mon Sep 17 00:00:00 2001 From: mkuba50 Date: Fri, 27 Oct 2017 21:38:31 +0200 Subject: [PATCH] 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 --- get.php | 78 ++++++++++++++++++++++++++++-------------------- shared/main.php | 3 +- shared/packs.php | 2 +- 3 files changed, 49 insertions(+), 34 deletions(-) diff --git a/get.php b/get.php index ed89b29..5f1f060 100644 --- a/get.php +++ b/get.php @@ -31,7 +31,7 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac } foreach($pack as $val) { - $temp = preg_grep('/'.$val.'.*\./i', $filesKeys); + $temp = preg_grep('/'.$val.'.*/i', $filesKeys); $filesTemp = array_merge($filesTemp, $temp); } @@ -124,21 +124,12 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac $out = preg_replace('/|<\/FileLocation>/', '', $out[0]); $files = array(); - $removeFiles = array(); - foreach($out as $val) { preg_match('/.*<\/FileDigest>/', $val, $sha1); $sha1 = preg_replace('/|<\/FileDigest>/', '', $sha1[0]); $sha1 = bin2hex(base64_decode($sha1)); - preg_match('/.*<\/Url>/', $val, $url); - $url = preg_replace('/|<\/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); + preg_match('/files\/.{8}-.{4}-.{4}-.{4}-.{12}/', $val, $guid); $guid = preg_replace('/files\/|\?$/', '', $guid[0]); 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; - $temp = array( - 'sha1' => $sha1, - 'size' => $size, - 'url' => $url, - 'uuid' => $guid, - 'expire' => intval($expire), - ); + if($size > $fileSizes[$name]) { + preg_match('/.*<\/Url>/', $val, $url); + $url = preg_replace('/|<\/Url>/', '', $url[0]); + $url = html_entity_decode($url); - if(!preg_match('/\.psf$/', $name)) { - if($size > $fileSizes[$name]) { - $fileSizes[$name] = $size; - $files = array_merge($files, array($name => $temp)); - } - } else { - if(!preg_match('/^Windows10\.0-KB/', $name)) { - $name = preg_replace('/\.psf$/', '', $name); - $removeFiles = array_merge($removeFiles, array($name)); + preg_match('/P1=.*?&/', $url, $expire); + if(isset($expire[0])) { + $expire = preg_replace('/P1=|&$/', '', $expire[0]); } + + $fileSizes[$name] = $size; + + $temp = array(); + $temp['sha1'] = $sha1; + $temp['size'] = $size; + $temp['url'] = $url; + $temp['uuid'] = $guid; + $temp['expire'] = intval($expire); + + $newName = preg_replace('/~31bf3856ad364e35/', '', $name); + $newName = preg_replace('/~~\.|~\./', '.', $newName); + $newName = preg_replace('/~/', '-', $newName); + + $files[$newName] = $temp; } } - if(!$uupFix) { - foreach($removeFiles as $val) { - if(preg_match('/'.$updateArch.'_.*/i', $val)) { - if(isset($files[$val.'.cab'])) unset($files[$val.'.cab']); - } + $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) { + $temp = preg_grep('/'.$updateArch.'_.*|arm64.arm_.*/i', $removeFiles); + + 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.'.cab'])) unset($files[$val.'.cab']); } diff --git a/shared/main.php b/shared/main.php index cacbf5a..a5d9788 100644 --- a/shared/main.php +++ b/shared/main.php @@ -16,7 +16,7 @@ limitations under the License. */ function uupApiVersion() { - return '1.4.1'; + return '1.5.0'; } function uupApiPrintBrand() { @@ -44,6 +44,7 @@ function sendWuPostRequest($url, $postData) { curl_setopt($req, CURLOPT_HEADER, 0); curl_setopt($req, CURLOPT_POST, 1); curl_setopt($req, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($req, CURLOPT_ENCODING, ''); curl_setopt($req, CURLOPT_POSTFIELDS, $postData); curl_setopt($req, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($req, CURLOPT_HTTPHEADER, array( diff --git a/shared/packs.php b/shared/packs.php index b8d12e8..6ba5a0c 100644 --- a/shared/packs.php +++ b/shared/packs.php @@ -77,7 +77,7 @@ $packs = array( 'Microsoft-Windows-EditionSpecific-Enterprise-WOW64-Package', 'Microsoft-Windows-EditionSpecific-Enterprise-arm64arm-Package', 'Microsoft\.ModernApps\.Client\.All', - 'Microsoft\.ModernApps\.Client\.enterprise', + 'Microsoft\.ModernApps\.Client\.enterprise\.', ), 'PROFESSIONAL' => array( 'Microsoft-Windows-EditionPack-Professional-Package',