From 352398a3096d0377ddc3bbaec3012cfa6ec137dd Mon Sep 17 00:00:00 2001 From: mkuba50 Date: Fri, 3 Nov 2017 19:33:17 +0100 Subject: [PATCH] API 1.6.0 - build number for fetching can be provided using build.minor format - added size prediction for files that are not in database --- fetchupd.php | 4 ++++ get.php | 32 +++++++++++++++++++++----------- shared/main.php | 2 +- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/fetchupd.php b/fetchupd.php index 8a9ab57..afba2af 100644 --- a/fetchupd.php +++ b/fetchupd.php @@ -27,6 +27,10 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build $flight = ucwords(strtolower($flight)); if($flight == 'Current') $flight = 'Active'; + $build = explode('.', $build); + if(isset($build[1])) $minor = intval($build[1]); + $build = intval($build[0]); + if(!($arch == 'amd64' || $arch == 'x86' || $arch == 'arm64')) { return array('error' => 'UNKNOWN_ARCH'); } diff --git a/get.php b/get.php index f1b36c9..db436e1 100644 --- a/get.php +++ b/get.php @@ -70,8 +70,8 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac if(empty($info)) { $info = array( 'ring' => 'WIF', - 'flight' => 'Skip', - 'checkBuild' => '10.0.16232.0', + 'flight' => 'Active', + 'checkBuild' => '10.0.16251.0', 'files' => array(), ); } else { @@ -90,6 +90,7 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac $updateId = preg_replace('/_rev\..*/', '', $updateId); } + $fetchTime = time(); consoleLogger('Fetching information from the server...'); $postData = composeFileGetRequest($updateId, uupDevice(), $info, $rev); $out = sendWuPostRequest('https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured', $postData); @@ -109,9 +110,9 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac $files = array(); foreach($out as $val) { - preg_match('/.*<\/FileDigest>/', $val, $sha1); - $sha1 = preg_replace('/|<\/FileDigest>/', '', $sha1[0]); - $sha1 = bin2hex(base64_decode($sha1)); + $sha1 = explode('', $val, 2); + $sha1 = explode('', $sha1[1], 2); + $sha1 = bin2hex(base64_decode($sha1[0])); preg_match('/files\/.{8}-.{4}-.{4}-.{4}-.{12}/', $val, $guid); $guid = preg_replace('/files\/|\?$/', '', $guid[0]); @@ -123,23 +124,32 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac } if(empty($info[$sha1]['name'])) { - $size = 0; + $size = -1; } else { $size = $info[$sha1]['size']; } - if(!isset($fileSizes[$name])) $fileSizes[$name] = 0; + if(!isset($fileSizes[$name])) $fileSizes[$name] = -2; if($size > $fileSizes[$name]) { - preg_match('/.*<\/Url>/', $val, $url); - $url = preg_replace('/|<\/Url>/', '', $url[0]); - $url = html_entity_decode($url); + $url = explode('', $val, 2); + $url = explode('', $url[1], 2); + $url = html_entity_decode($url[0]); preg_match('/P1=.*?&/', $url, $expire); if(isset($expire[0])) { $expire = preg_replace('/P1=|&$/', '', $expire[0]); } + $expire = intval($expire); + + if($size < 0) { + $temp = ($expire - $fetchTime) / 600; + $size = ($temp - 1) * 31457280; + if($size < 0) $size = 0; + unset($temp); + } + $fileSizes[$name] = $size; $temp = array(); @@ -147,7 +157,7 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac $temp['size'] = $size; $temp['url'] = $url; $temp['uuid'] = $guid; - $temp['expire'] = intval($expire); + $temp['expire'] = $expire; $newName = preg_replace('/~31bf3856ad364e35/', '', $name); $newName = preg_replace('/~~\.|~\./', '.', $newName); diff --git a/shared/main.php b/shared/main.php index 11d9d11..edf0dd4 100644 --- a/shared/main.php +++ b/shared/main.php @@ -16,7 +16,7 @@ limitations under the License. */ function uupApiVersion() { - return '1.5.1'; + return '1.6.0'; } function uupApiPrintBrand() {