mirror of
https://github.com/voc/streaming-website
synced 2024-11-10 14:44:21 +00:00
chore: centralize feedback config
This commit is contained in:
parent
d7f88962cc
commit
f77b532447
3 changed files with 43 additions and 6 deletions
31
config.php
31
config.php
|
@ -64,6 +64,37 @@ $GLOBALS['CONFIG']['DOWNLOAD'] = [
|
|||
];
|
||||
|
||||
$GLOBALS['CONFIG']['CDN'] = "cdn.c3voc.de";
|
||||
|
||||
/**
|
||||
* Konfiguration des Feedback-Formulars
|
||||
*
|
||||
* Wird dieser Block auskommentiert, wird das gesamte Feedback-System deaktiviert
|
||||
*/
|
||||
$GLOBALS['CONFIG']['FEEDBACK'] = array(
|
||||
/**
|
||||
* DSN zum abspeichern der eingegebenen Daten
|
||||
* die Datenbank muss eine Tabelle enthaltem, die dem in `lib/schema.sql` angegebenen
|
||||
* Schema entspricht.
|
||||
*
|
||||
* Achtung vor Dateirechten: Bei SQLite reicht es nicht, wenn wer Webseiten-Benutzer
|
||||
* die .sqlite3-Datei schreiben darf, er muss auch im übergeordneten Order neue
|
||||
* (Lock-)Dateien anlegen dürfen
|
||||
*/
|
||||
'DSN' => 'sqlite:/opt/streaming-feedback/feedback.sqlite3',
|
||||
|
||||
/**
|
||||
* Login-Daten für die /feedback/read/-Seite, auf der eingegangenes
|
||||
* Feedback gelesen werden kann.
|
||||
*
|
||||
* Durch auskommentieren der beiden Optionen wird diese Seite komplett deaktiviert,
|
||||
* es kann dann nur noch durch manuelle Inspektion der .sqlite3-Datei auf das Feedback
|
||||
* zugegriffen werden.
|
||||
*/
|
||||
'USERNAME' => 'katze',
|
||||
'PASSWORD' => trim(@file_get_contents('/opt/streaming-feedback/feedback-password')),
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Konfiguration der Room-Defaults
|
||||
*
|
||||
|
|
|
@ -162,7 +162,7 @@ class Conference extends ModelBase
|
|||
}
|
||||
|
||||
public function hasFeedback() {
|
||||
return $this->has('FEEDBACK');
|
||||
return $this->has('FEEDBACK') && $this->get('FEEDBACK') !== false;
|
||||
}
|
||||
public function getFeedbackUrl() {
|
||||
return joinpath([$this->getSlug(), 'feedback']).url_params();
|
||||
|
|
|
@ -9,6 +9,12 @@ class Feedback
|
|||
$this->conference = $conference;
|
||||
}
|
||||
|
||||
private function get($key) {
|
||||
return $this->conference->has(['FEEDBACK', $key])
|
||||
? $this->conference->get(['FEEDBACK', $key])
|
||||
: @$GLOBALS['CONFIG']['FEEDBACK'][$key];
|
||||
}
|
||||
|
||||
public function getConference() {
|
||||
return $this->conference;
|
||||
}
|
||||
|
@ -27,7 +33,7 @@ class Feedback
|
|||
|
||||
public function store($info)
|
||||
{
|
||||
$db = new PDO($this->getConference()->get('FEEDBACK.DSN'));
|
||||
$db = new PDO($this->get('DSN'));
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$stm = $db->prepare('
|
||||
|
@ -56,8 +62,8 @@ class Feedback
|
|||
{
|
||||
return
|
||||
isset($_SERVER['PHP_AUTH_USER']) &&
|
||||
$_SERVER['PHP_AUTH_USER'] == $this->getConference()->get('FEEDBACK.USERNAME') &&
|
||||
$_SERVER['PHP_AUTH_PW'] == $this->getConference()->get('FEEDBACK.PASSWORD');
|
||||
$_SERVER['PHP_AUTH_USER'] == $this->get('USERNAME') &&
|
||||
$_SERVER['PHP_AUTH_PW'] == $this->get('PASSWORD');
|
||||
}
|
||||
|
||||
public function requestLogin()
|
||||
|
@ -70,12 +76,12 @@ class Feedback
|
|||
|
||||
public function read($from, $to)
|
||||
{
|
||||
$db = new PDO($this->getConference()->get('FEEDBACK.DSN'));
|
||||
$db = new PDO($this->get('DSN'));
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$stm = $db->prepare('
|
||||
SELECT *
|
||||
FROM feedback
|
||||
FROM feedback
|
||||
WHERE reported BETWEEN :from AND :to
|
||||
ORDER BY reported DESC
|
||||
');
|
||||
|
|
Loading…
Reference in a new issue