5050
5151class page_action extends tform_actions {
5252
53+ // Returna a "3/2/1" path hash from a numeric id '123'
54+ function id_hash ($ id ,$ levels ) {
55+ $ hash = "" . $ id % 10 ;
56+ $ id /= 10 ;
57+ $ levels -- ;
58+ while ( $ levels > 0 ) {
59+ $ hash .= "/ " . $ id % 10 ;
60+ $ id /= 10 ;
61+ $ levels -- ;
62+ }
63+ return $ hash ;
64+ }
65+
5366 function onShowNew () {
5467 global $ app , $ conf ;
5568
@@ -345,6 +358,10 @@ function onAfterInsert() {
345358 $ web_rec = $ app ->tform ->getDataRecord ($ this ->id );
346359 $ web_config = $ app ->getconf ->get_server_config (intval ($ web_rec ["server_id " ]),'web ' );
347360 $ document_root = str_replace ("[website_id] " ,$ this ->id ,$ web_config ["website_path " ]);
361+ $ document_root = str_replace ("[website_idhash_1] " ,$ this ->id_hash ($ page_form ->id ,1 ),$ document_root );
362+ $ document_root = str_replace ("[website_idhash_2] " ,$ this ->id_hash ($ page_form ->id ,1 ),$ document_root );
363+ $ document_root = str_replace ("[website_idhash_3] " ,$ this ->id_hash ($ page_form ->id ,1 ),$ document_root );
364+ $ document_root = str_replace ("[website_idhash_4] " ,$ this ->id_hash ($ page_form ->id ,1 ),$ document_root );
348365
349366 // get the ID of the client
350367 if ($ _SESSION ["s " ]["user " ]["typ " ] != 'admin ' && !$ app ->auth ->has_clients ($ _SESSION ['s ' ]['user ' ]['userid ' ])) {
@@ -360,7 +377,12 @@ function onAfterInsert() {
360377 // Set the values for document_root, system_user and system_group
361378 $ system_user = $ app ->db ->quote ('web ' .$ this ->id );
362379 $ system_group = $ app ->db ->quote ('client ' .$ client_id );
363- $ document_root = $ app ->db ->quote (str_replace ("[client_id] " ,$ client_id ,$ document_root ));
380+ $ document_root = str_replace ("[client_id] " ,$ client_id ,$ document_root );
381+ $ document_root = str_replace ("[client_idhash_1] " ,$ this ->id_hash ($ client_id ,1 ),$ document_root );
382+ $ document_root = str_replace ("[client_idhash_2] " ,$ this ->id_hash ($ client_id ,2 ),$ document_root );
383+ $ document_root = str_replace ("[client_idhash_3] " ,$ this ->id_hash ($ client_id ,3 ),$ document_root );
384+ $ document_root = str_replace ("[client_idhash_4] " ,$ this ->id_hash ($ client_id ,4 ),$ document_root );
385+ $ document_root = $ app ->db ->quote ($ document_root );
364386 $ php_open_basedir = str_replace ("[website_path] " ,$ document_root ,$ web_config ["php_open_basedir " ]);
365387 $ php_open_basedir = $ app ->db ->quote (str_replace ("[website_domain] " ,$ web_rec ['domain ' ],$ php_open_basedir ));
366388 $ htaccess_allow_override = $ app ->db ->quote ($ web_config ["htaccess_allow_override " ]);
@@ -426,6 +448,10 @@ function onAfterUpdate() {
426448 $ web_rec = $ app ->tform ->getDataRecord ($ this ->id );
427449 $ web_config = $ app ->getconf ->get_server_config (intval ($ web_rec ["server_id " ]),'web ' );
428450 $ document_root = str_replace ("[website_id] " ,$ this ->id ,$ web_config ["website_path " ]);
451+ $ document_root = str_replace ("[website_idhash_1] " ,$ this ->id_hash ($ page_form ->id ,1 ),$ document_root );
452+ $ document_root = str_replace ("[website_idhash_2] " ,$ this ->id_hash ($ page_form ->id ,1 ),$ document_root );
453+ $ document_root = str_replace ("[website_idhash_3] " ,$ this ->id_hash ($ page_form ->id ,1 ),$ document_root );
454+ $ document_root = str_replace ("[website_idhash_4] " ,$ this ->id_hash ($ page_form ->id ,1 ),$ document_root );
429455
430456 // get the ID of the client
431457 if ($ _SESSION ["s " ]["user " ]["typ " ] != 'admin ' && !$ app ->auth ->has_clients ($ _SESSION ['s ' ]['user ' ]['userid ' ])) {
@@ -442,7 +468,12 @@ function onAfterUpdate() {
442468 // Set the values for document_root, system_user and system_group
443469 $ system_user = $ app ->db ->quote ('web ' .$ this ->id );
444470 $ system_group = $ app ->db ->quote ('client ' .$ client_id );
445- $ document_root = $ app ->db ->quote (str_replace ("[client_id] " ,$ client_id ,$ document_root ));
471+ $ document_root = str_replace ("[client_id] " ,$ client_id ,$ document_root );
472+ $ document_root = str_replace ("[client_idhash_1] " ,$ this ->id_hash ($ client_id ,1 ),$ document_root );
473+ $ document_root = str_replace ("[client_idhash_2] " ,$ this ->id_hash ($ client_id ,2 ),$ document_root );
474+ $ document_root = str_replace ("[client_idhash_3] " ,$ this ->id_hash ($ client_id ,3 ),$ document_root );
475+ $ document_root = str_replace ("[client_idhash_4] " ,$ this ->id_hash ($ client_id ,4 ),$ document_root );
476+ $ document_root = $ app ->db ->quote ($ document_root );
446477
447478 $ sql = "UPDATE web_domain SET system_user = ' $ system_user', system_group = ' $ system_group', document_root = ' $ document_root' WHERE domain_id = " .$ this ->id ;
448479 //$sql = "UPDATE web_domain SET system_user = '$system_user', system_group = '$system_group' WHERE domain_id = ".$this->id;
0 commit comments