1<?php
2/*
3 Copyright (C) 2020 Denver Gingerich <denver@ossguy.com>
4
5 This file is part of sgx-bwmsgsv2.
6
7 sgx-bwmsgsv2 is free software: you can redistribute it and/or modify it under
8 the terms of the GNU Affero General Public License as published by the Free
9 Software Foundation, either version 3 of the License, or (at your option) any
10 later version.
11
12 sgx-bwmsgsv2 is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
15 details.
16
17 You should have received a copy of the GNU Affero General Public License along
18 with sgx-bwmsgsv2. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21$time = microtime(true);
22
23$raw_data = file_get_contents('php://input');
24
25include 'settings-h2r.php';
26$redis = new Redis();
27$rv = $redis->pconnect($redis_host, $redis_port);
28
29if (!$rv) {
30 error_log("ERROR 1a in Redis connect at $time - cannot save $raw_data");
31 http_response_code(503); # Service Unavailable
32 exit(0);
33}
34
35if (!empty($redis_auth)) {
36 # TODO: check return value to confirm login succeeded
37 $redis->auth($redis_auth);
38}
39
40# TODO: MUST add ./tai versions of $time and $time2
41
42$time2 = microtime(true);
43
44$rv = $redis->lPush('incoming_messages-'.'test1a', # TODO: update queue name
45 '"ts_020-first_db_hit":'.$time2.',"ts_010-first_received":'.$time.',"MSG":'.$raw_data);
46
47if (!$rv) {
48 error_log("ERROR 2a in lPush at $time $time2 - cannot save $raw_data");
49 http_response_code(503); # Service Unavailable
50 exit(0);
51}
52
53print 'ok';
54
55?>