erster versuch

This commit is contained in:
Troy Grunt 2025-02-15 20:32:58 +01:00
parent 560ef6589c
commit b475672eac
3 changed files with 50 additions and 12 deletions

View File

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

View File

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

View File

@ -1,16 +1,50 @@
<?php <?php
function sendToTroy($data) { function sendToTroy($data) {
$url = 'https://troy-grunt.de/api.php'; $url = 'https://troy-grunt.de/api.php';
$options = array ( $options = array (
'http' => array ( 'http' => array (
'method' => 'POST', 'method' => 'POST',
'header' => array ( 'header' => array (
'Content-Type: application/json' 'Content-Type: application/json'
), ),
'content' => json_encode ( $data ) 'content' => json_encode ( $data )
) )
); );
$context = stream_context_create ( $options ); $context = stream_context_create ( $options );
return file_get_contents ( $url, false, $context ); return file_get_contents ( $url, false, $context );
}
function troysIssue($ident, $typ, $text = null, $data = [], $reaction = [], $wait_til = null) {
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);
} }
?> ?>