This commit is contained in:
Gilles Mouchet 2025-02-07 20:52:27 +01:00
commit 407859b310
82 changed files with 15481 additions and 0 deletions

6
.env.dist Normal file
View File

@ -0,0 +1,6 @@
# must be the same that SITE_VERSION define in php-fpm/.env
DOCKER_IMAGE_VERSION="3.25"
# docker image tag = DOCKER_IMAGE_VERSION
DOCKER_IMAGE=gmouchet/wwwgmo-php-fpm
NGINX_PORT=8085
PMA_PORT_WEB=8084

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
**/vendor
**/certs/*
.env
helm-old
mariadb-old

5
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"editor.fontSize": 13,
"terminal.integrated.fontSize": 13,
"window.zoomLevel": 1.4,
}

212
README.md Normal file
View File

@ -0,0 +1,212 @@
# wwwgmo stack
## Description
Examples site with nginx, phpfpm, mysql, phpmyadmin, elasticsearch and kibana
## Build environment
|**folders**|**description**|
|:---|:---|
|docker.sh|files to build the docker image|
|docker/mariadb|env file|
|docker/nginx|config file|
|docker/php-fpm|files to create docker image|
|src|site source|
## Docker
### Global environment variables
Copy file ALL `.env.dist` to `.env`
Complete or modify the values according to your needs
### Build
#### Install plugin php for elasticsearch
./docker.sh install
#### Build image
./docker.sh build
or
./docker.sh build-no-cache
### Start
./docker.sh start
#### Check
docker exec wwwgmo-mariadb mysql -uroot -p<MYSQL_ROOT_PASSWORD> mysql -e 'SELECT user,host FROM mysql.user;'
docker exec wwwgmo-elasticsearch curl -u elastic:<ELASTIC_PASSWORD> http://wwwgmo-elasticsearch:9200/_cluster/health?pretty
docker exec wwwgmo-php-fpm curl -s -u elastic:<ELASTIC_PASSWORD> http://wwwgmo-elasticsearch:9200/_cluster/health?pretty
#### Access
http://<server_name>:<NGINX_PORT>
## kubernetes
|**folders**|**description**|
|:---|:---|
|deploy.sh|files to deploy on k8s or k3s (see ./deploy.s -h)|
|helm|Chart root folder|
|Chart.yaml|Charts file|
|values-configs.yml|configs file use for kubernetes manifest|
|values-secrets.yaml|secrets file for kubernetes manifet (Must be encrypted with sops in a production environment)|
|templates/elasticsearch|manifests for elasticsearch|
|templates/kibana|manifests for kibana|
|templates/mariadb|manifests for mariadb|
|templates/phpmyadmin|manifests for phpmyadmin|
|templates/php-fpm|manifest for php-fpm|
### Secret registry (regcred)
You need credential to pull an image from private registry.
Create or modify the secret
```
kubectl create secret docker-registry secret-regcred --dry-run \
--docker-server=https://index.docker.io/v1/ \
--docker-username=<username> \
--docker-password=<secret> \
--docker-email=<adress@sample.com> -o yaml > helm/template/site/secret-regcred.yaml
```
### Certificats
cat certs/gmolab.net.key | base64 -w0
copy the base64 result into file `values-secrets-kXs.yaml` in ssl_key key
cat certs/gmolab.net.crt | base64 -w0
copy the base64 result into file `values-config-kXs.yaml` in ssl_crt key
### Docker image version
In the `helm/Chart.yaml` file, the `appVersion` value must match the version of the docker image (see DOCKER_IMAGE_VERSION in the `.env` file and SITE_VERSION in the `docker/php-fpm/.env` file)
## Deployment by script
This is the recommended way
>This script builds the docker image based on the Kubernetes VM architecture (AMD64 or ARM64). At each deployment the minor version of the image is incremented by 1.
./deploy.md -n wwwgmo -k k3s
## Manual deployment
### Set kubesystem config
rm -f $HOST/.kube/config
for **k3s**
ln -s $HOST/.kube/k3s $HOST/.kube/config
for **k8s**
ln -s $HOST/.kube/k8s $HOST/.kube/config
### Set namespace and kube system
export NS=wwwgmo
export KUBE_SYS=k3s|k8s
### Test template
helm template $NS --set kube=$KUBE_SYS ./helm --values=./helm/values-configs.yaml --values=./helm/values-secrets.yaml --namespace $NS
### Chart deployment
helm upgrade $NS --set kube=$KUBE_SYS ./helm --install --atomic --cleanup-on-fail --values=./helm/values-configs.yaml --values=./helm/values-secrets.yaml --namespace $NS --create-namespace
## Remove
helm uninstall $NS -n $NS
kubectl delete namespaces $NS
## NOTES
### Cronjob
When we deploy manually (I do not why) you must trig manually the cronjob to make a DB backup to termine correctly the helm command
kubectl create job -n $NS --from=cronjob/cronjob-mariadb-backupdb dbbackup-$(date +%Y-%m-%d-%H-%M-%S)
## Database
Not necessary because created during deployment. We leave the procedure below for information
First export NS environment variable
export NS=<your_namespace>
You can use `createDBOnKube.sh` or create manually with below commands
#### Create user
```bash
kubectl -n $NS exec statefulset-mariadb-0 --container mariadb -- /bin/bash -c "/usr/bin/mysql -u root -p<rootPass> -e \"CREATE USER 'gmo_db'@'%' IDENTIFIED BY '<dbPass>';\""
```
#### Check user
```bash
kubectl -n $NS exec statefulset-mariadb-0 --container mariadb -- /bin/bash -c "/usr/bin/mysql -u root -p<rootPass> -e 'SELECT user,host FROM mysql.user;'"
```
#### Create database
```bash
kubectl -n $NS exec statefulset-mariadb-0 --container mariadb -- /bin/bash -c "/usr/bin/mysql -u root -p<rootPass> -e \"CREATE DATABASE gmo_db;\""
```
#### Check database
```bash
kubectl -n $NS exec statefulset-mariadb-0 --container mariadb -- /bin/bash -c "/usr/bin/mysql -u root -p<rootPass> -e 'SHOW DATABASES;'"
```
#### Grants access
```bash
kubectl -n $NS exec statefulset-mariadb-0 --container mariadb -- /bin/bash -c "/usr/bin/mysql -u root -p<rootpass> -e \"GRANT ALL PRIVILEGES ON gmo_db.* TO 'gmo_db'@'%';FLUSH PRIVILEGES;\""
```
#### Check grants
```bash
kubectl -n $NS exec statefulset-mariadb-0 --container mariadb -- /bin/bash -c "/usr/bin/mysql -u root -p<rootPass> -e \"SHOW GRANTS FOR 'gmo_db'@'%';\""
```
## Troubeshooting
### How to Fix "Pods stuck in Terminating status" Error
```bash
kubectl get pods --all-namespaces | grep Terminating | while read line; do
pod_name=$(echo $line | awk '{print $2}' ) \
name_space=$(echo $line | awk '{print $1}' ); \
kubectl delete pods $pod_name -n $name_space --grace-period=0 --force
done
```
## Sources
[Elasticsearch-PHP](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html)
[Pull an Image from a Private Registry](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/)
[MariaDB Statefulset](https://mariadb.org/create-statefulset-mariadb-application-in-k8s/)
[PHP-FPM, nginx, kubernetes and docker](https://matthewpalmer.net/kubernetes-app-developer/articles/php-fpm-nginx-kubernetes.html)
## Changelog
### 3.25 (2024-04-14)
**New features:**
* added elasticsearch and kibana
* added option `install` to script `docker.sh` to install php elasticserch module
* created `deploy.sh` script
**Fixed bugs:**
* problem with display environment var in php site
**Updated:**
* added new features in README.md
* added Changelog part in README.md
---
### 2.5 (2024-03-29)
**Fixed bugs:**
* fixed somes bugs
**New features:**
* posibility to deploy on k3s or k8s
**Updated:**
* updated README.md
---
### 1.0 (2024-03-01)
* Created from scratch

44
configmap-nginx-not.yaml Normal file
View File

@ -0,0 +1,44 @@
# First, create a ConfigMap whose contents are used
# as the nginx.conf file in the web server.
# This server uses /var/www/html as its
# root document directory. When the server gets a
# request for *.php, it will forward that request
# to our PHP-FPM container.
kind: ConfigMap
apiVersion: v1
metadata:
name: configmap-nginx
labels:
{{- include "site.labels" . | nindent 4 }}
data:
default.conf: |
server {
listen 8080 default_server;
# Set nginx to serve files from the shared volume!
root /var/www/html/web;
index index.php;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
root /var/www/html/web;
try_files $uri =404;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $request_filename;
#fastcgi_split_path_info ^(.+\.php)(/.+)$;
#try_files $uri =404;
#include fastcgi_params;
#fastcgi_param REQUEST_METHOD $request_method;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_pass 127.0.0.1:9000;
}
}

66
configmap-nginx.yaml.old Normal file
View File

@ -0,0 +1,66 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: configmap-nginx
labels:
{{- include "site.labels" . | nindent 4 }}
data:
default.conf: |
# from http://geekyplatypus.com/dockerise-your-php-application-with-nginx-and-php7-fpm/
# Gzip Settings
gzip on;
# gzip_vary on;
gzip_proxied any;
gzip_comp_level 5;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# Security Headers
#add_header Content-Security-Policy "default-src 'self' https: data: 'unsafe-inline' 'unsafe-eval';" always;
#add_header X-Xss-Protection "1; mode=block" always;
#add_header X-Frame-Options "SAMEORIGIN" always;
#add_header X-Content-Type-Options "nosniff" always;
#add_header Referrer-Policy "origin-when-cross-origin" always;
#add_header Strict-Transport-Security "max-age=31536000" always;
server {
index index.php;
root /var/www/html/web;
listen 8080;
server_name _;
error_log /dev/stderr;
access_log /dev/stdout;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~ /\. {
deny all;
}
location / {
disable_symlinks off;
try_files $uri $uri/ /index.php;
}
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass archivescacm-php-fpm:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}

61
createDbOnKube.sh Executable file
View File

@ -0,0 +1,61 @@
#!/bin/bash
# check yq is installed
if [ ! -f "/usr/local/bin/yq" ]; then
echo "yq does not exist"
echo "see https://github.com/mikefarah/yq/releases/ to install yq"
exit
fi
# check env var NS (namespace is define)
if [ -z "${NS}" ]; then
echo "Environmet var NS is not defined"
exit
fi
echo "Namespace is $NS"
# set rootPass
root_pass=$(yq .mariadb.rootPass < helm/values-secrets-k3s.yaml)
# set user db
db_user=$(yq .site.phpfpmSite.db.user < helm/values-configs-k3s.yaml)
# set pass db
db_user_pass=$(yq .mariadb.dbPass < helm/values-secrets-k3s.yaml)
# set db name
db_name=$(yq .site.phpfpmSite.db.name < helm/values-configs-k3s.yaml)
echo "Root pass: $root_pass"
echo "DB user: $db_user"
echo "DB user pass: $db_user_pass"
echo "DB name: $db_name"
echo -e "\n"
echo "Create user if not exists"
kubectl -n $NS exec statefulset-mariadb-0 --container mariadb -- /bin/bash -c \
"/usr/bin/mysql -u root -p$root_pass -e \"CREATE USER IF NOT EXISTS '$db_user'@'%' IDENTIFIED BY '$db_user_pass';\""
echo "Check user ------------"
kubectl -n $NS exec statefulset-mariadb-0 --container mariadb -- /bin/bash -c \
"/usr/bin/mysql -u root -p$root_pass -e \"SELECT user,host FROM mysql.user WHERE user LIKE '$db_user%';\""
echo -e "-----------------------\n"
echo "Create database if not exists"
kubectl -n $NS exec statefulset-mariadb-0 --container mariadb -- /bin/bash -c \
"/usr/bin/mysql -u root -p$root_pass -e \"CREATE DATABASE IF NOT EXISTS $db_name;\""
echo "Check database---------"
kubectl -n $NS exec statefulset-mariadb-0 --container mariadb -- /bin/bash -c \
"/usr/bin/mysql -u root -p$root_pass -e \"SHOW DATABASES;\""
echo -e "-----------------------\n"
echo "Grants access"
kubectl -n $NS exec statefulset-mariadb-0 --container mariadb -- /bin/bash -c \
"/usr/bin/mysql -u root -p$root_pass -e \"GRANT ALL PRIVILEGES ON $db_name.* TO '$db_user'@'%';FLUSH PRIVILEGES;\""
echo "Check access-----------"
kubectl -n $NS exec statefulset-mariadb-0 --container mariadb -- /bin/bash -c \
"/usr/bin/mysql -u root -p$root_pass -e \"SHOW GRANTS FOR '$db_user'@'%';\""
echo -e "-----------------------\n"
#kubectl -n $NS exec statefulset-mariadb-0 --container mariadb -- /bin/bash -c \
#"/usr/bin/mysql -u root -p$root_pass -e \"DROP USER IF EXISTS '$db_user'@'%';\""
#kubectl -n $NS exec statefulset-mariadb-0 --container mariadb -- /bin/bash -c \
#"/usr/bin/mysql -u root -p$root_pass -e \"DROP DATABASE IF EXISTS $db_name;\""

1
cron Normal file
View File

@ -0,0 +1 @@
/usr/bin/mysqldump --verbose --hex-blob --complete-insert --single-transaction --skip-lock-tables --skip-add-locks --routines -h service-mariadb -uroot -ppa55w0rd wwwgmo | gzip - > /var/backups/$MYSQL_DATABASE-$(date +%Y-%m-%d_%H%M%S).sql.gz; find /var/backups/ -type f -mindepth 1 -mtime +14 -exec rm {} \;

142
deploy.sh Executable file
View File

@ -0,0 +1,142 @@
#!/bin/bash
############################################################
# Decription: Preinst linux GMo cloned server from VMWare WS
# Author: Gilles Mouchet (gilles.mouchet@gmail.com)
# Creation Date: 07-Apr-2024
# Version: 1.0
#
# V1.0 - 07-Apr-2024 - GMo
# Added
# - Creation of script from scratch
#
############################################################
version="1.0"
usage() {
cat << EOF
Usage: ./deploy.sh options
Deploy application on kubernetes
Options:
-n namespace
-k kubernetes system (k3s or k8s)
-h display this help text
-v version
EOF
}
options=$(getopt n:k:hv "$*")
[ $? -eq 0 ] || {
echo "Incorrect options provided"
usage
exit 1
}
eval set -- "$options"
no_args="true"
while true; do
case "$1" in
-k)
shift
case "$1" in
k3s)
kube_sys=$1
;;
k8s)
kube_sys=$1
;;
*)
usage
exit 1
;;
esac
;;
-n)
shift
ns=$1
;;
--)
shift
break
;;
-h)
usage
exit
;;
-v)
cat << EOF
deploy.sh $version
Copyright (C) 2021-`date +"%Y"` - GMo Free Software.
Written by Gilles Mouchet (gilles.mouchet@gmail.com)
EOF
exit
;;
*)
usage
exit 1
;;
esac
shift
no_args="false"
done
if [ -z "${kube_sys}" ] || [ -z "${ns}" ]; then
usage
exit 1
fi
# increment minor version at each deploy
# get Chart verion
chart_version=$(grep appVersion helm/Chart.yaml | cut -d '"' -f2)
# get Chart major version
chart_major_version=$(echo $chart_version | cut -d'.' -f1)
# get Chart minor verison
chart_minor_version=$(echo $chart_version | cut -d'.' -f2)
# increment minor version
let "chart_minor_version++"
# set new version
chart_new_version=$chart_major_version.$chart_minor_version
# replace in .env, .env.dist and Chart the version
env_file=(.env .env.dist ./docker/php-fpm/.env ./docker/php-fpm/.env.dist ./helm/Chart.yaml)
for f in ${env_file[@]}; do
case $f in
.env|.env.dist)
#sed -e "s|DOCKER_IMAGE_VERSION=\"$chart_version\"|DOCKER_IMAGE_VERSION=\"$chart_new_version\"|" < $f
sed -i "s|DOCKER_IMAGE_VERSION=\"$chart_version\"|DOCKER_IMAGE_VERSION=\"$chart_new_version\"|" $f
;;
./docker/php-fpm/.env|./docker/php-fpm/.env.dist)
#sed -e "s|SITE_VERSION=\"$chart_version\"|SITE_VERSION=\"$chart_new_version\"|" < $f
sed -i "s|SITE_VERSION=\"$chart_version\"|SITE_VERSION=\"$chart_new_version\"|" $f
;;
./helm/Chart.yaml)
#sed -e "s|appVersion: \"$chart_version\"|appVersion: \"$chart_new_version\"|" < $f
sed -i "s|appVersion: \"$chart_version\"|appVersion: \"$chart_new_version\"|" $f
;;
esac
done
echo $chart_version
echo $chart_new_version
echo $ns
echo $kube_sys
# git commit
git add .env.dist docker/php-fpm/.env.dist helm/Chart.yaml
git commit -m "deploy version $chart_new_version"
# build image and push in repo
./docker.sh install
./docker.sh build
./docker.sh push
# set config to connect kubernetes
rm -f $HOME/.kube/config
ln -s $HOME/.kube/$kube_sys $HOME/.kube/config
#helm template --set kube=$kube_sys ./helm --values=./helm/values-configs.yaml --values=./helm/values-secrets.yaml --namespace $ns --create-namespace
# deploy Chart
helm upgrade $ns --set kube=$kube_sys ./helm --install --atomic --cleanup-on-fail --values=./helm/values-configs.yaml --values=./helm/values-secrets.yaml --namespace $ns --create-namespace
kubectl create job -n $NS --from=cronjob/cronjob-mariadb-backupdb dbbackup-$(date +%Y-%m-%d-%H-%M-%S)

98
docker-compose.yml Normal file
View File

@ -0,0 +1,98 @@
# GMo Lab
#version: '2.3'
services:
## Linux nginx mysql php
wwwgmo-nginx:
container_name: wwwgmo-nginx
hostname: wwwgmo-nginx
image: nginxinc/nginx-unprivileged:1.23-alpine
volumes:
- './docker/nginx/default.conf:/etc/nginx/conf.d/default.conf'
- './certs:/etc/nginx/certs/'
- './src:/var/www/html:rw,cached'
ports:
- '${NGINX_PORT}:8080' #local:docker
depends_on:
- wwwgmo-php-fpm
#
wwwgmo-php-fpm:
container_name: wwwgmo-php-fpm
hostname: wwwgmo-php-fpm
#image: wwwgmo
image: ${DOCKER_IMAGE}:${DOCKER_IMAGE_VERSION}
env_file:
- ./docker/php-fpm/.env
volumes:
- './src/:/var/www/html:rw,cached'
build:
context: .
dockerfile: ./docker/php-fpm/Dockerfile
ports:
- '9000:9000' #local:docker
depends_on:
- wwwgmo-mariadb
wwwgmo-mariadb:
container_name: wwwgmo-mariadb
hostname: wwwgmo-mariadb
#image: mysql:8.0-debian
#image: mysql/mysql-server:8.0.27-aarch64
image: mariadb:10.11.7
volumes:
- 'wwwgmo-mariadb:/var/lib/mysql:z'
env_file:
- ./docker/mariadb/.env # ports:
wwwgmo-phpmyadmin:
container_name: wwwgmo-pma
image: phpmyadmin
links:
- wwwgmo-mariadb
env_file:
- ./docker/mariadb/.env
restart: always
ports:
- ${PMA_PORT_WEB}:80
# EK
wwwgmo-elasticsearch:
container_name: wwwgmo-elasticsearch
hostname: wwwgmo-elasticsearch
image: 'docker.elastic.co/elasticsearch/elasticsearch:7.17.19'
#image: 'docker.elastic.co/elasticsearch/elasticsearch:8.8.1'
volumes:
- 'wwwgmo-elasticsearch:/usr/share/elasticsearch/data'
restart: unless-stopped
env_file:
- ./docker/elasticsearch/.env
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
cap_add:
- IPC_LOCK
ports:
- '9200:9200'
- '9300:9300'
# kibana
wwwgmo_kibana:
container_name: wwwgmo-kibana
hostname: wwwgmo-kibana
image: docker.elastic.co/kibana/kibana:7.17.19
#image: docker.elastic.co/kibana/kibana:8.8.1
restart: unless-stopped
env_file:
- ./docker/kibana/.env
ports:
- 5601:5601
depends_on:
- wwwgmo-elasticsearch
volumes:
wwwgmo-mariadb:
wwwgmo-elasticsearch:

80
docker.sh Executable file
View File

@ -0,0 +1,80 @@
#!/bin/bash
set -e
_UID=$(id -u)
_GID=$(id -g)
export $(grep -v '^#' .env | xargs)
# check if certs folder exite in src
if [ ! -d "./src/certs" ]; then
mkdir ./src/certs
fi
while test $# -gt 0
do
case "$1" in
install)
env UID=${_UID} GID=${_GID} docker compose up -d wwwgmo-php-fpm
#docker exec --user root wwwgmo-php-fpm "/bin/sh -c 'cd /var/www/html/; composer require elasticsearch/elasticsearch'"
docker exec --user root wwwgmo-php-fpm /bin/sh -c "cd /var/www/html; composer require elasticsearch/elasticsearch"
env UID=${_UID} GID=${_GID} docker compose stop
;;
start)
env UID=${_UID} GID=${_GID} docker compose up -d;
docker exec --user root wwwgmo-php-fpm composer install --no-interaction
;;
start-nginx)
env UID=${_UID} GID=${_GID} docker compose up -d wwwgmo-nginx
;;
start-db)
env UID=${_UID} GID=${_GID} docker compose up -d wwwgmo-mariadb
;;
stop)
env UID=${_UID} GID=${_GID} docker compose stop
;;
bash)
docker exec -it wwwgmo-php-fpm /bin/sh
;;
bash-root)
docker exec --user root -it wwwgmo-php-fpm /bin/sh
;;
logs)
docker logs wwwgmo-php-fpm -f
;;
build-no-cache)
#cp ./certs/ca.pem ./src/certs/.
sudo chown -R $_UID:$_GID ./src/
env UID=${_UID} GID=${_GID} docker compose build --pull --no-cache
env UID=${_UID} GID=${_GID} docker compose up -d;
#docker exec --user root wwwgmo-php-fpm composer install --no-interaction
sleep 5 # wait mysql container up
#docker exec -it wwwgmo-mariadb /bin/bash -c "mysql -u root --password=password -e \
# \"CREATE USER IF NOT EXISTS 'xmaroot'@'%' IDENTIFIED BY 'sqlAdmin'; \
# GRANT ALL PRIVILEGES ON *.* TO 'xmaroot'@'%'; \
# flush privileges;\""
env UID=${_UID} GID=${_GID} docker compose stop
;;
build)
#cp ./certs/ca.pem ./src/certs/.
sudo chown -R $_UID:$_GID ./src/
env UID=${_UID} GID=${_GID} docker compose build
env UID=${_UID} GID=${_GID} docker compose up -d;
#docker exec --user root wwwgmo-php-fpm composer install --no-interaction
#sleep 5 # wait mysql container up
#docker exec -it wwwgmo-mysql /bin/bash -c "mysql -u root --password=password -e \
# \"CREATE USER IF NOT EXISTS 'xmaroot'@'%' IDENTIFIED BY 'sqlAdmin'; \
# GRANT ALL PRIVILEGES ON *.* TO 'xmaroot'@'%'; \
# flush privileges;\""
env UID=${_UID} GID=${_GID} docker compose stop
;;
push)
docker image push ${DOCKER_IMAGE}:${DOCKER_IMAGE_VERSION}
;;
*)
echo "docker.sh [start|stop|install|logs|bash-root|bash|build|build-no-cache|push]"
;;
esac
shift
done
exit 0

View File

@ -0,0 +1,6 @@
xpack.security.transport.ssl.enabled=true
xpack.security.enabled=true
discovery.type=single-node
cluster.name=gmo_es_cluster
ELASTIC_USERNAME=elastic
ELASTIC_PASSWORD=pa55w0rd

4
docker/kibana/.env.dist Normal file
View File

@ -0,0 +1,4 @@
ELASTICSEARCH_HOSTS=http://wwwgmo-elasticsearch:9200
ELASTICSEARCH_USERNAME=elastic
ELASTICSEARCH_PASSWORD=pa55w0rd
xpack.security.enabled=true

13
docker/mariadb/.env.dist Normal file
View File

@ -0,0 +1,13 @@
# mariadb
MYSQL_ROOT_PASSWORD=pa55w0rd
# db wwwgmo
MYSQL_DATABASE=wwwgmo
MYSQL_USER=wwwgmo
MYSQL_PASSWORD=password
MYSQL_TCP_PORT=3306
# phpmyadmin
PMA_HOST=wwwgmo-mariadb
PMA_USER=root
PMA_PASSWORD=pa55w0rd
PMA_PORT=3306
PMA_ARBITRARY=1

58
docker/nginx/default.conf Normal file
View File

@ -0,0 +1,58 @@
# from http://geekyplatypus.com/dockerise-your-php-application-with-nginx-and-php7-fpm/
# Gzip Settings
gzip on;
# gzip_vary on;
gzip_proxied any;
gzip_comp_level 5;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# Security Headers
#add_header Content-Security-Policy "default-src 'self' https: data: 'unsafe-inline' 'unsafe-eval';" always;
#add_header X-Xss-Protection "1; mode=block" always;
#add_header X-Frame-Options "SAMEORIGIN" always;
#add_header X-Content-Type-Options "nosniff" always;
#add_header Referrer-Policy "origin-when-cross-origin" always;
#add_header Strict-Transport-Security "max-age=31536000" always;
server {
index index.php;
root /var/www/html;
listen 8080;
server_name _;
error_log /dev/stderr;
access_log /dev/stdout;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~ /\. {
deny all;
}
location / {
disable_symlinks off;
try_files $uri $uri/ /index.php;
}
location ~* \.php$ {
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass wwwgmo-php-fpm:9000;
#fastcgi_pass archivescacm-php-fpm:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}

22
docker/php-fpm/.env.dist Normal file
View File

@ -0,0 +1,22 @@
# site
SITE_TITLE="Stack GMo - PHP-FPM - MariaDB - Elasticsearch"
# must be the same that DOCKER_IMAGE_VERSION define in .env
SITE_VERSION="3.25"
# db
DB_NAME=wwwgmo
DB_USER=wwwgmo
DB_PASSWORD=password
DB_HOST=wwwgmo-mariadb
DB_PORT=3306
DB_TABLE=tbl_email
# PMA
# the port must be the same as PMA_PORT_WEB define in .env on root project path
PMA_URL=http://gmoadm.gmolab.net:8084
KIBANA_URL=http://gmoadm.gmolab.net:5601
# Elsaticsearch/kibana
ES_HOST=wwwgmo-elasticsearch:9200
ES_USER=elastic
ES_PASSWORD=pa55w0rd
ES_INDEX=wwwgmo_index
KIB_PORT=5601

31
docker/php-fpm/Dockerfile Normal file
View File

@ -0,0 +1,31 @@
#https://hub.docker.com/r/rhamdeew/docker-php-8-fpm-alpine/dockerfile
#https://github.com/elastic/elasticsearch-php
FROM php:8.2.6-fpm-alpine
LABEL maintainer="gilles.mouchet@gmail.com"
RUN apk add --no-cache mysql-client msmtp perl wget procps shadow libzip libpng libjpeg-turbo libwebp freetype icu
RUN apk add --no-cache --virtual build-essentials \
icu-dev icu-libs zlib-dev g++ make automake autoconf libzip-dev \
libpng-dev libwebp-dev libjpeg-turbo-dev freetype-dev && \
docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp && \
docker-php-ext-install gd && \
docker-php-ext-install mysqli && \
docker-php-ext-install pdo_mysql && \
docker-php-ext-install intl && \
docker-php-ext-install opcache && \
docker-php-ext-install exif && \
docker-php-ext-install zip && \
apk del build-essentials && rm -rf /usr/src/php*
# install composer
RUN wget https://getcomposer.org/composer-stable.phar -O /usr/local/bin/composer && chmod +x /usr/local/bin/composer
RUN composer require elasticsearch/elasticsearch
# Switch en user www-data
USER www-data
WORKDIR /app
COPY --chown=www-data ./src/ /app/
COPY --chown=www-data ./docker/php-fpm/php.ini /usr/local/etc/php/php.ini
EXPOSE 9000/tcp

16
docker/php-fpm/php.ini Normal file
View File

@ -0,0 +1,16 @@
; For php.ini production
date.timezone = "Europe/Zurich"
memory_limit = 128M
; This is the php.ini-production INI file.
zend.exception_ignore_args = On
; In production, it is recommended to set this to 0 to reduce the output
; of sensitive information in stack traces.
zend.exception_string_param_max_len = 0
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
mysqlnd.collect_memory_statistics = Off
log_errors = On
error_log = /dev/stderr
zend.assertions = -1
expose_php = Off

29
helm/Chart.yaml Normal file
View File

@ -0,0 +1,29 @@
apiVersion: v2
name: www-site
description: www-site
maintainers:
- name: GMOLab
email: gilles.mouchet@gmail.com
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.0.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
# Also set the docker image tag
appVersion: "1.0"

View File

@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "site.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "site.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "site.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "site.labels" -}}
helm.sh/chart: {{ include "site.chart" . }}
{{ include "site.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "site.selectorLabels" -}}
app.kubernetes.io/name: {{ include "site.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "site.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "site.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,17 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: configmap-elasticsearch
namespace: {{ .Release.Namespace }}
labels:
app: site
tier: elastic
{{- include "site.labels" . | nindent 4 }}
data:
cluster.name: "wwwgmo-es"
discovery.type: "single-node"
ES_JAVA_OPTS: "-Xms512m -Xmx512m"
ELASTIC_USERNAME: elastic
ELASTIC_HOST: "service-elasticsearch"
xpack.security.enabled: "true"
xpack.security.transport.ssl.enabled: "true"

View File

@ -0,0 +1,12 @@
apiVersion: v1
kind: Secret
metadata:
name: secret-elasticsearch
namespace: {{ .Release.Namespace }}
labels:
app: site
tier: elasticsearch
{{- include "site.labels" . | nindent 4 }}
type: Opaque
stringData:
ELASTIC_PASSWORD: "{{ required ".Values.elastic.password entry is required!" .Values.elastic.password }}"

View File

@ -0,0 +1,19 @@
kind: Service
apiVersion: v1
metadata:
name: service-elasticsearch
namespace: {{ .Release.Namespace }}
labels:
app: site
tier: elastic
{{- include "site.labels" . | nindent 4 }}
spec:
selector:
app: site
tier: elastic
clusterIP: None
ports:
- port: 9200
name: rest
- port: 9300
name: inter-node

View File

@ -0,0 +1,131 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: statefulset-elasticsearch
namespace: {{ .Release.Namespace }}
labels:
app: site
tier: elastic
{{- include "site.labels" . | nindent 4 }}
spec:
serviceName: service-elasticsearch
# do not modify replica
replicas: 1
selector:
matchLabels:
app: site
tier: elastic
template:
metadata:
labels:
app: site
tier: elastic
{{- include "site.labels" . | nindent 8 }}
annotations:
checksum/configmap-env: {{ include (print $.Chart.Name "/templates/elasticsearch/configmap-elasticsearch.yaml") . | sha256sum }}
checksum/secret-env: {{ include (print $.Chart.Name "/templates/elasticsearch/secret-elasticsearch.yaml") . | sha256sum }}
spec:
priorityClassName: {{ required ".Values.elastic.priorityClassName entry is required!" .Values.elastic.priorityClassName }}
automountServiceAccountToken: false
containers:
- name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:{{ required ".Values.elastic.imageTag entry is required!" .Values.elastic.imageTag }}
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9200
name: rest
protocol: TCP
- containerPort: 9300
name: inter-node
protocol: TCP
volumeMounts:
- name: data
mountPath: /usr/share/elasticsearch/data
envFrom:
- configMapRef:
name: configmap-elasticsearch
- secretRef:
name: secret-elasticsearch
env:
- name: node.name
valueFrom:
fieldRef:
fieldPath: metadata.name
resources:
requests:
cpu: 100m
memory: 850Mi
ephemeral-storage: 128M
limits:
cpu: 1000m
memory: 1250Mi
ephemeral-storage: 512M
#No readiness probe : The node has to be immediatly resolvable
#No startup probe : The node has to be immediatly resolvable
livenessProbe:
exec:
command:
- "/bin/sh"
- "-c"
#- "curl -s --cacert /usr/share/elasticsearch/config/certificates/ca.pem https://localhost:9200 | grep -q 'missing authentication credentials'"
- "curl -s http://localhost:9200 | grep -q 'missing authentication credentials'"
periodSeconds: 10
failureThreshold: 3
initialDelaySeconds: 30
timeoutSeconds: 5
initContainers:
- name: fix-permissions
image: busybox
imagePullPolicy: IfNotPresent
command: ["sh", "-c", "chown -R 1000:1000 /usr/share/elasticsearch/data"]
securityContext:
privileged: true
volumeMounts:
- name: data
mountPath: /usr/share/elasticsearch/data
- name: increase-vm-max-map
image: busybox
imagePullPolicy: IfNotPresent
command: ["sysctl", "-w", "vm.max_map_count=262144"]
securityContext:
privileged: true
- name: increase-fd-ulimit
image: busybox
imagePullPolicy: IfNotPresent
command: ["sh", "-c", "ulimit -n 65536"]
securityContext:
privileged: true
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
app: elasticsearch
tier: elasticsearch
volumeClaimTemplates:
- metadata:
name: data
labels:
app: elastic
tier: elastic
spec:
{{- if eq "k3s" $.Values.kube }}
accessModes: [ "ReadWriteOnce" ]
storageClassName: {{ required ".Values.elastic.persistentVolumeClaim.k3sStorageClassName entry is required!" .Values.elastic.persistentVolumeClaim.k3sStorageClassName }}
{{- end }}
{{- if eq "k8s" $.Values.kube }}
accessModes: [ "ReadWriteMany" ]
storageClassName: {{ required ".Values.elastic.persistentVolumeClaim.k8sStorageClassName entry is required!" .Values.elastic.persistentVolumeClaim.k8sStorageClassName }}
{{- end }}
resources:
requests:
storage: {{ required ".Values.elastic.persistentVolumeClaim.storageRequest entry is required!" .Values.elastic.persistentVolumeClaim.storageRequest }}

View File

@ -0,0 +1,12 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: configmap-kibana
namespace: {{ .Release.Namespace }}
labels:
app: site
tier: kibana
{{- include "site.labels" . | nindent 4 }}
data:
ELASTICSEARCH_HOSTS: "{{ required ".Values.kibana.host entry is required!" .Values.kibana.host }}"
ELASTICSEARCH_USERNAME: "{{ required ".Values.kibana.username entry is required!" .Values.kibana.username }}"

View File

@ -0,0 +1,74 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment-kibana
namespace: {{ .Release.Namespace }}
labels:
app: site
tier: kibana
{{- include "site.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
app: site
tier: kibana
template:
metadata:
labels:
app: site
tier: kibana
{{- include "site.labels" . | nindent 8 }}
spec:
priorityClassName: {{ required ".Values.kibana.priorityClassName entry is required!" .Values.kibana.priorityClassName }}
automountServiceAccountToken: false
containers:
- name: kibana
image: docker.elastic.co/kibana/kibana:7.17.10
imagePullPolicy: IfNotPresent
envFrom:
- configMapRef:
name: configmap-kibana
- secretRef:
name: secret-kibana
#env:
# - name: ELASTICSEARCH_HOSTS
# value: '["http://statefulset-elasticsearch-0.service-elasticsearch:9200"]'
# - name: ELASTICSEARCH_USERNAME
# value: elastic
# - name: ELASTICSEARCH_PASSWORD
# value: password
ports:
- containerPort: 5601
resources:
requests:
cpu: 100m
memory: 300Mi
ephemeral-storage: 128M
limits:
cpu: 1000m
memory: 1Gi
ephemeral-storage: 512M
startupProbe:
tcpSocket:
port: 5601
failureThreshold: 12
periodSeconds: 10
livenessProbe:
tcpSocket:
port: 5601
periodSeconds: 10
failureThreshold: 3
initialDelaySeconds: 30
timeoutSeconds: 5
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
app: stackgmo
tier: kibana

View File

@ -0,0 +1,29 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
namespace: {{ .Release.Namespace }}
name: ingress-kibana
spec:
{{- if eq "k3s" $.Values.kube }}
ingressClassName: traefik
{{- end }}
{{- if eq "k8s" $.Values.kube }}
ingressClassName: nginx
{{- end }}
tls:
- hosts:
{{ required ".Values.site.ingress.kibana.hosts entry is required!" .Values.site.ingress.kibana.hosts }}
secretName: secret-ingress-tls
rules:
- host: {{ required ".Values.site.urlKibana entry is required!" .Values.site.urlKibana }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: service-kibana
port:
number: 5601

View File

@ -0,0 +1,10 @@
apiVersion: v1
kind: Secret
metadata:
name: secret-kibana
namespace: {{ .Release.Namespace }}
labels:
{{- include "site.labels" . | nindent 4 }}
type: Opaque
stringData:
ELASTICSEARCH_PASSWORD: "{{ required ".Values.elastic.password entry is required!" .Values.elastic.password }}"

View File

@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: service-kibana
namespace: {{ .Release.Namespace }}
labels:
app: site
tier: kibana
{{- include "site.labels" . | nindent 4 }}
spec:
ports:
- port: 5601
selector:
app: site
tier: kibana

View File

@ -0,0 +1,38 @@
apiVersion: v1
kind: ConfigMap
metadata:
namespace: {{ .Release.Namespace }}
name: configmap-mariadb-envvars
labels:
{{- include "site.labels" . | nindent 4 }}
data:
MYSQL_DATABASE: "{{ required ".Values.mariadb.databaseName entry is required!" .Values.mariadb.databaseName }}"
MYSQL_USER: "{{ required ".Values.site.phpfpmSite.db.user entry is required!" .Values.site.phpfpmSite.db.user }}"
MYSQL_PASSWORD: "{{ required ".Values.mariadb.dbPass entry is required!" .Values.mariadb.dbPass }}"
---
apiVersion: v1
kind: ConfigMap
metadata:
namespace: {{ .Release.Namespace }}
name: configmap-mariadb-config
labels:
{{- include "site.labels" . | nindent 4 }}
data:
docker.cnf: |
[mysqld]
skip-host-cache
skip-name-resolve
sql_mode=""
innodb_buffer_pool_size={{ required ".Values.mariadb.innoDbBufferPoolSize entry is required!" .Values.mariadb.innoDbBufferPoolSize }}
thread_cache_size = 128
sort_buffer_size = 5M
join_buffer_size = 64M
bulk_insert_buffer_size = 16M
tmp_table_size = 32M
max_heap_table_size = 32M
innodb_open_files = 400
innodb_io_capacity = 400
innodb_flush_method = O_DIRECT
query_cache_type=1
query_cache_size={{ required ".Values.mariadb.queryCacheSize entry is required!" .Values.mariadb.queryCacheSize }}
query_cache_limit={{ required ".Values.mariadb.queryCacheLimit entry is required!" .Values.mariadb.queryCacheLimit }}

View File

@ -0,0 +1,53 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: cronjob-mariadb-backupdb
namespace: {{ .Release.Namespace }}
labels:
{{- include "site.labels" . | nindent 4 }}
spec:
schedule: "30 20 * * *"
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 3
concurrencyPolicy: Forbid
startingDeadlineSeconds: 120
jobTemplate:
spec:
template:
metadata:
labels:
app: mariadb
tier: cronjob
{{- include "site.labels" . | nindent 12 }}
annotations:
checksum/configmap-env: {{ include (print $.Chart.Name "/templates/mariadb/configmap-mariadb.yaml") . | sha256sum }}
checksum/secret-env: {{ include (print $.Chart.Name "/templates/mariadb/secret-mariadb.yaml") . | sha256sum }}
spec:
automountServiceAccountToken: false
containers:
- image: {{ required ".Values.mariadb.repository entry is required!" .Values.mariadb.repository }}:{{ required ".Values.mariadb.tag entry is required!" .Values.mariadb.tag }}
imagePullPolicy: IfNotPresent
name: cronjob-mariadb-backupdb
envFrom:
- configMapRef:
name: configmap-mariadb-envvars
- secretRef:
name: secret-mariadb
command: ["/bin/sh", "-c"]
args:
- set -x;
ls -l /var/backups;
/usr/bin/mysqldump --verbose --hex-blob --complete-insert --single-transaction --skip-lock-tables --skip-add-locks --routines -h service-mariadb -uroot -p$MYSQL_ROOT_PASSWORD $MYSQL_DATABASE | gzip - > /var/backups/$MYSQL_DATABASE-$(date +%Y-%m-%d_%H%M%S).sql.gz;
find /var/backups/ -mindepth 1 -type f -mtime +14 -exec rm {} \;
volumeMounts:
- name: mariadb-datadir-bck
mountPath: /var/backups
restartPolicy: OnFailure
terminationGracePeriodSeconds: {{ required ".Values.mariadb.terminationGracePeriodSeconds entry is required!" .Values.mariadb.terminationGracePeriodSeconds }}
volumes:
- name: mariadb-datadir-bck
persistentVolumeClaim:
claimName: pvc-mariadb-datadir-bck

View File

@ -0,0 +1,47 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
namespace: {{ .Release.Namespace }}
name: pvc-mariadb-datadir
labels:
{{- include "site.labels" . | nindent 4 }}
annotations:
helm.sh/resource-policy: keep
spec:
{{- if eq "k3s" $.Values.kube }}
accessModes:
- ReadWriteOnce
storageClassName: {{ required ".Values.mariadb.persistentVolumeClaim.k3sStorageClassName entry is required!" .Values.mariadb.persistentVolumeClaim.k3sStorageClassName }}
{{- end }}
{{- if eq "k8s" $.Values.kube }}
accessModes:
- ReadWriteMany
storageClassName: {{ required ".Values.mariadb.persistentVolumeClaim.k8sStorageClassName entry is required!" .Values.mariadb.persistentVolumeClaim.k8sStorageClassName }}
{{- end }}
resources:
requests:
storage: {{ required ".Values.site.marioadb.persistentVolumeClaim.storageRequest entry is required!" .Values.mariadb.persistentVolumeClaim.storageRequest }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
namespace: {{ .Release.Namespace }}
name: pvc-mariadb-datadir-bck
labels:
{{- include "site.labels" . | nindent 4 }}
annotations:
helm.sh/resource-policy: keep
spec:
{{- if eq "k3s" $.Values.kube }}
accessModes:
- ReadWriteOnce
storageClassName: {{ required ".Values.mariadb.persistentVolumeClaim.k3sStorageClassName entry is required!" .Values.mariadb.persistentVolumeClaim.k3sStorageClassName }}
{{- end }}
{{- if eq "k8s" $.Values.kube }}
accessModes:
- ReadWriteMany
storageClassName: {{ required ".Values.mariadb.persistentVolumeClaim.k8sStorageClassName entry is required!" .Values.mariadb.persistentVolumeClaim.k8sStorageClassName }}
{{- end }}
resources:
requests:
storage: {{ required ".Values.mariadb.persistentVolumeClaim.backupdDbStorageRequest entry is required!" .Values.mariadb.persistentVolumeClaim.backupdDbStorageRequest }}

View File

@ -0,0 +1,10 @@
apiVersion: v1
kind: Secret
metadata:
namespace: {{ .Release.Namespace }}
name: secret-mariadb
labels:
{{- include "site.labels" . | nindent 4 }}
type: Opaque
stringData:
MYSQL_ROOT_PASSWORD: "{{ required ".Values.mariadb.rootPass entry is required!" .Values.mariadb.rootPass }}"

View File

@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
namespace: {{ .Release.Namespace }}
name: service-mariadb
labels:
{{- include "site.labels" . | nindent 4 }}
spec:
ports:
- port: 3306
selector:
app: mariadb
tier: mariadb
clusterIP: None #Headless service, commmunication will no go throught service proxy

View File

@ -0,0 +1,93 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
namespace: {{ .Release.Namespace }}
name: statefulset-mariadb
labels:
{{- include "site.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
app: mariadb
tier: mariadb
serviceName: "mariadb"
replicas: 1
template:
metadata:
labels:
app: mariadb
tier: mariadb
{{- include "site.labels" . | nindent 8 }}
annotations:
checksum/configmap: {{ include (print $.Template.BasePath "/mariadb/configmap-mariadb.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/mariadb/secret-mariadb.yaml") . | sha256sum }}
checksum/values-config: {{ .Files.Get "values-config-k3s.yaml" | sha256sum }}
spec:
automountServiceAccountToken: false
containers:
- image: {{ required ".Values.mariadb.repository entry is required!" .Values.mariadb.repository }}:{{ required ".Values.mariadb.tag entry is required!" .Values.mariadb.tag }}
imagePullPolicy: IfNotPresent
name: mariadb
envFrom:
- configMapRef:
name: configmap-mariadb-envvars
- secretRef:
name: secret-mariadb
ports:
- containerPort: 3306
name: mariadb
startupProbe:
tcpSocket:
port: 3306
failureThreshold: 12
periodSeconds: 10
timeoutSeconds: 5
livenessProbe:
tcpSocket:
port: 3306
periodSeconds: 60
failureThreshold: 1
initialDelaySeconds: 0
timeoutSeconds: 5
readinessProbe:
tcpSocket:
port: 3306
periodSeconds: 10
failureThreshold: 3
initialDelaySeconds: 0
timeoutSeconds: 5
resources:
requests:
memory: "{{ required ".Values.mariadb.ressourceRequest.memory entry is required!" .Values.mariadb.ressourceRequest.memory }}"
cpu: "{{ required ".Values.mariadb.ressourceRequest.cpu entry is required!" .Values.mariadb.ressourceRequest.cpu }}"
ephemeral-storage: "{{ required ".Values.mariadb.ressourceRequest.ephemeralStorage entry is required!" .Values.mariadb.ressourceRequest.ephemeralStorage }}"
limits:
memory: "{{ required ".Values.mariadb.ressourceLimit.memory entry is required!" .Values.mariadb.ressourceLimit.memory }}"
cpu: "{{ required ".Values.mariadb.ressourceLimit.cpu entry is required!" .Values.mariadb.ressourceLimit.cpu }}"
ephemeral-storage: "{{ required ".Values.mariadb.ressourceLimit.ephemeralStorage entry is required!" .Values.mariadb.ressourceLimit.ephemeralStorage }}"
volumeMounts:
- name: mariadb-datadir
mountPath: /var/lib/mysql
- name: mariadb-config
mountPath: /etc/mysql/conf.d/
lifecycle:
preStop:
exec:
command: ["/bin/sh","-c","pkill -SIGTERM mariadb"]
terminationGracePeriodSeconds: {{ required ".Values.mariadb.terminationGracePeriodSeconds entry is required!" .Values.mariadb.terminationGracePeriodSeconds }}
volumes:
- name: mariadb-datadir
persistentVolumeClaim:
claimName: pvc-mariadb-datadir
- name: mariadb-config
configMap:
name: configmap-mariadb-config

View File

@ -0,0 +1,37 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: configmap-nginx
labels:
{{- include "site.labels" . | nindent 4 }}
data:
default.conf: |
server {
index index.php;
root /var/www/html/web;
listen 8080;
server_name _;
charset utf-8;
error_log /dev/stderr;
access_log /dev/stdout;
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~ /\. {
deny all;
}
location / {
index index.php;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

View File

@ -0,0 +1,20 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: configmap-phpfpm
namespace: {{ .Release.Namespace }}
labels:
{{- include "site.labels" . | nindent 4 }}
data:
SITE_VERSION: "{{ required ".Chart.AppVersion entry is required!" .Chart.AppVersion }}"
SITE_TITLE: "{{ required ".Values.site.phpfpmSite.site.title entry is required!" .Values.site.phpfpmSite.site.title }}"
DB_HOST: "{{ required ".Values.site.phpfpmSite.db.host entry is required!" .Values.site.phpfpmSite.db.host }}"
DB_USER: "{{ required ".Values.site.phpfpmSite.db.user entry is required!" .Values.site.phpfpmSite.db.user }}"
DB_NAME: "{{ required ".Values.site.phpfpmSite.db.name entry is required!" .Values.site.phpfpmSite.db.name }}"
DB_PORT: "{{ required ".Values.site.phpfpmSite.db.port entry is required!" .Values.site.phpfpmSite.db.port }}"
DB_TABLE: "{{ required ".Values.site.phpfpmSite.db.tabl entry is required!" .Values.site.phpfpmSite.db.tabl }}"
PMA_URL: "https://{{ required ".Values.site.urlPma entry is required!" .Values.site.urlPma }}"
ES_HOST: "{{ required ".Values.site.phpfpmSite.es.host entry is required!" .Values.site.phpfpmSite.es.host }}"
ES_USER: "{{ required ".Values.site.phpfpmSite.es.user entry is required!" .Values.site.phpfpmSite.es.user }}"
ES_INDEX: "{{ required ".Values.site.phpfpmSite.es.index entry is required!" .Values.site.phpfpmSite.es.index }}"
KIBANA_URL: "https://{{ required ".Values.site.utlKibana entry is required!" .Values.site.urlKibana }}"

View File

@ -0,0 +1,181 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment-site
namespace: {{ .Release.Namespace }}
labels:
app: site
tier: backend
# {{- include "site.labels" . | nindent 4 }}
spec:
replicas: {{ required ".Values.site.replicas entry is required!" .Values.site.replicas }}
selector:
matchLabels:
app: site
tier: backend
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 25%
template:
metadata:
labels:
app: site
tier: backend
# {{- include "site.labels" . | nindent 8 }}
annotations:
checksum/configmap-nginx: {{ include (print $.Chart.Name "/templates/php-fpm/configmap-nginx.yaml") . | sha256sum }}
checksum/values-config: {{ .Files.Get "values-config-k3s.yaml" | sha256sum }}
checksum/values-secrets: {{ .Files.Get "values-secrets-k3s.yaml" | sha256sum }}
spec:
# if private registry. See README.md
imagePullSecrets:
- name: secret-regcred
containers:
## Container 1 : Nginx
- image: {{ required ".Values.site.nginxSite.repository entry is required!" .Values.site.nginxSite.repository }}:{{ required ".Values.site.nginxSite.tag entry is required!" .Values.site.nginxSite.tag }}
imagePullPolicy: {{ required ".Values.site.nginxSite.pullPolicy entry is required!" .Values.site.nginxSite.pullPolicy }}
name: nginx
ports:
- containerPort: 8080
name: nginx
volumeMounts:
# config ngnix
- name: volume-configmap-nginx
mountPath: {{ required ".Values.site.nginxSite.nginxConfigPath entry is required!" .Values.site.nginxSite.nginxConfigPath }}
subPath: default.conf
# site datas
- name: volume-pvc-site-files
mountPath: {{ required ".Values.site.filesMountPath entry is required!" .Values.site.filesMountPath }}
resources:
requests:
memory: "{{ required ".Values.site.nginxSite.ressourceRequest.memory entry is required!" .Values.site.nginxSite.ressourceRequest.memory }}"
cpu: "{{ required ".Values.site.nginxSite.ressourceRequest.cpu entry is required!" .Values.site.nginxSite.ressourceRequest.cpu }}"
ephemeral-storage: "{{ required ".Values.site.nginxSite.ressourceRequest.ephemeralStorage entry is required!" .Values.site.nginxSite.ressourceRequest.ephemeralStorage }}"
limits:
memory: "{{ required ".Values.site.nginxSite.ressourceLimit.memory entry is required!" .Values.site.nginxSite.ressourceLimit.memory }}"
cpu: "{{ required ".Values.site.nginxSite.ressourceLimit.cpu entry is required!" .Values.site.nginxSite.ressourceLimit.cpu }}"
ephemeral-storage: "{{ required ".Values.site.nginxSite.ressourceLimit.ephemeralStorage entry is required!" .Values.site.nginxSite.ressourceLimit.ephemeralStorage }}"
startupProbe:
tcpSocket:
port: 8080
#port: 80
failureThreshold: 30
periodSeconds: 10
livenessProbe:
tcpSocket:
port: 8080
#port: 80
periodSeconds: 30
failureThreshold: 3 #Default 3
initialDelaySeconds: 0
readinessProbe:
exec:
command:
- "/bin/sh"
- "-c"
- "curl -s http://localhost:8080"
periodSeconds: 10
failureThreshold: 3
initialDelaySeconds: 0
timeoutSeconds: 5
securityContext:
runAsNonRoot: true
runAsUser: 82
runAsGroup: 82
allowPrivilegeEscalation: false
#capabilities:
# drop:
# - ALL
### Container 2 : PHP-FPM
- image: {{ required ".Values.site.phpfpmSite.repository entry is required!" .Values.site.phpfpmSite.repository }}:{{ required ".Chart.AppVersion entry is required!" .Chart.AppVersion }}
imagePullPolicy: {{ required ".Values.site.phpfpmSite.pullPolicy entry is required!" .Values.site.phpfpmSite.pullPolicy }}
name: phpfpm
envFrom:
- configMapRef:
name: configmap-phpfpm
- secretRef:
name: secret-site
ports:
- containerPort: 9000
name: phpfpm
startupProbe:
tcpSocket:
port: 9000
failureThreshold: 30
periodSeconds: 10
livenessProbe:
tcpSocket:
port: 9000
periodSeconds: 30
failureThreshold: 3 #Default 3
initialDelaySeconds: 0
readinessProbe:
tcpSocket:
port: 9000
periodSeconds: 10
failureThreshold: 3
initialDelaySeconds: 0
timeoutSeconds: 5
securityContext:
runAsNonRoot: true
runAsUser: 82
runAsGroup: 82
allowPrivilegeEscalation: false
#capabilities:
# drop:
# - ALL
volumeMounts:
- name: volume-site-sources
mountPath: {{ required ".Values.site.sourcesMountPath entry is required!" .Values.site.sourcesMountPath }}
- name: volume-pvc-site-files
mountPath: {{ required ".Values.site.filesMountPath entry is required!" .Values.site.filesMountPath }}
lifecycle:
postStart:
exec:
command:
- "/bin/sh"
- "-c"
- |
cp -r /app/. {{ required ".Values.site.filesMountPath entry is required!" .Values.site.filesMountPath }}
volumes:
# config ngnix
- name: volume-configmap-nginx
configMap:
name: configmap-nginx
defaultMode: 420
# site datas
- name: volume-pvc-site-files
persistentVolumeClaim:
claimName: pvc-site-files
- name: volume-site-sources
emptyDir: {}
securityContext:
runAsNonRoot: true
runAsUser: 82
runAsGroup: 82
fsGroup: 82
fsGroupChangePolicy: "Always"
seccompProfile:
type: RuntimeDefault

View File

@ -0,0 +1,46 @@
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-site
namespace: {{ .Release.Namespace }}
labels:
app: site
tier: backend
# {{- include "site.labels" . | nindent 4 }} # label provenant de _helpers.tpl (label informatif pas obligatoire)
annotations:
{{- if eq "k3s" $.Values.kube }}
traefik.ingress.kubernetes.io/redirect-entry-point: https
traefik.ingress.kubernetes.io/preserve-host: "true"
{{- end }}
{{- if eq "k8s" $.Values.kube }}
#kubernetes.io/ingress.allow-http: "false"
#nginx.ingress.kubernetes.io/affinity: "cookie"
##nginx.ingress.kubernetes.io/session-cookie-name: "SAUTHSESSION*"
#nginx.ingress.kubernetes.io/proxy-body-size: "32m"
#nginx.org/client-max-body-size: "32m"
{{- end }}
spec:
{{- if eq "k3s" $.Values.kube }}
ingressClassName: traefik
{{- end }}
{{- if eq "k8s" $.Values.kube }}
ingressClassName: nginx
{{- end }}
tls:
- hosts:
{{ required ".Values.site.ingress.site.hosts entry is required!" .Values.site.ingress.site.hosts }}
secretName: secret-ingress-tls
rules:
- host: {{ required ".Values.site.host entry is required!" .Values.site.host }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: service-site
port:
number: 8080

View File

@ -0,0 +1,25 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
namespace: {{ .Release.Namespace }}
name: pvc-site-files
labels:
app: site
tier: backend
# {{- include "site.labels" . | nindent 4 }}
annotations:
helm.sh/resource-policy: keep
spec:
{{- if eq "k3s" $.Values.kube }}
accessModes:
- ReadWriteOnce
storageClassName: {{ required ".Values.site.persistentVolumeClaim.k3sStorageClassName entry is required!" .Values.site.persistentVolumeClaim.k3sStorageClassName }}
{{- end }}
{{- if eq "k8s" $.Values.kube }}
accessModes:
- ReadWriteMany
storageClassName: {{ required ".Values.site.persistentVolumeClaim.k8sStorageClassName entry is required!" .Values.site.persistentVolumeClaim.k8sStorageClassName }}
{{- end }}
resources:
requests:
storage: {{ required ".Values.site.persistentVolumeClaim.storageRequest entry is required!" .Values.site.persistentVolumeClaim.storageRequest }}

View File

@ -0,0 +1,10 @@
apiVersion: v1
data:
#tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUZpakNDQTNLZ0F3SUJBZ0lVQnNaUlB4aW1oRjRLMTFnWFgyTWtzZXdvb0drd0RRWUpLb1pJaHZjTkFRRUwKQlFBd2diNHhDekFKQmdOVkJBWVRBa05JTVEwd0N3WURWUVFJRXdSV1lYVmtNUTB3Q3dZRFZRUUhFd1JPZVc5dQpNU0V3SHdZRFZRUUtFeGhIVFU4Z1RHRmliM0poZEc5cGNtVWdLR2R0YjJ4aFlpa3hNREF1QmdOVkJBc1RKMU5KClRFRkNJQ2hUZVhOMFpXMWxJR2x1Wm05eWJXRjBhVzl1SUd4aFltOXlZWFJ2YVhKbEtURVNNQkFHQTFVRUF4TUoKUjAxUFRHRmlJRU5CTVNnd0pnWUpLb1pJaHZjTkFRa0JGaGxsZUhCc2IybDBMbWR0YjNSbFkyaEFaMjFoYVd3dQpZMjl0TUI0WERUSXpNRFF5TWpBMk1EWXdObG9YRFRJME1EUXlNVEEyTURZd05sb3dnY0V4Q3pBSkJnTlZCQVlUCkFrTklNUTB3Q3dZRFZRUUlFd1JXWVhWa01RMHdDd1lEVlFRSEV3Uk9lVzl1TVNFd0h3WURWUVFLRXhoSFRVOGcKVEdGaWIzSmhkRzlwY21VZ0tHZHRiMnhoWWlreE1EQXVCZ05WQkFzVEoxTkpURUZDSUNoVGVYTjBaVzFsSUdsdQpabTl5YldGMGFXOXVJR3hoWW05eVlYUnZhWEpsS1RFVk1CTUdBMVVFQXhRTUtpNW5iVzlzWVdJdWJtVjBNU2d3CkpnWUpLb1pJaHZjTkFRa0JGaGxsZUhCc2IybDBMbWR0YjNSbFkyaEFaMjFoYVd3dVkyOXRNSUlCSWpBTkJna3EKaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUFsUy9ncEpXdkNKZG9WQitqWFNoVG14c0hjTkx6NFp4agpTN21lNVhWSHRySWRlR0czUHlwb0VXTGJEcGcxVjB6aHVZbDJYajJmWTFuWnJRRm5IWnprZERLZGJybzYxZFVkCmdSVCsxNXBnWjl0NXZPWHdUUlNqWnFQVlAvaHdRSVlxTXV1T1lJbzNVQ090TmtwVHhSaUc4alpPU3hYdEQvRWIKQmdYR0N2d2l2cnBQMWVTUzdPYmJaQzVHaC9LYW9xZkhIbkhnejVZQnloMmJjTzM0czFibDZKb1UzWjNIOEhrcQpFN2JCSWlVTzNHcjY4bnVrWUdxZ3M5ZURRRWlZV2I4OHA0Rkh2N2dzWXdpV2VlQTE0N2J0bDlDUjRzR0hRdngwCjBnbkRVZkNnaTdBeTExZkZYYzNndlN0K0ErdUFtLzRmR3MrN0lJT0Y1MFQxQjNSMFRtYUxud0lEQVFBQm8zc3cKZVRBSkJnTlZIUk1FQWpBQU1CY0dBMVVkRVFRUU1BNkNEQ291WjIxdmJHRmlMbTVsZERBVEJnTlZIU1VFRERBSwpCZ2dyQmdFRkJRY0RBVEFkQmdOVkhRNEVGZ1FVSS9jeDFsbzhiN3Q1MmNNK256SEdLL0NiZ2trd0h3WURWUjBqCkJCZ3dGb0FVNVJKTnFPMjJTTzlVQXFPek0vTnZBTXViK1c0d0RRWUpLb1pJaHZjTkFRRUxCUUFEZ2dJQkFLQzgKcDJTZHRqSGpMQXBsS0tYMG9aVUJoOEJUVC9Vd0JTSXBJZkdxVS9rNlRJZG9rc2JTWGV1OVYwZHI4UWtFbXAxMgpJOU9jNWRIVDlBcDJZM0xMYTNzRmVJWDRvWkgrZkZ0alRBcmlPT2lpUk1IOEpDWERqZEhvelF0ZEQ2eEtBRm83CnJyaEsvQXUrNEdaSE1oclM3MFBUM3lJNHB5L2w4dVRrSUpIUXh2LytwUXkxN0RNN2w2NXpMSEFOR1JjVGhpcXoKQTVBRjNacU9SSGUyUXpLdnJ5NVFIcFB1ak9LNFFVMzA1WTVXRXE5OEVCRnVUK29zd2FORHloSGVteWlzdW1kNwpXcHZaTS9hNm50ZmNJT1Q3K3JiR3BWWG1wU1ZJaGFFcExhdWQrUWI2eDlIV0hwRFc3dDV3ZklDUjBXU3NNWTBnCnlla1pWRzZtMGpvUXpBbUpQM3JvRldSRlNTM3NrOExKTTAzYnJMeWJJNmdGWVFqdEpBK2t4T1Z5VVNmeXE0T0gKTml6YWxVdzZUeDlkRFV2YlRSelA0UXhSSGRna1NqelFaVHlMN1ZjKzBGU1BqOWk5S1dNcDk4NkNsUXE4RkdpUAoydkxkNnJUOFM3WEdjY3JWUlk2TllYdGRSWVVKS2lnWkNmYWExSWZ1L3J2NHRadGpnREFkRjlUSGd5VW1zMU43Cm4xTUZkQTZiZVZKRUtjc1VqZDRtMUdtc1FBLzloN1JreVJUclRLOEc2eWE0MU5ZRjJZTCtVM2JnU1pyaFFrM3EKbVp1TFdIOGx0SkwvR0FiN0J3K2VYMzUyVlZ0T09GNS9xNTY0RUlkcHJVWkJNTDJlYmxwMCtJTDZ4cFBhSjNDQQo4TW51amllbWh3aVFFRmpBMDNsNkltc2pzMHYxRVBGL082dm5iUE5nCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
tls.crt: {{- required ".Values.site.ssl_crt entry is required!" .Values.site.ssl_crt | nindent 4 }}
tls.key: {{- required ".Values.site.ssl_key entry is required!" .Values.site.ssl_key | nindent 4 }}
kind: Secret
metadata:
name: secret-ingress-tls
namespace: {{ .Release.Namespace }}
type: kubernetes.io/tls

View File

@ -0,0 +1,8 @@
apiVersion: v1
data:
.dockerconfigjson: eyJhdXRocyI6eyJodHRwczovL2luZGV4LmRvY2tlci5pby92MS8iOnsidXNlcm5hbWUiOiJnbW91Y2hldCIsInBhc3N3b3JkIjoiT3B0MW11c1ByaW1lX0RvY2tlciIsImVtYWlsIjoiZ21vdWNoZXRAYmx1ZXdpbi5jaCIsImF1dGgiOiJaMjF2ZFdOb1pYUTZUM0IwTVcxMWMxQnlhVzFsWDBSdlkydGxjZz09In19fQ==
kind: Secret
metadata:
name: secret-regcred
namespace: {{ .Release.Namespace }}
type: kubernetes.io/dockerconfigjson

View File

@ -0,0 +1,12 @@
apiVersion: v1
kind: Secret
metadata:
name: secret-site
namespace: {{ .Release.Namespace }}
labels:
{{- include "site.labels" . | nindent 4 }}
type: Opaque
stringData:
DB_PASSWORD: "{{ required ".Values.mariadb.dbPass entry is required!" .Values.mariadb.dbPass }}"
ES_PASSWORD: "{{ required ".Values.elastic.password entry is required!" .Values.elastic.password }}"

View File

@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
name: service-site
namespace: {{ .Release.Namespace }}
labels:
app: site
tier: backend
# {{- include "site.labels" . | nindent 4 }}
spec:
ports:
- port: 8080
protocol: TCP
selector:
app: site
tier: backend
type: ClusterIP

View File

@ -0,0 +1,32 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment-pma
labels:
app: phpmyadmin
spec:
replicas: 1
selector:
matchLabels:
app: phpmyadmin
template:
metadata:
labels:
app: phpmyadmin
spec:
containers:
- name: phpmyadmin
image: phpmyadmin
ports:
- containerPort: 80
env:
- name: PMA_HOST
value: service-mariadb
- name: PMA_PORT
value: "3306"
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: secret-mariadb
key: MYSQL_ROOT_PASSWORD

View File

@ -0,0 +1,42 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-pma
namespace: {{ .Release.Namespace }}
annotations:
{{- if eq "k3s" $.Values.kube }}
traefik.ingress.kubernetes.io/redirect-entry-point: https
traefik.ingress.kubernetes.io/preserve-host: "true"
#traefik.ingress.kubernetes.io/rewrite-target: /
#traefik.ingress.kubernetes.io/rule-type: PathPrefixStrip
{{- end }}
{{- if eq "k8s" $.Values.kube }}
#kubernetes.io/ingress.allow-http: "false"
#nginx.ingress.kubernetes.io/affinity: "cookie"
##nginx.ingress.kubernetes.io/session-cookie-name: "SAUTHSESSION*"
#nginx.ingress.kubernetes.io/proxy-body-size: "32m"
#nginx.org/client-max-body-size: "32m"
{{- end }}
spec:
{{- if eq "k3s" $.Values.kube }}
ingressClassName: traefik
{{- end }}
{{- if eq "k8s" $.Values.kube }}
ingressClassName: nginx
{{- end }}
tls:
- hosts:
{{ required ".Values.site.ingress.pma.hosts entry is required!" .Values.site.ingress.pma.hosts }}
secretName: secret-ingress-tls
rules:
- host: {{ required ".Values.site.urlPma entry is required!" .Values.site.urlPma }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: service-pma
port:
number: 80

View File

@ -0,0 +1,14 @@
---
apiVersion: v1
kind: Service
metadata:
name: service-pma
spec:
# type: NodePort
type: ClusterIP
selector:
app: phpmyadmin
ports:
- protocol: TCP
port: 80
targetPort: 80

109
helm/values-configs.yaml Normal file
View File

@ -0,0 +1,109 @@
# which kubernetes distribution we deploy
#kube: k3s
#kube: k8s
# elasticsearch
elastic:
priorityClassName: system-cluster-critical
imageTag: 7.17.16
persistentVolumeClaim:
storageRequest: 1Gi
k3sStorageClassName: local-path
k8sStorageClassName: longhorn
kibana:
username: elastic
priorityClassName: system-node-critical
host: http://statefulset-elasticsearch-0.service-elasticsearch:9200
mariadb:
repository: mariadb
pullPolicy: Always
tag: "10.11.7"
databaseName: gmo_db
innoDbBufferPoolSize: 256M
queryCacheSize: 256M
queryCacheLimit: 4M
ressourceRequest:
memory: 300Mi
cpu: 100m
ephemeralStorage: 128M
ressourceLimit:
memory: 1250Mi #1250 Mo RAM, au delà eviction
cpu: 200m # 0.1 core de CPU, au delà CPU Throttle
ephemeralStorage: 512M #512 Mo de storage non persistent (en + de ce qui est dans l'image), au delà éviction
terminationGracePeriodSeconds: 60
persistentVolumeClaim:
storageRequest: 5Gi
backupdDbStorageRequest: 10Gi
k3sStorageClassName: local-path
k8sStorageClassName: longhorn
site:
host: wwwgmo.gmolab.net
urlPma: wwwgmo-pma.gmolab.net
urlKibana: wwwgmo-kibana.gmolab.net
replicas: 1
priorityClassName: business-app-critical
terminationGracePeriodSeconds: 60
filesMountPath: /var/www/html/web
sourcesMountPath: /var/www/html
ssl_crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUZQekNDQXllZ0F3SUJBZ0lKQU5YN2sxZ3dnOVNjTUEwR0NTcUdTSWIzRFFFQkN3VUFNSUcrTVFzd0NRWUQKVlFRR0V3SkRTREVOTUFzR0ExVUVDQk1FVm1GMVpERU5NQXNHQTFVRUJ4TUVUbmx2YmpFaE1COEdBMVVFQ2hNWQpSMDFQSUV4aFltOXlZWFJ2YVhKbElDaG5iVzlzWVdJcE1UQXdMZ1lEVlFRTEV5ZFRTVXhCUWlBb1UzbHpkR1Z0ClpTQnBibVp2Y20xaGRHbHZiaUJzWVdKdmNtRjBiMmx5WlNreEVqQVFCZ05WQkFNVENVZE5UMHhoWWlCRFFURW8KTUNZR0NTcUdTSWIzRFFFSkFSWVpaWGh3Ykc5cGRDNW5iVzkwWldOb1FHZHRZV2xzTG1OdmJUQWVGdzB5TkRBMApNVE14TmpRNU5EQmFGdzB5TlRBME1UTXhOalE1TkRCYU1JSEJNUXN3Q1FZRFZRUUdFd0pEU0RFTk1Bc0dBMVVFCkNCTUVWbUYxWkRFTk1Bc0dBMVVFQnhNRVRubHZiakVoTUI4R0ExVUVDaE1ZUjAxUElFeGhZbTl5WVhSdmFYSmwKSUNobmJXOXNZV0lwTVRBd0xnWURWUVFMRXlkVFNVeEJRaUFvVTNsemRHVnRaU0JwYm1admNtMWhkR2x2YmlCcwpZV0p2Y21GMGIybHlaU2t4RlRBVEJnTlZCQU1VRENvdVoyMXZiR0ZpTG01bGRERW9NQ1lHQ1NxR1NJYjNEUUVKCkFSWVpaWGh3Ykc5cGRDNW5iVzkwWldOb1FHZHRZV2xzTG1OdmJUQ0NBU0l3RFFZSktvWklodmNOQVFFQkJRQUQKZ2dFUEFEQ0NBUW9DZ2dFQkFKVXY0S1NWcndpWGFGUWZvMTBvVTVzYkIzRFM4K0djWTB1NW51VjFSN2F5SFhoaAp0ejhxYUJGaTJ3NllOVmRNNGJtSmRsNDluMk5aMmEwQlp4MmM1SFF5blc2Nk90WFZIWUVVL3RlYVlHZmJlYnpsCjhFMFVvMmFqMVQvNGNFQ0dLakxyam1DS04xQWpyVFpLVThVWWh2STJUa3NWN1EveEd3WUZ4Z3I4SXI2NlQ5WGsKa3V6bTIyUXVSb2Z5bXFLbnh4NXg0TStXQWNvZG0zRHQrTE5XNWVpYUZOMmR4L0I1S2hPMndTSWxEdHhxK3ZKNwpwR0Jxb0xQWGcwQkltRm0vUEtlQlI3KzRMR01JbG5uZ05lTzI3WmZRa2VMQmgwTDhkTklKdzFId29JdXdNdGRYCnhWM040TDByZmdQcmdKditIeHJQdXlDRGhlZEU5UWQwZEU1bWk1OENBd0VBQWFNN01Ea3dDUVlEVlIwVEJBSXcKQURBWEJnTlZIUkVFRURBT2dnd3FMbWR0YjJ4aFlpNXVaWFF3RXdZRFZSMGxCQXd3Q2dZSUt3WUJCUVVIQXdFdwpEUVlKS29aSWh2Y05BUUVMQlFBRGdnSUJBR2RhMEJIVHNkOE1wNElYeEhRUFFZNGxrcGJsVmdIZzJFaFAxTFhsClpRbkxZckRPR1hEejB3dHdsaHI2NndjaTk3NU4vL1o3aFJzMUs4N2s3YmhWOFdBZklLYzA5ZHlhc2ZrbFhRZTgKNWU0cUNSVGhPV084aCtsSVVmbElSOHE3OVpBRG53N0pBMEZWZ20zdEUwcnpja1VmaXBFVVUyTCtlNDBIZnhSVgpxcDJ6b2MySVMwRnZ2MEZkNWUwd0krMng5TzFzMkZPcUNRa3lOZWU1SCtidGNnYXJkODdJbzZIeWhBMnYrZnIzCm1DenNkNzdiMkQ2K2FLVmNKWFNnR09BNVRRUjQ4TWVVOGNndEpxTkcwWXJGS045L2FBc2lGRWZMelJpdzhoRHcKanRiVUxTT1Btdm1FMXJXTGdpb28vNk5tcFNkWkZJaVFxQ0cyb3BiNUR3UjJrTGpjZkZ4N3loWGhzUllCdCt6Vwp3dzBlbjJSdXlEV3VqbWJtQUo5K0Uxb2hWTU00SXIzK21EcklPQlArcVRSak82UFB0NGVFT1JnUUlyd2U0WHJ5CkhWYjF5NXpPSHN6STZESkN1QXc4YjBaN293MnZCY3orVllsemt3M0lINWdGS01KeWVxZktKa0xkSzRqZlVLVHkKN3MvR3NRMEI5SERhT1U1OWdaOXJUMTE4SFpBVCtqZG9vaFhwOTI4MFhjeThUbHZZWE1veDIxZ0xLaE1jUFFkZgoyOWJvOEVCQnhhWUtMNWszcVRzamg4ZWd0KzFibFZCRTdzMk1BcGdJaFJxVlZTcmxSMldXWGovT2VOcFJXMlM0CjQrSWg5YXc5eWMrc0lValJ3Y2pCM1EwaG9iTWMrbEROQXRYM080OUxnMldaUmJWRnFxbFpVZWZyenRRa0pyZW8KK255TQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
nginxSite:
repository: nginxinc/nginx-unprivileged
pullPolicy: Always
tag: "1.23"
nginxConfigPath: /etc/nginx/conf.d/default.conf
ressourceRequest:
memory: 16M #16 Mo RAM
cpu: 50m # 0.05 core de CPU
ephemeralStorage: 512M #512 Mo de storage non persistent (en + de ce qui est dans l'image)
ressourceLimit:
memory: 128M #128 Mo RAM, au delà eviction
cpu: 500m # 0.5 core de CPU, au delà CPU Throttle
ephemeralStorage: 512M #512 Mo de storage non persistent (en + de ce qui est dans l'image), au delà éviction
ingress:
site:
hosts:
- wwwgmo.gmolab.net
pma:
hosts:
- wwwgmo-pma.gmolab.net
kibana:
hosts:
- wwwgmo-kibana.gmolab.net
phpfpmSite:
repository: gmouchet/wwwgmo-php-fpm
pullPolicy: Always
ressourceRequest:
memory: 16M #16 Mo RAM
cpu: 50m # 0.05 core de CPU
ephemeralStorage: 512M #512 Mo de storage non persistent (en + de ce qui est dans l'image)
ressourceLimit:
memory: 128M #128 Mo RAM, au delà eviction
cpu: 500m # 0.5 core de CPU, au delà CPU Throttle
ephemeralStorage: 512M #512 Mo de storage non persistent (en + de ce qui est dans l'image), au delà éviction
site:
title: "Stack GMo - PHP-FPM - MariaDB - Elasticsearch"
db:
name: gmo_db
user: gmo_db
host: service-mariadb
port: 3306
tabl: tbl_email
es:
host: service-elasticsearch:9200
user: elastic
index: wwwgmo_index
persistentVolumeClaim:
storageRequest: 1Gi
k3sStorageClassName: local-path
k8sStorageClassName: longhorn

10
helm/values-secrets.yaml Normal file
View File

@ -0,0 +1,10 @@
site:
ssl_key: LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JSUV2UUlCQURBTkJna3Foa2lHOXcwQkFRRUZBQVNDQktjd2dnU2pBZ0VBQW9JQkFRQ1ZMK0NrbGE4SWwyaFUKSDZOZEtGT2JHd2R3MHZQaG5HTkx1WjdsZFVlMnNoMTRZYmMvS21nUll0c09tRFZYVE9HNWlYWmVQWjlqV2RtdApBV2Nkbk9SME1wMXV1anJWMVIyQkZQN1htbUJuMjNtODVmQk5GS05tbzlVLytIQkFoaW95NjQ1Z2lqZFFJNjAyClNsUEZHSWJ5Tms1TEZlMFA4UnNHQmNZSy9DSyt1ay9WNUpMczV0dGtMa2FIOHBxaXA4Y2VjZURQbGdIS0hadHcKN2ZpelZ1WG9taFRkbmNmd2VTb1R0c0VpSlE3Y2F2cnllNlJnYXFDejE0TkFTSmhadnp5bmdVZS91Q3hqQ0paNQo0RFhqdHUyWDBKSGl3WWRDL0hUU0NjTlI4S0NMc0RMWFY4VmR6ZUM5SzM0RDY0Q2IvaDhhejdzZ2c0WG5SUFVICmRIUk9ab3VmQWdNQkFBRUNnZ0VBRGpNRXRrV0tQUGx1M3ZXS21VeEVTNGY5WTZTckVtSE4wRXIyTDdBWThrVHUKVkhpTElNSksyTDl5OVdiNzlMZUc2SFRkUlBKU2l2bmwrUGNnTnd1cGNYeDd5dFV1SjdvUUE5V0VFcHRKUDdsVApxSmRZdkNLOFpxd3Q3aTBabEsvd1c1dXdsOG12K0JCZE9tOUZSOXQzYjBoSFFyMloxdmJ1SG9XZ0tETFZUOEoxCis1MXlISC9VbGlIb0E4bzkxYUd3K3F5KzllWlJrdGpxSmlOWXpGMUMzVDB5Sk1yQXdxZXU4Z09ic2k3c2kwMWkKZ254d1VISDVVckNjaXZRTzQxWFBjUW5QYzQ5dTE4bkFRSGRxTTZNL05yTzZwWENUTnY0OHY2OEZsaDlmanBqawpvUDVJN0IwRThOTE5ZSDkyMEJUbE1hRFUvYVAwdE9HRXJHblgyWElBY1FLQmdRQzZRbFpJMjAyTmZMWnVSVmhoCjBMN3A4VklXWnE3UEl2US9tRHF4Rlc4WllkQk14RXY2UFZVTTl6VHVsVVh2TlM2SE9ncHAxUGxGVVNHM2dQRzUKZU1nR1piTTZjczJwM1dmOVVjZ1ZQYXM3Q2lGYnRZZXdJS0dYMWY5OHFMTU4ybkFTd2dVU0N5eUQrZER0UVpDWQp1VlRybnhZbUkrOHlBUFpOR3pSVUVNUnh1UUtCZ1FETkRBalpWTmNOeGJaVW1YWkZrMEp1YnNLUGZVMStYZVdrCkxCYkVCaDZwVG5hOWNVTE5Cc0F1ZjI4cEpFS1FQeXc4SVFEUDIwaDJXWUdIQ1FtNFZyMEM1TVN3TFVxNGdsalgKNHJ3bmxSZE44MDNqbjJTVUJjV1lGSGdNc1EyN2ZRT2lvNnVnUnUrZ0U2ZDMwa0lYTW1waUp4eHNuN3V5L0JBOAp1Z0pBc1R6MEZ3S0JnRE56ejlJZ2dyUHJGNW91bmRPbmpwV2hqRU9UNmdaZWFZcUh5dTdRTlBpV0JLeXdMU3piCmRIczRidTdaWFpCTzZLT0NiUTMvUHp6ZXhLbWtmU0gzTTRwUTNjbnZuTkNuME9veGhVd1kxUXhpS0FUbGlLNG0KMVh6VUtOZU80cWVaQ0F5bWZEQVgxaHcvRG0vOEJLMnJ4TUd5R0xSQWlQc1BPUHJqNFBpNENReEJBb0dBTmw0bgpob0N4V095QWtPUHo4VFMvbTRwd3VoMHVUQUJYb0hVMFFCdWpTNThMYXVXNklhVFZsajZoMmRYTWRIVGJwTUhYCmRrV2RiQXdGaFNtSFUwSmtjWHo1RGdHa1cxSHNmcW1XM0NQeS91OHhTdFo3azZnSUlXL2orUEdGUTU0OU5ZV1MKUHpndjExRCt5WTJOaXBzS2pDWDBxblNjRHpRNGxmRjRJWEVkU1ZjQ2dZRUF0VVQ2Y1BYdnYxamM4WVUvN3BjTApXR21WYldjcDNXbW5VK2FoaXBVM2l6YmxEUGkvWUR0aVhKSFVoYUl1TnZySVBKL2VIT1psejRPcVViS015YzFyCjV2blUrajg3MnZOdGViVkphemd1SHBHTzY3SVFrNHdJamp0TlQrQUYybUhjdnJUVTYyay9hWHJFSGN4ekZMMTMKcW1TcHNUVWtJYXFaZ2VMUERWMWNOZWc9Ci0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K
mariadb:
rootPass: pa55w0rd
dbPass: passw0rd
elastic:
password: pa55w0rd

34
src/checkindex.php Normal file
View File

@ -0,0 +1,34 @@
<?php
require_once 'config.php';
function checkindex($user,$password,$host,$index)
{
$curl = curl_init();
// construct url
curl_setopt($curl, CURLOPT_URL,"http://".$user.":".$password."@".$host."/".$index);
//curl_setopt($curl, CURLOPT_URL,"http://elasti:".$es_password."@".$es_host."/gmo_index");
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT ,5); // connect timeout
curl_setopt($curl, CURLOPT_TIMEOUT, 10); // curl timeout
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
if(FALSE === curl_exec($curl)){
//echo('open '.$es_index.' failed'."\n");
$retCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
return $retCode;
}
else{
// Fetch the HTTP-code (cred: @GZipp)
$retCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
return $retCode;
//echo('HTTP return code='.$retcode."\n");
}
curl_close($curl);
}
return checkindex($es_user,$es_password,$es_host,$es_index)
?>

10
src/composer.json Normal file
View File

@ -0,0 +1,10 @@
{
"config": {
"allow-plugins": {
"php-http/discovery": true
}
},
"require": {
"elasticsearch/elasticsearch": "^8.13"
}
}

966
src/composer.lock generated Normal file
View File

@ -0,0 +1,966 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "56a8f0b49795e6a4e319b9bce9722c3b",
"packages": [
{
"name": "elastic/transport",
"version": "v8.8.0",
"source": {
"type": "git",
"url": "https://github.com/elastic/elastic-transport-php.git",
"reference": "cdf9f63a16ec6bfb4c881ab89aa0e2a61fb7c20b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/elastic/elastic-transport-php/zipball/cdf9f63a16ec6bfb4c881ab89aa0e2a61fb7c20b",
"reference": "cdf9f63a16ec6bfb4c881ab89aa0e2a61fb7c20b",
"shasum": ""
},
"require": {
"composer-runtime-api": "^2.0",
"php": "^7.4 || ^8.0",
"php-http/discovery": "^1.14",
"php-http/httplug": "^2.3",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0 || ^2.0",
"psr/log": "^1 || ^2 || ^3"
},
"require-dev": {
"nyholm/psr7": "^1.5",
"php-http/mock-client": "^1.5",
"phpstan/phpstan": "^1.4",
"phpunit/phpunit": "^9.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Elastic\\Transport\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "HTTP transport PHP library for Elastic products",
"keywords": [
"PSR_17",
"elastic",
"http",
"psr-18",
"psr-7",
"transport"
],
"support": {
"issues": "https://github.com/elastic/elastic-transport-php/issues",
"source": "https://github.com/elastic/elastic-transport-php/tree/v8.8.0"
},
"time": "2023-11-08T10:51:51+00:00"
},
{
"name": "elasticsearch/elasticsearch",
"version": "v8.13.0",
"source": {
"type": "git",
"url": "https://github.com/elastic/elasticsearch-php.git",
"reference": "221723e9497515ec82833995a97c8546d9b6499a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/elastic/elasticsearch-php/zipball/221723e9497515ec82833995a97c8546d9b6499a",
"reference": "221723e9497515ec82833995a97c8546d9b6499a",
"shasum": ""
},
"require": {
"elastic/transport": "^8.8",
"guzzlehttp/guzzle": "^7.0",
"php": "^7.4 || ^8.0",
"psr/http-client": "^1.0",
"psr/http-message": "^1.1 || ^2.0",
"psr/log": "^1|^2|^3"
},
"require-dev": {
"ext-yaml": "*",
"ext-zip": "*",
"mockery/mockery": "^1.5",
"nyholm/psr7": "^1.5",
"php-http/message-factory": "^1.0",
"php-http/mock-client": "^1.5",
"phpstan/phpstan": "^1.4",
"phpunit/phpunit": "^9.5",
"psr/http-factory": "^1.0",
"symfony/finder": "~4.0",
"symfony/http-client": "^5.0|^6.0|^7.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Elastic\\Elasticsearch\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHP Client for Elasticsearch",
"keywords": [
"client",
"elastic",
"elasticsearch",
"search"
],
"support": {
"issues": "https://github.com/elastic/elasticsearch-php/issues",
"source": "https://github.com/elastic/elasticsearch-php/tree/v8.13.0"
},
"time": "2024-03-27T15:09:06+00:00"
},
{
"name": "guzzlehttp/guzzle",
"version": "7.8.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "41042bc7ab002487b876a0683fc8dce04ddce104"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/41042bc7ab002487b876a0683fc8dce04ddce104",
"reference": "41042bc7ab002487b876a0683fc8dce04ddce104",
"shasum": ""
},
"require": {
"ext-json": "*",
"guzzlehttp/promises": "^1.5.3 || ^2.0.1",
"guzzlehttp/psr7": "^1.9.1 || ^2.5.1",
"php": "^7.2.5 || ^8.0",
"psr/http-client": "^1.0",
"symfony/deprecation-contracts": "^2.2 || ^3.0"
},
"provide": {
"psr/http-client-implementation": "1.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.2",
"ext-curl": "*",
"php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999",
"php-http/message-factory": "^1.1",
"phpunit/phpunit": "^8.5.36 || ^9.6.15",
"psr/log": "^1.1 || ^2.0 || ^3.0"
},
"suggest": {
"ext-curl": "Required for CURL handler support",
"ext-intl": "Required for Internationalized Domain Name (IDN) support",
"psr/log": "Required for using the Log middleware"
},
"type": "library",
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": false
}
},
"autoload": {
"files": [
"src/functions_include.php"
],
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Jeremy Lindblom",
"email": "jeremeamia@gmail.com",
"homepage": "https://github.com/jeremeamia"
},
{
"name": "George Mponos",
"email": "gmponos@gmail.com",
"homepage": "https://github.com/gmponos"
},
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com",
"homepage": "https://github.com/Nyholm"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com",
"homepage": "https://github.com/sagikazarmark"
},
{
"name": "Tobias Schultze",
"email": "webmaster@tubo-world.de",
"homepage": "https://github.com/Tobion"
}
],
"description": "Guzzle is a PHP HTTP client library",
"keywords": [
"client",
"curl",
"framework",
"http",
"http client",
"psr-18",
"psr-7",
"rest",
"web service"
],
"support": {
"issues": "https://github.com/guzzle/guzzle/issues",
"source": "https://github.com/guzzle/guzzle/tree/7.8.1"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://github.com/Nyholm",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle",
"type": "tidelift"
}
],
"time": "2023-12-03T20:35:24+00:00"
},
{
"name": "guzzlehttp/promises",
"version": "2.0.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "bbff78d96034045e58e13dedd6ad91b5d1253223"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/bbff78d96034045e58e13dedd6ad91b5d1253223",
"reference": "bbff78d96034045e58e13dedd6ad91b5d1253223",
"shasum": ""
},
"require": {
"php": "^7.2.5 || ^8.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.2",
"phpunit/phpunit": "^8.5.36 || ^9.6.15"
},
"type": "library",
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": false
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Promise\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com",
"homepage": "https://github.com/Nyholm"
},
{
"name": "Tobias Schultze",
"email": "webmaster@tubo-world.de",
"homepage": "https://github.com/Tobion"
}
],
"description": "Guzzle promises library",
"keywords": [
"promise"
],
"support": {
"issues": "https://github.com/guzzle/promises/issues",
"source": "https://github.com/guzzle/promises/tree/2.0.2"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://github.com/Nyholm",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises",
"type": "tidelift"
}
],
"time": "2023-12-03T20:19:20+00:00"
},
{
"name": "guzzlehttp/psr7",
"version": "2.6.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/45b30f99ac27b5ca93cb4831afe16285f57b8221",
"reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221",
"shasum": ""
},
"require": {
"php": "^7.2.5 || ^8.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.1 || ^2.0",
"ralouphie/getallheaders": "^3.0"
},
"provide": {
"psr/http-factory-implementation": "1.0",
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.2",
"http-interop/http-factory-tests": "^0.9",
"phpunit/phpunit": "^8.5.36 || ^9.6.15"
},
"suggest": {
"laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
},
"type": "library",
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": false
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Psr7\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "George Mponos",
"email": "gmponos@gmail.com",
"homepage": "https://github.com/gmponos"
},
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com",
"homepage": "https://github.com/Nyholm"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com",
"homepage": "https://github.com/sagikazarmark"
},
{
"name": "Tobias Schultze",
"email": "webmaster@tubo-world.de",
"homepage": "https://github.com/Tobion"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com",
"homepage": "https://sagikazarmark.hu"
}
],
"description": "PSR-7 message implementation that also provides common utility methods",
"keywords": [
"http",
"message",
"psr-7",
"request",
"response",
"stream",
"uri",
"url"
],
"support": {
"issues": "https://github.com/guzzle/psr7/issues",
"source": "https://github.com/guzzle/psr7/tree/2.6.2"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://github.com/Nyholm",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7",
"type": "tidelift"
}
],
"time": "2023-12-03T20:05:35+00:00"
},
{
"name": "php-http/discovery",
"version": "1.19.4",
"source": {
"type": "git",
"url": "https://github.com/php-http/discovery.git",
"reference": "0700efda8d7526335132360167315fdab3aeb599"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-http/discovery/zipball/0700efda8d7526335132360167315fdab3aeb599",
"reference": "0700efda8d7526335132360167315fdab3aeb599",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.0|^2.0",
"php": "^7.1 || ^8.0"
},
"conflict": {
"nyholm/psr7": "<1.0",
"zendframework/zend-diactoros": "*"
},
"provide": {
"php-http/async-client-implementation": "*",
"php-http/client-implementation": "*",
"psr/http-client-implementation": "*",
"psr/http-factory-implementation": "*",
"psr/http-message-implementation": "*"
},
"require-dev": {
"composer/composer": "^1.0.2|^2.0",
"graham-campbell/phpspec-skip-example-extension": "^5.0",
"php-http/httplug": "^1.0 || ^2.0",
"php-http/message-factory": "^1.0",
"phpspec/phpspec": "^5.1 || ^6.1 || ^7.3",
"sebastian/comparator": "^3.0.5 || ^4.0.8",
"symfony/phpunit-bridge": "^6.4.4 || ^7.0.1"
},
"type": "composer-plugin",
"extra": {
"class": "Http\\Discovery\\Composer\\Plugin",
"plugin-optional": true
},
"autoload": {
"psr-4": {
"Http\\Discovery\\": "src/"
},
"exclude-from-classmap": [
"src/Composer/Plugin.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com"
}
],
"description": "Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations",
"homepage": "http://php-http.org",
"keywords": [
"adapter",
"client",
"discovery",
"factory",
"http",
"message",
"psr17",
"psr7"
],
"support": {
"issues": "https://github.com/php-http/discovery/issues",
"source": "https://github.com/php-http/discovery/tree/1.19.4"
},
"time": "2024-03-29T13:00:05+00:00"
},
{
"name": "php-http/httplug",
"version": "2.4.0",
"source": {
"type": "git",
"url": "https://github.com/php-http/httplug.git",
"reference": "625ad742c360c8ac580fcc647a1541d29e257f67"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-http/httplug/zipball/625ad742c360c8ac580fcc647a1541d29e257f67",
"reference": "625ad742c360c8ac580fcc647a1541d29e257f67",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0",
"php-http/promise": "^1.1",
"psr/http-client": "^1.0",
"psr/http-message": "^1.0 || ^2.0"
},
"require-dev": {
"friends-of-phpspec/phpspec-code-coverage": "^4.1 || ^5.0 || ^6.0",
"phpspec/phpspec": "^5.1 || ^6.0 || ^7.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Http\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Eric GELOEN",
"email": "geloen.eric@gmail.com"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com",
"homepage": "https://sagikazarmark.hu"
}
],
"description": "HTTPlug, the HTTP client abstraction for PHP",
"homepage": "http://httplug.io",
"keywords": [
"client",
"http"
],
"support": {
"issues": "https://github.com/php-http/httplug/issues",
"source": "https://github.com/php-http/httplug/tree/2.4.0"
},
"time": "2023-04-14T15:10:03+00:00"
},
{
"name": "php-http/promise",
"version": "1.3.1",
"source": {
"type": "git",
"url": "https://github.com/php-http/promise.git",
"reference": "fc85b1fba37c169a69a07ef0d5a8075770cc1f83"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-http/promise/zipball/fc85b1fba37c169a69a07ef0d5a8075770cc1f83",
"reference": "fc85b1fba37c169a69a07ef0d5a8075770cc1f83",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"friends-of-phpspec/phpspec-code-coverage": "^4.3.2 || ^6.3",
"phpspec/phpspec": "^5.1.2 || ^6.2 || ^7.4"
},
"type": "library",
"autoload": {
"psr-4": {
"Http\\Promise\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Joel Wurtz",
"email": "joel.wurtz@gmail.com"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com"
}
],
"description": "Promise used for asynchronous HTTP requests",
"homepage": "http://httplug.io",
"keywords": [
"promise"
],
"support": {
"issues": "https://github.com/php-http/promise/issues",
"source": "https://github.com/php-http/promise/tree/1.3.1"
},
"time": "2024-03-15T13:55:21+00:00"
},
{
"name": "psr/http-client",
"version": "1.0.3",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-client.git",
"reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90",
"reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90",
"shasum": ""
},
"require": {
"php": "^7.0 || ^8.0",
"psr/http-message": "^1.0 || ^2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for HTTP clients",
"homepage": "https://github.com/php-fig/http-client",
"keywords": [
"http",
"http-client",
"psr",
"psr-18"
],
"support": {
"source": "https://github.com/php-fig/http-client"
},
"time": "2023-09-23T14:17:50+00:00"
},
{
"name": "psr/http-factory",
"version": "1.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-factory.git",
"reference": "e616d01114759c4c489f93b099585439f795fe35"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35",
"reference": "e616d01114759c4c489f93b099585439f795fe35",
"shasum": ""
},
"require": {
"php": ">=7.0.0",
"psr/http-message": "^1.0 || ^2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interfaces for PSR-7 HTTP message factories",
"keywords": [
"factory",
"http",
"message",
"psr",
"psr-17",
"psr-7",
"request",
"response"
],
"support": {
"source": "https://github.com/php-fig/http-factory/tree/1.0.2"
},
"time": "2023-04-10T20:10:41+00:00"
},
{
"name": "psr/http-message",
"version": "2.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71",
"reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"support": {
"source": "https://github.com/php-fig/http-message/tree/2.0"
},
"time": "2023-04-04T09:54:51+00:00"
},
{
"name": "psr/log",
"version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001",
"reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001",
"shasum": ""
},
"require": {
"php": ">=8.0.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
],
"support": {
"source": "https://github.com/php-fig/log/tree/3.0.0"
},
"time": "2021-07-14T16:46:02+00:00"
},
{
"name": "ralouphie/getallheaders",
"version": "3.0.3",
"source": {
"type": "git",
"url": "https://github.com/ralouphie/getallheaders.git",
"reference": "120b605dfeb996808c31b6477290a714d356e822"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
"reference": "120b605dfeb996808c31b6477290a714d356e822",
"shasum": ""
},
"require": {
"php": ">=5.6"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.1",
"phpunit/phpunit": "^5 || ^6.5"
},
"type": "library",
"autoload": {
"files": [
"src/getallheaders.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ralph Khattar",
"email": "ralph.khattar@gmail.com"
}
],
"description": "A polyfill for getallheaders.",
"support": {
"issues": "https://github.com/ralouphie/getallheaders/issues",
"source": "https://github.com/ralouphie/getallheaders/tree/develop"
},
"time": "2019-03-08T08:55:37+00:00"
},
{
"name": "symfony/deprecation-contracts",
"version": "v3.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "7c3aff79d10325257a001fcf92d991f24fc967cf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf",
"reference": "7c3aff79d10325257a001fcf92d991f24fc967cf",
"shasum": ""
},
"require": {
"php": ">=8.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "3.4-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
}
},
"autoload": {
"files": [
"function.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.4.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2023-05-23T14:45:45+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.6.0"
}

36
src/config.php Normal file
View File

@ -0,0 +1,36 @@
<?php
//shared variables
$curYear = date('Y');
$data_csv_file = "sampleData.csv";
// Site
$site_version = getenv('SITE_VERSION');
$site_title = getenv('SITE_TITLE');
$site_copyright = "Version ". $site_version ." (c) 2022-". $curYear ." - Gilles Mouchet (gilles.mouchet@gmail.com)";
// DB
$host = getenv('DB_HOST');
$db = getenv('DB_NAME');
$user = getenv('DB_USER');
$password = getenv('DB_PASSWORD');
$table = getenv('DB_TABLE');
// PMA
$pmaUrl = getenv('PMA_URL');
// Kibana
$kibanaUrl = getenv('KIBANA_URL');
//site url
// get http_host without port
//list($realHost,)=explode(':',$_SERVER['HTTP_HOST']);
// phpmyadmin url
//$urlPhpMyAdmin="http://" . $realHost . ":" . getenv('PMA_PORT');
// site DB
$db_site_title = "GMo - Database";
// ES
$es_site_title = "GMo - Elasticsearch";
$es_host = getenv('ES_HOST');
$es_user = getenv('ES_USER');
$es_password = getenv('ES_PASSWORD');
$es_index = getenv('ES_INDEX');

22
src/connect-es.php Normal file
View File

@ -0,0 +1,22 @@
<?php
require_once "./vendor/autoload.php";
use Elastic\Elasticsearch\ClientBuilder;
require_once 'config.php';
function connect_es($es_host, $es_user, $es_password)
{
try {
// Connect to es
return ClientBuilder::create()
->setHosts([$es_host])
->setBasicAuthentication($es_user, $es_password)
->build();
//return $client;
}
catch (PDOException $e) {
die($e->getMessage());
}
}
return connect_es($es_host, $es_user, $es_password)
?>

16
src/connect.php Normal file
View File

@ -0,0 +1,16 @@
<?php
require_once 'config.php';
function connect($host, $db, $user, $password)
{
$dsn = "mysql:host=$host;dbname=$db;charset=UTF8";
try {
$options = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
return new PDO($dsn, $user, $password, $options);
} catch (PDOException $e) {
die($e->getMessage());
}
}
return connect($host, $db, $user, $password);

66
src/createindex.php Normal file
View File

@ -0,0 +1,66 @@
<?php
require_once 'config.php';
// connect to es
$client = require 'connect-es.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $es_site_title." v".$site_version ?></title>
<!-- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> -->
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/gmo.css">
</head>
<body>
<h2><?php echo $es_site_title ?></h2>
<?php echo $site_copyright; echo "<hr>"; ?>
<?php
// check if index exist
echo "Check if index <b>".$es_index."</b> exists<br>";
$params = [
'index' => $es_index,
];
try {
$response = $client->indices()->delete($params);
echo "Index <b>".$es_index."</b> exists. It is deleted and created<br>";
}
catch (Exception $e) {
echo "Index <b>".$es_index."</b> doesn't exist. <b>".$es_index."</b> will be created<br>";
}
// Create Index
echo "Create index <b>".$es_index."</b><br>";
$params = [
'index' => $es_index,
'body' => [
'settings' => [
'number_of_replicas' => 0
],
],
];
$response = $client->indices()->create($params);
// create document in index
$row = 0;
echo "<hr>";
if (($handle = fopen($data_csv_file, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 300, ";")) !== FALSE) {
$row++;
$firstname = $data[0];
$lastname = $data[1];
$email = $data[2];
echo 'Adding: '.$row .' '.$firstname.' '.$lastname.' ('.$email.')<br>';
$params = [
'index' => $es_index,
'body' => [ 'id' => $row, 'firstname' => $firstname, 'lastname' => $lastname, 'email' => $email]
];
$response = $client->index($params);
}
fclose($handle);
}
?>
</body>
</html>

58
src/createtable.php Normal file
View File

@ -0,0 +1,58 @@
<?php
require_once 'config.php';
// conection db
$conn = require 'connect.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $db_site_title." v".$site_version ?></title>
<!-- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> -->
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/gmo.css">
</head>
<body>
<h2><?php echo $db_site_title ?></h2>
<?php echo $site_copyright; echo "<hr>"; ?>
<?php
// sql to create table
$sql = "CREATE TABLE IF NOT EXISTS $table (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50) UNIQUE,
reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
mod_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)";
try {
$conn->query($sql);
echo "<p>Table <b>".$table."</b> created successfully</p>";
}
catch(PDOException $e) {
echo $e->getMessage();//Remove or change message in production code
}
// add record from csv files
$csvFile = fopen($data_csv_file, "r");
while (($getData = fgetcsv($csvFile, 10000, ";")) !== FALSE){
// Get row data
$firstname = $getData[0];
$lastname = $getData[1];
$email = $getData[2];
$sql = "INSERT INTO $table (firstname, lastname, email) VALUES (?,?,?)";
try {
$stmt= $conn->prepare($sql);
$stmt->execute([$firstname, $lastname, $email]);
echo "<p>Added '". $firstname. " ". $lastname ."' successfully</p>";
}
catch (PDOException $e){
echo $e->getMessage();;
}
}
$conn=null;
fclose($csvFile);
?>

2050
src/css/bootstrap-grid.css vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

7
src/css/bootstrap-grid.min.css vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

330
src/css/bootstrap-reboot.css vendored Normal file
View File

@ -0,0 +1,330 @@
/*!
* Bootstrap Reboot v4.0.0 (https://getbootstrap.com)
* Copyright 2011-2018 The Bootstrap Authors
* Copyright 2011-2018 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
html {
font-family: sans-serif;
line-height: 1.15;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
-ms-overflow-style: scrollbar;
-webkit-tap-highlight-color: transparent;
}
@-ms-viewport {
width: device-width;
}
article, aside, dialog, figcaption, figure, footer, header, hgroup, main, nav, section {
display: block;
}
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #212529;
text-align: left;
background-color: #fff;
}
[tabindex="-1"]:focus {
outline: 0 !important;
}
hr {
box-sizing: content-box;
height: 0;
overflow: visible;
}
h1, h2, h3, h4, h5, h6 {
margin-top: 0;
margin-bottom: 0.5rem;
}
p {
margin-top: 0;
margin-bottom: 1rem;
}
abbr[title],
abbr[data-original-title] {
text-decoration: underline;
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
cursor: help;
border-bottom: 0;
}
address {
margin-bottom: 1rem;
font-style: normal;
line-height: inherit;
}
ol,
ul,
dl {
margin-top: 0;
margin-bottom: 1rem;
}
ol ol,
ul ul,
ol ul,
ul ol {
margin-bottom: 0;
}
dt {
font-weight: 700;
}
dd {
margin-bottom: .5rem;
margin-left: 0;
}
blockquote {
margin: 0 0 1rem;
}
dfn {
font-style: italic;
}
b,
strong {
font-weight: bolder;
}
small {
font-size: 80%;
}
sub,
sup {
position: relative;
font-size: 75%;
line-height: 0;
vertical-align: baseline;
}
sub {
bottom: -.25em;
}
sup {
top: -.5em;
}
a {
color: #007bff;
text-decoration: none;
background-color: transparent;
-webkit-text-decoration-skip: objects;
}
a:hover {
color: #0056b3;
text-decoration: underline;
}
a:not([href]):not([tabindex]) {
color: inherit;
text-decoration: none;
}
a:not([href]):not([tabindex]):hover, a:not([href]):not([tabindex]):focus {
color: inherit;
text-decoration: none;
}
a:not([href]):not([tabindex]):focus {
outline: 0;
}
pre,
code,
kbd,
samp {
font-family: monospace, monospace;
font-size: 1em;
}
pre {
margin-top: 0;
margin-bottom: 1rem;
overflow: auto;
-ms-overflow-style: scrollbar;
}
figure {
margin: 0 0 1rem;
}
img {
vertical-align: middle;
border-style: none;
}
svg:not(:root) {
overflow: hidden;
}
table {
border-collapse: collapse;
}
caption {
padding-top: 0.75rem;
padding-bottom: 0.75rem;
color: #6c757d;
text-align: left;
caption-side: bottom;
}
th {
text-align: inherit;
}
label {
display: inline-block;
margin-bottom: .5rem;
}
button {
border-radius: 0;
}
button:focus {
outline: 1px dotted;
outline: 5px auto -webkit-focus-ring-color;
}
input,
button,
select,
optgroup,
textarea {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
button,
input {
overflow: visible;
}
button,
select {
text-transform: none;
}
button,
html [type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
padding: 0;
border-style: none;
}
input[type="radio"],
input[type="checkbox"] {
box-sizing: border-box;
padding: 0;
}
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"] {
-webkit-appearance: listbox;
}
textarea {
overflow: auto;
resize: vertical;
}
fieldset {
min-width: 0;
padding: 0;
margin: 0;
border: 0;
}
legend {
display: block;
width: 100%;
max-width: 100%;
padding: 0;
margin-bottom: .5rem;
font-size: 1.5rem;
line-height: inherit;
color: inherit;
white-space: normal;
}
progress {
vertical-align: baseline;
}
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
[type="search"] {
outline-offset: -2px;
-webkit-appearance: none;
}
[type="search"]::-webkit-search-cancel-button,
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-file-upload-button {
font: inherit;
-webkit-appearance: button;
}
output {
display: inline-block;
}
summary {
display: list-item;
cursor: pointer;
}
template {
display: none;
}
[hidden] {
display: none !important;
}
/*# sourceMappingURL=bootstrap-reboot.css.map */

