forked from uup-dump/api
Add option to provide optional fetch flags
This commit is contained in:
parent
d0bad95c11
commit
d597a83422
56
fetchupd.php
56
fetchupd.php
@ -21,6 +21,33 @@ require_once dirname(__FILE__).'/shared/cache.php';
|
|||||||
require_once dirname(__FILE__).'/shared/fileinfo.php';
|
require_once dirname(__FILE__).'/shared/fileinfo.php';
|
||||||
require_once dirname(__FILE__).'/listid.php';
|
require_once dirname(__FILE__).'/listid.php';
|
||||||
|
|
||||||
|
function uupApiPrivateParseFlags($str) {
|
||||||
|
$split = explode('+', $str);
|
||||||
|
$flags = [];
|
||||||
|
|
||||||
|
if(isset($split[1]))
|
||||||
|
$flags = explode(',', strtolower($split[1]));
|
||||||
|
|
||||||
|
return [$split[0], $flags];
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
function uupFetchUpd(
|
function uupFetchUpd(
|
||||||
$arch = 'amd64',
|
$arch = 'amd64',
|
||||||
$ring = 'WIF',
|
$ring = 'WIF',
|
||||||
@ -38,20 +65,11 @@ function uupFetchUpd(
|
|||||||
$flight = ucwords(strtolower($flight));
|
$flight = ucwords(strtolower($flight));
|
||||||
$flight = 'Active';
|
$flight = 'Active';
|
||||||
|
|
||||||
|
$buildWithFlags = $build;
|
||||||
|
[$build, $flags] = uupApiPrivateParseFlags($build);
|
||||||
|
|
||||||
if($build == 'latest' || (!$build)) {
|
if($build == 'latest' || (!$build)) {
|
||||||
$builds = array('22000.1');
|
$build = uupApiPrivateGetLatestBuild();
|
||||||
|
|
||||||
$ids = uupListIds();
|
|
||||||
if(isset($ids['error'])) {
|
|
||||||
$ids['builds'] = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(empty($ids['builds'])) {
|
|
||||||
$build = $builds[0];
|
|
||||||
} else {
|
|
||||||
$build = $ids['builds'][0]['build'];
|
|
||||||
}
|
|
||||||
unset($builds, $ids);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$build = explode('.', $build);
|
$build = explode('.', $build);
|
||||||
@ -96,13 +114,13 @@ function uupFetchUpd(
|
|||||||
$type = 'Production';
|
$type = 'Production';
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = "api-fetch-$arch-$ring-$flight-$build-$minor-$sku-$type";
|
$res = "api-fetch-$arch-$ring-$flight-$buildWithFlags-$minor-$sku-$type";
|
||||||
$cache = new UupDumpCache($res);
|
$cache = new UupDumpCache($res);
|
||||||
$fromCache = $cache->get();
|
$fromCache = $cache->get();
|
||||||
if($fromCache !== false) return $fromCache;
|
if($fromCache !== false) return $fromCache;
|
||||||
|
|
||||||
consoleLogger('Fetching information from the server...');
|
consoleLogger('Fetching information from the server...');
|
||||||
$composerArgs = [$arch, $flight, $ring, $build, $sku, $type];
|
$composerArgs = [$arch, $flight, $ring, $build, $sku, $type, $flags];
|
||||||
$out = sendWuPostRequestHelper('client', 'composeFetchUpdRequest', $composerArgs);
|
$out = sendWuPostRequestHelper('client', 'composeFetchUpdRequest', $composerArgs);
|
||||||
if($out['error'] != 200) {
|
if($out['error'] != 200) {
|
||||||
consoleLogger('The request has failed');
|
consoleLogger('The request has failed');
|
||||||
@ -130,7 +148,7 @@ function uupFetchUpd(
|
|||||||
$num++;
|
$num++;
|
||||||
consoleLogger("Checking build information for update {$num} of {$updatesNum}...");
|
consoleLogger("Checking build information for update {$num} of {$updatesNum}...");
|
||||||
|
|
||||||
$info = parseFetchUpdate($val, $out, $arch, $ring, $flight, $build, $sku, $type);
|
$info = parseFetchUpdate($val, $out, $arch, $ring, $flight, $build, $sku, $type, $flags);
|
||||||
if(isset($info['error'])) {
|
if(isset($info['error'])) {
|
||||||
$errorCount++;
|
$errorCount++;
|
||||||
continue;
|
continue;
|
||||||
@ -160,7 +178,7 @@ function uupFetchUpd(
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku, $type) {
|
function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku, $type, $flags) {
|
||||||
$updateNumId = preg_replace('/<UpdateInfo><ID>|<\/ID>.*/i', '', $updateInfo);
|
$updateNumId = preg_replace('/<UpdateInfo><ID>|<\/ID>.*/i', '', $updateInfo);
|
||||||
|
|
||||||
$updates = preg_replace('/<Update>/', "\n<Update>", $out);
|
$updates = preg_replace('/<Update>/', "\n<Update>", $out);
|
||||||
@ -351,6 +369,10 @@ function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku
|
|||||||
$temp['releasetype'] = $type;
|
$temp['releasetype'] = $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!empty($flags)) {
|
||||||
|
$temp['flags'] = $flags;
|
||||||
|
}
|
||||||
|
|
||||||
$temp['created'] = time();
|
$temp['created'] = time();
|
||||||
$temp['sha256ready'] = true;
|
$temp['sha256ready'] = true;
|
||||||
$temp['files'] = $shaArray;
|
$temp['files'] = $shaArray;
|
||||||
|
@ -16,7 +16,7 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function uupApiVersion() {
|
function uupApiVersion() {
|
||||||
return '1.42.1';
|
return '1.43.0-dev';
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once dirname(__FILE__).'/auths.php';
|
require_once dirname(__FILE__).'/auths.php';
|
||||||
|
@ -16,7 +16,7 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Composes DeviceAttributes parameter needed to fetch data
|
// Composes DeviceAttributes parameter needed to fetch data
|
||||||
function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type) {
|
function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $flags) {
|
||||||
$branch = branchFromBuild($build);
|
$branch = branchFromBuild($build);
|
||||||
$blockUpgrades = 0;
|
$blockUpgrades = 0;
|
||||||
$flightEnabled = 1;
|
$flightEnabled = 1;
|
||||||
@ -216,11 +216,11 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type) {
|
|||||||
'WuClientVer='.$build,
|
'WuClientVer='.$build,
|
||||||
);
|
);
|
||||||
|
|
||||||
if(uupApiConfigIsTrue('fetch_sync_current_only')) {
|
if(in_array('thisonly', $flags)) {
|
||||||
$attrib[] = 'MediaBranch='.$branch;
|
$attrib[] = 'MediaBranch='.$branch;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($ring == 'MSIT' && uupApiConfigIsTrue('allow_corpnet')) {
|
if(in_array('corpnet', $flags) && uupApiConfigIsTrue('allow_corpnet')) {
|
||||||
$attrib[] = 'DUInternal=1';
|
$attrib[] = 'DUInternal=1';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,7 +316,8 @@ function composeFileGetRequest($updateId, $info, $rev = 1, $type = 'Production')
|
|||||||
isset($info['checkBuild']) ? $info['checkBuild'] : '10.0.19041.1',
|
isset($info['checkBuild']) ? $info['checkBuild'] : '10.0.19041.1',
|
||||||
isset($info['arch']) ? $info['arch'] : 'amd64',
|
isset($info['arch']) ? $info['arch'] : 'amd64',
|
||||||
isset($info['sku']) ? $info['sku'] : 48,
|
isset($info['sku']) ? $info['sku'] : 48,
|
||||||
$type
|
$type,
|
||||||
|
isset($info['flags']) ? $info['flags'] : [],
|
||||||
);
|
);
|
||||||
|
|
||||||
return <<<XML
|
return <<<XML
|
||||||
@ -360,7 +361,7 @@ XML;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Composes POST data for fetching the latest update information from Windows Update
|
// Composes POST data for fetching the latest update information from Windows Update
|
||||||
function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type = 'Production') {
|
function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type = 'Production', $flags = []) {
|
||||||
$device = uupDevice();
|
$device = uupDevice();
|
||||||
$encData = uupEncryptedData();
|
$encData = uupEncryptedData();
|
||||||
$uuid = genUUID();
|
$uuid = genUUID();
|
||||||
@ -448,11 +449,11 @@ function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type
|
|||||||
$build,
|
$build,
|
||||||
$arch,
|
$arch,
|
||||||
$sku,
|
$sku,
|
||||||
$type
|
$type,
|
||||||
|
$flags
|
||||||
);
|
);
|
||||||
|
|
||||||
$syncCurrent = uupApiConfigIsTrue('fetch_sync_current_only');
|
$syncCurrent = in_array('thisonly', $flags) ? 'true' : 'false';
|
||||||
$syncCurrentStr = $syncCurrent ? 'true' : 'false';
|
|
||||||
|
|
||||||
return <<<XML
|
return <<<XML
|
||||||
<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
|
<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
|
||||||
@ -575,7 +576,7 @@ function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type
|
|||||||
</ExtendedUpdateInfoParameters>
|
</ExtendedUpdateInfoParameters>
|
||||||
<ClientPreferredLanguages/>
|
<ClientPreferredLanguages/>
|
||||||
<ProductsParameters>
|
<ProductsParameters>
|
||||||
<SyncCurrentVersionOnly>$syncCurrentStr</SyncCurrentVersionOnly>
|
<SyncCurrentVersionOnly>$syncCurrent</SyncCurrentVersionOnly>
|
||||||
<DeviceAttributes>$deviceAttributes</DeviceAttributes>
|
<DeviceAttributes>$deviceAttributes</DeviceAttributes>
|
||||||
<CallerAttributes>$callerAttrib</CallerAttributes>
|
<CallerAttributes>$callerAttrib</CallerAttributes>
|
||||||
<Products>$products</Products>
|
<Products>$products</Products>
|
||||||
|
Loading…
Reference in New Issue
Block a user