Skip to content

Commit

Permalink
zorg Code v4.6.0
Browse files Browse the repository at this point in the history
Merge pull request #69 👀 from zorgch/develop
  • Loading branch information
oliveratgithub committed Jun 6, 2023
2 parents f10957c + 2a37d45 commit 63e19b4
Show file tree
Hide file tree
Showing 75 changed files with 1,930 additions and 1,782 deletions.
200 changes: 200 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
# PHP dotENV - https://github.com/vlucas/phpdotenv
# Copy this file as new /.env & adjust all settings to the corresponging Environment!
ENVIRONMENT="development" # Use "development" for any non-productive envs

# Database connection (required):
MYSQL_HOST="localhost" # Required! Use "localhost" or Docker service hostname
MYSQL_DATABASE="" # Required!
MYSQL_USER="" # Required!
MYSQL_PASSWORD=""
MYSQL_CHARSET="utf8mb4"

# Directory paths (required):
APP_ROOT="/var/www" # Absolute path to App root, no trailing /-slash
WWW_ROOT="${APP_ROOT}/html" # No trailing /-slash
INCLUDES_DIR="${WWW_ROOT}/includes/"
ERRORLOG_DIR="${APP_ROOT}/data/errlog/"
UPLOAD_DIR="${APP_ROOT}/data/upload/"
MODELS_DIR="${WWW_ROOT}/models/"
VIEWS_DIR="${WWW_ROOT}/templates/"
CONTROLLERS_DIR="${WWW_ROOT}/controller/"
FILES_DIR="${APP_ROOT}/data/files/"
GALLERY_DIR="${APP_ROOT}/data/gallery/"
GALLERY_UPLOAD_DIR="${UPLOAD_DIR}new-galleries/"
IMAGES_DIR="${WWW_ROOT}/images/"
APOD_TEMP_IMAGE_DIR="${APP_ROOT}/data/temp/"
GO_IMAGES_DIR="${IMAGES_DIR}go/"
HZ_MAPS_DIR="${APP_ROOT}/data/hz_maps"
HZ_MAPS_IMAGES_DIR="${IMAGES_DIR}hz/"
QRCODEIMAGES_DIR="${IMAGES_DIR}swissqrbill"
TAUSCHARTIKEL_IMGAGES_DIR="${APP_ROOT}/data/tauschboerse/"
USERIMAGES_DIR="${APP_ROOT}/data/userimages/"
USERIMAGES_ARCHIVE_DIR="${USERIMAGES_DIR}archiv/"

