X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/ecf7d911c95935f8cfb2403f645cd12f93d8c3f5..b3ed433e388b83e055958b395ebc0e08172cd079:/WEB-INF/lib/common.lib.php diff --git a/WEB-INF/lib/common.lib.php b/WEB-INF/lib/common.lib.php index 3dce388f..210ec41c 100644 --- a/WEB-INF/lib/common.lib.php +++ b/WEB-INF/lib/common.lib.php @@ -339,8 +339,24 @@ function ttAccessAllowed($required_right) exit(); } + // Check IP restriction, if set. + if ($user->allow_ip && !$user->can('override_allow_ip')) { + $access_allowed = false; + $user_ip = $_SERVER['REMOTE_ADDR']; + $allowed_ip_array = explode(',', $user->allow_ip); + foreach ($allowed_ip_array as $allowed_ip) { + $len = strlen($allowed_ip); + if (substr($user_ip, 0, $len) === $allowed_ip) { + $access_allowed = true; + break; + } + } + if (!$access_allowed) return false; + } + // Check if user has the right. if (in_array($required_right, $user->rights)) { + import('ttUserHelper'); ttUserHelper::updateLastAccess(); return true; }