File diff suppressed because one or more lines are too long

8
src/css/bootstrap-reboot.min.css vendored Normal file
View File

@ -0,0 +1,8 @@
/*!
* Bootstrap Reboot v4.0.0 (https://getbootstrap.com)
* Copyright 2011-2018 The Bootstrap Authors
* Copyright 2011-2018 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/*,::after,::before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-ms-overflow-style:scrollbar;-webkit-tap-highlight-color:transparent}@-ms-viewport{width:device-width}article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus{outline:0!important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0}address{margin-bottom:1rem;font-style:normal;line-height:inherit}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}dfn{font-style:italic}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent;-webkit-text-decoration-skip:objects}a:hover{color:#0056b3;text-decoration:underline}a:not([href]):not([tabindex]){color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus,a:not([href]):not([tabindex]):hover{color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus{outline:0}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto;-ms-overflow-style:scrollbar}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg:not(:root){overflow:hidden}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none!important}
/*# sourceMappingURL=bootstrap-reboot.min.css.map */

File diff suppressed because one or more lines are too long

8975
src/css/bootstrap.css vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

7
src/css/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

27
src/css/gmo.css Normal file
View File

@ -0,0 +1,27 @@
body
{
// text-align: center;
//background-color: #8EA1AD;
// font-family:Verdana, Geneva, Arial, Helvetica, sans-serif;
// color: #990000;
margin-left: 15px;
}
div.error {
color: red;
font-size: 13px;
margin-bottom: 23px;
}
div.noerror {
color: green;
font-size: 13px;
margin-bottom: 23px;
}
th, td {
padding: 8px;
}
h6 {
font-size: 10px;
}

