Skip to content

Commit 15d78a3

Browse files
committed
added symlink creation for websites on the server.
1 parent 3f6bd21 commit 15d78a3

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

interface/web/sites/web_domain_edit.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ function onAfterInsert() {
199199
$client = $app->db->queryOneRecord("SELECT client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
200200
$client_id = intval($client["client_id"]);
201201
} else {
202-
$client_id = intval($this->dataRecord["client_group_id"]);
203-
$client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($this->dataRecord["client_group_id"]));
202+
//$client_id = intval($this->dataRecord["client_group_id"]);
203+
$client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($this->dataRecord["sys_groupid"]));
204204
$client_id = intval($client["client_id"]);
205205
}
206206

@@ -235,8 +235,8 @@ function onAfterUpdate() {
235235
$client = $app->db->queryOneRecord("SELECT client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
236236
$client_id = intval($client["client_id"]);
237237
} else {
238-
$client_id = intval(@$web_rec["client_group_id"]);
239-
$client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval(@$this->dataRecord["client_group_id"]));
238+
//$client_id = intval(@$web_rec["client_group_id"]);
239+
$client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval(@$this->dataRecord["sys_groupid"]));
240240
$client_id = intval($client["client_id"]);
241241
}
242242

server/mods-enabled/web_module.inc.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ class web_module {
3434
var $class_name = 'web_module';
3535
var $actions_available = array( 'web_domain_insert',
3636
'web_domain_update',
37-
'web_domain_delete');
37+
'web_domain_delete',
38+
'ftp_user_insert',
39+
'ftp_user_update',
40+
'ftp_user_delete',
41+
'shell_user_insert',
42+
'shell_user_update',
43+
'shell_user_delete');
3844

3945
/*
4046
This function is called when the module is loaded
@@ -81,6 +87,16 @@ function process($tablename,$action,$data) {
8187
if($action == 'u') $app->plugins->raiseEvent('web_domain_update',$data);
8288
if($action == 'd') $app->plugins->raiseEvent('web_domain_delete',$data);
8389
break;
90+
case 'ftp_user':
91+
if($action == 'i') $app->plugins->raiseEvent('ftp_user_insert',$data);
92+
if($action == 'u') $app->plugins->raiseEvent('ftp_user_update',$data);
93+
if($action == 'd') $app->plugins->raiseEvent('ftp_user_delete',$data);
94+
break;
95+
case 'shell_user':
96+
if($action == 'i') $app->plugins->raiseEvent('shell_user_insert',$data);
97+
if($action == 'u') $app->plugins->raiseEvent('shell_user_update',$data);
98+
if($action == 'd') $app->plugins->raiseEvent('shell_user_delete',$data);
99+
break;
84100
} // end switch
85101
} // end function
86102

server/plugins-enabled/apache2_plugin.inc.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,19 @@ function update($event_name,$data) {
104104
if(!is_dir('/var/log/ispconfig/httpd/'.$data["new"]["domain"])) exec('mkdir -p /var/log/ispconfig/httpd/'.$data["new"]["domain"]);
105105
if(!is_link($data["new"]["document_root"]."/log")) exec("ln -s /var/log/ispconfig/httpd/".$data["new"]["domain"]." ".$data["new"]["document_root"]."/log");
106106

107-
// TODO: Create the symlinks
107+
// Create the symlinks for the sites
108+
$client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($data["new"]["sys_groupid"]));
109+
$client_id = intval($client["client_id"]);
110+
unset($client);
111+
$tmp_symlinks_array = explode(':',$web_config["website_symlinks"]);
112+
foreach($tmp_symlinks_array as $tmp_symlink) {
113+
$tmp_symlink = str_replace("[client_id]",$client_id,$tmp_symlink);
114+
$tmp_symlink = str_replace("[website_domain]",$data["new"]["domain"],$tmp_symlink);
115+
if(!is_link($tmp_symlink)) {
116+
exec("ln -s ".escapeshellcmd($data["new"]["document_root"])."/ ".escapeshellcmd($tmp_symlink));
117+
$app->log("Creating Symlink: ln -s ".$data["new"]["document_root"]."/ ".$tmp_symlink,LOGLEVEL_DEBUG);
118+
}
119+
}
108120

109121
// Copy the error pages
110122
$error_page_path = escapeshellcmd($data["new"]["web_document_root"])."/web/error/";

0 commit comments

Comments
 (0)