Keep 2 folders synchronized

Code to copy all changes from one folder to another. I use it to copy changes from my local folder to development server mounted by SSHFS.

In example files are filtered. Only *.cpp and *.h files are copied.

while inotifywait -e modify,create,delete "/home/jskalski/p/prv/otserv/"; do
    rsync -zvur --include="*.cpp" --include="*.h" --exclude="*" "/home/jskalski/p/prv/otserv/" "/mnt/devserver/home/js/otserv/"
done

Limit number of connections per IP

Limit number of incoming concurrent connections per IP to 1.

On all ports and IPs of server:

iptables -t filter -I INPUT -p tcp -j ACCEPT
iptables -t filter -I INPUT -p tcp -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -t filter -I INPUT -p tcp --syn -m connlimit --connlimit-above 1 --connlimit-mask 32 -j DROP

On port 80 of server:

iptables -t filter -I INPUT -p tcp --dport 80 -j ACCEPT
iptables -t filter -I INPUT -p tcp --dport 80 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -t filter -I INPUT -p tcp --syn --dport 80 -m connlimit --connlimit-above 1 --connlimit-mask 32 -j DROP

On port 80 and IP 91.134.189.246 of server (in case when server has more IPs):

iptables -t filter -I INPUT -p tcp -d 91.134.189.246 --dport 80 -j ACCEPT
iptables -t filter -I INPUT -p tcp -d 91.134.189.246 --dport 80 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -t filter -I INPUT -p tcp --syn -d 91.134.189.246 --dport 80 -m connlimit --connlimit-above 1 --connlimit-mask 32 -j DROP

Find newest files in directory (recursively)

List files from oldest to newest, recursively.

find . -type f -print0 | xargs -0 stat --format '%Y :%y %n' | sort -n |  awk '{print strftime("%Y-%m-%d %H:%M:%S", $1), $5}' | tail --lines=50

Result:

(...)
2019-04-19 12:21:31 ./klientotc/modules/gamelib/ui/uiminimap.lua
2019-04-19 15:04:22 ./klientotc/modules/game_hotkeys/hotkeys_manager.otui
2019-04-19 15:11:36 ./klientotc/modules/game_hotkeys/hotkeys_manager.lua
2019-04-19 16:18:34 ./klientotc/.git/index
2019-04-19 16:18:34 ./klientotc/modules/corelib/ui/uiminiwindowcontainer.lua
2019-04-19 16:33:01 ./klientotc/modules/corelib/ui/uiminiwindow.lua
2019-04-19 17:15:50 ./klientotc.zip
2019-04-23 07:35:34 ./klientotc/Kasteria.log
2019-04-25 07:25:25 ./klientotc/.idea/workspace.xml
2019-04-26 10:26:27 ./source/.idea/workspace.xml

TEST

TEST

<?php
  error_reporting(E_ALL ^ E_NOTICE);
  session_start();

  header("Content-Type: text/html; charset=utf-8");
  require_once('panel/config/config.inc.php');
  require_once('panel/config/func.inc.php');

    if (FORCE_DOMAIN && $_SERVER['HTTP_HOST'] != FORCE_DOMAIN) {
        $protocol = (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on') ? 'http' : 'https';
        header("HTTP/1.1 301 Moved Permanently");
        header("Location: " . $protocol . "://" . FORCE_DOMAIN . "/" . $_SERVER['REQUEST_URI']);
        header("Connection: close");
        exit();
    }

    if (FORCE_HTTPS && (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) {
        $currentDomain = $_SERVER['HTTP_HOST'];
        header("HTTP/1.1 301 Moved Permanently");
        header("Location: https://" . $currentDomain . "/" . $_SERVER['REQUEST_URI']);
        header("Connection: close");
        exit();
    }