33
src/deleteindex.php Normal file
View File

@ -0,0 +1,33 @@
<?php
require_once 'config.php';
$client = require 'connect-es.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $es_site_title." v".$site_version ?></title>
<!-- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> -->
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/gmo.css">
</head>
<body>
<h2><?php echo $es_site_title ?></h2>
<?php echo $site_copyright; echo "<hr>"; ?>
<?php
//if ($index == true) {
// check if index exist
echo "Check if index <b>".$es_index."</b> exists<br>";
$params = [
'index' => $es_index,
];
try {
$response = $client->indices()->delete($params);
echo "Index <b>".$es_index."</b> exists. it will be deleted<br>";
//echo "<b>".$es_index."</b> deleted";
}
catch (Exception $e) {
echo $e;
}

30
src/deletetable.php Normal file
View File

@ -0,0 +1,30 @@
<?php
require_once 'config.php';
// conection db
$conn = require 'connect.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $db_site_title." v".$site_version ?></title>
<!-- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> -->
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/gmo.css">
</head>
<body>
<h2><?php echo $db_site_title ?></h2>
<?php echo $site_copyright; echo "<hr>"; ?>
<?php
// sql to create table
$sql = "DROP TABLE IF EXISTS $table;";
try {
$conn->query($sql);
echo "<p>Table <b>".$table."</b> deleted successfully</p>";
}
catch(PDOException $e) {
echo $e->getMessage();//Remove or change message in production code
}
$conn=null;
?>

43
src/esinfo.php Normal file
View File

@ -0,0 +1,43 @@
<?php
require_once 'config.php';
// connect es
$client = require 'connect-es.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $es_site_title." ".$es_site_version ?></title>
<!-- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> -->
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/gmo.css">
</head>
<body>
<h2><?php echo $es_site_title ?></h2>
<?php echo $site_copyright; echo "<hr>"; ?>
<?php
// get info
$response = $client->info();
// get es status
$curl = curl_init();
// construct url
curl_setopt($curl, CURLOPT_URL,"http://".$es_user.":".$es_password."@".$es_host."/_cluster/health");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
//executing curl
$status = curl_exec($curl);
// closing curl
curl_close($curl);
// decode
$array = json_decode($status, true);
// display result
echo "<h4>Informations</h4>";
echo "<p><b>Name:</b> ".$response['name']."<br>";
echo "<b>Cluster name:</b> ".$response['cluster_name']."<br>";
echo "<b>Elasticsearch version:</b> ".$response['version']['number']."<br>";
echo "<b>Cluster health status:</b> ".$array['status']."</p>";
?>

5
src/images/pen.svg Normal file
View File

@ -0,0 +1,5 @@
<svg class="bi bi-pen" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M5.707 13.707a1 1 0 01-.39.242l-3 1a1 1 0 01-1.266-1.265l1-3a1 1 0 01.242-.391L10.086 2.5a2 2 0 012.828 0l.586.586a2 2 0 010 2.828l-7.793 7.793zM3 11l7.793-7.793a1 1 0 011.414 0l.586.586a1 1 0 010 1.414L5 13l-3 1 1-3z" clip-rule="evenodd"/>
<path fill-rule="evenodd" d="M9.854 2.56a.5.5 0 00-.708 0L5.854 5.855a.5.5 0 01-.708-.708L8.44 1.854a1.5 1.5 0 012.122 0l.293.292a.5.5 0 01-.707.708l-.293-.293z" clip-rule="evenodd"/>
<path d="M13.293 1.207a1 1 0 011.414 0l.03.03a1 1 0 01.03 1.383L13.5 4 12 2.5l1.293-1.293z"/>
</svg>

