2017-09-22 21:24:31 +02:00
|
|
|
<?php
|
|
|
|
/*
|
2021-01-19 08:06:51 +01:00
|
|
|
Copyright 2021 whatever127
|
2017-09-22 21:24:31 +02:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2017-09-29 23:40:56 +02:00
|
|
|
require_once dirname(__FILE__).'/shared/main.php';
|
|
|
|
require_once dirname(__FILE__).'/shared/requests.php';
|
2022-08-25 17:46:16 +02:00
|
|
|
require_once dirname(__FILE__).'/shared/cache.php';
|
2022-09-13 23:41:43 +02:00
|
|
|
require_once dirname(__FILE__).'/shared/fileinfo.php';
|
2017-09-30 16:38:26 +02:00
|
|
|
require_once dirname(__FILE__).'/listid.php';
|
2017-09-23 17:47:19 +02:00
|
|
|
|
2023-11-03 20:13:28 +01:00
|
|
|
function uupApiPrivateParseFlags($str) {
|
|
|
|
$split = explode('+', $str);
|
2023-11-09 20:36:28 +01:00
|
|
|
$flagsSafe = [];
|
2023-11-03 20:13:28 +01:00
|
|
|
|
2023-11-09 20:29:25 +01:00
|
|
|
if(isset($split[1])) {
|
|
|
|
$flags = array_unique(explode(',', strtolower($split[1])));
|
|
|
|
$flagsSafe = array_intersect(getAllowedFlags(), $flags);
|
|
|
|
}
|
2023-11-03 20:13:28 +01:00
|
|
|
|
2023-11-09 20:29:25 +01:00
|
|
|
return [$split[0], $flagsSafe];
|
2023-11-03 20:13:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function uupApiPrivateGetLatestBuild() {
|
|
|
|
$builds = array('22000.1');
|
|
|
|
|
|
|
|
$ids = uupListIds();
|
|
|
|
if(isset($ids['error'])) {
|
|
|
|
$ids['builds'] = array();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(empty($ids['builds'])) {
|
|
|
|
$build = $builds[0];
|
|
|
|
} else {
|
|
|
|
$build = $ids['builds'][0]['build'];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $build;
|
|
|
|
}
|
|
|
|
|
2024-02-28 18:38:42 +01:00
|
|
|
function uupApiPrivateGetAcceptableBranches() {
|
|
|
|
return [
|
|
|
|
'auto',
|
|
|
|
'rs2_release',
|
|
|
|
'rs3_release',
|
|
|
|
'rs4_release',
|
|
|
|
'rs5_release',
|
|
|
|
'rs5_release_svc_hci',
|
|
|
|
'19h1_release',
|
|
|
|
'vb_release',
|
|
|
|
'fe_release_10x',
|
|
|
|
'fe_release',
|
|
|
|
'co_release',
|
|
|
|
'ni_release',
|
|
|
|
'zn_release',
|
|
|
|
'ge_release',
|
|
|
|
'rs_prerelease',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
function uupApiPrivateNormalizeFetchParams($params) {
|
|
|
|
$np = array_replace([
|
|
|
|
'arch' => 'amd64',
|
|
|
|
'ring' => 'WIF',
|
|
|
|
'flight' => 'Active',
|
|
|
|
'branch' => 'ge_release',
|
|
|
|
'build' => 'latest',
|
2024-03-12 20:50:07 +01:00
|
|
|
'minor' => 0,
|
2024-02-28 18:38:42 +01:00
|
|
|
'sku' => 48,
|
|
|
|
'type' => 'Production',
|
|
|
|
'flags' => [],
|
|
|
|
], $params);
|
|
|
|
|
|
|
|
if(!is_array($np['flags'])) $np['flags'] = [];
|
|
|
|
|
|
|
|
$np['arch'] = strtolower($np['arch']);
|
|
|
|
$np['ring'] = strtoupper($np['ring']);
|
|
|
|
$np['flight'] = ucwords(strtolower($np['flight']));
|
|
|
|
$np['branch'] = strtolower($np['branch']);
|
|
|
|
$np['build'] = strtolower($np['build']);
|
2024-03-12 20:50:07 +01:00
|
|
|
$np['minor'] = intval($np['minor']);
|
2024-02-28 18:38:42 +01:00
|
|
|
$np['sku'] = intval($np['sku']);
|
|
|
|
$np['type'] = ucwords(strtolower($np['type']));
|
|
|
|
$np['flags'] = array_map('strtolower', $np['flags']);
|
|
|
|
|
|
|
|
return $np;
|
|
|
|
}
|
|
|
|
|
2018-11-16 17:59:48 +01:00
|
|
|
function uupFetchUpd(
|
|
|
|
$arch = 'amd64',
|
|
|
|
$ring = 'WIF',
|
|
|
|
$flight = 'Active',
|
|
|
|
$build = 'latest',
|
|
|
|
$minor = '0',
|
|
|
|
$sku = '48',
|
2021-02-06 14:26:21 +01:00
|
|
|
$type = 'Production',
|
2018-11-16 17:59:48 +01:00
|
|
|
$cacheRequests = 0
|
|
|
|
) {
|
2024-02-28 18:38:42 +01:00
|
|
|
[$build, $flags] = uupApiPrivateParseFlags($build);
|
|
|
|
|
|
|
|
$params = [
|
|
|
|
'arch' => $arch,
|
|
|
|
'ring' => $ring,
|
|
|
|
'flight' => $flight,
|
|
|
|
'build' => $build,
|
2024-03-12 20:50:07 +01:00
|
|
|
'minor' => $minor,
|
2024-02-28 18:38:42 +01:00
|
|
|
'sku' => $sku,
|
|
|
|
'type' => $type,
|
|
|
|
'flags' => $flags,
|
|
|
|
];
|
|
|
|
|
|
|
|
return uupFetchUpd2($params, $cacheRequests);
|
|
|
|
}
|
|
|
|
|
|
|
|
function uupFetchUpd2($params, $cacheRequests = 0) {
|
2017-09-23 17:47:19 +02:00
|
|
|
uupApiPrintBrand();
|
2017-09-22 21:24:31 +02:00
|
|
|
|
2024-02-28 18:38:42 +01:00
|
|
|
$np = uupApiPrivateNormalizeFetchParams($params);
|
|
|
|
|
|
|
|
$arch = $np['arch'];
|
|
|
|
$ring = $np['ring'];
|
2020-07-15 04:07:06 +02:00
|
|
|
$flight = 'Active';
|
2024-02-28 18:38:42 +01:00
|
|
|
$branch = $np['branch'];
|
|
|
|
$build = $np['build'];
|
2024-03-12 20:50:07 +01:00
|
|
|
$minor = $np['minor'];
|
2024-02-28 18:38:42 +01:00
|
|
|
$sku = $np['sku'];
|
|
|
|
$type = $np['type'];
|
|
|
|
$flags = $np['flags'];
|
2017-09-22 21:24:31 +02:00
|
|
|
|
2023-11-09 20:36:28 +01:00
|
|
|
$flagsStr = implode(',', $flags);
|
2018-06-14 19:40:51 +02:00
|
|
|
|
2023-11-11 03:39:16 +01:00
|
|
|
if(strtolower($build) == 'latest' || (!$build)) {
|
2023-11-03 20:13:28 +01:00
|
|
|
$build = uupApiPrivateGetLatestBuild();
|
2018-06-14 19:40:51 +02:00
|
|
|
}
|
|
|
|
|
2017-11-03 19:33:17 +01:00
|
|
|
$build = explode('.', $build);
|
|
|
|
if(isset($build[1])) $minor = intval($build[1]);
|
|
|
|
$build = intval($build[0]);
|
|
|
|
|
2019-06-16 19:00:45 +02:00
|
|
|
if(!($arch == 'amd64' || $arch == 'x86' || $arch == 'arm64' || $arch == 'arm' || $arch == 'all')) {
|
2017-09-22 21:24:31 +02:00
|
|
|
return array('error' => 'UNKNOWN_ARCH');
|
|
|
|
}
|
|
|
|
|
2023-03-14 16:09:51 +01:00
|
|
|
if(!($ring == 'CANARY' || $ring == 'DEV' || $ring == 'BETA' || $ring == 'RELEASEPREVIEW' || $ring == 'WIF' || $ring == 'WIS' || $ring == 'RP' || $ring == 'RETAIL' || $ring == 'MSIT')) {
|
2017-09-22 21:24:31 +02:00
|
|
|
return array('error' => 'UNKNOWN_RING');
|
|
|
|
}
|
|
|
|
|
2020-07-15 04:07:06 +02:00
|
|
|
if(!($flight == 'Mainline' || $flight == 'Active' || $flight == 'Skip')) {
|
2017-09-22 21:24:31 +02:00
|
|
|
return array('error' => 'UNKNOWN_FLIGHT');
|
|
|
|
}
|
|
|
|
|
|
|
|
if($flight == 'Skip' && $ring != 'WIF') {
|
|
|
|
return array('error' => 'UNKNOWN_COMBINATION');
|
|
|
|
}
|
|
|
|
|
2019-01-25 20:29:53 +01:00
|
|
|
if($build < 9841 || $build > PHP_INT_MAX-1) {
|
2017-09-22 21:24:31 +02:00
|
|
|
return array('error' => 'ILLEGAL_BUILD');
|
|
|
|
}
|
|
|
|
|
2019-01-25 20:29:53 +01:00
|
|
|
if($minor < 0 || $minor > PHP_INT_MAX-1) {
|
2017-10-13 22:55:46 +02:00
|
|
|
return array('error' => 'ILLEGAL_MINOR');
|
|
|
|
}
|
|
|
|
|
2024-02-28 18:38:42 +01:00
|
|
|
if(!in_array($branch, uupApiPrivateGetAcceptableBranches()))
|
|
|
|
$branch = 'auto';
|
|
|
|
|
2020-07-15 04:07:06 +02:00
|
|
|
if($ring == 'DEV') $ring = 'WIF';
|
|
|
|
if($ring == 'BETA') $ring = 'WIS';
|
|
|
|
if($ring == 'RELEASEPREVIEW') $ring = 'RP';
|
|
|
|
|
2017-09-22 21:24:31 +02:00
|
|
|
if($flight == 'Active' && $ring == 'RP') $flight = 'Current';
|
|
|
|
|
2017-10-13 22:55:46 +02:00
|
|
|
$build = '10.0.'.$build.'.'.$minor;
|
2017-09-22 21:24:31 +02:00
|
|
|
|
2021-02-06 14:26:21 +01:00
|
|
|
$type = ucwords(strtolower($type));
|
|
|
|
if(!($type == 'Production' || $type == 'Test')) {
|
|
|
|
$type = 'Production';
|
|
|
|
}
|
|
|
|
|
2024-02-28 18:38:42 +01:00
|
|
|
$res = "api-fetch-$arch-$ring-$flight-$branch-$build-$flagsStr-$minor-$sku-$type";
|
2022-08-25 17:46:16 +02:00
|
|
|
$cache = new UupDumpCache($res);
|
2022-10-22 01:20:13 +02:00
|
|
|
$fromCache = $cache->get();
|
|
|
|
if($fromCache !== false) return $fromCache;
|
2018-11-16 17:59:48 +01:00
|
|
|
|
2022-10-22 01:20:13 +02:00
|
|
|
consoleLogger('Fetching information from the server...');
|
2024-02-28 18:38:42 +01:00
|
|
|
$composerArgs = [$arch, $flight, $ring, $build, $sku, $type, $flags, $branch];
|
2023-10-21 02:34:51 +02:00
|
|
|
$out = sendWuPostRequestHelper('client', 'composeFetchUpdRequest', $composerArgs);
|
2023-11-08 23:58:39 +01:00
|
|
|
if($out === false || $out['error'] != 200) {
|
2023-10-21 02:34:51 +02:00
|
|
|
consoleLogger('The request has failed');
|
|
|
|
return array('error' => 'WU_REQUEST_FAILED');
|
|
|
|
}
|
2018-11-16 17:59:48 +01:00
|
|
|
|
2023-10-21 02:34:51 +02:00
|
|
|
$out = html_entity_decode($out['out']);
|
2022-10-22 01:20:13 +02:00
|
|
|
consoleLogger('Information has been successfully fetched.');
|
2017-09-22 21:24:31 +02:00
|
|
|
|
2017-10-13 22:55:46 +02:00
|
|
|
preg_match_all('/<UpdateInfo>.*?<\/UpdateInfo>/', $out, $updateInfos);
|
2019-05-24 18:25:57 +02:00
|
|
|
$updateInfo = preg_grep('/<IsLeaf>true<\/IsLeaf>/', $updateInfos[0]);
|
2017-10-13 22:55:46 +02:00
|
|
|
sort($updateInfo);
|
|
|
|
|
2018-04-11 18:01:27 +02:00
|
|
|
if(empty($updateInfo)) {
|
2017-10-13 22:55:46 +02:00
|
|
|
consoleLogger('An error has occurred');
|
|
|
|
return array('error' => 'NO_UPDATE_FOUND');
|
|
|
|
}
|
|
|
|
|
2018-04-11 18:01:27 +02:00
|
|
|
$errorCount = 0;
|
|
|
|
$updatesNum = count($updateInfo);
|
|
|
|
$num = 0;
|
|
|
|
$updateArray = array();
|
|
|
|
|
|
|
|
foreach($updateInfo as $val) {
|
|
|
|
$num++;
|
|
|
|
consoleLogger("Checking build information for update {$num} of {$updatesNum}...");
|
|
|
|
|
2024-02-28 18:38:42 +01:00
|
|
|
$info = parseFetchUpdate($val, $out, $arch, $ring, $flight, $build, $sku, $type, $flags, $branch);
|
2018-04-11 18:01:27 +02:00
|
|
|
if(isset($info['error'])) {
|
|
|
|
$errorCount++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$updateArray[] = $info;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($errorCount == $updatesNum) {
|
|
|
|
return array('error' => 'EMPTY_FILELIST');
|
|
|
|
}
|
|
|
|
|
2022-10-22 01:20:13 +02:00
|
|
|
$data = [
|
2018-04-11 18:01:27 +02:00
|
|
|
'apiVersion' => uupApiVersion(),
|
|
|
|
'updateId' => $updateArray[0]['updateId'],
|
|
|
|
'updateTitle' => $updateArray[0]['updateTitle'],
|
|
|
|
'foundBuild' => $updateArray[0]['foundBuild'],
|
|
|
|
'arch' => $updateArray[0]['arch'],
|
2019-09-14 17:26:57 +02:00
|
|
|
'fileWrite' => $updateArray[0]['fileWrite'],
|
2018-04-11 18:01:27 +02:00
|
|
|
'updateArray' => $updateArray,
|
2022-10-22 01:20:13 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
if($cacheRequests == 1) {
|
|
|
|
$cache->put($data, 120);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
2018-04-11 18:01:27 +02:00
|
|
|
}
|
|
|
|
|
2024-02-28 18:38:42 +01:00
|
|
|
function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku, $type, $flags, $branch) {
|
2018-04-11 18:01:27 +02:00
|
|
|
$updateNumId = preg_replace('/<UpdateInfo><ID>|<\/ID>.*/i', '', $updateInfo);
|
2017-10-13 22:55:46 +02:00
|
|
|
|
|
|
|
$updates = preg_replace('/<Update>/', "\n<Update>", $out);
|
|
|
|
preg_match_all('/<Update>.*<\/Update>/', $updates, $updates);
|
|
|
|
|
|
|
|
$updateMeta = preg_grep('/<ID>'.$updateNumId.'<\/ID>/', $updates[0]);
|
|
|
|
sort($updateMeta);
|
|
|
|
|
|
|
|
$updateFiles = preg_grep('/<Files>.*<\/Files>/', $updateMeta);
|
|
|
|
sort($updateFiles);
|
|
|
|
|
2019-05-24 18:25:57 +02:00
|
|
|
if(!isset($updateFiles[0])) {
|
|
|
|
consoleLogger('An error has occurred');
|
|
|
|
return array('error' => 'EMPTY_FILELIST');
|
|
|
|
}
|
|
|
|
|
2017-10-13 22:55:46 +02:00
|
|
|
preg_match('/<Files>.*<\/Files>/', $updateFiles[0], $fileList);
|
2019-05-24 18:25:57 +02:00
|
|
|
if(!isset($fileList[0]) || empty($fileList[0])) {
|
2017-10-01 16:06:01 +02:00
|
|
|
consoleLogger('An error has occurred');
|
2017-09-30 16:42:48 +02:00
|
|
|
return array('error' => 'EMPTY_FILELIST');
|
2017-09-22 21:24:31 +02:00
|
|
|
}
|
|
|
|
|
2019-08-28 16:26:16 +02:00
|
|
|
preg_match('/ProductReleaseInstalled Name\="(.*?)\..*\.(.*?)" Version\="10\.0\.(.*?)"/', $updateInfo, $info);
|
2019-10-25 16:44:35 +02:00
|
|
|
$foundType = @strtolower($info[1]);
|
|
|
|
$foundArch = @strtolower($info[2]);
|
|
|
|
$foundBuild = @$info[3];
|
2017-10-13 22:55:46 +02:00
|
|
|
|
2021-02-06 14:26:21 +01:00
|
|
|
if(!isset($foundArch) || empty($foundArch)) {
|
2021-01-19 08:06:51 +01:00
|
|
|
preg_match('/ProductReleaseInstalled Name\="(.*?)\.(.*?)" Version\="10\.0\.(.*?)"/', $updateInfo, $info);
|
|
|
|
$foundType = @strtolower($info[1]);
|
|
|
|
$foundArch = @strtolower($info[2]);
|
|
|
|
$foundBuild = @$info[3];
|
|
|
|
}
|
|
|
|
|
2021-10-14 22:38:26 +02:00
|
|
|
if(!isset($foundArch) || empty($foundArch)) {
|
|
|
|
preg_match('/ProductReleaseInstalled Name\="(.*?)\.(.*?)" Version\="(.*?)"/', $updateInfo, $info);
|
|
|
|
$foundType = @strtolower($info[1]);
|
|
|
|
$foundArch = @strtolower($info[2]);
|
|
|
|
$foundBuild = @$info[3];
|
|
|
|
}
|
|
|
|
|
2017-10-14 15:31:30 +02:00
|
|
|
$updateTitle = preg_grep('/<Title>.*<\/Title>/', $updateMeta);
|
|
|
|
sort($updateTitle);
|
|
|
|
|
2017-10-13 22:55:46 +02:00
|
|
|
preg_match('/<Title>.*?<\/Title>/i', $updateTitle[0], $updateTitle);
|
|
|
|
$updateTitle = preg_replace('/<Title>|<\/Title>/i', '', $updateTitle);
|
2017-09-22 21:24:31 +02:00
|
|
|
sort($updateTitle);
|
|
|
|
|
|
|
|
if(isset($updateTitle[0])) {
|
|
|
|
$updateTitle = $updateTitle[0];
|
|
|
|
} else {
|
|
|
|
$updateTitle = 'Windows 10 build '.$foundBuild;
|
|
|
|
}
|
|
|
|
|
2021-02-06 14:26:21 +01:00
|
|
|
if($foundType == 'hololens' || $foundType == 'wcosdevice0')
|
|
|
|
$updateTitle = preg_replace('/ for .{3,5}-based/i', ' for', $updateTitle);
|
|
|
|
|
2018-01-07 01:17:08 +01:00
|
|
|
$isCumulativeUpdate = 0;
|
2021-10-14 22:38:26 +02:00
|
|
|
if(preg_match('/\d{4}-\d{2}.+Update|Cumulative Update|Microsoft Edge|Windows Feature Experience Pack|Cumulative security Hotpatch/i', $updateTitle)) {
|
2018-04-11 18:01:27 +02:00
|
|
|
$isCumulativeUpdate = 1;
|
2018-01-07 01:17:08 +01:00
|
|
|
$updateTitle = preg_replace('/ for .{3,5}-based systems| \(KB.*?\)/i', '', $updateTitle);
|
|
|
|
}
|
2017-10-23 22:53:33 +02:00
|
|
|
|
2021-01-26 22:52:54 +01:00
|
|
|
$updateTitle = preg_replace("/ ?\d{4}-\d{2}\D ?| ?$foundArch ?| ?x64 ?/i", '', $updateTitle);
|
2019-03-12 18:26:33 +01:00
|
|
|
|
2021-10-22 19:38:07 +02:00
|
|
|
if($foundType == 'server') {
|
2019-08-28 16:26:16 +02:00
|
|
|
$updateTitle = str_replace('Windows 10', 'Windows Server', $updateTitle);
|
2021-10-22 19:38:07 +02:00
|
|
|
$updateTitle = str_replace('Windows 11', 'Windows Server', $updateTitle);
|
|
|
|
}
|
2019-08-28 16:26:16 +02:00
|
|
|
|
2021-05-27 22:28:47 +02:00
|
|
|
if($sku == 406)
|
|
|
|
$updateTitle = str_replace('Microsoft server operating system', 'Azure Stack HCI', $updateTitle);
|
|
|
|
|
2021-01-26 22:52:54 +01:00
|
|
|
if($foundType == 'sedimentpack')
|
|
|
|
$updateTitle = $updateTitle.' - KB4023057';
|
|
|
|
|
2021-02-06 14:26:21 +01:00
|
|
|
if($foundType == 'hololens' || $foundType == 'wcosdevice0')
|
|
|
|
$updateTitle = $updateTitle.' - '.$type;
|
|
|
|
|
2019-08-28 16:26:16 +02:00
|
|
|
if(!preg_match("/$foundBuild/i", $updateTitle))
|
2017-10-23 22:53:33 +02:00
|
|
|
$updateTitle = $updateTitle.' ('.$foundBuild.')';
|
|
|
|
|
2018-04-11 18:01:27 +02:00
|
|
|
preg_match('/UpdateID=".*?"/', $updateInfo, $updateId);
|
|
|
|
preg_match('/RevisionNumber=".*?"/', $updateInfo, $updateRev);
|
2017-10-23 22:53:33 +02:00
|
|
|
|
2017-09-22 21:24:31 +02:00
|
|
|
$updateId = preg_replace('/UpdateID="|"$/', '', $updateId[0]);
|
2017-10-23 22:53:33 +02:00
|
|
|
$updateRev = preg_replace('/RevisionNumber="|"$/', '', $updateRev[0]);
|
|
|
|
|
2017-09-22 21:24:31 +02:00
|
|
|
consoleLogger('Successfully checked build information.');
|
|
|
|
|
2017-10-23 22:53:33 +02:00
|
|
|
$updateString = $updateId;
|
|
|
|
if($updateRev != 1) {
|
|
|
|
$updateString = $updateId.'_rev.'.$updateRev;
|
|
|
|
}
|
|
|
|
|
2019-07-02 17:47:32 +02:00
|
|
|
$ids = uupListIds();
|
|
|
|
if(!isset($ids['error'])) {
|
|
|
|
$ids = $ids['builds'];
|
|
|
|
$namesList = array();
|
|
|
|
|
|
|
|
foreach($ids as $val) {
|
|
|
|
$testName = $val['build'].' '.$val['title'].' '.$val['arch'];
|
|
|
|
|
|
|
|
if($val['uuid'] != $updateString) {
|
|
|
|
$namesList[$val['uuid']] = $testName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$num = 1;
|
|
|
|
$buildName = $foundBuild.' '.$updateTitle.' '.$foundArch;
|
|
|
|
while(in_array($buildName, $namesList, true)) {
|
|
|
|
$num++;
|
|
|
|
$buildName = "$foundBuild $updateTitle ($num) $foundArch";
|
|
|
|
}
|
|
|
|
|
|
|
|
if($num > 1) $updateTitle = "$updateTitle ($num)";
|
|
|
|
}
|
|
|
|
|
2018-03-17 17:29:59 +01:00
|
|
|
consoleLogger("--- UPDATE INFORMATION ---");
|
|
|
|
consoleLogger("Title: ".$updateTitle);
|
2019-06-16 19:00:45 +02:00
|
|
|
consoleLogger("Architecture: ".$foundArch);
|
2018-03-17 17:29:59 +01:00
|
|
|
consoleLogger("Build number: ".$foundBuild);
|
|
|
|
consoleLogger("Update ID: ".$updateString);
|
|
|
|
consoleLogger("--- UPDATE INFORMATION ---");
|
|
|
|
|
2019-10-25 16:44:35 +02:00
|
|
|
if((!$foundBuild) && (!$foundArch)) {
|
|
|
|
consoleLogger('No architecture nor build number specified! What the hell is this?');
|
|
|
|
return array('error' => 'BROKEN_UPDATE');
|
|
|
|
}
|
|
|
|
|
2022-09-16 00:34:44 +02:00
|
|
|
$isCorpnet = preg_match('/Corpnet Required/i', $updateTitle);
|
|
|
|
if($isCorpnet && !uupApiConfigIsTrue('allow_corpnet')) {
|
2019-07-27 19:43:02 +02:00
|
|
|
consoleLogger('Skipping corpnet only update...');
|
|
|
|
return array('error' => 'CORPNET_ONLY_UPDATE');
|
|
|
|
}
|
|
|
|
|
2017-09-22 21:24:31 +02:00
|
|
|
$fileWrite = 'NO_SAVE';
|
2022-09-13 23:41:43 +02:00
|
|
|
if(!uupApiFileInfoExists($updateId)) {
|
2017-09-22 21:24:31 +02:00
|
|
|
consoleLogger('WARNING: This build is NOT in the database. It will be saved now.');
|
2017-09-30 16:38:26 +02:00
|
|
|
consoleLogger('Parsing information to write...');
|
2017-09-22 21:24:31 +02:00
|
|
|
|
|
|
|
$fileList = preg_replace('/<Files>|<\/Files>/', '', $fileList[0]);
|
2021-09-19 15:58:48 +02:00
|
|
|
preg_match_all('/<File.*?<\/File>/', $fileList, $fileList);
|
2017-09-22 21:24:31 +02:00
|
|
|
|
|
|
|
$shaArray = array();
|
|
|
|
|
|
|
|
foreach($fileList[0] as $val) {
|
|
|
|
preg_match('/Digest=".*?"/', $val, $sha1);
|
|
|
|
$sha1 = preg_replace('/Digest="|"$/', '', $sha1[0]);
|
|
|
|
$sha1 = bin2hex(base64_decode($sha1));
|
|
|
|
|
2021-01-29 17:52:19 +01:00
|
|
|
preg_match('/FileName=".*?"/', $val, $name);
|
|
|
|
$name = preg_replace('/FileName="|"$/', '', $name[0]);
|
|
|
|
|
2017-09-22 21:24:31 +02:00
|
|
|
preg_match('/Size=".*?"/', $val, $size);
|
|
|
|
$size = preg_replace('/Size="|"$/', '', $size[0]);
|
|
|
|
|
2021-09-19 15:58:48 +02:00
|
|
|
preg_match('/(<AdditionalDigest.*Algorithm="SHA256".*>)(.*?)(<\/AdditionalDigest>)/', $val, $sha256);
|
|
|
|
$sha256 = bin2hex(base64_decode($sha256[2]));
|
|
|
|
|
2017-09-22 21:24:31 +02:00
|
|
|
$temp = array(
|
|
|
|
'name' => $name,
|
|
|
|
'size' => $size,
|
2021-09-19 15:58:48 +02:00
|
|
|
'sha256' => $sha256,
|
2017-09-22 21:24:31 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$shaArray = array_merge($shaArray, array($sha1 => $temp));
|
|
|
|
}
|
|
|
|
|
|
|
|
unset($temp, $sha1, $name, $size);
|
|
|
|
|
|
|
|
ksort($shaArray);
|
|
|
|
|
2017-10-16 18:03:26 +02:00
|
|
|
$temp = array();
|
|
|
|
$temp['title'] = $updateTitle;
|
2020-07-13 06:16:00 +02:00
|
|
|
$temp['ring'] = $ring;
|
|
|
|
$temp['flight'] = $flight;
|
2024-02-28 18:38:42 +01:00
|
|
|
$temp['branch'] = $branch;
|
2019-06-16 19:00:45 +02:00
|
|
|
$temp['arch'] = $foundArch;
|
2017-10-16 18:03:26 +02:00
|
|
|
$temp['build'] = $foundBuild;
|
|
|
|
$temp['checkBuild'] = $build;
|
2018-04-29 21:33:19 +02:00
|
|
|
$temp['sku'] = $sku;
|
2017-10-16 18:03:26 +02:00
|
|
|
|
2018-01-07 01:17:08 +01:00
|
|
|
if($isCumulativeUpdate) {
|
2017-10-16 18:03:26 +02:00
|
|
|
$temp['containsCU'] = 1;
|
|
|
|
}
|
|
|
|
|
2021-02-06 14:26:21 +01:00
|
|
|
if($foundType == 'hololens' || $foundType == 'wcosdevice0') {
|
|
|
|
$temp['releasetype'] = $type;
|
|
|
|
}
|
|
|
|
|
2023-11-03 20:13:28 +01:00
|
|
|
if(!empty($flags)) {
|
|
|
|
$temp['flags'] = $flags;
|
|
|
|
}
|
|
|
|
|
2019-02-08 17:20:28 +01:00
|
|
|
$temp['created'] = time();
|
2021-09-19 15:58:48 +02:00
|
|
|
$temp['sha256ready'] = true;
|
2017-10-16 18:03:26 +02:00
|
|
|
$temp['files'] = $shaArray;
|
2017-09-22 21:24:31 +02:00
|
|
|
|
|
|
|
consoleLogger('Successfully parsed the information.');
|
|
|
|
consoleLogger('Writing new build information to the disk...');
|
|
|
|
|
2022-09-13 23:41:43 +02:00
|
|
|
$success = uupApiWriteFileinfo($updateString, $temp);
|
2017-09-22 21:24:31 +02:00
|
|
|
if($success) {
|
|
|
|
consoleLogger('Successfully written build information to the disk.');
|
|
|
|
$fileWrite = 'INFO_WRITTEN';
|
2022-08-26 20:10:15 +02:00
|
|
|
uupApiPrivateInvalidateFileinfoCache();
|
2017-09-22 21:24:31 +02:00
|
|
|
} else {
|
|
|
|
consoleLogger('An error has occured while writing the information to the disk.');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
consoleLogger('This build already exists in the database.');
|
|
|
|
}
|
|
|
|
|
|
|
|
return array(
|
2017-10-23 22:53:33 +02:00
|
|
|
'updateId' => $updateString,
|
2017-09-22 21:24:31 +02:00
|
|
|
'updateTitle' => $updateTitle,
|
|
|
|
'foundBuild' => $foundBuild,
|
2019-06-16 19:00:45 +02:00
|
|
|
'arch' => $foundArch,
|
2017-09-22 21:24:31 +02:00
|
|
|
'fileWrite' => $fileWrite,
|
|
|
|
);
|
|
|
|
}
|