From 15d78a3e167f3783377ca2c1d8f570a25d137b35 Mon Sep 17 00:00:00 2001 From: tbrehm <t.brehm@ispconfig.org> Date: Wed, 17 Oct 2007 14:55:24 -0400 Subject: [PATCH] added symlink creation for websites on the server. --- server/plugins-enabled/apache2_plugin.inc.php | 30 ++++++++++++++++++++++++++++-- 1 files changed, 28 insertions(+), 2 deletions(-) diff --git a/server/plugins-enabled/apache2_plugin.inc.php b/server/plugins-enabled/apache2_plugin.inc.php index a068fe5..520bcb7 100644 --- a/server/plugins-enabled/apache2_plugin.inc.php +++ b/server/plugins-enabled/apache2_plugin.inc.php @@ -49,6 +49,10 @@ $app->plugins->registerEvent('web_domain_update',$this->plugin_name,'update'); $app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'delete'); + $app->plugins->registerEvent('server_ip_insert',$this->plugin_name,'server_ip'); + $app->plugins->registerEvent('server_ip_update',$this->plugin_name,'server_ip'); + $app->plugins->registerEvent('server_ip_delete',$this->plugin_name,'server_ip'); + } function insert($event_name,$data) { @@ -100,11 +104,23 @@ if(!is_dir('/var/log/ispconfig/httpd/'.$data["new"]["domain"])) exec('mkdir -p /var/log/ispconfig/httpd/'.$data["new"]["domain"]); if(!is_link($data["new"]["document_root"]."/log")) exec("ln -s /var/log/ispconfig/httpd/".$data["new"]["domain"]." ".$data["new"]["document_root"]."/log"); - // TODO: Create the symlinks + // Create the symlinks for the sites + $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($data["new"]["sys_groupid"])); + $client_id = intval($client["client_id"]); + unset($client); + $tmp_symlinks_array = explode(':',$web_config["website_symlinks"]); + foreach($tmp_symlinks_array as $tmp_symlink) { + $tmp_symlink = str_replace("[client_id]",$client_id,$tmp_symlink); + $tmp_symlink = str_replace("[website_domain]",$data["new"]["domain"],$tmp_symlink); + if(!is_link($tmp_symlink)) { + exec("ln -s ".escapeshellcmd($data["new"]["document_root"])."/ ".escapeshellcmd($tmp_symlink)); + $app->log("Creating Symlink: ln -s ".$data["new"]["document_root"]."/ ".$tmp_symlink,LOGLEVEL_DEBUG); + } + } // Copy the error pages $error_page_path = escapeshellcmd($data["new"]["web_document_root"])."/web/error/"; - exec("copy /usr/local/ispconfig/server/conf/error/".escapeshellcmd($conf["language"])."/* ".$error_page_path); + exec("cp /usr/local/ispconfig/server/conf/error/".substr(escapeshellcmd($conf["language"]),0,2)."/* ".$error_page_path); // Create group and user, if not exist $app->uses("system"); @@ -225,6 +241,16 @@ } + //* This function is called when a IP on the server is inserted, updated or deleted + function server_ip($event_name,$data) { + global $app, $conf; + + // Here we write the name virtualhost directives + // NameVirtualHost IP:80 + // NameVirtualHost IP:443 + + } + } // end class -- Gitblit v1.9.1