# Application settings:
HOSTNAME=""
HTTP_PROTOCOL="https" # https or http
SITE_FQDN="${HTTP_PROTOCOL}://${HOSTNAME}" # No trailing slash
PAGETITLE_SUFFIX=" - ${HOSTNAME}"
LOCALE="de_CH"
TIMEZONE="Europe/Zurich"
ENCODING="UTF-8"
EMAILS_FROM="info@${HOSTNAME}"
ADMIN_EMAIL="root@${HOSTNAME}"
ERROR_REPORTING_LEVELS="E_ALL & ~E_DEPRECATED & ~E_STRICT" # Use E_ALL for development
ERRORLOG_FILETYPE=".log" # Extension with .-prefix
GIT_REPOSITORY_ROOT="${APP_ROOT}/"
GIT_REPOSITORY_USER="GITUSER"
GIT_REPOSITORY_REPO="REPONAME"
GIT_REPOSITORY_URL="https://github.com/${GIT_REPOSITORY_USER}/${GIT_REPOSITORY_REPO}/commit/"
TELEGRAM_CHATLINK="" # Full URL to a Telegram-Chat
TELEGRAM_PARSE_MODE="html"
TELEGRAM_DISABLE_WEBPAGE_PREVIEW="false"
TELEGRAM_DISABLE_NOTIFICATION="false"
TWITTER_NAME="" # Without prefixed @-char
FACEBOOK_APPID=""
FACEBOOK_PAGENAME=""
URLPATH_ACTIONS="/actions/"
URLPATH_AJAX="${URLPATH_JS}ajax/"
URLPATH_CSS="/css/"
URLPATH_HZ_IMAGES="${URLPATH_IMAGES}hz/"
URLPATH_IMAGES="/images/"
URLPATH_JS="/js/"
URLPATH_RSS="${SITE_FQDN}/?layout=rss"
URLPATH_SCRIPTS="/scripts/"
URLPATH_USERIMAGES="/data/userimages/"
URLPATH_UTILS="/util/"
USERLEVEL_ALLE="0"
USERLEVEL_USER="1"
USERLEVEL_MEMBER="2"
USERLEVEL_ADMIN="3"
USER_TIMEOUT="200" # In seconds: 3 Minutes
USER_OLD_AFTER="94608000" # In seconds: 3 Jahre
USER_USE_CURRENT_LOGIN="TRUE"
USER_USE_REGISTRATION_CODE="TRUE"
USER_USE_ONLINE_LIST="TRUE"
USERIMAGE_ENABLED="TRUE"
USERIMAGE_EXTENSION=".jpg" # Extension with .-prefix
USERIMAGE_SIZE_LARGE="500"
USERIMAGE_SIZE_SMALL="150"
USERIMAGE_DEFAULT="none${USERIMAGE_EXTENSION}" # Must be within USERIMAGES_DIR
ADDLE_MAX_GAMES="1"
ADDLE_BASE_POINTS="1600"
ADDLE_MAX_POINTS_TRANSFERABLE="32"
APOD_GALLERY_ID="41" # Match to gallery_albums-Table `id`
BUGTRACKER_FILTER_DEFAULT="?show[]=open&show[]=notdenied&show[]=assigned&show[]=unassigned"
CHESS_DWZ_BASE_POINTS="1600"
CHESS_DWZ_MAX_POINTS_TRANSFERABLE="32"
FORUM_DEFAULT_MAXDEPTH="10"
FORUM_THREAD_CLEARCACHE_AFTER="30" # In Tagen
GALLERY_MAX_PIC_SIZE="['width'=>800, 'height'=>800]"
GALLERY_MAX_THUMBNAIL_SIZE="['width'=>150, 'height'=>150]"
GALLERY_THUMBPAGE="['width'=>4, 'height'=>3, 'padding'=>10]"
GO_OFFSET_PIC="250"
GO_LINKRADIUS="15"
GO_FIELDSIZE="40"
GO_LINEWIDTH="2"
GO_STARDOTWIDTH="10"
GO_STONEBIGWIDTH="190"
GO_LASTSTONEWIDTH="10"
HZ_MAPS_EXTENSION=".gif"
HZ_MAX_GAMES="5"
HZ_TURN_TIME="259200" # In Sekunden: 3 Tage
HZ_TURN_COUNT="4"
HZ_TURN_ADD_MONEY="10"
SETI_TEAM_NAME=""
SETI_EMAIL=""
STRING_NOT_FOUND="Reference not found in String list"

# Session settings:
SESSION_ID="z"
SESSION_LIFETIME="43200" # In seconds
ENABLE_COOKIES="TRUE"
COOKIE_DOMAIN=".${HOSTNAME}" # Prefixed .-dot is recommended
COOKIE_EXPIRATION="604800" # In seconds. Note: seconds to be added to current time()+COOKIE_EXPIRATION!
COOKIE_PATH="/"
COOKIE_SAMESITE="Lax" # Strict, None, or Lax (default/fallback)
COOKIE_HTTPONLY="true" # true or false (true is strongly recommended)
COOKIE_SECURE="" # Use true=https, false=http (corresponding to HTTP_PROTOCOL)
COOKIE_SESSION="${SESSION_ID}"
COOKIE_USERID="autologin_id"
COOKIE_USERPW="autologin_pw"

# Smarty Templates settings:
SMARTY_CACHE="${APP_ROOT}/data/smartylib/cache/"
SMARTY_COMPILE="${APP_ROOT}/data/smartylib/templates_c/"
SMARTY_DIR="${WWW_ROOT}/smartylib/"
SMARTY_TRUSTED_DIRS="${WWW_ROOT}/scripts/" # (array) with strings
SMARTY_TEMPLATES_HTML="${VIEWS_DIR}" # (array) with strings
SMARTY_PACKAGES_DIR="${WWW_ROOT}/packages/"
SMARTY_PACKAGES_EXTENSION=".php"
SMARTY_DEFAULT_TPL_ID="23"
SMARTY_404PAGE_TPL_FILE="file:layout/pages/404_page.tpl"