After

Width:  |  Height:  |  Size: 684 B

4
src/images/trash.svg Normal file
View File

@ -0,0 +1,4 @@
<svg class="bi bi-trash" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path d="M5.5 5.5A.5.5 0 016 6v6a.5.5 0 01-1 0V6a.5.5 0 01.5-.5zm2.5 0a.5.5 0 01.5.5v6a.5.5 0 01-1 0V6a.5.5 0 01.5-.5zm3 .5a.5.5 0 00-1 0v6a.5.5 0 001 0V6z"/>
<path fill-rule="evenodd" d="M14.5 3a1 1 0 01-1 1H13v9a2 2 0 01-2 2H5a2 2 0 01-2-2V4h-.5a1 1 0 01-1-1V2a1 1 0 011-1H6a1 1 0 011-1h2a1 1 0 011 1h3.5a1 1 0 011 1v1zM4.118 4L4 4.059V13a1 1 0 001 1h6a1 1 0 001-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z" clip-rule="evenodd"/>
</svg>

After

Width:  |  Height:  |  Size: 566 B

86
src/index.php Normal file
View File

@ -0,0 +1,86 @@
<?php
require_once 'config.php';
$date=date("d/m/Y");
$time=date("H:i:s");
$userAgent=htmlentities($_SERVER['HTTP_USER_AGENT'],ENT_QUOTES,"UTF-8");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $site_title; ?></title>
<!-- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9M
uhOf23Q9Ifjh" crossorigin="anonymous"> -->
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/gmo.css">
<?php
echo "<h2>".$site_title."</h2>";
echo $site_copyright;
echo "<hr>";
echo "<h3>MariaDB</h3>";
?>
<table>
<tr>
<td><a href="./createtable.php">Create table </a></td>
<td>&nbsp;&nbsp;</td>
<td>Create an add records in table <b><?php echo $table; ?></b> </td>
</tr>
<tr>
<td><a href="./deletetable.php">Remove table</a></td>
<td>&nbsp;&nbsp;</td>
<td>Remove table <b><?php echo $table; ?></b></td>
</tr>
<tr>
<td><a href="./managetable.php" target="_blank">Manage EMails</a></td>
<td>&nbsp;&nbsp;</td>
<td>Manage EMails (you must create table <b><?php echo $table; ?></b> before manage emails)</td>
</tr>
<tr>
<td><a href="<?php echo $pmaUrl?>" target="_blank">MariaDB manager</a></td>
<td>&nbsp;&nbsp;</td>
<td>Manage Database</td>
</tr>
<tr>
<td><a href="./phpinfo.php">PHP Info</a></td>
<td>&nbsp;&nbsp;</td>
<td>PHP informations</td>
</tr>
</table>
</div>
<hr>
<h3>Elasticsearch</h3>
<table>
<!-- <tr><td>&nbsp;&nbsp;</td></tr> -->
<tr>
<td><a href="./createindex.php">Create index </a></td>
<td>&nbsp;&nbsp;</td>
<td>Create index <b><?php echo $es_index;?></b> and add documents</td>
</tr>
<tr>
<td><a href="./deleteindex.php">Delete index</a></td>
<td>&nbsp;&nbsp;</td>
<td>Remove elasticsearch index <b><?php echo $es_index;?></b> </td>
</tr>
<tr>
<td><a href="./searchindex.php">Résultats de recherche</a></td>
<td>&nbsp;&nbsp;</td>
<td>Résultats de divers recherches dans l'index <b><?php echo $es_index;?></b> </td>
</tr>
<tr>
<td><a href="<?php echo $kibanaUrl?>" target="_blank">Kibana</a></td>
<td>&nbsp;&nbsp;</td>
<td>Elasticsearch indexes manager</td>
</tr>
<tr>
<td><a href="./esinfo.php">Elasticsearch info</a></td>
<td>&nbsp;&nbsp;</td>
<td>Elasticsearch informations</td>
</tr>
</table>
<hr>
<h6><?php echo "Browser&nbsp;: $userAgent\n"?><br>
<?php echo "Nous sommes le $date, il est $time.\n"?></h6>
</body>
</html>

