From b7e2020cec585292385c5a68e0d84edd4388e5b8 Mon Sep 17 00:00:00 2001 From: Adam Jarvis Date: Wed, 10 Oct 2018 17:08:45 +0100 Subject: [PATCH 1/3] Updates readme for Linux file perms --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bdf6f22..32c1f49 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ Project Version - - + + Project License @@ -35,6 +35,10 @@ An exact mirror of this repo [can be viewed here](https://aar.ark-group.org) whi 2. Download the [latest web release](https://github.com/alexcroox/R3-Web/releases/latest) 3. Rename `config.template.php` to `config.php`, pay close attention to `DB_*`, `WEB_PATH` and timezone configurations 4. Upload the files to your web server which matches the URL in `WEB_PATH` in `config.php`. Take note of `/.htaccess` in the download that may be hidden on your system before you upload. +5. _(linux specifc)_ give the `cache` directory permissions for your web-server user account: +``` +chown www-data:www-data -R cache/ +``` ### Important information to get the most from R3 @@ -56,5 +60,5 @@ You can find me (Titan) on the [R3 Discord](https://discord.gg/qcE3dRP) or feel ### Why not x framework/language -In an ideal world I'd be using web sockets and node to stream from the game server straight to a flat json file, and to the browser. +In an ideal world I'd be using web sockets and node to stream from the game server straight to a flat json file, and to the browser. However the goal is to allow Arma 3 server admins to be able to run this and contribute. PHP + MySQL is the most common setup these administrators (with potentially limited sysadmin knowledge or sudo access) will have so it is the correct choice, as limiting as that can be! From 538d29d449074b067618f343e3a97c7ec7f1e653 Mon Sep 17 00:00:00 2001 From: Adam Jarvis Date: Wed, 10 Oct 2018 17:09:04 +0100 Subject: [PATCH 2/3] file_get_contents is bad for http Now use curl instead. Obvilusly better implimented as a utility function/class. Works for now though --- dist/inc/classes/Replays.php | 13 +++++++++++-- dist/playback.php | 7 ++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/dist/inc/classes/Replays.php b/dist/inc/classes/Replays.php index 15c4c18..6e0eff9 100644 --- a/dist/inc/classes/Replays.php +++ b/dist/inc/classes/Replays.php @@ -290,12 +290,21 @@ public function getPlayerMissions($replayData) { public function getIcons() { - return file_get_contents('https://r3icons.titanmods.xyz/config.json'); + return $this->my_curl('https://r3icons.titanmods.xyz/config.json'); } public function getObjectiveMarkers() { - return file_get_contents('https://r3icons.titanmods.xyz/markers.json'); + return $this->my_curl('https://r3icons.titanmods.xyz/markers.json'); + } + + function my_curl($url) { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); + $data = curl_exec($ch); + curl_close($ch); + return $data; } public function getHtmlReplaysForPlayer($playerId, $replayData = FALSE) { diff --git a/dist/playback.php b/dist/playback.php index acbd4dc..c71d50f 100644 --- a/dist/playback.php +++ b/dist/playback.php @@ -24,7 +24,12 @@ $metaImage = WEB_PATH . '/maps/' . strtolower($replayDetails->map) . '/tiles/0/0/0.png'; $page = 'playback'; -$mappingConfig = file_get_contents('https://r3tiles-a.titanmods.xyz/config.json'); +$url = 'https://r3tiles-a.titanmods.xyz/config.json'; +$ch = curl_init(); +curl_setopt($ch, CURLOPT_URL, $url); +curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); +$mappingConfig = curl_exec($ch); +curl_close($ch); $playerList = $replays->fetchReplayPlayers($_GET['replayId'], $replayDetails->playerList); From ccd63c0db92ce451d08c70d621c1a52464853975 Mon Sep 17 00:00:00 2001 From: Adam Jarvis Date: Wed, 10 Oct 2018 17:50:04 +0100 Subject: [PATCH 3/3] Toying with the idea of docker --- docker-compose.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..6d5acbc --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,40 @@ +version: '2' + +services: + db: + image: mariadb:10.1.26 + container_name: r3_db + restart: always + environment: + MYSQL_USER: r3 + MYSQL_PASSWORD: password + MYSQL_ROOT_PASSWORD: password + MYSQL_DATABASE: r3 + volumes: + - r3_db_data:/var/lib/mysql + ports: + - "3306:3306" + + web: + depends_on: + - db + build: + context: . + dockerfile: web.docker + image: local/r3_web + container_name: r3_web + restart: always + environment: + VIRTUAL_HOST: r3.local + DB_HOST: r3_db + DB_USER: r3 + DB_PASSWORD: password + DB_NAME: r3 + ports: + - "8080:80" + volumes: + - ./dist:/var/www/html/ + +volumes: + r3_db_data: + dist: