Rev 424 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 424 | Rev 511 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * OIDplus 2.0 |
2 | * OIDplus 2.0 |
3 | * Copyright 2019 Daniel Marschall, ViaThinkSoft |
3 | * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft |
4 | * |
4 | * |
5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | * you may not use this file except in compliance with the License. |
6 | * you may not use this file except in compliance with the License. |
7 | * You may obtain a copy of the License at |
7 | * You may obtain a copy of the License at |
8 | * |
8 | * |
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | * |
10 | * |
11 | * Unless required by applicable law or agreed to in writing, software |
11 | * Unless required by applicable law or agreed to in writing, software |
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | * See the License for the specific language governing permissions and |
14 | * See the License for the specific language governing permissions and |
15 | * limitations under the License. |
15 | * limitations under the License. |
16 | */ |
16 | */ |
17 | 17 | ||
18 | plugin_combobox_change_callbacks.push(function(strPlugin) { |
18 | plugin_combobox_change_callbacks.push(function(strPlugin) { |
19 | document.getElementById('DBPLUGIN_PARAMS_MySQL').style.display = (strPlugin == 'MySQL') ? "Block" : "None"; |
19 | document.getElementById('DBPLUGIN_PARAMS_MySQL').style.display = (strPlugin == 'MySQL') ? "Block" : "None"; |
20 | }); |
20 | }); |
21 | 21 | ||
22 | rebuild_callbacks.push(function() { |
22 | rebuild_callbacks.push(function() { |
23 | var e = document.getElementById("db_plugin"); |
23 | var e = document.getElementById("db_plugin"); |
24 | var strPlugin = e.options[e.selectedIndex].value; |
24 | var strPlugin = e.options[e.selectedIndex].value; |
25 | if (strPlugin != 'MySQL') return true; |
25 | if (strPlugin != 'MySQL') return true; |
26 | 26 | ||
27 | document.getElementById('struct_cli_1').innerHTML = ''; |
27 | document.getElementById('struct_cli_1').innerHTML = ''; |
28 | document.getElementById('struct_cli_2').innerHTML = ''; |
28 | document.getElementById('struct_cli_2').innerHTML = ''; |
29 | document.getElementById('struct_1').href = 'struct_empty.sql.php'; |
29 | document.getElementById('struct_1').href = 'struct_empty.sql.php'; |
30 | document.getElementById('struct_2').href = 'struct_with_examples.sql.php'; |
30 | document.getElementById('struct_2').href = 'struct_with_examples.sql.php'; |
31 | 31 | ||
32 | error = false; |
32 | error = false; |
33 | 33 | ||
34 | // Check 1: host must not be empty |
34 | // Check 1: host must not be empty |
35 | if (document.getElementById('mysql_host').value.length == 0) |
35 | if (document.getElementById('mysql_host').value.length == 0) |
36 | { |
36 | { |
37 | document.getElementById('mysql_host_warn').innerHTML = '<font color="red">'+_L('Please specify a host name!')+'</font>'; |
37 | document.getElementById('mysql_host_warn').innerHTML = '<font color="red">'+_L('Please specify a host name!')+'</font>'; |
38 | document.getElementById('config').innerHTML = '<b><?php</b><br><br><i>// ERROR: Please specify a host name!</i>'; // do not translate |
38 | document.getElementById('config').innerHTML = '<b><?php</b><br><br><i>// ERROR: Please specify a host name!</i>'; // do not translate |
39 | error = true; |
39 | error = true; |
40 | } else { |
40 | } else { |
41 | document.getElementById('mysql_host_warn').innerHTML = ''; |
41 | document.getElementById('mysql_host_warn').innerHTML = ''; |
42 | } |
42 | } |
43 | 43 | ||
44 | // Check 2: Username must not be empty |
44 | // Check 2: Username must not be empty |
45 | if (document.getElementById('mysql_username').value.length == 0) |
45 | if (document.getElementById('mysql_username').value.length == 0) |
46 | { |
46 | { |
47 | document.getElementById('mysql_username_warn').innerHTML = '<font color="red">'+_L('Please specify a username!')+'</font>'; |
47 | document.getElementById('mysql_username_warn').innerHTML = '<font color="red">'+_L('Please specify a username!')+'</font>'; |
48 | document.getElementById('config').innerHTML = '<b><?php</b><br><br><i>// ERROR: Please specify a username!</i>'; // do not translate |
48 | document.getElementById('config').innerHTML = '<b><?php</b><br><br><i>// ERROR: Please specify a username!</i>'; // do not translate |
49 | error = true; |
49 | error = true; |
50 | } else { |
50 | } else { |
51 | document.getElementById('mysql_username_warn').innerHTML = ''; |
51 | document.getElementById('mysql_username_warn').innerHTML = ''; |
52 | } |
52 | } |
53 | 53 | ||
54 | // Check 3: Database name must not be empty |
54 | // Check 3: Database name must not be empty |
55 | if (document.getElementById('mysql_database').value.length == 0) |
55 | if (document.getElementById('mysql_database').value.length == 0) |
56 | { |
56 | { |
57 | document.getElementById('mysql_database_warn').innerHTML = '<font color="red">'+_L('Please specify a database name!')+'</font>'; |
57 | document.getElementById('mysql_database_warn').innerHTML = '<font color="red">'+_L('Please specify a database name!')+'</font>'; |
58 | document.getElementById('config').innerHTML = '<b><?php</b><br><br><i>// ERROR: Please specify a database name!</i>'; // do not translate |
58 | document.getElementById('config').innerHTML = '<b><?php</b><br><br><i>// ERROR: Please specify a database name!</i>'; // do not translate |
59 | error = true; |
59 | error = true; |
60 | } else { |
60 | } else { |
61 | document.getElementById('mysql_database_warn').innerHTML = ''; |
61 | document.getElementById('mysql_database_warn').innerHTML = ''; |
62 | } |
62 | } |
63 | 63 | ||
64 | document.getElementById('struct_1').href = setupdir+'struct_empty.sql.php?plugin=mysql&prefix='+encodeURI(document.getElementById('tablename_prefix').value)+'&database='+encodeURI(document.getElementById('mysql_database').value)+'&slang=mysql'; |
64 | document.getElementById('struct_1').href = setupdir+'struct_empty.sql.php?plugin=mysql&prefix='+encodeURI(document.getElementById('tablename_prefix').value)+'&database='+encodeURI(document.getElementById('mysql_database').value)+'&slang=mysql'; |
65 | document.getElementById('struct_2').href = setupdir+'struct_with_examples.sql.php?plugin=mysql&prefix='+encodeURI(document.getElementById('tablename_prefix').value)+'&database='+encodeURI(document.getElementById('mysql_database').value)+'&slang=mysql'; |
65 | document.getElementById('struct_2').href = setupdir+'struct_with_examples.sql.php?plugin=mysql&prefix='+encodeURI(document.getElementById('tablename_prefix').value)+'&database='+encodeURI(document.getElementById('mysql_database').value)+'&slang=mysql'; |
66 | document.getElementById('struct_cli_1').innerHTML = '<br>'+_L('or via command line:')+'<br><code>curl -s "'+document.getElementById('struct_1').href+'" | mysql -u '+document.getElementById('mysql_username').value+' -p</code>'; |
66 | document.getElementById('struct_cli_1').innerHTML = '<br>'+_L('or via command line:')+'<br><code>curl -s "'+document.getElementById('struct_1').href+'" | mysql -u '+document.getElementById('mysql_username').value+' -p</code>'; |
67 | document.getElementById('struct_cli_2').innerHTML = '<br>'+_L('or via command line:')+'<br><code>curl -s "'+document.getElementById('struct_2').href+'" | mysql -u '+document.getElementById('mysql_username').value+' -p</code>'; |
67 | document.getElementById('struct_cli_2').innerHTML = '<br>'+_L('or via command line:')+'<br><code>curl -s "'+document.getElementById('struct_2').href+'" | mysql -u '+document.getElementById('mysql_username').value+' -p</code>'; |
68 | 68 | ||
69 | return !error; |
69 | return !error; |
70 | }); |
70 | }); |
71 | 71 | ||
72 | rebuild_config_callbacks.push(function() { |
72 | rebuild_config_callbacks.push(function() { |
73 | var e = document.getElementById("db_plugin"); |
73 | var e = document.getElementById("db_plugin"); |
74 | var strPlugin = e.options[e.selectedIndex].value; |
74 | var strPlugin = e.options[e.selectedIndex].value; |
75 | if (strPlugin != 'MySQL') return ''; |
75 | if (strPlugin != 'MySQL') return ''; |
76 | 76 | ||
77 | return 'OIDplus::baseConfig()->setValue(\'MYSQL_HOST\', \''+document.getElementById('mysql_host').value+'\');<br>' + |
77 | return 'OIDplus::baseConfig()->setValue(\'MYSQL_HOST\', \''+document.getElementById('mysql_host').value+'\');<br>' + |
78 | 'OIDplus::baseConfig()->setValue(\'MYSQL_USERNAME\', \''+document.getElementById('mysql_username').value+'\');<br>' + |
78 | 'OIDplus::baseConfig()->setValue(\'MYSQL_USERNAME\', \''+document.getElementById('mysql_username').value+'\');<br>' + |
79 | 'OIDplus::baseConfig()->setValue(\'MYSQL_PASSWORD\', base64_decode(\''+b64EncodeUnicode(document.getElementById('mysql_password').value)+'\'));<br>' + |
79 | 'OIDplus::baseConfig()->setValue(\'MYSQL_PASSWORD\', base64_decode(\''+b64EncodeUnicode(document.getElementById('mysql_password').value)+'\'));<br>' + |
80 | 'OIDplus::baseConfig()->setValue(\'MYSQL_DATABASE\', \''+document.getElementById('mysql_database').value+'\');<br>'; |
80 | 'OIDplus::baseConfig()->setValue(\'MYSQL_DATABASE\', \''+document.getElementById('mysql_database').value+'\');<br>'; |
81 | }); |
81 | }); |
82 | 82 |