From b3c0a471864b0c9bfca1e05c69ae851715464f18 Mon Sep 17 00:00:00 2001 From: mkuba50 Date: Thu, 11 Oct 2018 21:35:25 +0200 Subject: [PATCH] Revert "Parse XML using XML parser instead of using regex in get.php" This reverts commit 582842345393a4ce50e2bd88487a7c1b237f14c2. --- get.php | 41 ++++++++++++++++++----------------------- shared/main.php | 2 +- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/get.php b/get.php index 26e4fe5..e9ba01d 100644 --- a/get.php +++ b/get.php @@ -170,10 +170,6 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac $updateId = preg_replace('/_rev\..*/', '', $updateId); } - $updateArch = (isset($info['arch'])) ? $info['arch'] : 'UNKNOWN'; - $updateBuild = (isset($info['build'])) ? $info['build'] : 'UNKNOWN'; - $updateName = (isset($info['title'])) ? $info['title'] : 'Unknown update: '.$updateId; - $fetchTime = time(); consoleLogger('Fetching information from the server...'); $postData = composeFileGetRequest($updateId, uupDevice(), $info, $rev); @@ -181,32 +177,27 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac consoleLogger('Information has been successfully fetched.'); consoleLogger('Parsing information...'); - $xmlOut = simplexml_load_string($out); - $xmlBody = $xmlOut->children('s', true)->Body->children(); - - if(!isset($xmlBody->GetExtendedUpdateInfo2Response)) { + preg_match_all('/.*?<\/FileLocation>/', $out, $out); + if(empty($out[0])) { consoleLogger('An error has occurred'); return array('error' => 'EMPTY_FILELIST'); } - $getResponse = $xmlBody->GetExtendedUpdateInfo2Response; - $getResult = $xmlBody->GetExtendedUpdateInfo2Result; + $updateArch = (isset($info['arch'])) ? $info['arch'] : 'UNKNOWN'; + $updateBuild = (isset($info['build'])) ? $info['build'] : 'UNKNOWN'; + $updateName = (isset($info['title'])) ? $info['title'] : 'Unknown update: '.$updateId; - if(!isset($getResult->FileLocations)) { - consoleLogger('An error has occurred'); - return array('error' => 'EMPTY_FILELIST'); - } - - $fileLocations = $getResult->FileLocations; $info = $info['files']; + $out = preg_replace('/|<\/FileLocation>/', '', $out[0]); $files = array(); - foreach($fileLocations->FileLocation as $val) { - $sha1 = bin2hex(base64_decode($val->FileDigest)); - $url = $val->Url; + foreach($out as $val) { + $sha1 = explode('', $val, 2); + $sha1 = explode('', $sha1[1], 2); + $sha1 = bin2hex(base64_decode($sha1[0])); - preg_match('/files\/(.{8}-.{4}-.{4}-.{4}-.{12})/', $url, $guid); - $guid = $guid[1]; + preg_match('/files\/.{8}-.{4}-.{4}-.{4}-.{12}/', $val, $guid); + $guid = preg_replace('/files\/|\?$/', '', $guid[0]); if(empty($info[$sha1]['name'])) { $name = $guid; @@ -223,9 +214,13 @@ function uupGetFiles($updateId = 'c2a1d787-647b-486d-b264-f90f3782cdc6', $usePac if(!isset($fileSizes[$name])) $fileSizes[$name] = -2; if($size > $fileSizes[$name]) { - preg_match('/P1=(.*?)&/', $url, $expire); + $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 = $expire[1]; + $expire = preg_replace('/P1=|&$/', '', $expire[0]); } $expire = intval($expire); diff --git a/shared/main.php b/shared/main.php index 0e55306..a592548 100644 --- a/shared/main.php +++ b/shared/main.php @@ -16,7 +16,7 @@ limitations under the License. */ function uupApiVersion() { - return '1.15.10'; + return '1.15.11'; } require_once dirname(__FILE__).'/auths.php';