Skip to content

Commit be9816e

Browse files
author
redray
committed
1 parent e51e75b commit be9816e

File tree

9 files changed

+36
-3
lines changed

9 files changed

+36
-3
lines changed

install/sql/ispconfig3.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,7 @@ CREATE TABLE `web_database` (
10411041
`database_name` varchar(255) default NULL,
10421042
`database_user` varchar(255) default NULL,
10431043
`database_password` varchar(255) default NULL,
1044+
`database_charset` varchar(64) default NULL,
10441045
`remote_access` varchar(255) NOT NULL default 'y',
10451046
`active` varchar(255) NOT NULL default 'y',
10461047
PRIMARY KEY (`database_id`)

interface/web/sites/database_edit.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,14 @@ function onSubmit() {
192192
function onUpdate() {
193193
global $app, $conf;
194194

195-
//* Prevent that the database name is changed
195+
//* Prevent that the database name and charset is changed
196196
$old_record = $app->tform->getDataRecord($this->id);
197197
if($old_record["database_name"] != $this->dataRecord["database_name"]) {
198198
$app->tform->errorMessage .= $app->tform->wordbook["database_name_change_txt"].'<br />';
199199
}
200+
if($old_record["database_charset"] != $this->dataRecord["database_charset"]) {
201+
$app->tform->errorMessage .= $app->tform->wordbook["database_charset_change_txt"].'<br />';
202+
}
200203
unset($old_record);
201204

202205
parent::onUpdate();

interface/web/sites/form/database.tform.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@
115115
'width' => '30',
116116
'maxlength' => '255'
117117
),
118+
'database_charset' => array (
119+
'datatype' => 'VARCHAR',
120+
'formtype' => 'SELECT',
121+
'default' => 'y',
122+
'value' => array('' => 'MySQL Default','latin1' => 'Latin 1','utf8' => 'UTF-8')
123+
),
118124
'remote_access' => array (
119125
'datatype' => 'VARCHAR',
120126
'formtype' => 'CHECKBOX',

interface/web/sites/lib/lang/de_database.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ $wb['type_txt'] = 'Type';
44
$wb['database_name_txt'] = 'Database name';
55
$wb['database_user_txt'] = 'Database user';
66
$wb['database_password_txt'] = 'Database password';
7+
$wb["database_charset_txt"] = 'Database charset';
78
$wb['remote_access_txt'] = 'Remote Access';
89
$wb['client_txt'] = 'Client';
910
$wb['active_txt'] = 'Active';
@@ -17,4 +18,5 @@ $wb['database_user_error_unique'] = 'There is already a database user with this
1718
$wb['database_user_error_regex'] = 'Invalid database user name. The username may contain these characters: a-z, A-Z, 0-9 and the underscore. Length: 2 - 64 characters.';
1819
$wb['limit_database_txt'] = 'The max. number of databases is reached.';
1920
$wb['database_name_change_txt'] = 'The database name can not be changed';
21+
$wb["database_charset_change_txt"] = 'The database charset can not be changed';
2022
?>

interface/web/sites/lib/lang/en_database.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ $wb["type_txt"] = 'Type';
44
$wb["database_name_txt"] = 'Database name';
55
$wb["database_user_txt"] = 'Database user';
66
$wb["database_password_txt"] = 'Database password';
7+
$wb["database_charset_txt"] = 'Database charset';
78
$wb["remote_access_txt"] = 'Remote Access';
89
$wb["client_txt"] = 'Client';
910
$wb["active_txt"] = 'Active';
@@ -17,4 +18,5 @@ $wb["database_user_error_unique"] = 'There is already a database user with this
1718
$wb["database_user_error_regex"] = 'Invalid database user name. The username may contain these characters: a-z, A-Z, 0-9 and the underscore. Length: 2 - 64 characters.';
1819
$wb["limit_database_txt"] = 'The max. number of databases is reached.';
1920
$wb["database_name_change_txt"] = 'The database name can not be changed';
21+
$wb["database_charset_change_txt"] = 'The database charset can not be changed';
2022
?>

interface/web/sites/lib/lang/nl_database.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ $wb["type_txt"] = 'Type';
44
$wb["database_name_txt"] = 'Databasenaam';
55
$wb["database_user_txt"] = 'Database gebruiker';
66
$wb["database_password_txt"] = 'Database wachtwoord';
7+
$wb["database_charset_txt"] = 'Database charset';
78
$wb["remote_access_txt"] = 'Remote Access';
89
$wb["client_txt"] = 'Klant';
910
$wb["active_txt"] = 'Actief';
@@ -17,4 +18,5 @@ $wb["database_user_error_unique"] = 'Er bestaat al een database gebruiker met de
1718
$wb["database_user_error_regex"] = 'Ongeldige database gebruikersnaam. De gebruikersnaam bevat deze karakters: a-z, A-Z, 0-9 en de underscore. Lengte: 2 - 64 karakters.';
1819
$wb["limit_database_txt"] = 'The max. aantal databases is bereikt.';
1920
$wb["database_name_change_txt"] = 'De databasenaam kan niet worden gewijzigd.';
21+
$wb["database_charset_change_txt"] = 'The database charset can not be changed';
2022
?>

interface/web/sites/lib/lang/ru_database.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ $wb["type_txt"] = 'Тип';
44
$wb["database_name_txt"] = 'Database name';
55
$wb["database_user_txt"] = 'Database user';
66
$wb["database_password_txt"] = 'Database password';
7+
$wb["database_charset_txt"] = 'Database charset';
78
$wb["remote_access_txt"] = 'Remote Access';
89
$wb["client_txt"] = 'Client';
910
$wb["active_txt"] = 'Активный';
@@ -17,4 +18,5 @@ $wb["database_user_error_unique"] = 'There is already a database user with this
1718
$wb["database_user_error_regex"] = 'Invalid database user name. The username may contain these characters: a-z, A-Z, 0-9 and the underscore. Length: 2 - 64 characters.';
1819
$wb["limit_database_txt"] = 'The max. number of databases is reached.';
1920
$wb["database_name_change_txt"] = 'The database name can not be changed';
21+
$wb["database_charset_change_txt"] = 'The database charset can not be changed';
2022
?>

interface/web/sites/templates/database_edit.htm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@
4747
<td class="frmText11">{tmpl_var name='database_password_txt'}:</td>
4848
<td class="frmText11"><input name="database_password" type="password" class="text" value="{tmpl_var name='database_password'}" size="30" maxlength="255"></td>
4949
</tr>
50+
<tr>
51+
<td class="frmText11">{tmpl_var name='database_charset_txt'}:</td>
52+
<td class="frmText11">
53+
<select name="database_charset" class="text">
54+
{tmpl_var name='database_charset'}
55+
</select>
56+
</td>
57+
</tr>
5058
<tr>
5159
<td class="frmText11">{tmpl_var name='remote_access_txt'}:</td>
5260
<td class="frmText11">{tmpl_var name='remote_access'}</td>

server/plugins-available/mysql_clientdb_plugin.inc.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,16 @@ function db_insert($event_name,$data) {
6969
$app->log('Unable to connect to the database'.mysql_error($link),LOGLEVEL_ERROR);
7070
return;
7171
}
72-
72+
73+
// Charset for the new table
74+
if($data["new"]["database_charset"] != '') {
75+
$query_charset_table = ' DEFAULT CHARACTER SET '.$data["new"]["database_charset"];
76+
} else {
77+
$query_charset_table = '';
78+
}
79+
7380
//* Create the new database
74-
if (mysql_query('CREATE DATABASE '.mysql_real_escape_string($data["new"]["database_name"]),$link)) {
81+
if (mysql_query('CREATE DATABASE '.mysql_real_escape_string($data["new"]["database_name"]).$query_charset_table,$link)) {
7582
$app->log('Created MySQL database: '.$data["new"]["database_name"],LOGLEVEL_DEBUG);
7683
} else {
7784
$app->log('Unable to connect to the database'.mysql_error($link),LOGLEVEL_ERROR);

0 commit comments

Comments
 (0)