# Services, APIs, and API-Keys:
# - Facebook GraphAPI
FACEBOOK_API_KEY=""
# - Google APIs
GOOGLE_RECAPTCHA_LOCALE="de-CH" # reCAPTCHA supported languages: https://developers.google.com/recaptcha/docs/language
GOOGLE_RECAPTCHA_KEY=""
GOOGLE_RECAPTCHA_SECRET=""
GOOGLE_MAPS_API_KEY=""
GOOGLE_MAP_API="https://maps.googleapis.com/maps/api/geocode/json?key=${GOOGLE_MAPS_API_KEY}"
# - ipinfo.io API
IPINFO_API_KEY="" # API can be queried without Token (but has lower rate limit)
# - NASA APIs
SPACEWEATHER_SOURCE="https://www.spaceweather.com/"
NASA_API_KEY="DEMO_KEY" # API can be queried with the DEMO_KEY, but has rate limits
NASA_APOD_API="https://api.nasa.gov/planetary/apod?api_key=${NASA_API_KEY}"
NASA_APOD_SOURCE="https://apod.nasa.gov/apod/"
NASA_NEO_API="https://api.nasa.gov/neo/rest/v1/stats?api_key=${NASA_API_KEY}"
NASA_DONKI_API_CME="https://api.nasa.gov/DONKI/CME?startDate=yyyy-MM-dd&endDate=yyyy-MM-dd&api_key=${NASA_API_KEY}"
NASA_DONKI_API_CMEA="https://api.nasa.gov/DONKI/CMEAnalysis?startDate=2016-09-01&endDate=2016-09-30&mostAccurateOnly=true&speed=500&halfAngle=30&catalog=ALL&api_key=${NASA_API_KEY}"
NASA_DONKI_API_GST="https://api.nasa.gov/DONKI/GST?startDate=yyyy-MM-dd&endDate=yyyy-MM-dd&api_key=${NASA_API_KEY}"
NASA_DONKI_API_IPS="https://api.nasa.gov/DONKI/IPS?startDate=yyyy-MM-dd&endDate=yyyy-MM-dd&location=LOCATION&catalog=CATALOG&api_key=${NASA_API_KEY}"
NASA_DONKI_API_FLR="https://api.nasa.gov/DONKI/FLR?startDate=yyyy-MM-dd&endDate=yyyy-MM-dd&api_key=${NASA_API_KEY}"
NASA_DONKI_API_SEP="https://api.nasa.gov/DONKI/SEP?startDate=yyyy-MM-dd&endDate=yyyy-MM-dd&api_key=${NASA_API_KEY}"
NASA_DONKI_API_MPC="https://api.nasa.gov/DONKI/MPC?startDate=yyyy-MM-dd&endDate=yyyy-MM-dd&api_key=${NASA_API_KEY}"
NASA_DONKI_API_RBE="https://api.nasa.gov/DONKI/RBE?startDate=yyyy-MM-dd&endDate=yyyy-MM-dd&api_key=${NASA_API_KEY}"
NASA_DONKI_API_HSS="https://api.nasa.gov/DONKI/HSS?startDate=yyyy-MM-dd&endDate=yyyy-MM-dd&api_key=${NASA_API_KEY}"
NASA_DONKI_API_WSA="https://api.nasa.gov/DONKI/WSAEnlilSimulations?startDate=2016-01-06&endDate=2016-01-06&api_key=${NASA_API_KEY}"
NASA_DONKI_API_Notifications="https://api.nasa.gov/DONKI/notifications?startDate=2014-05-01&endDate=2014-05-08&type=all&api_key=${NASA_API_KEY}"
# - SETI
SETI_TEAM_URL="http://setiathome2.ssl.berkeley.edu/fcgi-bin/fcgi?cmd=team_lookup_xml&name=${SETI_TEAM_NAME}" # FIXME: no longer working
# - Telegram Bot API
TELEGRAM_BOT="" # as registered with @BotFather
TELEGRAM_BOT_API_KEY="" # as provided by @BotFather
TELEGRAM_BOT_API="https://api.telegram.org/bot${TELEGRAM_BOT_API_KEY}/"
TELEGRAM_BOT_API_AUTH_PASSWORD="" # (string) A secret password required to authorise access to the webhook
TELEGRAM_BOT_API_IPWHITELIST="[]" # (array) When using `validate_request`, like: [ '1.2.3.4', '1.1.1.1-2.2.2.2']
TELEGRAM_BOT_API_USERWHITELIST="[]" # (array) An array of Telegram UserIDs that have admin access to your bot (must be integers)
TELEGRAM_BOT_API_SSLCERT_PATH="" # (string) Path to a self-signed certificate (if necessary), like: "/server.crt"
TELEGRAM_BOT_API_CHAT="" # (integer) Chat-ID where the Telegram Bot will post to
TELEGRAM_BOT_API_FILES_DIR="" # (array) List of configurable paths.
TELEGRAM_BOT_API_LOG_DIR="${ERRORLOG_DIR}" # (array) Paths where the log files should be put.
# - Twitter API
TWITTER_API_KEY=""
TWITTER_API_SECRET=""
TWITTER_API_TOKEN=""
TWITTER_API_TOKENSECRET=""
TWITTER_API_CALLBACK_URL=""

