@@ -51,7 +51,7 @@ function web_domain($field_name, $field_value, $validator) {
5151
5252 $ result = $ this ->_check_unique ($ field_value );
5353 if (!$ result ) return $ this ->get_error ('domain_error_unique ' );
54-
54+
5555 $ pattern = '/\.acme\.invalid$/ ' ;
5656 if (preg_match ($ pattern , $ field_value )) return $ this ->get_error ('domain_error_acme_invalid ' );
5757 }
@@ -68,7 +68,7 @@ function sub_domain($field_name, $field_value, $validator) {
6868
6969 $ result = $ this ->_check_unique ($ field_value );
7070 if (!$ result ) return $ this ->get_error ('domain_error_unique ' );
71-
71+
7272 $ pattern = '/\.acme\.invalid$/ ' ;
7373 if (preg_match ($ pattern , $ field_value )) return $ this ->get_error ('domain_error_acme_invalid ' );
7474 }
@@ -83,7 +83,7 @@ function alias_domain($field_name, $field_value, $validator) {
8383
8484 $ result = $ this ->_check_unique ($ field_value );
8585 if (!$ result ) return $ this ->get_error ('domain_error_unique ' );
86-
86+
8787 $ pattern = '/\.acme\.invalid$/ ' ;
8888 if (preg_match ($ pattern , $ field_value )) return $ this ->get_error ('domain_error_acme_invalid ' );
8989 }
@@ -98,7 +98,7 @@ function web_domain_autosub($field_name, $field_value, $validator) {
9898 } else {
9999 $ check_domain = $ _POST ['domain ' ];
100100 }
101-
101+
102102 $ app ->uses ('ini_parser,getconf ' );
103103 $ settings = $ app ->getconf ->get_global_config ('domains ' );
104104 if ($ settings ['use_domain_module ' ] == 'y ' ) {
@@ -111,26 +111,26 @@ function web_domain_autosub($field_name, $field_value, $validator) {
111111 $ result = $ this ->_check_unique ($ field_value . '. ' . $ check_domain , true );
112112 if (!$ result ) return $ this ->get_error ('domain_error_autosub ' );
113113 }
114-
114+
115115 /* Check apache directives */
116116 function web_apache_directives ($ field_name , $ field_value , $ validator ) {
117117 global $ app ;
118-
118+
119119 if (trim ($ field_value ) != '' ) {
120120 $ security_config = $ app ->getconf ->get_security_config ('ids ' );
121-
121+
122122 if ($ security_config ['apache_directives_scan_enabled ' ] == 'yes ' ) {
123-
123+
124124 // Get blacklist
125125 $ blacklist_path = '/usr/local/ispconfig/security/apache_directives.blacklist ' ;
126126 if (is_file ('/usr/local/ispconfig/security/apache_directives.blacklist.custom ' )) $ blacklist_path = '/usr/local/ispconfig/security/apache_directives.blacklist.custom ' ;
127127 if (!is_file ($ blacklist_path )) $ blacklist_path = realpath (ISPC_ROOT_PATH .'/../security/apache_directives.blacklist ' );
128-
128+
129129 $ directives = explode ("\n" ,$ field_value );
130130 $ regex = explode ("\n" ,file_get_contents ($ blacklist_path ));
131131 $ blocked = false ;
132132 $ blocked_line = '' ;
133-
133+
134134 if (is_array ($ directives ) && is_array ($ regex )) {
135135 foreach ($ directives as $ directive ) {
136136 $ directive = trim ($ directive );
@@ -144,31 +144,31 @@ function web_apache_directives($field_name, $field_value, $validator) {
144144 }
145145 }
146146 }
147-
147+
148148 if ($ blocked === true ) {
149149 return $ this ->get_error ('apache_directive_blocked_error ' ).' ' .$ blocked_line ;
150150 }
151151 }
152-
152+
153153 /* Check nginx directives */
154154 function web_nginx_directives ($ field_name , $ field_value , $ validator ) {
155155 global $ app ;
156-
156+
157157 if (trim ($ field_value ) != '' ) {
158158 $ security_config = $ app ->getconf ->get_security_config ('ids ' );
159-
159+
160160 if ($ security_config ['nginx_directives_scan_enabled ' ] == 'yes ' ) {
161-
161+
162162 // Get blacklist
163163 $ blacklist_path = '/usr/local/ispconfig/security/nginx_directives.blacklist ' ;
164164 if (is_file ('/usr/local/ispconfig/security/nginx_directives.blacklist.custom ' )) $ blacklist_path = '/usr/local/ispconfig/security/nginx_directives.blacklist.custom ' ;
165165 if (!is_file ($ blacklist_path )) $ blacklist_path = realpath (ISPC_ROOT_PATH .'/../security/nginx_directives.blacklist ' );
166-
166+
167167 $ directives = explode ("\n" ,$ field_value );
168168 $ regex = explode ("\n" ,file_get_contents ($ blacklist_path ));
169169 $ blocked = false ;
170170 $ blocked_line = '' ;
171-
171+
172172 if (is_array ($ directives ) && is_array ($ regex )) {
173173 foreach ($ directives as $ directive ) {
174174 $ directive = trim ($ directive );
@@ -182,16 +182,16 @@ function web_nginx_directives($field_name, $field_value, $validator) {
182182 }
183183 }
184184 }
185-
185+
186186 if ($ blocked === true ) {
187187 return $ this ->get_error ('nginx_directive_blocked_error ' ).' ' .$ blocked_line ;
188188 }
189189 }
190-
190+
191191
192192 /* internal validator function to match regexp */
193193 function _regex_validate ($ domain_name , $ allow_wildcard = false ) {
194- $ pattern = '/^ ' . ($ allow_wildcard == true ? '(\*\.)? ' : '' ) . '[\w\.\-]{1,255}\.[a-zA-Z0-9\-]{2,30 }$/ ' ;
194+ $ pattern = '/^ ' . ($ allow_wildcard == true ? '(\*\.)? ' : '' ) . '[\w\.\-]{1,255}\.[a-zA-Z0-9\-]{2,63 }$/ ' ;
195195 return preg_match ($ pattern , $ domain_name );
196196 }
197197
@@ -229,8 +229,8 @@ function _check_unique($domain_name, $only_domain = false) {
229229 $ domain_params [] = $ aliassubdomain ['domain ' ];
230230 }
231231 }
232-
233-
232+
233+
234234 $ qrystr = "SELECT d.domain_id, IF(d.parent_domain_id != 0 AND p.domain_id IS NOT NULL, p.ip_address, d.ip_address) as `ip_address`, IF(d.parent_domain_id != 0 AND p.domain_id IS NOT NULL, p.ipv6_address, d.ipv6_address) as `ipv6_address` FROM `web_domain` as d LEFT JOIN `web_domain` as p ON (p.domain_id = d.parent_domain_id) WHERE (d.domain = ? " . $ additional_sql1 . ") AND d.server_id = ? AND d.domain_id != ? " . ($ primary_id ? " AND d.parent_domain_id != ? " : "" );
235235 $ params = array_merge (array ($ domain_name ), $ domain_params , array ($ domain ['server_id ' ], $ primary_id , $ primary_id ));
236236 $ checks = $ app ->db ->queryAllRecords ($ qrystr , true , $ params );
@@ -242,7 +242,7 @@ function _check_unique($domain_name, $only_domain = false) {
242242 if ($ domain ['ipv6_address ' ] != '' && $ check ['ipv6_address ' ] == $ domain ['ipv6_address ' ]) return false ;
243243 }
244244 }
245-
245+
246246 if ($ only_domain == false ) {
247247 $ qrystr = "SELECT d.domain_id, IF(d.parent_domain_id != 0 AND p.domain_id IS NOT NULL, p.ip_address, d.ip_address) as `ip_address`, IF(d.parent_domain_id != 0 AND p.domain_id IS NOT NULL, p.ipv6_address, d.ipv6_address) as `ipv6_address` FROM `web_domain` as d LEFT JOIN `web_domain` as p ON (p.domain_id = d.parent_domain_id) WHERE (CONCAT(d.subdomain, '.', d.domain) = ? " . $ additional_sql2 . ") AND d.server_id = ? AND d.domain_id != ? " . ($ primary_id ? " AND d.parent_domain_id != ? " : "" );
248248 $ params = array_merge (array ($ domain_name ), $ domain_params , array ($ domain ['server_id ' ], $ primary_id , $ primary_id ));
@@ -256,7 +256,7 @@ function _check_unique($domain_name, $only_domain = false) {
256256 }
257257 }
258258 }
259-
259+
260260 return true ;
261261 }
262262
@@ -274,6 +274,6 @@ function _wildcard_limit() {
274274 }
275275 return true ; // admin may always add wildcard domain
276276 }
277-
277+
278278
279279}
0 commit comments