From 456afc6a124af420b987a367ffce6a3d81c4b3e3 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Thu, 16 Feb 2023 20:46:12 +0100 Subject: [PATCH] donations.php cleanup --- dataCollector/dataCollector.php | 9 +++------ databaseConnection/databaseConnection.php | 10 ++++++++++ donations/donations.php | 18 ++++++++++++++---- 3 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 databaseConnection/databaseConnection.php diff --git a/dataCollector/dataCollector.php b/dataCollector/dataCollector.php index 66f22d4..867420a 100644 --- a/dataCollector/dataCollector.php +++ b/dataCollector/dataCollector.php @@ -1,5 +1,6 @@ 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); diff --git a/databaseConnection/databaseConnection.php b/databaseConnection/databaseConnection.php new file mode 100644 index 0000000..8e4ba03 --- /dev/null +++ b/databaseConnection/databaseConnection.php @@ -0,0 +1,10 @@ +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';