diff --git a/fetchupd.php b/fetchupd.php index 71258a9..6693189 100644 --- a/fetchupd.php +++ b/fetchupd.php @@ -66,17 +66,50 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build $out = html_entity_decode($out); consoleLogger('Information has been successfully fetched.'); - consoleLogger('Checking build information...'); preg_match_all('/.*?<\/UpdateInfo>/', $out, $updateInfos); $updateInfo = preg_grep('/Install<\/Action>/', $updateInfos[0]); sort($updateInfo); - if(empty($updateInfo[0])) { + if(empty($updateInfo)) { consoleLogger('An error has occurred'); return array('error' => 'NO_UPDATE_FOUND'); } - $updateNumId = preg_replace('/|<\/ID>.*/i', '', $updateInfo[0]); + $errorCount = 0; + $updatesNum = count($updateInfo); + $num = 0; + $updateArray = array(); + + foreach($updateInfo as $val) { + $num++; + consoleLogger("Checking build information for update {$num} of {$updatesNum}..."); + + $info = parseFetchUpdate($val, $out, $arch, $ring, $flight, $build); + if(isset($info['error'])) { + $errorCount++; + continue; + } + + $updateArray[] = $info; + } + + if($errorCount == $updatesNum) { + return array('error' => 'EMPTY_FILELIST'); + } + + return array( + 'apiVersion' => uupApiVersion(), + 'updateId' => $updateArray[0]['updateId'], + 'updateTitle' => $updateArray[0]['updateTitle'], + 'foundBuild' => $updateArray[0]['foundBuild'], + 'arch' => $updateArray[0]['arch'], + 'fileWrite' => $updateArray[0]['foundBuild'], + 'updateArray' => $updateArray, + ); +} + +function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build) { + $updateNumId = preg_replace('/|<\/ID>.*/i', '', $updateInfo); $updates = preg_replace('//', "\n", $out); preg_match_all('/.*<\/Update>/', $updates, $updates); @@ -93,7 +126,7 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build return array('error' => 'EMPTY_FILELIST'); } - preg_match('/Version\=".*?"/', $updateInfo[0], $foundBuild); + preg_match('/Version\=".*?"/', $updateInfo, $foundBuild); $foundBuild = preg_replace('/Version="10\.0\.|"/', '', $foundBuild[0]); $updateTitle = preg_grep('/.*<\/Title>/', $updateMeta); @@ -111,18 +144,21 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build $isCumulativeUpdate = 0; if(preg_match('/Cumulative Update/', $updateTitle)) { + $isCumulativeUpdate = 1; $updateTitle = preg_replace('/.*Cumulative Update/i', 'Cumulative Update', $updateTitle); $updateTitle = preg_replace('/ for .{3,5}-based systems| \(KB.*?\)/i', '', $updateTitle); - $updateTitle = $updateTitle.' ('.$foundBuild.')'; - $isCumulativeUpdate = 1; + + if(!preg_match("/$foundBuild/", $updateTitle)) { + $updateTitle = $updateTitle.' ('.$foundBuild.')'; + } } if(preg_match('/Feature update/i', $updateTitle)) { $updateTitle = $updateTitle.' ('.$foundBuild.')'; } - preg_match('/UpdateID=".*?"/', $updateInfo[0], $updateId); - preg_match('/RevisionNumber=".*?"/', $updateInfo[0], $updateRev); + preg_match('/UpdateID=".*?"/', $updateInfo, $updateId); + preg_match('/RevisionNumber=".*?"/', $updateInfo, $updateRev); $updateId = preg_replace('/UpdateID="|"$/', '', $updateId[0]); $updateRev = preg_replace('/RevisionNumber="|"$/', '', $updateRev[0]); @@ -218,7 +254,6 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build } return array( - 'apiVersion' => uupApiVersion(), 'updateId' => $updateString, 'updateTitle' => $updateTitle, 'foundBuild' => $foundBuild, diff --git a/get.php b/get.php index d89888b..4025188 100644 --- a/get.php +++ b/get.php @@ -43,6 +43,7 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac $info = array( 'ring' => 'WIF', 'flight' => 'Active', + 'arch' => 'amd64', 'checkBuild' => '10.0.16251.0', 'files' => array(), ); diff --git a/shared/main.php b/shared/main.php index a8f7176..8cbd468 100644 --- a/shared/main.php +++ b/shared/main.php @@ -16,7 +16,7 @@ limitations under the License. */ function uupApiVersion() { - return '1.11.1'; + return '1.12.0'; } function uupApiPrintBrand() {