@@ -897,24 +897,48 @@ function update($event_name,$data) {
897897 */
898898 $ this ->_patchVhostWebdav ($ vhost_file , $ data ['new ' ]['document_root ' ] . '/webdav ' );
899899
900- // Set the symlink to enable the vhost
900+ //* Set the symlink to enable the vhost
901+ //* First we check if there is a old type of symlink and remove it
901902 $ vhost_symlink = escapeshellcmd ($ web_config ['vhost_conf_enabled_dir ' ].'/ ' .$ data ['new ' ]['domain ' ].'.vhost ' );
903+ if (is_link ($ vhost_symlink )) unlink ($ vhost_symlink );
904+
905+ //* Remove old or changed symlinks
906+ if ($ data ['new ' ]['subdomain ' ] != $ data ['old ' ]['subdomain ' ] or $ data ['new ' ]['active ' ] == 'n ' ) {
907+ $ vhost_symlink = escapeshellcmd ($ web_config ['vhost_conf_enabled_dir ' ].'/900- ' .$ data ['new ' ]['domain ' ].'.vhost ' );
908+ if (is_link ($ vhost_symlink )) {
909+ unlink ($ vhost_symlink );
910+ $ app ->log ('Removing symlink: ' .$ vhost_symlink .'-> ' .$ vhost_file ,LOGLEVEL_DEBUG );
911+ }
912+ $ vhost_symlink = escapeshellcmd ($ web_config ['vhost_conf_enabled_dir ' ].'/100- ' .$ data ['new ' ]['domain ' ].'.vhost ' );
913+ if (is_link ($ vhost_symlink )) {
914+ unlink ($ vhost_symlink );
915+ $ app ->log ('Removing symlink: ' .$ vhost_symlink .'-> ' .$ vhost_file ,LOGLEVEL_DEBUG );
916+ }
917+ }
918+
919+ //* New symlink
920+ if ($ data ['new ' ]['subdomain ' ] == '* ' ) {
921+ $ vhost_symlink = escapeshellcmd ($ web_config ['vhost_conf_enabled_dir ' ].'/900- ' .$ data ['new ' ]['domain ' ].'.vhost ' );
922+ } else {
923+ $ vhost_symlink = escapeshellcmd ($ web_config ['vhost_conf_enabled_dir ' ].'/100- ' .$ data ['new ' ]['domain ' ].'.vhost ' );
924+ }
902925 if ($ data ['new ' ]['active ' ] == 'y ' && !is_link ($ vhost_symlink )) {
903926 symlink ($ vhost_file ,$ vhost_symlink );
904927 $ app ->log ('Creating symlink: ' .$ vhost_symlink .'-> ' .$ vhost_file ,LOGLEVEL_DEBUG );
905928 }
906929
907- // Remove the symlink, if site is inactive
908- if ($ data ['new ' ]['active ' ] == 'n ' && is_link ($ vhost_symlink )) {
909- unlink ($ vhost_symlink );
910- $ app ->log ('Removing symlink: ' .$ vhost_symlink .'-> ' .$ vhost_file ,LOGLEVEL_DEBUG );
911- }
912-
913930 // remove old symlink and vhost file, if domain name of the site has changed
914931 if ($ this ->action == 'update ' && $ data ['old ' ]['domain ' ] != '' && $ data ['new ' ]['domain ' ] != $ data ['old ' ]['domain ' ]) {
915- $ vhost_symlink = escapeshellcmd ($ web_config ['vhost_conf_enabled_dir ' ].'/ ' .$ data ['old ' ]['domain ' ].'.vhost ' );
916- unlink ($ vhost_symlink );
917- $ app ->log ('Removing symlink: ' .$ vhost_symlink .'-> ' .$ vhost_file ,LOGLEVEL_DEBUG );
932+ $ vhost_symlink = escapeshellcmd ($ web_config ['vhost_conf_enabled_dir ' ].'/900- ' .$ data ['old ' ]['domain ' ].'.vhost ' );
933+ if (is_link ($ vhost_symlink )) {
934+ unlink ($ vhost_symlink );
935+ $ app ->log ('Removing symlink: ' .$ vhost_symlink .'-> ' .$ vhost_file ,LOGLEVEL_DEBUG );
936+ }
937+ $ vhost_symlink = escapeshellcmd ($ web_config ['vhost_conf_enabled_dir ' ].'/100- ' .$ data ['old ' ]['domain ' ].'.vhost ' );
938+ if (is_link ($ vhost_symlink )) {
939+ unlink ($ vhost_symlink );
940+ $ app ->log ('Removing symlink: ' .$ vhost_symlink .'-> ' .$ vhost_file ,LOGLEVEL_DEBUG );
941+ }
918942 $ vhost_file = escapeshellcmd ($ web_config ['vhost_conf_dir ' ].'/ ' .$ data ['old ' ]['domain ' ].'.vhost ' );
919943 unlink ($ vhost_file );
920944 $ app ->log ('Removing file: ' .$ vhost_file ,LOGLEVEL_DEBUG );
0 commit comments