# zorg settings:
VORSTAND_USER="451" # Match to user-Table `id`
BARBARA_HARRIS="59" # Match to user-Table `id`
ROSENVERKAEUFER="439" # Match to user-Table `id`
THE_ARCHITECT="582" # Match to user-Table `id`
ANFICKER_USER_ID="9999"
ZORG_VEREIN_NAME="zorg Verein"
ZORG_VEREIN_EMAIL=""
ZORG_VEREIN_STRASSE=""
ZORG_VEREIN_PLZ="9000"
ZORG_VEREIN_ORT="St. Gallen"
ZORG_VEREIN_LAND="Schweiz"
ZORG_VEREIN_LAND_ISO2="CH"
ZORG_VEREIN_KONTO_BANK="St. Galler Kantonalbank"
ZORG_VEREIN_KONTO_SWIFT="KBSGCH22"
ZORG_VEREIN_KONTO_IBAN="CH7500781622431172000"
ZORG_VEREIN_KONTO_IBAN_QRBILL="CH9730781622431172000"
ZORG_VEREIN_KONTO_CURRENCY="CHF"
ZORG_VEREIN_KONTO_BESRID=""
34 changes: 17 additions & 17 deletions Docker/.env.docker
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# === Docker ===
COMPOSE_PROJECT_NAME=zorg
OS_PLATFORM=linux/x86_64
HTTP_PORT=80
HTTPS_PORT=443
DOMAINNAME=zorg.local
APACHE_USER=www-data
APACHE_GROUP=www-data
APACHE_WEBROOT=/var/www
PHP_Version=7.4
PHP_INI_DIR=/usr/local/etc/php
MYSQL_VERSION=5.7
MYSQL_LOCAL_DATABASE_PATH=./Docker/mysql57
MYSQL_PORT=3306
MYSQL_DATABASE=zooomclan
MYSQL_USER=root
MYSQL_PASSWORD=
PHPMYADMIN_PORT=8080
COMPOSE_PROJECT_NAME="zorg"
OS_PLATFORM="linux/x86_64"
HTTP_PORT="80"
HTTPS_PORT="443"
DOMAINNAME="zorg.local"
APACHE_USER="www-data"
APACHE_GROUP="www-data"
APACHE_WEBROOT="/var/www"
PHP_Version="7.4"
PHP_INI_DIR="/usr/local/etc/php"
MYSQL_VERSION="5.7"
MYSQL_LOCAL_DATABASE_PATH="./Docker/mysql57"
MYSQL_PORT="3306"
MYSQL_DATABASE="zooomclan"
MYSQL_USER="root"
MYSQL_PASSWORD=""
PHPMYADMIN_PORT="8080"
64 changes: 40 additions & 24 deletions Docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
## Docker configs
Edit the file: `.env.docker`

## Using docker-sync
### Using docker-sync
`docker-sync` greatly improves the performance of synced volumes from the local file system to Docker, giving a nearly live-performance for read/write operations.

