diff --git a/data/definition.js b/data/definition.js index f97a26c..939fc8c 100755 --- a/data/definition.js +++ b/data/definition.js @@ -368,7 +368,7 @@ const language = "de"; */ const statsRecord = 0; -const statsServer = "http://localhost/extras/statistics/vote_txt.php"; +const statsServer = "http://localhost/extras/statistics/vote_db.php"; /* diff --git a/extras/statistics/results.txt b/extras/statistics/results.txt index bbebd90..1701725 100644 --- a/extras/statistics/results.txt +++ b/extras/statistics/results.txt @@ -18,3 +18,6 @@ 0.0.0.0 2021-07-02 1,-1,-1,-1,-1,1 1.5,6,4,3 0.0.0.0 2021-07-02 -1,-1,-1,-1,-1,-1 1.5,4,4,3 0.0.0.0 2021-07-02 -1,0,1,99 5,1,0,2 +0.0.0.0 2023-02-05 1,-1,-1,-1,-1,1 1.5,6,4,3 Bananen,TBC,Neutrale,APPD +0.0.0.0 2023-02-05 1,1,1,1,1,1 4.5,2,2,3 APPD,Neutrale,Bananen,TBC +0.0.0.0 2023-02-05 1,-1,-1,-1,-1,1 1.5,6,4,3 Bananen,TBC,Neutrale,APPD diff --git a/extras/statistics/results_db.sql b/extras/statistics/results_db.sql index 6eb2fed..be91f36 100644 --- a/extras/statistics/results_db.sql +++ b/extras/statistics/results_db.sql @@ -3,6 +3,7 @@ -- https://www.phpmyadmin.net/ -- COMMIT: Marius Nisslmueller, Bad Honnef, Juni 2020 +-- Anpassungen: Mathias Steudtner, Februar 2023 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; @@ -18,7 +19,8 @@ CREATE TABLE `Results` ( `ip` varchar(255) NOT NULL, `timestamp` varchar(255) NOT NULL, `personal` varchar(255) NOT NULL, - `parties` varchar(1023) NOT NULL + `parties` varchar(1023) NOT NULL, + `partynames` varchar(1023) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- diff --git a/extras/statistics/vote_db.php b/extras/statistics/vote_db.php index b497cdc..536aad5 100644 --- a/extras/statistics/vote_db.php +++ b/extras/statistics/vote_db.php @@ -1,7 +1,7 @@ EMPFOHLENE EINSTELLUNG (gemäß DSGVO), da politische Meinungen abgefragt werden. // -// EN: If you do not wish to save any IP addresses (privacy) please uncomment the following line. +// EN: If you do not wish to save any IP addresses (privacy) please activate the following "$ip" line. // It replaces the result of "$ip" with zeros but keeps the right format. -// -> SUGGESTED SETTING (according to EDPR) because you're asking for political views +// -> SUGGESTED SETTING (according to EDPR) because we're asking for political views $ip="0.0.0.0"; - + // $timestamp = time(); // Unix-Zeitstempel // $timestamp = date("Y-m-d H:i:s"); ausführliches Datumsformat -> nicht empfohlen, da rückverfolgbar über ACCESS.LOG @@ -43,9 +43,11 @@ // Sanitize User Input $mowPersonalValues = mysqli_real_escape_string($conn, $_GET["mowpersonal"]); $mowPartiesValues = mysqli_real_escape_string($conn, $_GET["mowparties"]); + $mowPartynamesValue = mysqli_real_escape_string($conn, $_GET["mowpartynames"]); + // Prepare and execute SQL Statement - $sql = "INSERT INTO `$tablename` (ip, timestamp, personal, parties) VALUES ('$ip', '$timestamp', '$mowPersonalValues', '$mowPartiesValues')"; + $sql = "INSERT INTO `$tablename` (ip, timestamp, personal, parties, partynames) VALUES ('$ip', '$timestamp', '$mowPersonalValues', '$mowPartiesValues', '$mowPartynamesValue')"; // Send data diff --git a/extras/statistics/vote_txt.php b/extras/statistics/vote_txt.php index 9b5e6e4..88ecc19 100644 --- a/extras/statistics/vote_txt.php +++ b/extras/statistics/vote_txt.php @@ -97,7 +97,7 @@ // $timestamp = date("Y-m-d H:i:s"); ausführliches Datumsformat -> nicht empfohlen, da rückverfolgbar über ACCESS.LOG $timestamp = date("Y-m-d"); -$somecontent = "\n".$ip." ".$timestamp." ".$_GET["mowpersonal"]." ".$_GET["mowparties"]; +$somecontent = "\n".$ip." ".$timestamp." ".$_GET["mowpersonal"]." ".$_GET["mowparties"]." ".$_GET["mowpartynames"]; // DE: Sichergehen, dass die Datei existiert und beschreibbar ist // EN: Let's make sure the file exists and is writable first. diff --git a/system/changelog.md b/system/changelog.md index 143eaa5..bb98a71 100755 --- a/system/changelog.md +++ b/system/changelog.md @@ -21,6 +21,10 @@ ## Versions: +### 0.6.0.8.20230205 + +- Added a new column `partynames` to the SQL-queries and data-base. So, it's easier to see results. + ### 0.6.0.7.20230203 - Addon `extras/addon_contacts_in_results.js` can now read email addresses from data-tags in `parties.csv` diff --git a/system/general.js b/system/general.js index af572bb..9ac6ebe 100755 --- a/system/general.js +++ b/system/general.js @@ -3,7 +3,7 @@ // License: GPL 3 // Mathias Steudtner http://www.medienvilla.com -var version = "0.6.0.7.20230203" +var version = "0.6.0.8.20230205" // Globale Variablen var arQuestionsShort = new Array(); // Kurzform der Fragen: Atomkraft, Flughafenausbau, ... @@ -182,14 +182,21 @@ function fnSendResults(arResults, arPersonalPositions) } } - - var strResults = arResults.join(","); - // var strPersonalPositions = arPersonalPositions.join(","); - var strPersonalPositions = arPersonalPositionsForStats.join(","); + // Ergebnisse für Statistik vorbereiten + const strResults = arResults.join(","); + const strPersonalPositions = arPersonalPositionsForStats.join(","); + + let strPartynames = ""; + for (let i=0; i<=intParties-1; i++) { + let partyNum=arSortParties[i]; + let strPartyname = arPartyNamesShort[partyNum] + strPartynames += strPartyname+"," + } + strPartynames = strPartynames.slice(0, -1) // letztes Komma wieder entfernen. ;-) - $.get(statsServer, { mowpersonal: strPersonalPositions, mowparties: strResults } ); + $.get(statsServer, { mowpersonal: strPersonalPositions, mowparties: strResults, mowpartynames: strPartynames } ); - console.log("Mat-O-Wahl. Daten gesendet an Server: "+statsServer+" - mowpersonal: "+strPersonalPositions+" - mowparties: "+strResults+"") + console.log("Mat-O-Wahl. Statistik an Server gesendet: "+statsServer+" ? mowpersonal= "+strPersonalPositions+" & mowparties= "+strResults+" & mowpartynames= "+strPartynames) }