$error, 'out' => $out ]; } function sendWuPostRequest($url, $postData) { return sendWuPostRequestInternal($url, $postData)['out']; } function sendWuPostRequestHelper( $endpoint, $postComposer, $postComposerArgs, $saveCookie = true ) { $endpoints = [ 'client' => 'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx', 'clientSecured' => 'https://fe3cr.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured' ]; $postData = call_user_func_array($postComposer, $postComposerArgs); if($postData === false) return false; $data = sendWuPostRequestInternal($endpoints[$endpoint], $postData, $saveCookie); if($data['error'] == 500 && preg_match('/(ConfigChanged|CookieExpired|InvalidCookie)<\/ErrorCode>/', $data['out'])) { uupInvalidateCookie(); $postData = call_user_func_array($postComposer, $postComposerArgs); return sendWuPostRequestInternal($endpoints[$endpoint], $postData, $saveCookie); } return $data; } function consoleLogger($message, $showTime = 1) { if(php_sapi_name() != 'cli') return $currTime = ''; if($showTime) { $currTime = '['.date('Y-m-d H:i:s T', time()).'] '; } $msg = $currTime.$message; fwrite(STDERR, $msg."\n"); } function uupDumpApiGetConfig() { if(!file_exists('config.ini')) { return null; } return parse_ini_file('config.ini'); } function uupApiCheckUpdateId($updateId) { return preg_match( '/^[\da-fA-F]{8}-([\da-fA-F]{4}-){3}[\da-fA-F]{12}(_rev\.\d+)?$/', $updateId ); } function uupApiIsServer($skuId) { $serverSkus = [ 7, 8, 12, 13, 79, 80, 120, 145, 146, 147, 148, 159, 160, 406, 407, 408 ]; return in_array($skuId, $serverSkus); } function uupApiBuildMajor($build) { if($build == null) return null; if(!str_contains($build, '.')) return intval($build); return intval(explode('.', $build)[0]); } function uupApiFixDownloadLink($link) { return $link; } function uupApiReadJson($path) { $data = @file_get_contents($path); if(empty($data)) return false; return json_decode($data, true); } function uupApiWriteJson($path, $data) { return file_put_contents($path, json_encode($data)."\n"); } function uupApiPacksExist($updateId) { return file_exists('packs/'.$updateId.'.json.gz'); } function uupApiConfigIsTrue($config) { $data = uupDumpApiGetConfig(); if(!isset($data[$config])) return false; return $data[$config] == true; } function getAllowedFlags() { $flags = ['thisonly']; if(uupApiConfigIsTrue('allow_corpnet')) $flags[] = 'corpnet'; return $flags; }