311
src/managetable.php Normal file
View File

@ -0,0 +1,311 @@
<?php
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
require_once 'config.php';
// conection db
$conn=require 'connect.php';
$defaultAction='add';
$defaultModCre=false; // display or not created/modified date
$defaultBtnMoreLess='More';
$firstName='';
$lastName='';
$email='';
$flagAction=$defaultAction;
$id='';
$modcre=$defaultModCre;
$btnMoreLess=$defaultBtnMoreLess;
$validEntry=true;
$beforeModifiedEmail='';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $db_site_title." v".$site_version ?></title>
<!-- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> -->
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/gmo.css">
</head>
<body>
<h2><?php echo $db_site_title ?></h2>
<?php echo $site_copyright; echo "<hr>"; ?>
<script>
function validate(msg)
{
conf = confirm("Are you sure you want to delete " + msg + " ?");
if (conf)
return true;
else
return false;
}
</script>
<br>
<h5>Add/Modify </h5>
<?php
function emailExistInDB($db, $table, $emailToVerif, $emailBeforeMod)
{
if ($emailToVerif != $emailBeforeMod) {
//echo "I connect to DB to verify<br>";
try{
/* Create a prepared statement */
$stmt = $db -> prepare("SELECT email FROM ". $table .";");
/* execute the query */
$stmt -> execute();
/* fetch all results */
$res = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($res as $row){
extract($row);
//echo $email."<br>";
if ($emailToVerif == $email) {
echo $email." found in DB<br>";
$returnCode=true;
break;
}
else {
//echo $email." pas trouvé<br>";
$returnCode=false;
}
}
}
catch (PDOExecption $e){
echo $e->getMessage();
}
}
else {
$returnCode=false;
}
/*echo "Exit from DnsNameExistInDB function<br>";*/
return $returnCode; /* false $emailToVerif doesn't exist - true $emailToVerif exist */
}
// ADD/MODIFY RECORD
if (isset($_POST['send'])) {
/* set var from form */
$firstName = isset($_POST['firstName']) ? trim($_POST['firstName']) : "";
//$beforeModifieFirst = isset($_POST['firstNameBeforeModified']) ? trim($_POST['firstNameBeforeModified']) : "";
$lastName = isset($_POST['lastName']) ? trim($_POST['lastName']) : "";
//$beforeModifiedLastName = isset($_POST['lastNameBeforeModified']) ? trim($_POST['lastNameBeforeModified']) : "";
$email = isset($_POST['email']) ? trim($_POST['email']) : "";
$beforeModifiedEmail = isset($_POST['emailBeforeModified']) ? trim($_POST['emailBeforeModified']) : "";
$flagAction = isset($_POST['flagAction']) ? $_POST['flagAction'] : "";
$id = isset($_POST['id']) ? $_POST['id'] : "";
/* define the format of the DNS name and ip address */
$validEmail="/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/";
/* verify correct dnsname and ip address */
//echo "Verify email<br>";
if ($firstName == '' || $lastName == '' || !(preg_match($validEmail, $email)) || emailExistInDB($conn, $table, $email, $beforeModifiedEmail)) {
print"<div class='error'>One (or more) mandatory field(s) has (have) not been correctly filled in.<br>";
$validEntry=false;
if ($firstName == ''){
print "Mandatory 'Firstname' field.";
$validEntry=false;
}
elseif ($lastName == ''){
print "Mandatory 'Lastname' field.";
$validEntry=false;
}
elseif ($email == ''){
print "Mandatory 'EMail' field.";
$validEntry=false;
}
elseif (! preg_match($validEmail, $email)){
print "'".$email."' format invalid. ";
$validEntry=false;
}
if (emailExistInDB($conn, $table, $email, $beforeModifiedEmail)){
print "'".$email."' already exist. ";
$validEntry=false;
}
print"</div>";
}
/* All is ok we try to add record into DB */
if ($validEntry){
/*echo "Add/Update record into DB<br>"; */
if ($flagAction=="add"){
$stmt = $conn -> prepare("INSERT INTO $table (firstname, lastname, email) VALUES (:firstName, :lastName, :email)");
$stmt -> bindParam(':firstName', $firstName, PDO::PARAM_STR);
$stmt -> bindParam(':lastName', $lastName, PDO::PARAM_STR);
$stmt -> bindParam(':email', $email, PDO::PARAM_STR);
}
if ($flagAction=="modify"){
//$timestamp = date("Y-m-d h:i:s");
$stmt = $conn->prepare("UPDATE $table SET firstname = :firstName, lastname = :lastName, email = :email WHERE id =:id");
$stmt -> bindParam(':id', $id, PDO::PARAM_INT);
$stmt -> bindParam(':lastName', $lastName, PDO::PARAM_STR);
$stmt -> bindParam(':firstName', $firstName, PDO::PARAM_STR);
$stmt -> bindParam(':email', $email, PDO::PARAM_STR);
}
try{
/* execute the query */
$stmt -> execute();
}
catch (PDOExecption $e){
//echo $e->getMessage();
//print "<div class='error'>". $stmt -> errorInfo()[2]. " - ".$email."</div>";
print "<div class='error'> - ".$email."</div>";
}
}
$firstName='';
$lastName='';
$email='';
$flagAction=$defaultAction;
$id='';
}
// DELETE IP
if (isset($_POST['delete'])) {
$id = isset($_POST['id']) ? $_POST['id'] : "";
try {
$sql = "DELETE FROM $table WHERE id = :id";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
$stmt->execute();
/* close connection */
$db = null;
}
catch (PDOExecption $e){
echo $e->getMessage();
}
}
// MODIFIER
if (isset($_POST['modify'])) {
$firstName = isset($_POST['firstName']) ? $_POST['firstName'] : "";
//$beforeModifyfirstName = isset($_POST['firstName']) ? $_POST['firstName'] : "";
$lastName = isset($_POST['lastName']) ? $_POST['lastName'] : "";
//$beforeModifylastName = isset($_POST['lastName']) ? $_POST['lastName'] : "";
$email = isset($_POST['email']) ? $_POST['email'] : "";
$beforeModifiedEmail = isset($_POST['email']) ? $_POST['email'] : "";
// $description = isset($_POST['description']) ? $_POST['description'] : "";
$flagAction = isset($_POST['flagAction']) ? $_POST['flagAction'] : "";
$id = isset($_POST['id']) ? $_POST['id'] : "";
}
//DISPLAY MORE
if (isset($_POST['displaymore'])) {
$modcre = isset($_POST['modcre']) ? $_POST['modcre'] : "";
if ($modcre){
$modcre=false;
$btnMoreLess='More';
}
elseif (! $modcre){
$modcre=true;
$btnMoreLess='Less';
}
}
?>
<!-- Formulaire pour la saisie et la modifcation -->
<form method="post" action="<?php echo($_SERVER['PHP_SELF']); ?>">
<table border=0>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>EMail</th>
</tr>
<tr>
<?php
print '<td><input type="text" name="firstName" maxlength="30" value="'.$firstName.'" /></td>'.
'<td><input type="text" name="lastName" maxlength="30" value="'.$lastName.'" /></td>'.
'<td><input type="text" name="email" maxlength="100" value="'.$email.'" /></td>'.
'<td><input type="hidden" name="firstNameBeforeModified" maxlength="15" value="'.$firstName.'" /></td>'.
'<td><input type="hidden" name="lastNameBeforeModified" maxlength="100" value="'.$lastName.'" /></td>'.
'<td><input type="hidden" name="emailBeforeModified" maxlength="100" value="'.$email.'" /></td>'.
'<td><input type="hidden" name="flagAction" value="'.$flagAction.'" /></td>'.
'<td><input type="hidden" name="id" value="'.$id.'" /></td>'.
'<td><input type="hidden" name="modcre" value="'.$modcre.'"></td></tr><tr>';
//'<td><input type="submit" name="send" value="Ok" />&nbsp;<input type="submit" name="nextip" value="Next free IP">&nbsp;'.
//'<input type="reset" value="Cancel" />&nbsp;<input type="submit" value="Update DNS"</td>';
?>
</tr>
</table>
<table>
<tr>
<td><input type="submit" name="send" value="Ok" />
<input type="reset" value="Cancel" />&nbsp;<input type="submit" name="displaymore" value="<?php echo $btnMoreLess ?>" >
</td>
</tr>
</table>
</form>
<p></p>
<!-- Affiche la liste des adresses -->
<h5>EMails list</h5>
<?php
try{
//include('connexion.php');
//$db = new PDO('sqlite:'.$dbName);
/* Create a prepared statement - sort by ip address - whoau find on https://stackoverflow.com/questions/23092783/best-way-to-sort-by-ip-addresses-in-sql */
$stmt = $conn -> prepare("SELECT * FROM $table ORDER BY firstname");
//$stmt = $conn -> prepare("SELECT * FROM $table where firstname like 'T%'");
/* execute the query */
$stmt -> execute();
/* fetch all results */
$res = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo "<table border=1>".
"<tr>".
"<th>ID</th>".
"<th>Firstname</th>".
"<th>Lastname</th>".
"<th>EMail</th>";
if ($modcre){
echo "<th>Created</th>".
"<th>Modified</th>";
}
echo "<th>Actions</th>".
"</tr>";
foreach($res as $row){
extract($row);
echo "<tr>".
"<td>".$id."</td>".
"<td>".$firstname."</td>".
"<td>".$lastname."</td>".
"<td>".$email."</td>";
if ($modcre){
echo "<td>".$reg_date."</td>".
"<td>".$mod_date."</td>";
}
echo "<td>";
?>
<form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post">
<?php
echo "<input type='hidden' name='firstName' value='".$firstname."'>".
"<input type='hidden' name='lastName' value='".$lastname."'>".
"<input type='hidden' name='email' value='".$email."'>".
"<input type='hidden' name='flagAction' value='modify'>".
"<input type='hidden' name='id' value='".$id."'>".
"<button type='submit' name='modify' title='Modify'><img src='images/pen.svg' alt='pen' /></button>&nbsp;".
"<button onclick='return validate(\"".$firstname." ".$lastname." (".$email.")\");' type='submit' name='delete' title='Delete'><img src='images/trash.svg' alt='trash' /></button>".
"</td></form></tr>";
}
echo "</table>";
/* close connection */
//$db = null;
}
catch (PDOExecption $e){
echo $e->getMessage();
}
?>
</body>
</html>

