';
diff --git a/htdocs/dav/fileserver.php b/htdocs/dav/fileserver.php
index b056ac9730c..4a38511305e 100644
--- a/htdocs/dav/fileserver.php
+++ b/htdocs/dav/fileserver.php
@@ -55,6 +55,22 @@ if (empty($conf->dav->enabled))
accessforbidden();
+// Restrict API to some IPs
+if (! empty($conf->global->DAV_RESTICT_ON_IP))
+{
+ $allowedip=explode(' ', $conf->global->DAV_RESTICT_ON_IP);
+ $ipremote = getUserRemoteIP();
+ if (! in_array($ipremote, $allowedip))
+ {
+ dol_syslog('Remote ip is '.$ipremote.', not into list '.$conf->global->DAV_RESTICT_ON_IP);
+ print 'DAV not allowed from the IP '.$ipremote;
+ header('HTTP/1.1 503 DAV not allowed from your IP '.$ipremote);
+ //print $conf->global->DAV_RESTICT_ON_IP;
+ exit(0);
+ }
+}
+
+
$entity = (GETPOST('entity', 'int') ? GETPOST('entity', 'int') : (!empty($conf->entity) ? $conf->entity : 1));
// settings
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index ee3da865377..726ba624434 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -1932,5 +1932,6 @@ DeleteEmailCollector=Delete email collector
ConfirmDeleteEmailCollector=Are you sure you want to delete this email collector?
RecipientEmailsWillBeReplacedWithThisValue=Recipient emails will be always replaced with this value
AtLeastOneDefaultBankAccountMandatory=At least 1 default bank account must be defined
-RestrictApiToIps=Allow available APIs to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can use the available APIs.
+RESTICT_API_ON_IP=Allow available APIs to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can use the available APIs.
+RESTICT_ON_IP=Allow access to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can access.
BaseOnSabeDavVersion=Based on the library SabreDAV version
\ No newline at end of file