Subversion Repositories oidplus

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. <div id="DBPLUGIN_PARAMS_MySQL">
  2.         <p>MySQL hostname and port:<br><input id="mysql_host" type="text" value="localhost:3306" onkeypress="rebuild()" onkeyup="rebuild()">  <span id="mysql_host_warn"></p>
  3.         <p>MySQL username:<br><input id="mysql_username" type="text" onkeypress="rebuild()" onkeyup="rebuild()"> <span id="mysql_username_warn"></p>
  4.         <p>MySQL password:<br><input id="mysql_password" type="password" autocomplete="new-password" onkeypress="rebuild()" onkeyup="rebuild()"></p>
  5.         <p>MySQL database name:<br><input id="mysql_database" type="text" onkeypress="rebuild()" onkeyup="rebuild()"> <span id="mysql_database_warn"></p>
  6. </div>
  7. <script>
  8. plugin_combobox_change_callbacks.push(function(strPlugin) {
  9.         document.getElementById('DBPLUGIN_PARAMS_MySQL').style.display = (strPlugin == 'MySQL') ? "Block" : "None";
  10. });
  11. rebuild_callbacks.push(function() {
  12.         var e = document.getElementById("db_plugin");
  13.         var strPlugin = e.options[e.selectedIndex].value;
  14.         if (strPlugin != 'MySQL') return true;
  15.  
  16.         document.getElementById('struct_cli_1').innerHTML = '';
  17.         document.getElementById('struct_cli_2').innerHTML = '';
  18.         document.getElementById('struct_1').href = 'struct_empty.sql.php';
  19.         document.getElementById('struct_2').href = 'struct_with_examples.sql.php';
  20.  
  21.         error = false;
  22.  
  23.         // Check 1: host must not be empty
  24.         if (document.getElementById('mysql_host').value.length == 0)
  25.         {
  26.                 document.getElementById('mysql_host_warn').innerHTML = '<font color="red">Please specify a host name!</font>';
  27.                 document.getElementById('config').innerHTML = '<b>&lt?php</b><br><br><i>// ERROR: Please specify a host name!</i>';
  28.                 error = true;
  29.         } else {
  30.                 document.getElementById('mysql_host_warn').innerHTML = '';
  31.         }
  32.  
  33.         // Check 2: Username must not be empty
  34.         if (document.getElementById('mysql_username').value.length == 0)
  35.         {
  36.                 document.getElementById('mysql_username_warn').innerHTML = '<font color="red">Please specify a username!</font>';
  37.                 document.getElementById('config').innerHTML = '<b>&lt?php</b><br><br><i>// ERROR: Please specify a username!</i>';
  38.                 error = true;
  39.         } else {
  40.                 document.getElementById('mysql_username_warn').innerHTML = '';
  41.         }
  42.  
  43.         // Check 3: Database name must not be empty
  44.         if (document.getElementById('mysql_database').value.length == 0)
  45.         {
  46.                 document.getElementById('mysql_database_warn').innerHTML = '<font color="red">Please specify a database name!</font>';
  47.                 document.getElementById('config').innerHTML = '<b>&lt?php</b><br><br><i>// ERROR: Please specify a database name!</i>';
  48.                 error = true;
  49.         } else {
  50.                 document.getElementById('mysql_database_warn').innerHTML = '';
  51.         }
  52.  
  53.         document.getElementById('struct_cli_1').innerHTML = '<br>or via command line:<br><code>curl -s "'+owndir+'struct_empty.sql.php?plugin=mysql&prefix='+encodeURI(document.getElementById('tablename_prefix').value)+'&database='+encodeURI(document.getElementById('mysql_database').value)+'" | mysql -u '+document.getElementById('mysql_username').value+' -p</code>';
  54.         document.getElementById('struct_cli_2').innerHTML = '<br>or via command line:<br><code>curl -s "'+owndir+'struct_with_examples.sql.php?plugin=mysql&prefix='+encodeURI(document.getElementById('tablename_prefix').value)+'&database='+encodeURI(document.getElementById('mysql_database').value)+' | mysql -u '+document.getElementById('mysql_username').value+' -p</code>';
  55.         document.getElementById('struct_1').href = owndir+'struct_empty.sql.php?plugin=mysql&prefix='+encodeURI(document.getElementById('tablename_prefix').value)+'&database='+encodeURI(document.getElementById('mysql_database').value);
  56.         document.getElementById('struct_2').href = owndir+'struct_with_examples.sql.php?plugin=mysql&prefix='+encodeURI(document.getElementById('tablename_prefix').value)+'&database='+encodeURI(document.getElementById('mysql_database').value);
  57.  
  58.         return !error;
  59. });
  60. rebuild_config_callbacks.push(function() {
  61.         var e = document.getElementById("db_plugin");
  62.         var strPlugin = e.options[e.selectedIndex].value;
  63.         if (strPlugin != 'MySQL') return '';
  64.  
  65.         return '<b>define</b>(\'OIDPLUS_MYSQL_HOST\',       \''+document.getElementById('mysql_host').value+'\');<br>' +
  66.                '<b>define</b>(\'OIDPLUS_MYSQL_USERNAME\',   \''+document.getElementById('mysql_username').value+'\');<br>' +
  67.                '<b>define</b>(\'OIDPLUS_MYSQL_PASSWORD\',   \''+b64EncodeUnicode(document.getElementById('mysql_password').value)+'\'); // base64 encoded<br>' +
  68.                '<b>define</b>(\'OIDPLUS_MYSQL_DATABASE\',   \''+document.getElementById('mysql_database').value+'\');<br>';
  69. });
  70. </script>
  71.