From f57e9f79ead81bf10c25377f4fa7493b43f9a6f7 Mon Sep 17 00:00:00 2001 From: Dave Umrysh Date: Fri, 19 Mar 2021 11:26:42 -0600 Subject: [PATCH] first commit --- getDBLog.php | 35 +++++++++++++++ warehouse_get.php | 109 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 getDBLog.php create mode 100644 warehouse_get.php diff --git a/getDBLog.php b/getDBLog.php new file mode 100644 index 0000000..dca1b1e --- /dev/null +++ b/getDBLog.php @@ -0,0 +1,35 @@ + \ No newline at end of file diff --git a/warehouse_get.php b/warehouse_get.php new file mode 100644 index 0000000..2ad92f4 --- /dev/null +++ b/warehouse_get.php @@ -0,0 +1,109 @@ +message != ""){ + error_log($web_result); + + // Push to Matrix + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL,$web_hook_room); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array('secret' => $web_hook_secret, 'message' => "Error on the data warehouse"))); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); + $result = curl_exec($ch); + curl_close($ch); + + exit(); + }else{ + foreach($json_object->data->transactions as $query) { + $result = mysqli_query ( $connect, $query->argument ); + $records_inserted = $records_inserted +1; + } + + // Push to Matrix + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL,$web_hook_room); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array('secret' => $web_hook_secret, 'message' => "Data warehouse inserted ".$records_inserted." queries"))); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); + $result = curl_exec($ch); + curl_close($ch); + } + }catch (Exception $e) { + $error_message = 'Exception Message: ' .$e->getMessage(); + error_log($error_message); + error_log($web_result); + + // Push to Matrix + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL,$web_hook_room); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array('secret' => $web_hook_secret, 'message' => "Error on the data warehouse"))); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); + $result = curl_exec($ch); + curl_close($ch); + } + +}else{ + echo '{ "message": "Invalid post variables", "data": {}}'; +} +?> \ No newline at end of file