Cookie ajouté pour le thème du site
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
f18ff6cbcf
commit
4ea6f09766
@ -1,21 +1,28 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
index index.php;
|
||||
root /var/www/public;
|
||||
error_page 404 /index.php;
|
||||
|
||||
root /var/www/html;
|
||||
index index.php index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
location ~ ^/(images|javascript|js|css|flash|media|static)/ {
|
||||
root /var/www/public;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
include fastcgi_params;
|
||||
fastcgi_pass php:9000; # service name defined in docker-compose.yml file
|
||||
fastcgi_pass web:9000; # service name defined in docker-compose.yml file like web
|
||||
fastcgi_param REQUEST_METHOD $request_method;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,15 +1,42 @@
|
||||
version: '3'
|
||||
services:
|
||||
web:
|
||||
|
||||
nginx:
|
||||
image: nginx:latest
|
||||
ports:
|
||||
- "8080:80"
|
||||
- "3000:80"
|
||||
volumes:
|
||||
- ./public:/var/www/html
|
||||
- ./config/nginx.conf:/etc/nginx/conf.d
|
||||
links:
|
||||
- php
|
||||
php:
|
||||
image: php:7.4-fpm
|
||||
- ./config/nginx.conf:/etc/nginx/conf.d/default.conf
|
||||
- .:/var/www
|
||||
depends_on:
|
||||
- mysql
|
||||
- web
|
||||
|
||||
web:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./config/Dockerfile
|
||||
ports:
|
||||
- 9000:9000
|
||||
volumes:
|
||||
- ./src:/var/www/html
|
||||
- .:/var/www
|
||||
depends_on:
|
||||
- mysql
|
||||
environment:
|
||||
DB_HOST: mysql
|
||||
DB_PORT: port
|
||||
DB_DATABASE: test
|
||||
DB_USER: user
|
||||
DB_PASSWORD: pass
|
||||
APP_ENV: development
|
||||
|
||||
mysql:
|
||||
image: mysql:latest
|
||||
container_name: my-mysql-container
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: pass
|
||||
MYSQL_DATABASE: test
|
||||
MYSQL_USER: user
|
||||
MYSQL_PASSWORD: pass
|
||||
ports:
|
||||
- "3307:3306"
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,15 @@
|
||||
document.getElementById('saveButton').addEventListener('click', function() {
|
||||
var preferences = {
|
||||
notifications: document.getElementById('notif').checked,
|
||||
theme: document.getElementById('theme').value
|
||||
};
|
||||
|
||||
fetch('/index.php/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(preferences),
|
||||
})
|
||||
.catch((error) => console.error('Error:', error));
|
||||
});
|
@ -0,0 +1,17 @@
|
||||
document.getElementById('saveButton').addEventListener('click', function() {
|
||||
var preferences = {
|
||||
notifications: document.getElementById('notif').checked,
|
||||
theme: document.getElementById('theme').value
|
||||
};
|
||||
|
||||
fetch('/savePreferences', {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(preferences),
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => console.log(data))
|
||||
.catch((error) => console.error('Error:', error));
|
||||
});
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Data\Core;
|
||||
|
||||
class Preferences {
|
||||
private String $cookie;
|
||||
private Array $theme;
|
||||
|
||||
public function __construct(){
|
||||
if (isset($_COOKIE['preferences'])){
|
||||
$this->cookie = $_COOKIE['preferences'];
|
||||
} else {
|
||||
$this->cookie = setcookie('preferences', 'base_theme', time()+(3600*24)*7);
|
||||
}
|
||||
$this->theme = array(
|
||||
'base_theme',
|
||||
'dark_theme',
|
||||
'pink_theme'
|
||||
);
|
||||
}
|
||||
|
||||
public function majCookie(String $maj){
|
||||
try{
|
||||
foreach($this->theme as $t){
|
||||
$this->cookie = $maj;
|
||||
setcookie('preferences', $maj);
|
||||
}
|
||||
} catch (Exception $e){
|
||||
throw new ValueError;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCookie():String{
|
||||
return $this->cookie;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in new issue