Subversion Repositories oidplus

Rev

Rev 502 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 502 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_ODBC').style.display = (strPlugin == 'ODBC') ? "Block" : "None";
19
        document.getElementById('DBPLUGIN_PARAMS_ODBC').style.display = (strPlugin == 'ODBC') ? "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 != 'ODBC') return true;
25
        if (strPlugin != 'ODBC') 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: dsn must not be empty
34
        // Check 1: dsn must not be empty
35
        if (document.getElementById('odbc_dsn').value.length == 0)
35
        if (document.getElementById('odbc_dsn').value.length == 0)
36
        {
36
        {
37
                document.getElementById('odbc_dsn_warn').innerHTML = '<font color="red">'+_L('Please specify a DSN!')+'</font>';
37
                document.getElementById('odbc_dsn_warn').innerHTML = '<font color="red">'+_L('Please specify a DSN!')+'</font>';
38
                document.getElementById('config').innerHTML = '<b>&lt?php</b><br><br><i>// ERROR: Please specify a DSN!</i>'; // do not translate
38
                document.getElementById('config').innerHTML = '<b>&lt?php</b><br><br><i>// ERROR: Please specify a DSN!</i>'; // do not translate
39
                error = true;
39
                error = true;
40
        } else {
40
        } else {
41
                document.getElementById('odbc_dsn_warn').innerHTML = '';
41
                document.getElementById('odbc_dsn_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('odbc_username').value.length == 0)
45
        if (document.getElementById('odbc_username').value.length == 0)
46
        {
46
        {
47
                document.getElementById('odbc_username_warn').innerHTML = '<font color="red">'+_L('Please specify a username!')+'</font>';
47
                document.getElementById('odbc_username_warn').innerHTML = '<font color="red">'+_L('Please specify a username!')+'</font>';
48
                document.getElementById('config').innerHTML = '<b>&lt?php</b><br><br><i>// ERROR: Please specify a username!</i>'; // do not translate
48
                document.getElementById('config').innerHTML = '<b>&lt?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('odbc_username_warn').innerHTML = '';
51
                document.getElementById('odbc_username_warn').innerHTML = '';
52
        }
52
        }
53
 
53
 
54
        document.getElementById('struct_1').href = setupdir+'struct_empty.sql.php?plugin=odbc&prefix='+encodeURI(document.getElementById('tablename_prefix').value)+'&slang='+encodeURI(document.getElementById('odbc_slang').value);
54
        document.getElementById('struct_1').href = setupdir+'struct_empty.sql.php?plugin=odbc&prefix='+encodeURI(document.getElementById('tablename_prefix').value)+'&slang='+encodeURI(document.getElementById('odbc_slang').value);
55
        document.getElementById('struct_2').href = setupdir+'struct_with_examples.sql.php?plugin=odbc&prefix='+encodeURI(document.getElementById('tablename_prefix').value)+'&slang='+encodeURI(document.getElementById('odbc_slang').value);
55
        document.getElementById('struct_2').href = setupdir+'struct_with_examples.sql.php?plugin=odbc&prefix='+encodeURI(document.getElementById('tablename_prefix').value)+'&slang='+encodeURI(document.getElementById('odbc_slang').value);
56
        if (document.getElementById('odbc_slang').value == 'mysql') {
56
        if (document.getElementById('odbc_slang').value == 'mysql') {
57
                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('odbc_username').value+' -p</code>';
57
                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('odbc_username').value+' -p</code>';
58
                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('odbc_username').value+' -p</code>';
58
                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('odbc_username').value+' -p</code>';
59
        } else if (document.getElementById('odbc_slang').value == 'pgsql') {
59
        } else if (document.getElementById('odbc_slang').value == 'pgsql') {
60
                document.getElementById('struct_cli_1').innerHTML = '<br>'+_L('or via command line:')+'<br><code>curl -s "'+document.getElementById('struct_1').href+'" | psql -h <font color="red">localhost</font> -U '+document.getElementById('odbc_username').value+' -d <font color="red">oidplus</font> -a</code>';
60
                document.getElementById('struct_cli_1').innerHTML = '<br>'+_L('or via command line:')+'<br><code>curl -s "'+document.getElementById('struct_1').href+'" | psql -h <font color="red">localhost</font> -U '+document.getElementById('odbc_username').value+' -d <font color="red">oidplus</font> -a</code>';
61
                document.getElementById('struct_cli_2').innerHTML = '<br>'+_L('or via command line:')+'<br><code>curl -s "'+document.getElementById('struct_2').href+'" | psql -h <font color="red">localhost</font> -U '+document.getElementById('odbc_username').value+' -d <font color="red">oidplus</font> -a</code>';
61
                document.getElementById('struct_cli_2').innerHTML = '<br>'+_L('or via command line:')+'<br><code>curl -s "'+document.getElementById('struct_2').href+'" | psql -h <font color="red">localhost</font> -U '+document.getElementById('odbc_username').value+' -d <font color="red">oidplus</font> -a</code>';
62
        } else {
62
        } else {
63
                document.getElementById('struct_cli_1').innerHTML = '';
63
                document.getElementById('struct_cli_1').innerHTML = '';
64
                document.getElementById('struct_cli_2').innerHTML = '';
64
                document.getElementById('struct_cli_2').innerHTML = '';
65
        }
65
        }
66
 
66
 
67
        return !error;
67
        return !error;
68
});
68
});
69
 
69
 
70
rebuild_config_callbacks.push(function() {
70
rebuild_config_callbacks.push(function() {
71
        var e = document.getElementById("db_plugin");
71
        var e = document.getElementById("db_plugin");
72
        var strPlugin = e.options[e.selectedIndex].value;
72
        var strPlugin = e.options[e.selectedIndex].value;
73
        if (strPlugin != 'ODBC') return '';
73
        if (strPlugin != 'ODBC') return '';
74
 
74
 
75
        return 'OIDplus::baseConfig()->setValue(\'ODBC_DSN\',          \''+document.getElementById('odbc_dsn').value+'\');<br>' +
75
        return 'OIDplus::baseConfig()->setValue(\'ODBC_DSN\',          \''+document.getElementById('odbc_dsn').value+'\');<br>' +
76
               'OIDplus::baseConfig()->setValue(\'ODBC_USERNAME\',     \''+document.getElementById('odbc_username').value+'\');<br>' +
76
               'OIDplus::baseConfig()->setValue(\'ODBC_USERNAME\',     \''+document.getElementById('odbc_username').value+'\');<br>' +
77
               'OIDplus::baseConfig()->setValue(\'ODBC_PASSWORD\',     base64_decode(\''+b64EncodeUnicode(document.getElementById('odbc_password').value)+'\'));<br>' +
77
               'OIDplus::baseConfig()->setValue(\'ODBC_PASSWORD\',     base64_decode(\''+b64EncodeUnicode(document.getElementById('odbc_password').value)+'\'));<br>' +
78
               'OIDplus::baseConfig()->setValue(\'FORCE_DBMS_SLANG\',  \''+document.getElementById('odbc_slang').value+'\');<br>'; // optional
78
               'OIDplus::baseConfig()->setValue(\'FORCE_DBMS_SLANG\',  \''+document.getElementById('odbc_slang').value+'\');<br>'; // optional
79
});
79
});
80
 
80