3
src/phpinfo.php Normal file
View File

@ -0,0 +1,3 @@
<?php
phpinfo();
?>

42
src/readcsv.php Normal file
View File

@ -0,0 +1,42 @@
<?php
$CSVvar = fopen("sampleData.csv", "r");
if ($CSVvar !== FALSE) {
?>
<html>
<head>
<style>
table,th,td {
border: 1px solid black;
}
</style>
</head>
<div>
<table style="border:1px solid black">
<thead>
<tr>
<th><b>Prénom</b></th>
<th><b>Nom</b></th>
<th><b>Courriel</b></th>
</tr>
</thead>
<?php
while (! feof($CSVvar)) {
$data = fgetcsv($CSVvar, 1000, ";");
if (! empty($data)) {
?>
<tr>
<td><?php echo $data[0]; ?></td>
<td><div> <?php echo $data[1]?></td>
<td><div><?php echo $data[2]; ?></div></td>
</tr>
<?php }?>
<?php
}
?>
</table>
</div>
</html>
<?php
}
fclose($CSVvar);
?>

98
src/sampleData.csv Normal file
View File

@ -0,0 +1,98 @@
Alex;Kuze;alex@alexkuze.ch;
Ali;Gator;ali@aligator.ch;
Alphonse;Danltas;alphonse@alphonsedanltas.ch;
Amédée;Pan;amedee@amedeepan.ch;
Amélie;Oration;amelie@amelieoration.ch;
André;Sanfraper;andre@andresanfraper.ch;
Anne;Orak;anne@anneorak.ch;
Annick;Roche;annick@annickroche.ch;
Annie;Versaire;annie@annieversaire.ch;
Aretha;Connery;aretha@arethaconnery.ch;
Arman;Dibule;arman@armandibule.ch;
Arsene;Dunez;arsene@arsenedunez.ch;
Aubin;Didon;aubin@aubindidon.ch;
Aubin;Marie;aubin@aubinmarie.ch;
Aude;Vaisselle;aude@audevaisselle.ch;
Axel;Air;axel@axelair.ch;
Candy;Raton;candy@candyraton.ch;
Carie;Dentaire;carie@cariedentaire.ch;
Cathy;Mini;cathy@cathymini.ch;
Céline;Aivitable;celine@celineaivitable.ch;
Chantal;Opéra;chantal@chantalopera.ch;
Charles;Attan;charles@charlesattan.ch;
Chris;Lair;chris@chrislair.ch;
Christiane;Isme;christiane@christianeisme.ch;
Clair;Azil;clair@clairazil.ch;
Claire;Obscur;claire@claireobscur.ch;
Clément;Tine;clement@clementtine.ch;
Emile;Sabord;emile@emilesabord.ch;
Emma;Husse;emma@emmahusse.ch;
Emma;Taume;emma@emmataume.ch;
Emy;Sfere;emy@emysfere.ch;
Eva;Anchier;eva@evaanchier.ch;
Eve;Angile;eve@eveangile.ch;
Eve;Euriendire;eve@eveeuriendire.ch;
Frank;Eaudeport;frank@frankeaudeport.ch;
Fred;Ujour;fred@fredujour.ch;
Gilles;Mouchet;gilles@gillesmouchet.ch;
Harry;Vancouran;harry@harryvancouran.ch;
Hél√®ne;Aze;hel√®ne@hel√®neaze.ch;
Henri;Encore;henri@henriencore.ch;
Hercule;Letrax;hercule@herculeletrax.ch;
Hillary;Jaune;hillary@hillaryjaune.ch;
Homere;Dalor;homere@homeredalor.ch;
Kim;Hainerve;kim@kimhainerve.ch;
Kurt;Hermal;kurt@kurthermal.ch;
Kurt;Paille;kurt@kurtpaille.ch;
Larry;Golade;larry@larrygolade.ch;
Laurent;Barre;laurent@laurentbarre.ch;
Lee;Steric;lee@leesteric.ch;
Léo;Parre;leo@leoparre.ch;
Lewis;Air;lewis@lewisair.ch;
Line;Uzable;line@lineuzable.ch;
Lori;Ginal;lori@loriginal.ch;
Louis;Dire;louis@louisdire.ch;
Luc;Arne;luc@lucarne.ch;
Luc;Assion;luc@lucassion.ch;
Luc;Ratif;luc@lucratif.ch;
Luce;Tancil;luce@lucetancil.ch;
Lydie;Oduvillage;lydie@lydieoduvillage.ch;
Marc;Delamain;marc@marcdelamain.ch;
Maya;Partir;maya@mayapartir.ch;
Mel;Odrame;mel@melodrame.ch;
Mona;Ster;mona@monaster.ch;
Nathan;Riendemoi;nathan@nathanriendemoi.ch;
Nick;Otine;nick@nickotine.ch;
Nicole;Nicravatte;nicole@nicolenicravatte.ch;
Nicole;Pasledoit;nicole@nicolepasledoit.ch;
Ondine;Oucesoir;ondine@ondineoucesoir.ch;
Patrice;Tounet;patrice@patricetounet.ch;
Patty;Bulair;patty@pattybulair.ch;
Pierre;Afeu;pierre@pierreafeu.ch;
Pierre;Ponce;pierre@pierreponce.ch;
Rick;Hochet;rick@rickhochet.ch;
Ruddy;Mantère;ruddy@ruddymantère.ch;
Sacha;Touille;sacha@sachatouille.ch;
Sam;Agasse;sam@samagasse.ch;
Sarah;Trap;sarah@sarahtrap.ch;
Serge;Ouin;serge@sergeouin.ch;
Simon;Tagnar;simon@simontagnar.ch;
Sophie;Stiquet;sophie@sophiestiquet.ch;
Ted;Laparti;ted@tedlaparti.ch;
Teddy;Fissile;teddy@teddyfissile.ch;
Terry;Goureux;terry@terrygoureux.ch;
Tex;Ajerre;tex@texajerre.ch;
Théo;Coint;theo@theocoint.ch;
Théo;Courant;theo@theocourant.ch;
Thibaut;Monfils;thibaut@thibautmonfils.ch;
Thomas;Tefarci;thomas@thomastefarci.ch;
Thor;Nade;thor@thornade.ch;
Tony;Truand;tony@tonytruand.ch;
Vincent;Pourcent;vincent@vincentpourcent.ch;
Vincent;Time;vincent@vincenttime.ch;
Yann;Akpourlui;yann@yannakpourlui.ch;
Yshi;Potte;yshi@yshipotte.ch;
Yvan;Descloux;yvan@yvandescloux.ch;
Yves;Rogne;yves@yvesrogne.ch;
Yves;Vaurien;yves@yvesvaurien.ch;
Yvon;Pasbien;yvon@yvonpasbien.ch;
1 Alex Kuze alex@alexkuze.ch
2 Ali Gator ali@aligator.ch
3 Alphonse Danltas alphonse@alphonsedanltas.ch
4 Amédée Pan amedee@amedeepan.ch
5 Amélie Oration amelie@amelieoration.ch
6 André Sanfraper andre@andresanfraper.ch
7 Anne Orak anne@anneorak.ch
8 Annick Roche annick@annickroche.ch
9 Annie Versaire annie@annieversaire.ch
10 Aretha Connery aretha@arethaconnery.ch
11 Arman Dibule arman@armandibule.ch
12 Arsene Dunez arsene@arsenedunez.ch
13 Aubin Didon aubin@aubindidon.ch
14 Aubin Marie aubin@aubinmarie.ch
15 Aude Vaisselle aude@audevaisselle.ch
16 Axel Air axel@axelair.ch
17 Candy Raton candy@candyraton.ch
18 Carie Dentaire carie@cariedentaire.ch
19 Cathy Mini cathy@cathymini.ch
20 Céline Aivitable celine@celineaivitable.ch
21 Chantal Opéra chantal@chantalopera.ch
22 Charles Attan charles@charlesattan.ch
23 Chris Lair chris@chrislair.ch
24 Christiane Isme christiane@christianeisme.ch
25 Clair Azil clair@clairazil.ch
26 Claire Obscur claire@claireobscur.ch
27 Clément Tine clement@clementtine.ch
28 Emile Sabord emile@emilesabord.ch
29 Emma Husse emma@emmahusse.ch
30 Emma Taume emma@emmataume.ch
31 Emy Sfere emy@emysfere.ch
32 Eva Anchier eva@evaanchier.ch
33 Eve Angile eve@eveangile.ch
34 Eve Euriendire eve@eveeuriendire.ch
35 Frank Eaudeport frank@frankeaudeport.ch
36 Fred Ujour fred@fredujour.ch
37 Gilles Mouchet gilles@gillesmouchet.ch
38 Harry Vancouran harry@harryvancouran.ch
39 Hél√®ne Aze hel√®ne@hel√®neaze.ch
40 Henri Encore henri@henriencore.ch
41 Hercule Letrax hercule@herculeletrax.ch
42 Hillary Jaune hillary@hillaryjaune.ch
43 Homere Dalor homere@homeredalor.ch
44 Kim Hainerve kim@kimhainerve.ch
45 Kurt Hermal kurt@kurthermal.ch
46 Kurt Paille kurt@kurtpaille.ch
47 Larry Golade larry@larrygolade.ch
48 Laurent Barre laurent@laurentbarre.ch
49 Lee Steric lee@leesteric.ch
50 Léo Parre leo@leoparre.ch
51 Lewis Air lewis@lewisair.ch
52 Line Uzable line@lineuzable.ch
53 Lori Ginal lori@loriginal.ch
54 Louis Dire louis@louisdire.ch
55 Luc Arne luc@lucarne.ch
56 Luc Assion luc@lucassion.ch
57 Luc Ratif luc@lucratif.ch
58 Luce Tancil luce@lucetancil.ch
59 Lydie Oduvillage lydie@lydieoduvillage.ch
60 Marc Delamain marc@marcdelamain.ch
61 Maya Partir maya@mayapartir.ch
62 Mel Odrame mel@melodrame.ch
63 Mona Ster mona@monaster.ch
64 Nathan Riendemoi nathan@nathanriendemoi.ch
65 Nick Otine nick@nickotine.ch
66 Nicole Nicravatte nicole@nicolenicravatte.ch
67 Nicole Pasledoit nicole@nicolepasledoit.ch
68 Ondine Oucesoir ondine@ondineoucesoir.ch
69 Patrice Tounet patrice@patricetounet.ch
70 Patty Bulair patty@pattybulair.ch
71 Pierre Afeu pierre@pierreafeu.ch
72 Pierre Ponce pierre@pierreponce.ch
73 Rick Hochet rick@rickhochet.ch
74 Ruddy Mantère ruddy@ruddymantère.ch
75 Sacha Touille sacha@sachatouille.ch
76 Sam Agasse sam@samagasse.ch
77 Sarah Trap sarah@sarahtrap.ch
78 Serge Ouin serge@sergeouin.ch
79 Simon Tagnar simon@simontagnar.ch
80 Sophie Stiquet sophie@sophiestiquet.ch
81 Ted Laparti ted@tedlaparti.ch
82 Teddy Fissile teddy@teddyfissile.ch
83 Terry Goureux terry@terrygoureux.ch
84 Tex Ajerre tex@texajerre.ch
85 Théo Coint theo@theocoint.ch
86 Théo Courant theo@theocourant.ch
87 Thibaut Monfils thibaut@thibautmonfils.ch
88 Thomas Tefarci thomas@thomastefarci.ch
89 Thor Nade thor@thornade.ch
90 Tony Truand tony@tonytruand.ch
91 Vincent Pourcent vincent@vincentpourcent.ch
92 Vincent Time vincent@vincenttime.ch
93 Yann Akpourlui yann@yannakpourlui.ch
94 Yshi Potte yshi@yshipotte.ch
95 Yvan Descloux yvan@yvandescloux.ch
96 Yves Rogne yves@yvesrogne.ch
97 Yves Vaurien yves@yvesvaurien.ch
98 Yvon Pasbien yvon@yvonpasbien.ch

