From 28cd07d1a75c4e9dcaecac49efee0091f2fc62fa Mon Sep 17 00:00:00 2001
From: A. Täffner <darkalex@firesplash.de>
Date: Thu, 07 Apr 2016 05:30:49 -0400
Subject: [PATCH] Implemented a checkbox "enable DNSSEC" in DNS-Wizard. This Checkbox can be enabled or disabled by template.
---
interface/web/sites/shell_user_edit.php | 57 ++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 44 insertions(+), 13 deletions(-)
diff --git a/interface/web/sites/shell_user_edit.php b/interface/web/sites/shell_user_edit.php
index 24ef093..2b606c2 100644
--- a/interface/web/sites/shell_user_edit.php
+++ b/interface/web/sites/shell_user_edit.php
@@ -82,7 +82,11 @@
$app->tpl->setVar("username", $app->tools_sites->removePrefix($this->dataRecord['username'], $this->dataRecord['username_prefix'], $shelluser_prefix));
}
- $app->tpl->setVar("username_prefix", $app->tools_sites->getPrefix($this->dataRecord['username_prefix'], $shelluser_prefix, $global_config['shelluser_prefix']));
+ if($this->dataRecord['username'] == "") {
+ $app->tpl->setVar("username_prefix", $shelluser_prefix);
+ } else {
+ $app->tpl->setVar("username_prefix", $app->tools_sites->getPrefix($this->dataRecord['username_prefix'], $shelluser_prefix, $global_config['shelluser_prefix']));
+ }
if($this->id > 0) {
//* we are editing a existing record
@@ -90,6 +94,12 @@
$app->tpl->setVar("parent_domain_id_value", $this->dataRecord["parent_domain_id"]);
} else {
$app->tpl->setVar("edit_disabled", 0);
+ }
+
+ if($this->dataRecord['chroot'] == 'jailkit'){
+ $app->tpl->setVar("is_jailkit", true);
+ } else {
+ $app->tpl->setVar("is_jailkit", false);
}
parent::onShowEnd();
@@ -99,14 +109,12 @@
global $app, $conf;
// Get the record of the parent domain
- //$parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".$app->functions->intval(@$this->dataRecord["parent_domain_id"]) . " AND ".$app->tform->getAuthSQL('r'));
- //if(!$parent_domain || $parent_domain['domain_id'] != @$this->dataRecord['parent_domain_id']) $app->tform->errorMessage .= $app->tform->lng("no_domain_perm");
if(isset($this->dataRecord["parent_domain_id"])) {
- $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".$app->functions->intval(@$this->dataRecord["parent_domain_id"]) . " AND ".$app->tform->getAuthSQL('r'));
+ $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ? AND ".$app->tform->getAuthSQL('r'), @$this->dataRecord["parent_domain_id"]);
if(!$parent_domain || $parent_domain['domain_id'] != @$this->dataRecord['parent_domain_id']) $app->tform->errorMessage .= $app->tform->lng("no_domain_perm");
} else {
$tmp = $app->tform->getDataRecord($this->id);
- $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".$app->functions->intval($tmp["parent_domain_id"]) . " AND ".$app->tform->getAuthSQL('r'));
+ $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ? AND ".$app->tform->getAuthSQL('r'), $tmp["parent_domain_id"]);
if(!$parent_domain) $app->tform->errorMessage .= $app->tform->lng("no_domain_perm");
unset($tmp);
}
@@ -135,6 +143,8 @@
}
}
unset($blacklist);
+
+ if($app->functions->is_allowed_user(trim(strtolower($this->dataRecord['username']))) == false) $app->tform->errorMessage .= $app->tform->lng('username_not_allowed_txt');
/*
* If the names should be restricted -> do it!
@@ -157,17 +167,27 @@
function onAfterInsert() {
global $app, $conf;
- $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($this->dataRecord["parent_domain_id"]));
- $server_id = $web["server_id"];
- $dir = $web["document_root"];
- $puser = $web["system_user"];
- $pgroup = $web["system_group"];
+ $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $this->dataRecord["parent_domain_id"]);
+
+ $server_id = $app->functions->intval($web["server_id"]);
+ if($this->dataRecord['chroot'] == 'jailkit'){
+ $dir = $app->db->quote($web["document_root"]);
+ } else {
+ $dir = $app->db->quote($web["document_root"].'/home/'.$this->dataRecord['username']);
+ }
+ $uid = $web["system_user"];
+ $gid = $web["system_group"];
+
+ // Check system user and group
+ if($app->functions->is_allowed_user($uid) == false || $app->functions->is_allowed_group($gid) == false) {
+ $app->error($app->tform->lng('invalid_system_user_or_group_txt'));
+ }
// The FTP user shall be owned by the same group then the website
- $sys_groupid = $web['sys_groupid'];
+ $sys_groupid = $app->functions->intval($web['sys_groupid']);
- $sql = "UPDATE shell_user SET server_id = $server_id, dir = '$dir', puser = '$puser', pgroup = '$pgroup', sys_groupid = '$sys_groupid' WHERE shell_user_id = ".$this->id;
- $app->db->query($sql);
+ $sql = "UPDATE shell_user SET server_id = ?, dir = ?, puser = ?, pgroup = ?, sys_groupid = ? WHERE shell_user_id = ?";
+ $app->db->query($sql, $server_id, $dir, $uid, $gid, $sys_groupid, $this->id);
}
@@ -208,7 +228,18 @@
function onAfterUpdate() {
global $app, $conf;
+ if(isset($this->dataRecord['chroot'])){
+ $shell_user = $app->db->queryOneRecord("SELECT * FROM shell_user WHERE shell_user_id = ".$this->id);
+ $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($this->dataRecord["parent_domain_id"]));
+ $dir = $shell_user['dir'];
+ if($this->dataRecord['chroot'] == 'jailkit'){
+ $dir = $app->db->quote($web["document_root"]);
+ } else {
+ if($this->oldDataRecord['chroot'] == 'jailkit') $dir = $app->db->quote($web["document_root"].'/home/'.$this->dataRecord['username']);
+ }
+ if($dir != $shell_user['dir']) $app->db->query("UPDATE shell_user SET dir = '$dir' WHERE shell_user_id = ".$this->id);
+ }
}
}
--
Gitblit v1.9.1