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 39 additions and 34 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

@@ -14,36 +14,37 @@ function sendToTroy($data) {
return file_get_contents ( $url, false, $context ); return file_get_contents ( $url, false, $context );
} }
function sendToGitea($title, $message) { function troysIssue($ident, $typ, $text = null, $data = [], $reaction = []) {
// secret.php liegt in lib/ global $sql;
require 'secret.php'; $url = "https://issues.troy-grunt.de/api/input";
$url = rtrim($giteaUrl, '/') . "/repos/$giteaOwner/$giteaRepo/issues"; $payload = [
"domain" => $sql->issuedata['domain'],
$data = [ "secret" => $sql->issuedata['secret'],
"title" => $title, "ident" => $ident,
"body" => $message "typ" => $typ,
"text" => $text,
"data" => $data,
"reaction" => $reaction
]; ];
// Entferne null-Werte aus dem Array
$payload = array_filter($payload, function ($value) {
return $value !== null;
});
$options = [ $options = [
'http' => [ "http" => [
'method' => 'POST', "header" => "Content-Type: application/json\r\n",
'header' => [ "method" => "POST",
"Content-Type: application/json", "content" => json_encode($payload),
"Authorization: token $giteaToken" "ignore_errors" => true
],
'content' => json_encode($data)
] ]
]; ];
$context = stream_context_create($options); $context = stream_context_create($options);
$result = file_get_contents($url, false, $context); $result = file_get_contents($url, false, $context);
if ($result === FALSE) {
throw new Exception("Fehler beim Erstellen der Anfrage");
}
return json_decode($result, true); return json_decode($result, true);
} }
?> ?>