View File

@ -0,0 +1,3 @@
Alex;Kuze;alex@alexkuze.ch;
Ali;Gator;ali@aligator.ch;
Alphonse;Danltas;alphonse@alphonsedanltas.ch;
1 Alex Kuze alex@alexkuze.ch
2 Ali Gator ali@aligator.ch
3 Alphonse Danltas alphonse@alphonsedanltas.ch

106
src/searchindex.php Normal file
View File

@ -0,0 +1,106 @@
<?php
require_once 'config.php';
// connect to es
$client = require 'connect-es.php';
$index_status = require 'checkindex.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $es_site_title." v".$site_version ?></title>
<!-- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> -->
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/gmo.css">
</head>
<body>
<h2><?php echo $es_site_title ?></h2>
<h6><?php echo $site_copyright ?></h6>
<br>
<?php
function displayInfoSearch($response){
echo "<p>";
printf("Total docs: %d\n", $response['hits']['total']['value']);
echo "<br>";
printf("Max score : %.4f\n", $response['hits']['max_score']);
echo "<br>";
printf("Took : %d ms\n", $response['took']);
echo "</p>";
}
function displayResult($response){
$hits=$response['hits']['total']['value'];
$result = null;
$i = 0;
while ($i < $hits) {
$result[$i] = $response['hits']['hits'][$i]['_source'];
$i++;
}
$row = 0;
foreach ($result as $key => $value) {
//while ($row < 15) {
echo $value['id'] . " : ";
echo $value['firstname'] . " : ";
echo $value['lastname'] . " : ";
echo $value['email'] . "<br>";
//}
//$row++;
}
echo "<br>";
}
//
if ($index_status == 200) {
// search one item
$params = [
'index' => $es_index,
'from' => 0, // <--- Start at #1
'size' => 10,
'body' => [
'query' => [
'match' => [
'firstname' => 'chantal'
]
]
]
];
$response = $client->search($params);
echo "<b>Result of the research 'match (chantal)'</b>";
displayInfoSearch($response);
displayResult($response);
// Search wildcard
$params = [
'index' => $es_index,
'body' => [
'query' => [
'wildcard' => ["firstname" => "yv*"]
]
]
];
$response = $client->search($params);
echo "<b>Result of the research 'wildcard (yv*)'</b>";
displayInfoSearch($response);
displayResult($response);
// Search all item
$params = [
'index' => $es_index,
'body' => '{
"from": 0,
"size": 100, //dispay 100 result (default is 10)
"query": {
"match_all": {}
}
}',
];
$response = $client->search($params);
echo "<b>Result of the research 'match_all'</b>";
displayInfoSearch($response);
displayResult($response);
}
else {
echo "Problem with index <b>".$es_index."</b> (".$index_status.")";
}
?>