X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=9f50d15323d2ea40207e14d08d030cfcdbb20025;hb=adcdac1dec45090e2fa1cd4a340e91a40c7a205f;hp=1f148d781e225cd402fa6454aeceb849bf4febf4;hpb=a973afeac7b7399d35b881920f0afc1947765ccd;p=github%2Fshaarli%2FShaarli.git diff --git a/index.php b/index.php index 1f148d78..9f50d153 100644 --- a/index.php +++ b/index.php @@ -1,6 +1,6 @@ /shaarli/ define('WEB_PATH', substr($_SERVER['REQUEST_URI'], 0, 1+strrpos($_SERVER['REQUEST_URI'], '/', 0))); @@ -45,6 +45,16 @@ error_reporting(E_ALL^E_WARNING); // 3rd-party libraries +if (! file_exists(__DIR__ . '/vendor/autoload.php')) { + header('Content-Type: text/plain; charset=utf-8'); + echo "Error: missing Composer configuration\n\n" + ."If you installed Shaarli through Git or using the development branch,\n" + ."please refer to the installation documentation to install PHP" + ." dependencies using Composer:\n" + ."- https://github.com/shaarli/Shaarli/wiki/Server-requirements\n" + ."- https://github.com/shaarli/Shaarli/wiki/Download-and-Installation"; + exit; +} require_once 'inc/rain.tpl.class.php'; require_once __DIR__ . '/vendor/autoload.php'; @@ -322,8 +332,17 @@ include $conf->get('resource.ban_file', 'data/ipbans.php'); function ban_loginFailed($conf) { $ip = $_SERVER['REMOTE_ADDR']; + $trusted = $conf->get('security.trusted_proxies', array()); + if (in_array($ip, $trusted)) { + $ip = getIpAddressFromProxy($_SERVER, $trusted); + if (!$ip) { + return; + } + } $gb = $GLOBALS['IPBANS']; - if (!isset($gb['FAILURES'][$ip])) $gb['FAILURES'][$ip]=0; + if (! isset($gb['FAILURES'][$ip])) { + $gb['FAILURES'][$ip]=0; + } $gb['FAILURES'][$ip]++; if ($gb['FAILURES'][$ip] > ($conf->get('security.ban_after') - 1)) {