donations.php

cleanup
This commit is contained in:
schrom01 2023-02-16 20:46:12 +01:00
parent f0a1149558
commit 456afc6a12
3 changed files with 27 additions and 10 deletions

View File

@ -1,5 +1,6 @@
<?php
require $_SERVER['DOCUMENT_ROOT'] . '/spreadSheetReader/read_write_xlsx.php';
require $_SERVER['DOCUMENT_ROOT'] . '/databaseConnection/databaseConnection.php';
$fileName = $_SERVER['DOCUMENT_ROOT'] . '/data/data.xlsx';
function objectToArray($object, $fullJSON) {
return [$object -> id,
@ -13,12 +14,8 @@ function objectToArray($object, $fullJSON) {
$object -> countWatchD];
}
$databaseAddress = "127.0.0.1";
$databasePort = "3306";
$databaseName = "u517357132_genderwatchpro";
$databaseUser = "u517357132_genderwatchpro";
$databasePassword = "zU!7gRHA6x";
$conn = new mysqli($databaseAddress, $databaseUser, $databasePassword, $databaseName);
$conn = getDatabaseConnection();
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);

View File

@ -0,0 +1,10 @@
<?php
function getDatabaseConnection() {
$databaseAddress = "127.0.0.1";
$databasePort = "3306";
$databaseName = "u517357132_genderwatchpro";
$databaseUser = "u517357132_genderwatchpro";
$databasePassword = "zU!7gRHA6x";
return new mysqli($databaseAddress, $databaseUser, $databasePassword, $databaseName);
}

View File

@ -1,15 +1,25 @@
<?php
$dolibarrURL = "https://dolibarr.romanschenk.ch/";
$dolibarrAPIKey = "4mQX4x4x65MlkGZ9HUD5A4oElqTn92kl";
require $_SERVER['DOCUMENT_ROOT'] . '/databaseConnection/databaseConnection.php';
$conn = getDatabaseConnection();
$sql = "SELECT `value` FROM `dolibarrInformation` WHERE `information` = 'apiKey'";
$result = $conn->query($sql);
$dolibarrAPIKey = mysql_fetch_array($result)["value"];
$conn = getDatabaseConnection();
$sql = "SELECT `value` FROM `dolibarrInformation` WHERE `information` = 'url'";
$result = $conn->query($sql);
$dolibarrURL = mysql_fetch_array($result)["value"];
function createDonation($amount, $dolibarrURL, $dolibarrAPIKey) {
$BusinesspartnerID = "220";
$pulicNote = "Automatisch generiert von genderwatchprotocol.com";
$pulicNote = "Automatisch generiert von genderwatchprotocol";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $dolibarrURL."api/index.php/donations");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"amount\": ".$amount.", \"date\": ".time().", \"socid\": ".$BusinesspartnerID.", \"note_public\": \"Automatisch generiert von genderwatchprotocol.com\"}");
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"amount\": ".$amount.", \"date\": ".time().", \"socid\": ".$BusinesspartnerID.", \"note_public\": \"".$pulicNote."\"}");
$headers = array();
$headers[] = 'Content-Type: application/json';