### On macOS
#### Setup on macOS
(The following steps are copied from [this online documentation](https://reece.tech/posts/osx-docker-performance/))

#### Install docker-sync
##### Install docker-sync

```
gem install --user-install docker-sync
Expand Down Expand Up @@ -51,38 +51,49 @@ docker-sync-stack start -c ./Docker/docker-sync.yml
docker compose --project-directory ./ --file ./Docker/docker-compose.yml --env-file ./Docker/.env.docker up
```

### Using a pre-existing local database

```
MYSQL_LOCAL_DATABASE_PATH=/path/to/my/mysql57 docker compose --project-directory ./ --file ./Docker/docker-compose.yml --env-file ./Docker/.env.docker up -d
```

#### Fix possible "Tablespace missing"-errors
To fix the MySQL-Error 1812 `Tablespace is missing for table zooomclan . <table-name>` try the following command per affected `<table-name>`:

```ALTER TABLE zooomclan.<table-name> IMPORT TABLESPACE```


Usage
## Usage
---
### Service configurations
#### MySQL connection config
Add the Docker's `zorg-db`-service IP-address to the file: `/www/.env`
The MySQL database host name is `zorg-db` and needs be added to the PHP environment config file `/www/.env`.

#### sendmail SMTP config
Edit the msmtprc config file in the `./Docker/sendmail/` directory and replace the following placeholders with real values:
* SMTP_HOST => mail.mymailserver.com
* SMTP_EMAIL => myemail@mymailserver.com
* SMTP_PASSWORD => password for your SMTP_EMAIL account

Further details on the sendmail / msmtprc integration can be found here: [Send email on testing docker container with php and sendmail](https://stackoverflow.com/a/63977888/5750030)

#### Show the website
### Show the website
[http://localhost/](http://localhost/)

…or with a hosts entry pointing to `127.0.0.1` and SSL: [https://zorg.local/]
…or with a hosts entry pointing to `127.0.0.1` and SSL: [https://zorg.local/](https://zorg.local/)

#### Use PHPMyAdmin to manage the database
### Use PHPMyAdmin to manage the database
[http://localhost:8080/](http://localhost:8080/)

…or with a hosts entry pointing to `127.0.0.1`: [http://zorg.local:8080/]
…or with a hosts entry pointing to `127.0.0.1`: [http://zorg.local:8080/](http://zorg.local:8080/)

* **Server**: use the Docker's `zorg-db`-service IP-address
* **Server**: use the Docker's `zorg-db`-service hostname or IP-address
* **Username**: use the defined `MYSQL_USER`-environment value
* **Password**: use the defined `MYSQL_PASSWORD`-environment value

#### Docker services inspection
#### Using a pre-existing local database
The best way is to import an SQL-dump using the phpmysql Docker service at [http://localhost:8080/](http://localhost:8080/).

Alternatively the path to a local database folder can be provided by overriding the ENV var `MYSQL_LOCAL_DATABASE_PATH`:
```
MYSQL_LOCAL_DATABASE_PATH=/path/to/my/mysql57 docker compose --project-directory ./ --file ./Docker/docker-compose.yml --env-file ./Docker/.env.docker up -d
```

#### Fix possible "Tablespace missing"-errors
To fix the MySQL-Error 1812 `Tablespace is missing for table zooomclan . <table-name>` try the following command per affected `<table-name>`:

```ALTER TABLE zooomclan.<table-name> IMPORT TABLESPACE```


## Docker services inspection
Find IP of a container service (can also be seen in the network details)

`docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' SERVICENAME`
Expand Down Expand Up @@ -111,11 +122,16 @@ Enter into interactive shell mode for a container service

`docker exec -it SERVICENAME sh`

#### docker-sync inspection
### docker-sync inspection
!! Refresh docker-sync after updating the `docker-compose.yml`-file

`docker-sync clean`

Inspect running docker-sync services:

`docker volume ls | grep -sync`

### sendmail Logfile
Inspect the logfile for sendmail / msmtprc:

`docker exec -it zorg-web cat /var/log/sendmail.log`
Loading

0 comments on commit 63e19b4

Please sign in to comment.