@@ -44,11 +44,14 @@ function apply_client_templates($clientId) {
4444 if (trim ($ item ) != '' ){
4545 $ sql = "SELECT * FROM client_template WHERE template_id = " . $ app ->functions ->intval ($ item );
4646 $ addLimits = $ app ->db ->queryOneRecord ($ sql );
47+ $ app ->log ('Template processing subtemplate ' . $ item . ' for client ' . $ clientId , LOGLEVEL_DEBUG );
4748 /* maybe the template is deleted in the meantime */
4849 if (is_array ($ addLimits )){
4950 foreach ($ addLimits as $ k => $ v ){
5051 /* we can remove this condition, but it is easier to debug with it (don't add ids and other non-limit values) */
51- if (strpos ($ k , 'limit ' ) !== false ){
52+ if (strpos ($ k , 'limit ' ) !== false or $ k == 'ssh_chroot ' or $ k == 'web_php_options ' or $ k == 'force_suexec ' ){
53+ $ app ->log ('Template processing key ' . $ k . ' for client ' . $ clientId , LOGLEVEL_DEBUG );
54+
5255 /* process the numerical limits */
5356 if (is_numeric ($ v )){
5457 /* switch for special cases */
@@ -84,15 +87,29 @@ function apply_client_templates($clientId) {
8487 $ limits_values = explode ($ form ["tabs " ]["limits " ]["fields " ][$ k ]["separator " ],$ limits [$ k ]);
8588 }
8689 $ additional_values = explode ($ form ["tabs " ]["limits " ]["fields " ][$ k ]["separator " ],$ v );
87-
90+ $ app -> log ( ' Template processing key ' . $ k . ' type CHECKBOXARRAY, lim / add: ' . implode ( ' , ' , $ limits_values ) . ' / ' . implode ( ' , ' , $ additional_values ) . ' for client ' . $ clientId , LOGLEVEL_DEBUG );
8891 /* unification of limits_values (master template) and additional_values (additional template) */
8992 $ limits_unified = array ();
9093 foreach ($ form ["tabs " ]["limits " ]["fields " ][$ k ]["value " ] as $ key => $ val ){
9194 if (in_array ($ key ,$ limits_values ) || in_array ($ key ,$ additional_values )) $ limits_unified [] = $ key ;
9295 }
9396 $ limits [$ k ] = implode ($ form ["tabs " ]["limits " ]["fields " ][$ k ]["separator " ],$ limits_unified );
9497 break ;
95-
98+ case 'CHECKBOX ' :
99+ if ($ k == 'force_suexec ' ) {
100+ // 'n' is less limited than y
101+ if (!isset ($ limits [$ k ])){
102+ $ limits [$ k ] = 'y ' ;
103+ }
104+ if ($ limits [$ k ] == 'n ' || $ v == 'n ' ) $ limits [$ k ] = 'n ' ;
105+ } else {
106+ // 'y' is less limited than n
107+ if (!isset ($ limits [$ k ])){
108+ $ limits [$ k ] = 'n ' ;
109+ }
110+ if ($ limits [$ k ] == 'y ' || $ v == 'y ' ) $ limits [$ k ] = 'y ' ;
111+ }
112+ break ;
96113 case 'SELECT ' :
97114 $ limit_values = array_keys ($ form ["tabs " ]["limits " ]["fields " ][$ k ]["value " ]);
98115 /* choose the lower index of the two SELECT items */
@@ -116,6 +133,7 @@ function apply_client_templates($clientId) {
116133 $ update .= '` ' . $ k . "`=' " . $ v . "' " ;
117134 }
118135 }
136+ $ app ->log ('Template processed for client ' . $ clientId . ', update string: ' . $ update , LOGLEVEL_DEBUG );
119137 if ($ update != '' ) {
120138 $ sql = 'UPDATE client SET ' . $ update . " WHERE client_id = " . $ app ->functions ->intval ($ clientId );
121139 $ app ->db ->query ($ sql );
0 commit comments