Add files via upload
This commit is contained in:
parent
9c2c959275
commit
2f4a6e2527
138
GetFirmwareUpdates/GetGarminSingleUpdate.php
Normal file
138
GetFirmwareUpdates/GetGarminSingleUpdate.php
Normal file
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
require 'basic_protobuf.php';
|
||||
|
||||
if (!isset($_GET['id'])) die('Required parameter missing.');
|
||||
$part_numbers = array('006-B' . $_GET['id'] . '-00');
|
||||
|
||||
// 1. Generating the request to Garmin Express server.
|
||||
|
||||
$main_template = file_get_contents('RequestTemplate.txt');
|
||||
$updatefile_template = file_get_contents('RequestUpdateFileTemplate.txt');
|
||||
|
||||
$update_files = '';
|
||||
foreach ($part_numbers as $part_number)
|
||||
$update_files .= str_replace('%part_number%', chop($part_number), $updatefile_template) . "\n";
|
||||
|
||||
$device_xml = str_replace('%part_number%', chop($part_numbers[0]), $main_template);
|
||||
$device_xml = str_replace('%update_files%', $update_files, $device_xml);
|
||||
|
||||
$request_data =
|
||||
write_string(1,
|
||||
write_string(1, 'express') .
|
||||
write_string(2, 'en_US') .
|
||||
write_string(3, 'Windows') .
|
||||
write_string(4, '601 Service Pack 1')
|
||||
) .
|
||||
write_string(2, $device_xml);
|
||||
|
||||
|
||||
// 2. POSTing the data to the update server.
|
||||
|
||||
$ch=curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, 'http://omt.garmin.com/Rce/ProtobufApi/SoftwareUpdateService/GetAllUnitSoftwareUpdates');
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, 'Garmin Core Service Win - 5.7.0.2');
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Garmin-Client-Name: CoreService',
|
||||
'Garmin-Client-Version: 5.7.0.2',
|
||||
'X-garmin-client-id: EXPRESS',
|
||||
'Garmin-Client-Platform: windows',
|
||||
'Garmin-Client-Platform-Version: 601',
|
||||
'Garmin-Client-Platform-Version-Revision: 1',
|
||||
'Content-Type: application/octet-stream'
|
||||
)
|
||||
);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $request_data);
|
||||
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$answer = curl_exec($ch);
|
||||
|
||||
|
||||
echo "Information from Garmin Express server:<br>\r\n";
|
||||
|
||||
$info = curl_getinfo($ch);
|
||||
if ($info['http_code'] == '200') {
|
||||
$records = read_message($answer);
|
||||
if (is_array($records["1"])) {
|
||||
$records = $records["1"];
|
||||
} else {
|
||||
$records = array($records["1"]);
|
||||
}
|
||||
$update_list = array();
|
||||
|
||||
foreach ($records as $record) {
|
||||
$fields = read_message($record);
|
||||
if (isset($fields[15]) && strcasecmp($fields[15], 'Firmware')) {
|
||||
$fields[6] = read_message($fields[6]);
|
||||
|
||||
if (!is_array($fields[1]))
|
||||
$fields[1] = array($fields[1]);
|
||||
|
||||
$changes = str_replace("\xE2\x80\xA2", "\x95", join('<br>', $fields[1]));
|
||||
|
||||
echo(join('<br>', array($fields[2], $changes, $fields[8], $fields[9], make_url($fields[6][2]), $fields[6][3], $fields[6][4])));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo $info['http_code'];
|
||||
echo '<pre>'; print_r($info); echo '</pre>';
|
||||
}
|
||||
|
||||
|
||||
// 5. Generating the request to WebUpdater server.
|
||||
$main_template = file_get_contents('RequestTemplate_WebUpdater.txt');
|
||||
$updatefile_template = file_get_contents('RequestUpdateFileTemplate_WebUpdater.txt');
|
||||
|
||||
$update_files = '';
|
||||
foreach ($part_numbers as $part_number)
|
||||
$update_files .= str_replace('%part_number%', chop($part_number), $updatefile_template) . "\n";
|
||||
|
||||
$request_data = str_replace('%part_number%', chop($part_numbers[0]), $main_template);
|
||||
$request_data = str_replace('%update_files%', $update_files, $request_data);
|
||||
|
||||
|
||||
// 6. POSTing the data to the update server.
|
||||
$ch=curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://www.garmin.com/support/WUSoftwareUpdate.jsp');
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, 'Undefined agent');
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $request_data);
|
||||
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$answer = curl_exec($ch);
|
||||
|
||||
|
||||
echo "<br><br>Information from Garmin Update server:<br>\r\n";
|
||||
|
||||
$info = curl_getinfo($ch);
|
||||
if ($info['http_code'] == '200') {
|
||||
$xml = new SimpleXMLElement($answer);
|
||||
foreach ($xml as $record) {
|
||||
echo (string)$record->Update->Description . "<br>";
|
||||
|
||||
$changes = urldecode((string)$record->Update->ChangeDescription);
|
||||
echo $changes . "<br>";
|
||||
printf("%u.%02u<br>", (int)$record->Update->Version->VersionMajor, (int)$record->Update->Version->VersionMinor);
|
||||
echo make_url((string)$record->Update->AdditionalInfo) . "<br>";
|
||||
echo make_url((string)$record->Update->UpdateFile->Location) . "<br>";
|
||||
echo (string)$record->Update->UpdateFile->MD5Sum . "<br>";
|
||||
echo (string)$record->Update->UpdateFile->Size . "<br>";
|
||||
}
|
||||
} else {
|
||||
echo $info['http_code'] . '<br>';
|
||||
print_r($info);
|
||||
echo '<br>' . $answer;
|
||||
}
|
||||
|
||||
function make_url($str) {
|
||||
return '<a href="' .$str. '">' .$str. '</a>';
|
||||
}
|
||||
?>
|
1
GetFirmwareUpdates/LatestGarminFirmwaresLineTemplate.txt
Normal file
1
GetFirmwareUpdates/LatestGarminFirmwaresLineTemplate.txt
Normal file
@ -0,0 +1 @@
|
||||
<tr><td>%model%</td><td>%part_number%</td><td>Release %version%</td><td><a href="%URL%">Download</a> (%size% Kb) <div style="display: none">MD5: %MD5%</div></td><td><span style="display: %visible_wu_1%">%build_type_wu% %version_wu%</span></td><td><a href="%details_URL_wu%">Details</a><span style="display: %visible_wu_2%; padding-left: 1em"><a href="%URL_wu%">Download</a> (%size_wu% Kb)</span><div style="display: none">MD5: %MD5_wu%</div></td></tr>
|
21
GetFirmwareUpdates/LatestGarminFirmwaresTemplate.txt
Normal file
21
GetFirmwareUpdates/LatestGarminFirmwaresTemplate.txt
Normal file
@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html>
|
||||
<link rel="stylesheet" href="/main.css"/>
|
||||
<body>
|
||||
<table border="1" cellpadding="10">
|
||||
<tr><th rowspan="2">Model</th><th rowspan="2">Update Part Number</th><th colspan="2">Garmin Express</th><th colspan="2">WebUpdater</th></tr>
|
||||
<tr><th>Firmware Version</th><th>Link</th><th>Firmware Version</th><th>Links</th></tr>
|
||||
%update_lines%
|
||||
</table><br><a href="http://metrika.yandex.ru/stat/?id=5821864&from=informer" target="_blank" rel="nofollow"><img src="//bs.yandex.ru/informer/5821864/3_0_FFFFFFFF_FFFFFFFF_0_pageviews" style="width:88px; height:31px; border:0;"></a><div style="display:none;"><script type="text/javascript">
|
||||
(function(w, c) {
|
||||
(w[c] = w[c] || []).push(function() {
|
||||
try {
|
||||
w.yaCounter5821864 = new Ya.Metrika(5821864);
|
||||
yaCounter5821864.clickmap(true);
|
||||
yaCounter5821864.trackLinks(true);
|
||||
|
||||
} catch(e) { }
|
||||
});
|
||||
})(window, 'yandex_metrika_callbacks');
|
||||
</script></div><script src="//mc.yandex.ru/metrika/watch.js" type="text/javascript" defer></script><noscript><div><img src="//mc.yandex.ru/watch/5821864" style="position:absolute; left:-9999px;" alt=""></div></noscript>
|
||||
</body>
|
||||
</html>
|
64
GetFirmwareUpdates/RequestPartNumbers.txt
Normal file
64
GetFirmwareUpdates/RequestPartNumbers.txt
Normal file
@ -0,0 +1,64 @@
|
||||
006-B0661-00
|
||||
006-B0795-00
|
||||
006-B0896-00
|
||||
006-B0960-00
|
||||
006-B1113-00
|
||||
006-B1169-00
|
||||
006-B1247-00
|
||||
006-B1275-00
|
||||
006-B1305-00
|
||||
006-B1339-00
|
||||
006-B1340-00
|
||||
006-B1506-00
|
||||
006-B1561-00
|
||||
006-B1562-00
|
||||
006-B1567-00
|
||||
006-B1651-00
|
||||
006-B1716-00
|
||||
006-B1726-00
|
||||
006-B1736-00
|
||||
006-B1836-00
|
||||
006-B1859-00
|
||||
006-B1988-00
|
||||
006-B2067-00
|
||||
006-B2140-00
|
||||
006-B2204-00
|
||||
006-B2250-00
|
||||
006-B2267-00
|
||||
006-B2268-00
|
||||
006-B2269-00
|
||||
006-B2270-00
|
||||
006-B2299-00
|
||||
006-B2442-00
|
||||
006-B2444-00
|
||||
006-B2479-00
|
||||
006-B2512-00
|
||||
006-B2530-00
|
||||
006-B2531-00
|
||||
006-B2586-00
|
||||
006-B2587-00
|
||||
006-B2588-00
|
||||
006-B2589-00
|
||||
006-B2590-00
|
||||
006-B2604-00
|
||||
006-B2614-00
|
||||
006-B2684-00
|
||||
006-B2705-00
|
||||
006-B2713-00
|
||||
006-B2819-00
|
||||
006-B2859-00
|
||||
006-B2893-00
|
||||
006-B2894-00
|
||||
006-B2900-00
|
||||
006-B3011-00
|
||||
006-B3028-00
|
||||
006-B3095-00
|
||||
006-B3098-00
|
||||
006-B3110-00
|
||||
006-B3111-00
|
||||
006-B3112-00
|
||||
006-B3115-00
|
||||
006-B3187-00
|
||||
006-B3196-00
|
||||
006-B3197-00
|
||||
006-B3198-00
|
12
GetFirmwareUpdates/RequestTemplate.txt
Normal file
12
GetFirmwareUpdates/RequestTemplate.txt
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Device xmlns="http://www.garmin.com/xmlschemas/GarminDevice/v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.garmin.com/xmlschemas/GarminDevice/v2 http://www.garmin.com/xmlschemas/GarminDevicev2.xsd">
|
||||
<Model>
|
||||
<PartNumber>%part_number%</PartNumber>
|
||||
<SoftwareVersion>1</SoftwareVersion>
|
||||
<Description>-</Description>
|
||||
</Model>
|
||||
<Id>2345678910</Id>
|
||||
<MassStorageMode>
|
||||
%update_files%
|
||||
</MassStorageMode>
|
||||
</Device>
|
4
GetFirmwareUpdates/RequestTemplate_WebUpdater.txt
Normal file
4
GetFirmwareUpdates/RequestTemplate_WebUpdater.txt
Normal file
@ -0,0 +1,4 @@
|
||||
req=%3C?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Requests xmlns="http://www.garmin.com/xmlschemas/UnitSoftwareUpdate/v3">
|
||||
%update_files%
|
||||
</Requests>
|
1
GetFirmwareUpdates/RequestUpdateFileTemplate.txt
Normal file
1
GetFirmwareUpdates/RequestUpdateFileTemplate.txt
Normal file
@ -0,0 +1 @@
|
||||
<UpdateFile><PartNumber>%part_number%</PartNumber><Version><Major>0</Major><Minor>1</Minor></Version><Path>Garmin</Path><FileName>GUPDATE.GCD</FileName></UpdateFile>
|
@ -0,0 +1 @@
|
||||
<Request><PartNumber>%part_number%</PartNumber><TransferType>USB</TransferType><Region><RegionId>14</RegionId><Version><VersionMajor>0</VersionMajor><VersionMinor>1</VersionMinor><BuildType>Release</BuildType></Version></Region></Request>
|
97
GetFirmwareUpdates/basic_protobuf.php
Normal file
97
GetFirmwareUpdates/basic_protobuf.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
function read_varint(&$str) {
|
||||
$res = 0;
|
||||
$multiplier = 1;
|
||||
|
||||
do {
|
||||
if ($str === '') break;
|
||||
|
||||
$val = ord(substr($str, 0, 1)); $str = substr($str, 1);
|
||||
|
||||
$res += ($val & 0x7F) * $multiplier;
|
||||
$multiplier <<= 7;
|
||||
} while ($val & 0x80);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function read_message($str) {
|
||||
$res = array();
|
||||
|
||||
while ($str) {
|
||||
$id = read_varint($str);
|
||||
$wiretype = $id & 7;
|
||||
$id >>= 3;
|
||||
|
||||
if ($wiretype == 0) {
|
||||
// Varint
|
||||
$val = read_varint($str);
|
||||
} elseif ($wiretype == 1) {
|
||||
// 64-bit. Skip it.
|
||||
$str = substr($str, 8);
|
||||
} elseif ($wiretype == 2) {
|
||||
$len = read_varint($str);
|
||||
$val = substr($str, 0, $len);
|
||||
$str = substr($str, $len);
|
||||
} elseif ($wiretype == 5) {
|
||||
// int32
|
||||
list($val) = unpack("V", $str);
|
||||
$str = substr($str, 4);
|
||||
} else {
|
||||
die("Unsupported wiretype $wiretype\n");
|
||||
}
|
||||
|
||||
if (isset($res[$id])) {
|
||||
if (!is_array($res[$id]))
|
||||
$res[$id] = array($res[$id]);
|
||||
array_push($res[$id], $val);
|
||||
} else
|
||||
$res[$id] = $val;
|
||||
}
|
||||
|
||||
if ((count($res) == 1) && is_array($res[1]))
|
||||
$res = $res[1];
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
function pack_varint($val) {
|
||||
$res = '';
|
||||
while ($val) {
|
||||
$mod = $val % 0x80;
|
||||
$val >>= 7;
|
||||
|
||||
if ($val) $mod |= 0x80;
|
||||
|
||||
$res .= pack('c', $mod);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
function pack_int32($val) {
|
||||
return pack('V', $val);
|
||||
}
|
||||
|
||||
function pack_string($str) {
|
||||
return pack_varint(strlen($str)) . $str;
|
||||
}
|
||||
|
||||
|
||||
function write_varint($id, $val) {
|
||||
$id <<= 3;
|
||||
return pack_varint($id) . pack_varint($val);
|
||||
}
|
||||
|
||||
function write_int32($id, $val) {
|
||||
$id <<= 3;
|
||||
$id |= 5;
|
||||
return pack_varint($id) . pack_int32($val);
|
||||
}
|
||||
|
||||
function write_string($id, $val) {
|
||||
$id <<= 3;
|
||||
$id |= 2;
|
||||
return pack_varint($id) . pack_string($val);
|
||||
}
|
||||
?>
|
8
GetFirmwareUpdates/compare.php
Normal file
8
GetFirmwareUpdates/compare.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
require("htmldiff/html_diff.php");
|
||||
|
||||
$html1 = file('../generated/LatestGarminFirmwares_prev.html'); array_shift($html1); $html1 = join('', $html1);
|
||||
$html2 = file('../generated/LatestGarminFirmwares.html'); array_shift($html2); $html2 = join('', $html2);
|
||||
|
||||
echo html_diff($html1, $html2);
|
||||
?>
|
Reference in New Issue
Block a user