Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
ISPConfig
ISPConfig 3
Commits
db5aa62b
Commit
db5aa62b
authored
Dec 15, 2008
by
tbrehm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Added a global system settings storage in ini format.
- Updated the user and database prefixes to use this storage.
parent
d062c991
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
235 additions
and
281 deletions
+235
-281
install/lib/installer_base.lib.php
install/lib/installer_base.lib.php
+5
-0
install/sql/ispconfig3.sql
install/sql/ispconfig3.sql
+18
-0
install/tpl/system.ini.master
install/tpl/system.ini.master
+19
-0
install/update.php
install/update.php
+22
-0
interface/lib/classes/getconf.inc.php
interface/lib/classes/getconf.inc.php
+8
-2
interface/web/sites/database_edit.php
interface/web/sites/database_edit.php
+59
-95
interface/web/sites/ftp_user_edit.php
interface/web/sites/ftp_user_edit.php
+48
-94
interface/web/sites/shell_user_edit.php
interface/web/sites/shell_user_edit.php
+46
-87
interface/web/sites/tools.inc.php
interface/web/sites/tools.inc.php
+2
-0
server/lib/classes/getconf.inc.php
server/lib/classes/getconf.inc.php
+8
-3
No files found.
install/lib/installer_base.lib.php
View file @
db5aa62b
...
...
@@ -159,6 +159,11 @@ class installer_base {
if
(
count
(
$db_tables
)
==
0
)
{
$this
->
error
(
'Unable to load SQL-Dump into database table.'
);
}
//* Load system.ini into the sys_ini table
$system_ini
=
$this
->
db
->
quote
(
rf
(
'tpl/system.ini.master'
));
$this
->
db
->
query
(
"UPDATE sys_ini SET config = '
$system_ini
' WHERE sysini_id = 1"
);
}
}
...
...
install/sql/ispconfig3.sql
View file @
db5aa62b
...
...
@@ -997,6 +997,24 @@ INSERT INTO `sys_group` (`groupid`, `name`, `description`, `client_id`) VALUES (
-- --------------------------------------------------------
--
-- Tabellenstruktur fr Tabelle `sys_ini`
--
CREATE
TABLE
`sys_ini`
(
`sysini_id`
int
(
11
)
NOT
NULL
auto_increment
,
`config`
longtext
NOT
NULL
,
PRIMARY
KEY
(
`sysini_id`
)
)
ENGINE
=
MyISAM
AUTO_INCREMENT
=
1
;
--
-- Daten fr Tabelle `sys_ini`
--
INSERT
INTO
`sys_ini`
(
`sysini_id`
,
`config`
)
VALUES
(
1
,
''
);
-- --------------------------------------------------------
--
-- Tabellenstruktur fr Tabelle `sys_log`
--
...
...
install/tpl/system.ini.master
0 → 100644
View file @
db5aa62b
[global]
[admin]
[client]
[dns]
[mail]
[monitor]
[sites]
dbname_prefix=[CLIENTNAME]_
dbuser_prefix=[CLIENTNAME]
ftpuser_prefix=[CLIENTNAME]
shelluser_prefix=[CLIENTNAME]
[tools]
\ No newline at end of file
install/update.php
View file @
db5aa62b
...
...
@@ -199,6 +199,28 @@ unset($tpl_ini_array);
unset
(
$new_ini
);
//** Update system ini
$tmp_server_rec
=
$inst
->
db
->
queryOneRecord
(
"SELECT config FROM sys_ini WHERE sysini_id = 1"
);
$old_ini_array
=
ini_to_array
(
stripslashes
(
$tmp_server_rec
[
'config'
]));
unset
(
$tmp_server_rec
);
$tpl_ini_array
=
ini_to_array
(
rf
(
'tpl/system.ini.master'
));
// update the new template with the old values
if
(
is_array
(
$old_ini_array
))
{
foreach
(
$old_ini_array
as
$tmp_section_name
=>
$tmp_section_content
)
{
foreach
(
$tmp_section_content
as
$tmp_var_name
=>
$tmp_var_content
)
{
$tpl_ini_array
[
$tmp_section_name
][
$tmp_var_name
]
=
$tmp_var_content
;
}
}
}
$new_ini
=
array_to_ini
(
$tpl_ini_array
);
$inst
->
db
->
query
(
"UPDATE sys_ini SET config = '"
.
mysql_real_escape_string
(
$new_ini
)
.
"' WHERE sysini_id = 1"
);
unset
(
$old_ini_array
);
unset
(
$tpl_ini_array
);
unset
(
$new_ini
);
//** Shall the services be reconfigured during update
$reconfigure_services_answer
=
$inst
->
simple_query
(
'Reconfigure Services?'
,
array
(
'yes'
,
'no'
),
'yes'
);
...
...
interface/lib/classes/getconf.inc.php
View file @
db5aa62b
...
...
@@ -44,9 +44,15 @@ class getconf {
return
(
$section
==
''
)
?
$this
->
config
[
$server_id
]
:
$this
->
config
[
$server_id
][
$section
];
}
public
function
get_global_config
()
{
public
function
get_global_config
(
$section
=
''
)
{
global
$app
;
die
(
"not yet implemented"
);
if
(
!
is_array
(
$this
->
config
[
'global'
]))
{
$app
->
uses
(
'ini_parser'
);
$tmp
=
$app
->
db
->
queryOneRecord
(
"SELECT config FROM sys_ini WHERE sysini_id = 1"
);
$this
->
config
[
'global'
]
=
$app
->
ini_parser
->
parse_ini_string
(
stripslashes
(
$tmp
[
"config"
]));
}
return
(
$section
==
''
)
?
$this
->
config
[
'global'
]
:
$this
->
config
[
'global'
][
$section
];
}
}
...
...
interface/web/sites/database_edit.php
View file @
db5aa62b
...
...
@@ -153,39 +153,25 @@ class page_action extends tform_actions {
* If the names are restricted -> remove the restriction, so that the
* data can be edited
*/
if
(
$interfaceConf
[
'restrict_names'
]
==
true
){
/* get the restriction */
$restriction
=
'[CLIENTNAME]_'
;
if
(
isset
(
$interfaceConf
[
'restrict_dbname'
]))
$restriction
=
$interfaceConf
[
'restrict_dbname'
];
$tmpRestriction
=
$restriction
;
/* Get the group-id */
if
(
$_SESSION
[
"s"
][
"user"
][
"typ"
]
!=
'admin'
)
{
// Get the group-id of the user
$client_group_id
=
$_SESSION
[
"s"
][
"user"
][
"default_group"
];
}
else
{
// Get the group-id from the data itself
$client_group_id
=
$this
->
dataRecord
[
'sys_groupid'
];
}
/* get the name of the client */
$tmp
=
$app
->
db
->
queryOneRecord
(
"SELECT name FROM sys_group WHERE groupid = "
.
$client_group_id
);
$clientName
=
$tmp
[
'name'
];
if
(
$clientName
==
""
)
$clientName
=
'default'
;
$clientName
=
convertClientName
(
$clientName
);
$restriction
=
str_replace
(
'[CLIENTNAME]'
,
$clientName
,
$restriction
);
if
(
$this
->
dataRecord
[
'database_name'
]
!=
""
){
/* REMOVE the restriction */
$app
->
tpl
->
setVar
(
"database_name"
,
str_replace
(
$restriction
,
''
,
$this
->
dataRecord
[
'database_name'
]));
$app
->
tpl
->
setVar
(
"database_user"
,
str_replace
(
$restriction
,
''
,
$this
->
dataRecord
[
'database_user'
]));
}
if
(
$_SESSION
[
"s"
][
"user"
][
"typ"
]
==
'admin'
||
$app
->
auth
->
has_clients
(
$_SESSION
[
's'
][
'user'
][
'userid'
]))
{
$app
->
tpl
->
setVar
(
"database_name_prefix"
,
$tmpRestriction
);
$app
->
tpl
->
setVar
(
"database_user_prefix"
,
$tmpRestriction
);
}
else
{
$app
->
tpl
->
setVar
(
"database_name_prefix"
,
$restriction
);
$app
->
tpl
->
setVar
(
"database_user_prefix"
,
$restriction
);
}
//* Get the database name and database user prefix
$app
->
uses
(
'getconf'
);
$global_config
=
$app
->
getconf
->
get_global_config
(
'sites'
);
$dbname_prefix
=
(
$global_config
[
'dbname_prefix'
]
==
''
)
?
''
:
str_replace
(
'[CLIENTNAME]'
,
$this
->
getClientName
(),
$global_config
[
'dbname_prefix'
]);
$dbuser_prefix
=
(
$global_config
[
'dbuser_prefix'
]
==
''
)
?
''
:
str_replace
(
'[CLIENTNAME]'
,
$this
->
getClientName
(),
$global_config
[
'dbuser_prefix'
]);
if
(
$this
->
dataRecord
[
'database_name'
]
!=
""
){
/* REMOVE the restriction */
$app
->
tpl
->
setVar
(
"database_name"
,
str_replace
(
$dbname_prefix
,
''
,
$this
->
dataRecord
[
'database_name'
]));
$app
->
tpl
->
setVar
(
"database_user"
,
str_replace
(
$dbuser_prefix
,
''
,
$this
->
dataRecord
[
'database_user'
]));
}
if
(
$_SESSION
[
"s"
][
"user"
][
"typ"
]
==
'admin'
||
$app
->
auth
->
has_clients
(
$_SESSION
[
's'
][
'user'
][
'userid'
]))
{
$app
->
tpl
->
setVar
(
"database_name_prefix"
,
$global_config
[
'dbname_prefix'
]);
$app
->
tpl
->
setVar
(
"database_user_prefix"
,
$global_config
[
'dbuser_prefix'
]);
}
else
{
$app
->
tpl
->
setVar
(
"database_name_prefix"
,
$dbname_prefix
);
$app
->
tpl
->
setVar
(
"database_user_prefix"
,
$dbuser_prefix
);
}
parent
::
onShowEnd
();
...
...
@@ -233,44 +219,23 @@ class page_action extends tform_actions {
global
$app
,
$conf
,
$interfaceConf
;
/*
* If the names should be restricted -> do it!
*/
if
(
$interfaceConf
[
'restrict_names'
]
==
true
){
/* get the restriction */
$restriction
=
'[CLIENTNAME]_'
;
if
(
isset
(
$interfaceConf
[
'restrict_dbname'
]))
$restriction
=
$interfaceConf
[
'restrict_dbname'
];
/* Get the group-id */
if
(
$_SESSION
[
"s"
][
"user"
][
"typ"
]
!=
'admin'
)
{
// Get the group-id of the user
$client_group_id
=
$_SESSION
[
"s"
][
"user"
][
"default_group"
];
}
else
{
// Get the group-id from the data itself
$client_group_id
=
$this
->
dataRecord
[
'client_group_id'
];
}
/* get the name of the client */
$tmp
=
$app
->
db
->
queryOneRecord
(
"SELECT name FROM sys_group WHERE groupid = "
.
$client_group_id
);
$clientName
=
$tmp
[
'name'
];
if
(
$clientName
==
""
)
$clientName
=
'default'
;
$clientName
=
convertClientName
(
$clientName
);
$restriction
=
str_replace
(
'[CLIENTNAME]'
,
$clientName
,
$restriction
);
}
else
{
$restriction
=
''
;
}
$error
=
false
;
* If the names should be restricted -> do it!
*/
//* Get the database name and database user prefix
$app
->
uses
(
'getconf'
);
$global_config
=
$app
->
getconf
->
get_global_config
(
'sites'
);
$dbname_prefix
=
(
$global_config
[
'dbname_prefix'
]
==
''
)
?
''
:
str_replace
(
'[CLIENTNAME]'
,
$this
->
getClientName
(),
$global_config
[
'dbname_prefix'
]);
$dbuser_prefix
=
(
$global_config
[
'dbuser_prefix'
]
==
''
)
?
''
:
str_replace
(
'[CLIENTNAME]'
,
$this
->
getClientName
(),
$global_config
[
'dbuser_prefix'
]);
//* Prevent that the database name and charset is changed
$old_record
=
$app
->
tform
->
getDataRecord
(
$this
->
id
);
if
(
$old_record
[
"database_name"
]
!=
$restriction
.
$this
->
dataRecord
[
"database_name"
])
{
$app
->
tform
->
errorMessage
.
=
$app
->
tform
->
wordbook
[
"database_name_change_txt"
]
.
'<br />'
;
$error
=
true
;
}
if
(
$old_record
[
"database_charset"
]
!=
$this
->
dataRecord
[
"database_charset"
])
{
$app
->
tform
->
errorMessage
.
=
$app
->
tform
->
wordbook
[
"database_charset_change_txt"
]
.
'<br />'
;
$error
=
true
;
}
//* Check if the server has been changed
...
...
@@ -280,15 +245,14 @@ class page_action extends tform_actions {
//* Add a error message and switch back to old server
$app
->
tform
->
errorMessage
.
=
$app
->
lng
(
'The Server can not be changed.'
);
$this
->
dataRecord
[
"server_id"
]
=
$rec
[
'server_id'
];
$error
=
true
;
}
}
unset
(
$old_record
);
if
(
$
error
==
false
){
if
(
$
app
->
tform
->
errorMessage
==
''
){
/* restrict the names if there is no error */
$this
->
dataRecord
[
'database_name'
]
=
$
restriction
.
$this
->
dataRecord
[
'database_name'
];
$this
->
dataRecord
[
'database_user'
]
=
$
restriction
.
$this
->
dataRecord
[
'database_user'
];
$this
->
dataRecord
[
'database_name'
]
=
$
dbname_prefix
.
$this
->
dataRecord
[
'database_name'
];
$this
->
dataRecord
[
'database_user'
]
=
$
dbuser_prefix
.
$this
->
dataRecord
[
'database_user'
];
}
parent
::
onBeforeUpdate
();
...
...
@@ -297,34 +261,16 @@ class page_action extends tform_actions {
function
onBeforeInsert
()
{
global
$app
,
$conf
,
$interfaceConf
;
/*
* If the names should be restricted -> do it!
*/
if
(
$interfaceConf
[
'restrict_names'
]
==
true
){
/* get the restriction */
$restriction
=
'[CLIENTNAME]_'
;
if
(
isset
(
$interfaceConf
[
'restrict_dbname'
]))
$restriction
=
$interfaceConf
[
'restrict_dbname'
];
/* Get the group-id */
if
(
$_SESSION
[
"s"
][
"user"
][
"typ"
]
!=
'admin'
)
{
// Get the group-id of the user
$client_group_id
=
$_SESSION
[
"s"
][
"user"
][
"default_group"
];
}
else
{
// Get the group-id from the data itself
$client_group_id
=
$this
->
dataRecord
[
'client_group_id'
];
}
/* get the name of the client */
$tmp
=
$app
->
db
->
queryOneRecord
(
"SELECT name FROM sys_group WHERE groupid = "
.
$client_group_id
);
$clientName
=
$tmp
[
'name'
];
if
(
$clientName
==
""
)
$clientName
=
'default'
;
$clientName
=
convertClientName
(
$clientName
);
$restriction
=
str_replace
(
'[CLIENTNAME]'
,
$clientName
,
$restriction
);
/* restrict the names */
$this
->
dataRecord
[
'database_name'
]
=
$restriction
.
$this
->
dataRecord
[
'database_name'
];
$this
->
dataRecord
[
'database_user'
]
=
$restriction
.
$this
->
dataRecord
[
'database_user'
];
}
//* Get the database name and database user prefix
$app
->
uses
(
'getconf'
);
$global_config
=
$app
->
getconf
->
get_global_config
(
'sites'
);
$dbname_prefix
=
(
$global_config
[
'dbname_prefix'
]
==
''
)
?
''
:
str_replace
(
'[CLIENTNAME]'
,
$this
->
getClientName
(),
$global_config
[
'dbname_prefix'
]);
$dbuser_prefix
=
(
$global_config
[
'dbuser_prefix'
]
==
''
)
?
''
:
str_replace
(
'[CLIENTNAME]'
,
$this
->
getClientName
(),
$global_config
[
'dbuser_prefix'
]);
/* restrict the names */
$this
->
dataRecord
[
'database_name'
]
=
$dbname_prefix
.
$this
->
dataRecord
[
'database_name'
];
$this
->
dataRecord
[
'database_user'
]
=
$dbuser_prefix
.
$this
->
dataRecord
[
'database_user'
];
parent
::
onBeforeInsert
();
}
...
...
@@ -358,6 +304,24 @@ class page_action extends tform_actions {
}
}
function
getClientName
()
{
global
$app
,
$conf
;
if
(
$_SESSION
[
"s"
][
"user"
][
"typ"
]
!=
'admin'
)
{
// Get the group-id of the user
$client_group_id
=
$_SESSION
[
"s"
][
"user"
][
"default_group"
];
}
else
{
// Get the group-id from the data itself
$client_group_id
=
$this
->
dataRecord
[
'client_group_id'
];
}
/* get the name of the client */
$tmp
=
$app
->
db
->
queryOneRecord
(
"SELECT name FROM sys_group WHERE groupid = "
.
$client_group_id
);
$clientName
=
$tmp
[
'name'
];
if
(
$clientName
==
""
)
$clientName
=
'default'
;
$clientName
=
convertClientName
(
$clientName
);
}
}
...
...
interface/web/sites/ftp_user_edit.php
View file @
db5aa62b
...
...
@@ -79,38 +79,20 @@ class page_action extends tform_actions {
* If the names are restricted -> remove the restriction, so that the
* data can be edited
*/
if
(
$interfaceConf
[
'restrict_names'
]
==
true
){
/* get the restriction */
$restriction
=
'[CLIENTNAME]_'
;
if
(
isset
(
$interfaceConf
[
'restrict_ftpuser'
]))
$restriction
=
$interfaceConf
[
'restrict_ftpuser'
];
$tmplRestriction
=
$restriction
;
/* Get the group-id */
if
(
$_SESSION
[
"s"
][
"user"
][
"typ"
]
!=
'admin'
)
{
// Get the group-id of the user
$client_group_id
=
$_SESSION
[
"s"
][
"user"
][
"default_group"
];
}
else
{
// Get the group-id from the data itself
$web
=
$app
->
db
->
queryOneRecord
(
"SELECT sys_groupid FROM web_domain WHERE domain_id = "
.
intval
(
$this
->
dataRecord
[
"parent_domain_id"
]));
$client_group_id
=
$web
[
'sys_groupid'
];
}
/* get the name of the client */
$tmp
=
$app
->
db
->
queryOneRecord
(
"SELECT name FROM sys_group WHERE groupid = "
.
$client_group_id
);
$clientName
=
$tmp
[
'name'
];
if
(
$clientName
==
""
)
$clientName
=
'default'
;
$clientName
=
convertClientName
(
$clientName
);
$restriction
=
str_replace
(
'[CLIENTNAME]'
,
$clientName
,
$restriction
);
if
(
$this
->
dataRecord
[
'username'
]
!=
""
){
/* REMOVE the restriction */
$app
->
tpl
->
setVar
(
"username"
,
str_replace
(
$restriction
,
''
,
$this
->
dataRecord
[
'username'
]));
$app
->
tpl
->
setVar
(
"username"
,
str_replace
(
$restriction
,
''
,
$this
->
dataRecord
[
'username'
]));
}
if
(
$_SESSION
[
"s"
][
"user"
][
"typ"
]
==
'admin'
||
$app
->
auth
->
has_clients
(
$_SESSION
[
's'
][
'user'
][
'userid'
]))
{
$app
->
tpl
->
setVar
(
"username_prefix"
,
$tmplRestriction
);
}
else
{
$app
->
tpl
->
setVar
(
"username_prefix"
,
$restriction
);
}
$app
->
uses
(
'getconf'
);
$global_config
=
$app
->
getconf
->
get_global_config
(
'sites'
);
$ftpuser_prefix
=
(
$global_config
[
'ftpuser_prefix'
]
==
''
)
?
''
:
str_replace
(
'[CLIENTNAME]'
,
$this
->
getClientName
(),
$global_config
[
'ftpuser_prefix'
]);
if
(
$this
->
dataRecord
[
'username'
]
!=
""
){
/* REMOVE the restriction */
$app
->
tpl
->
setVar
(
"username"
,
str_replace
(
$ftpuser_prefix
,
''
,
$this
->
dataRecord
[
'username'
]));
}
if
(
$_SESSION
[
"s"
][
"user"
][
"typ"
]
==
'admin'
||
$app
->
auth
->
has_clients
(
$_SESSION
[
's'
][
'user'
][
'userid'
]))
{
$app
->
tpl
->
setVar
(
"username_prefix"
,
$global_config
[
'ftpuser_prefix'
]);
}
else
{
$app
->
tpl
->
setVar
(
"username_prefix"
,
$ftpuser_prefix
);
}
parent
::
onShowEnd
();
...
...
@@ -130,39 +112,15 @@ class page_action extends tform_actions {
function
onBeforeInsert
()
{
global
$app
,
$conf
,
$interfaceConf
;
$error
=
false
;
/*
* If the names should be restricted -> do it!
*/
if
(
$error
==
false
){
if
(
$interfaceConf
[
'restrict_names'
]
==
true
){
/* get the restriction */
$restriction
=
'[CLIENTNAME]_'
;
if
(
isset
(
$interfaceConf
[
'restrict_ftpuser'
]))
$restriction
=
$interfaceConf
[
'restrict_ftpuser'
];
/* Get the group-id */
if
(
$_SESSION
[
"s"
][
"user"
][
"typ"
]
!=
'admin'
)
{
// Get the group-id of the user
$client_group_id
=
$_SESSION
[
"s"
][
"user"
][
"default_group"
];
}
else
{
// Get the group-id from the data itself
$web
=
$app
->
db
->
queryOneRecord
(
"SELECT sys_groupid FROM web_domain WHERE domain_id = "
.
intval
(
$this
->
dataRecord
[
"parent_domain_id"
]));
$client_group_id
=
$web
[
'sys_groupid'
];
}
/* get the name of the client */
$tmp
=
$app
->
db
->
queryOneRecord
(
"SELECT name FROM sys_group WHERE groupid = "
.
$client_group_id
);
$clientName
=
$tmp
[
'name'
];
if
(
$clientName
==
""
)
$clientName
=
'default'
;
$clientName
=
convertClientName
(
$clientName
);
$restriction
=
str_replace
(
'[CLIENTNAME]'
,
$clientName
,
$restriction
);
/* restrict the names */
$this
->
dataRecord
[
'username'
]
=
$restriction
.
$this
->
dataRecord
[
'username'
];
}
$app
->
uses
(
'getconf'
);
$global_config
=
$app
->
getconf
->
get_global_config
(
'sites'
);
$ftpuser_prefix
=
(
$global_config
[
'ftpuser_prefix'
]
==
''
)
?
''
:
str_replace
(
'[CLIENTNAME]'
,
$this
->
getClientName
(),
$global_config
[
'ftpuser_prefix'
]);
if
(
$app
->
tform
->
errorMessage
==
''
)
{
$this
->
dataRecord
[
'username'
]
=
$ftpuser_prefix
.
$this
->
dataRecord
[
'username'
];
}
parent
::
onBeforeInsert
();
}
...
...
@@ -187,39 +145,17 @@ class page_action extends tform_actions {
function
onBeforeUpdate
()
{
global
$app
,
$conf
,
$interfaceConf
;
$error
=
false
;
/*
* If the names should be restricted -> do it!
*/
if
(
$error
==
false
){
/*
* If the names should be restricted -> do it!
*/
if
(
$interfaceConf
[
'restrict_names'
]
==
true
){
/* get the restriction */
$restriction
=
'[CLIENTNAME]_'
;
if
(
isset
(
$interfaceConf
[
'restrict_dbname'
]))
$restriction
=
$interfaceConf
[
'restrict_dbname'
];
/* Get the group-id */
if
(
$_SESSION
[
"s"
][
"user"
][
"typ"
]
!=
'admin'
)
{
// Get the group-id of the user
$client_group_id
=
$_SESSION
[
"s"
][
"user"
][
"default_group"
];
}
else
{
// Get the group-id from the data itself
$web
=
$app
->
db
->
queryOneRecord
(
"SELECT sys_groupid FROM web_domain WHERE domain_id = "
.
intval
(
$this
->
dataRecord
[
"parent_domain_id"
]));
$client_group_id
=
$web
[
'sys_groupid'
];
}
/* get the name of the client */
$tmp
=
$app
->
db
->
queryOneRecord
(
"SELECT name FROM sys_group WHERE groupid = "
.
$client_group_id
);
$clientName
=
$tmp
[
'name'
];
if
(
$clientName
==
""
)
$clientName
=
'default'
;
$clientName
=
convertClientName
(
$clientName
);
$restriction
=
str_replace
(
'[CLIENTNAME]'
,
$clientName
,
$restriction
);
/* restrict the names */
$this
->
dataRecord
[
'username'
]
=
$restriction
.
$this
->
dataRecord
[
'username'
];
}
$app
->
uses
(
'getconf'
);
$global_config
=
$app
->
getconf
->
get_global_config
(
'sites'
);
$ftpuser_prefix
=
(
$global_config
[
'ftpuser_prefix'
]
==
''
)
?
''
:
str_replace
(
'[CLIENTNAME]'
,
$this
->
getClientName
(),
$global_config
[
'ftpuser_prefix'
]);
/* restrict the names */
if
(
$app
->
tform
->
errorMessage
==
''
)
{
$this
->
dataRecord
[
'username'
]
=
$restriction
.
$this
->
dataRecord
[
'username'
];
}
}
...
...
@@ -229,6 +165,24 @@ class page_action extends tform_actions {
}
function
getClientName
()
{
global
$app
,
$conf
;
if
(
$_SESSION
[
"s"
][
"user"
][
"typ"
]
!=
'admin'
)
{
// Get the group-id of the user
$client_group_id
=
$_SESSION
[
"s"
][
"user"
][
"default_group"
];
}
else
{
// Get the group-id from the data itself
$client_group_id
=
$this
->
dataRecord
[
'client_group_id'
];
}
/* get the name of the client */
$tmp
=
$app
->
db
->
queryOneRecord
(
"SELECT name FROM sys_group WHERE groupid = "
.
$client_group_id
);
$clientName
=
$tmp
[
'name'
];
if
(
$clientName
==
""
)
$clientName
=
'default'
;
$clientName
=
convertClientName
(
$clientName
);
}
}
$page
=
new
page_action
;
...
...
interface/web/sites/shell_user_edit.php
View file @
db5aa62b
...
...
@@ -79,38 +79,19 @@ class page_action extends tform_actions {
* If the names are restricted -> remove the restriction, so that the
* data can be edited
*/
if
(
$interfaceConf
[
'restrict_names'
]
==
true
){
/* get the restriction */
$restriction
=
'[CLIENTNAME]_'
;
if
(
isset
(
$interfaceConf
[
'restrict_shelluser'
]))
$restriction
=
$interfaceConf
[
'restrict_shelluser'
];
$tmplRestriction
=
$restriction
;
/* Get the group-id */
if
(
$_SESSION
[
"s"
][
"user"
][
"typ"
]
!=
'admin'
)
{
// Get the group-id of the user
$client_group_id
=
$_SESSION
[
"s"
][
"user"
][
"default_group"
];
}
else
{
// Get the group-id from the data itself
$web
=
$app
->
db
->
queryOneRecord
(
"SELECT sys_groupid FROM web_domain WHERE domain_id = "
.
intval
(
$this
->
dataRecord
[
"parent_domain_id"
]));
$client_group_id
=
$web
[
'sys_groupid'
];
}
/* get the name of the client */
$tmp
=
$app
->
db
->
queryOneRecord
(
"SELECT name FROM sys_group WHERE groupid = "
.
$client_group_id
);
$clientName
=
$tmp
[
'name'
];
if
(
$clientName
==
""
)
$clientName
=
'default'
;
$clientName
=
convertClientName
(
$clientName
);
$restriction
=
str_replace
(
'[CLIENTNAME]'
,
$clientName
,
$restriction
);
if
(
$this
->
dataRecord
[
'username'
]
!=
""
){
/* REMOVE the restriction */
$app
->
tpl
->
setVar
(
"username"
,
str_replace
(
$restriction
,
''
,
$this
->
dataRecord
[
'username'
]));
$app
->
tpl
->
setVar
(
"username"
,
str_replace
(
$restriction
,
''
,
$this
->
dataRecord
[
'username'
]));
}
if
(
$_SESSION
[
"s"
][
"user"
][
"typ"
]
==
'admin'
||
$app
->
auth
->
has_clients
(
$_SESSION
[
's'
][
'user'
][
'userid'
]))
{
$app
->
tpl
->
setVar
(
"username_prefix"
,
$tmplRestriction
);
}
else
{
$app
->
tpl
->
setVar
(
"username_prefix"
,
$restriction
);
}
$app
->
uses
(
'getconf'
);
$global_config
=
$app
->
getconf
->
get_global_config
(
'sites'
);
$shelluser_prefix
=
(
$global_config
[
'shelluser_prefix'
]
==
''
)
?
''
:
str_replace
(
'[CLIENTNAME]'
,
$this
->
getClientName
(),
$global_config
[
'shelluser_prefix'
]);
if
(
$this
->
dataRecord
[
'username'
]
!=
""
){
/* REMOVE the restriction */
$app
->
tpl
->
setVar
(
"username"
,
str_replace
(
$shelluser_prefix
,
''
,
$this
->
dataRecord
[
'username'
]));
}
if
(
$_SESSION
[
"s"
][
"user"
][
"typ"
]
==
'admin'
||
$app
->
auth
->
has_clients
(
$_SESSION
[
's'
][
'user'
][
'userid'
]))
{
$app
->
tpl
->
setVar
(
"username_prefix"
,
$global_config
[
'shelluser_prefix'
]);
}
else
{
$app
->
tpl
->
setVar
(
"username_prefix"
,
$shelluser_prefix
);
}
parent
::
onShowEnd
();
...
...
@@ -131,13 +112,11 @@ class page_action extends tform_actions {
function
onBeforeInsert
()
{
global
$app
,
$conf
,
$interfaceConf
;
$error
=
false
;
// check if the username is not blacklisted
$blacklist
=
file
(
ISPC_LIB_PATH
.
'/shelluser_blacklist'
);
foreach
(
$blacklist
as
$line
)
{
if
(
strtolower
(
trim
(
$line
))
==
strtolower
(
trim
(
$this
->
dataRecord
[
'username'
]))){
$app
->
tform
->
errorMessage
.
=
'The username is not allowed.'
;
$error
=
true
;
}
}
unset
(
$blacklist
);
...
...
@@ -145,32 +124,14 @@ class page_action extends tform_actions {
/*
* If the names should be restricted -> do it!
*/
if
(
$error
==
false
){
if
(
$interfaceConf
[
'restrict_names'
]
==
true
){
/* get the restriction */
$restriction
=
'[CLIENTNAME]_'
;
if
(
isset
(
$interfaceConf
[
'restrict_shelluser'
]))
$restriction
=
$interfaceConf
[
'restrict_shelluser'
];
/* Get the group-id */
if
(
$_SESSION
[
"s"
][
"user"
][
"typ"
]
!=
'admin'
)
{
// Get the group-id of the user
$client_group_id
=
$_SESSION
[
"s"
][
"user"
][
"default_group"
];
}
else
{
// Get the group-id from the data itself
$web
=
$app
->
db
->
queryOneRecord
(
"SELECT sys_groupid FROM web_domain WHERE domain_id = "
.
intval
(
$this
->
dataRecord
[
"parent_domain_id"
]));
$client_group_id
=
$web
[
'sys_groupid'
];
}
/* get the name of the client */
$tmp
=
$app
->
db
->
queryOneRecord
(
"SELECT name FROM sys_group WHERE groupid = "
.
$client_group_id
);
$clientName
=
$tmp
[
'name'
];
if
(
$clientName
==
""
)
$clientName
=
'default'
;
$clientName
=
convertClientName
(
$clientName
);
$restriction
=
str_replace
(
'[CLIENTNAME]'
,
$clientName
,
$restriction
);
/* restrict the names */
$this
->
dataRecord
[
'username'
]
=
$restriction
.
$this
->
dataRecord
[
'username'
];
}
if
(
$app
->
tform
->
errorMessage
==
''
){
$app
->
uses
(
'getconf'
);
$global_config
=
$app
->
getconf
->
get_global_config
(
'sites'
);
$shelluser_prefix
=
(
$global_config
[
'shelluser_prefix'
]
==
''
)
?
''
:
str_replace
(
'[CLIENTNAME]'
,
$this
->
getClientName
(),
$global_config
[
'shelluser_prefix'
]);
/* restrict the names */
$this
->
dataRecord
[
'username'
]
=
$shelluser_prefix
.
$this
->
dataRecord
[
'username'
];
}
parent
::
onBeforeInsert
();
}
...
...
@@ -195,13 +156,11 @@ class page_action extends tform_actions {
function
onBeforeUpdate
()
{
global
$app
,
$conf
,
$interfaceConf
;
$error
=
false
;
// check if the username is not blacklisted
$blacklist
=
file
(
ISPC_LIB_PATH
.
'/shelluser_blacklist'
);
foreach
(
$blacklist
as
$line
)
{