Compare commits

..

2 Commits

Author SHA1 Message Date
61b52d8427 troys issues funktion 2025-02-15 21:02:11 +01:00
b475672eac erster versuch 2025-02-15 20:32:58 +01:00
3 changed files with 50 additions and 12 deletions

View File

@ -8,6 +8,8 @@ $_m['data'] = '';
$_m['pre'] = '';
$_m['salt'] = '';
$_m['issuedata'] = ['domain'=>'','secret'=>''];
$_sendermail = 'noreply@.de';
$_smtp['srv'] = 'mail.seemsleg.it';
$_smtp['user'] = 'noreply@.de';

View File

@ -4,6 +4,7 @@ class SQL {
private $res = false;
private $m;
public $salt;
public $issuedata;
public $pre;
public $cnt_get = 0;
public $cnt_set = 0;
@ -11,6 +12,7 @@ class SQL {
require_once ('secret.php');
$this->m = $_m;
$this->issuedata = $_m['issuedata'];
$this->pre = $_m ['pre'];
$this->salt = $_m ['salt'];
if (SQL_LOG)

View File

@ -1,16 +1,50 @@
<?php
function sendToTroy($data) {
$url = 'https://troy-grunt.de/api.php';
$options = array (
'http' => array (
'method' => 'POST',
'header' => array (
'Content-Type: application/json'
),
'content' => json_encode ( $data )
)
);
$context = stream_context_create ( $options );
return file_get_contents ( $url, false, $context );
$url = 'https://troy-grunt.de/api.php';
$options = array (
'http' => array (
'method' => 'POST',
'header' => array (
'Content-Type: application/json'
),
'content' => json_encode ( $data )
)
);
$context = stream_context_create ( $options );
return file_get_contents ( $url, false, $context );
}
function troysIssue($ident, $typ, $text = null, $data = [], $reaction = []) {
global $sql;
$url = "https://issues.troy-grunt.de/api/input";
$payload = [
"domain" => $sql->issuedata['domain'],
"secret" => $sql->issuedata['secret'],
"ident" => $ident,
"typ" => $typ,
"text" => $text,
"data" => $data,
"reaction" => $reaction
];
// Entferne null-Werte aus dem Array
$payload = array_filter($payload, function ($value) {
return $value !== null;
});
$options = [
"http" => [
"header" => "Content-Type: application/json\r\n",
"method" => "POST",
"content" => json_encode($payload),
"ignore_errors" => true
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
return json_decode($result, true);
}
?>