Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 77 add partyname to statistics #80

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";


/*
Expand Down
3 changes: 3 additions & 0 deletions extras/statistics/results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion extras/statistics/results_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

--
Expand Down
14 changes: 8 additions & 6 deletions extras/statistics/vote_db.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

// COMMIT: Marius Nisslmueller, Bad Honnef, Juni 2020
// Anpassungen: Mathias Steudtner, Mai 2021
// Anpassungen: Mathias Steudtner, 05/2021, 02/2023

// Include Database Settings
include "db_settings.php";
Expand All @@ -25,16 +25,16 @@
$ip = explode (',', $ip);
$ip = $ip[0];

// DE: Wenn keine IP gespeichert werden soll, einfach die folgende Zeile auskommentieren.
// DE: Wenn keine IP gespeichert werden soll, einfach die folgende Zeile "$ip" aktivieren.
// Hierbei wird das soeben erhaltene Ergebnis von "$ip" mit einem "Null-Wert" überschrieben
// aber das Format für die simple Auswertung (results.html) bleibt erhalten.
// -> 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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion extras/statistics/vote_txt.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions system/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
21 changes: 14 additions & 7 deletions system/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...
Expand Down Expand Up @@ -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)
}


Expand Down