-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate.php
60 lines (45 loc) · 1.62 KB
/
update.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
require 'vendor/autoload.php';
date_default_timezone_set('UTC');
use Aws\DynamoDb\DynamoDbClient;
use Aws\DynamoDb\Marshaler;
use Aws\S3\S3Client;
$aws_conf = [
'region' => 'us-west-2',
'version' => 'latest',
];
$sdk = new Aws\Sdk($aws_conf);
$s3 = $sdk->createS3();
$bucket = "lr-stash";
$key = "head/md5sums.json";
$res = $s3->getObject([
'Bucket' => $bucket,
'Key' => $key,
]);
echo $res['Body']->getContents();
if(isset($_GET['data'])){
try{
$data = @json_decode(@urldecode($_GET['data']), true);
$dynamodb = $sdk->createDynamoDb();
$marshaler = new Marshaler();
$item = [];
$pv = $data['pluginVersion'];
$item["pluginVersion"] = $pv['major'] . "." . $pv['minor'] . "." . $pv['revision'];
$lv = $data['lightroomVersion'];
$item["lightroomVersion"] = $lv['major'] . "." . $lv['minor'] . "." . $lv['build'] . "." . $lv['revision'];
$item["arch"] = $data['arch'];
$item["os"] = $data['os'];
$item["username"] = array_key_exists('username', $data) ? $data['username'] : "Nil" ;
$item["uploadCount"] = array_key_exists('uploadCount', $data) ? strval($data['uploadCount']) : '0' ;
$item["lastSeen"] = gmdate(DateTime::ATOM);
$item["no_hash"] = !array_key_exists('hash', $data) || empty($data['hash']);
$item["uuid"] = $item["no_hash"] ? md5($_SERVER['HTTP_X_FORWARDED_FOR']) : $data['hash'];
$response = $dynamodb->putItem([
'TableName' => "lr-stash",
'Item' => $marshaler->marshalItem($item)
]);
} catch (Exception $e) {
//do nothing, we don't care too much about the db
}
}
?>