db-pref.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. # ***** BEGIN LICENSE BLOCK *****
  3. # This file is part of DotClear.
  4. # Copyright (c) 2004 Olivier Meunier and contributors. All rights
  5. # reserved.
  6. #
  7. # DotClear is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # DotClear is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with DotClear; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. #
  21. # ***** END LICENSE BLOCK *****
  22. define('STEP',3);
  23. require dirname(__FILE__).'/prepend.php';
  24. $db_host = '';
  25. $db_user = '';
  26. $db_pass = '';
  27. $db_name = '';
  28. $db_prefix = 'dc_';
  29. $err = '';
  30. if (!empty($_POST['check']))
  31. {
  32. $db_host = trim($_POST['db_host']);
  33. $db_user = trim($_POST['db_user']);
  34. $db_pass = trim($_POST['db_pass']);
  35. $db_name = trim($_POST['db_name']);
  36. $db_prefix = trim($_POST['db_prefix']);
  37. if (!preg_match('/^[A-Za-z_]+$/',$db_prefix)) {
  38. $err = __('Invalid tables prefix. It can contain only letters or "_".');
  39. }
  40. # On tente une connexion
  41. if ($err == '')
  42. {
  43. $con = new connection($db_user,$db_pass,$db_host,$db_name);
  44. if ($con->error()) {
  45. $err = $con->error();
  46. } else {
  47. $ses->reg('db_host',$db_host);
  48. $ses->reg('db_user',$db_user);
  49. $ses->reg('db_pass',$db_pass);
  50. $ses->reg('db_name',$db_name);
  51. $ses->reg('db_prefix',$db_prefix);
  52. $ses->reg('step',4);
  53. header('Location: db-install.php');
  54. exit;
  55. }
  56. }
  57. }
  58. require dirname(__FILE__).'/__top.php';
  59. echo '<h2>'.__('Database parameters').'</h2>';
  60. if ($err != '') {
  61. echo
  62. '<p><strong>'.__('Error, check your parameters.').'</strong></p>'.
  63. '<p class="important">'.$err.'</p>';
  64. }
  65. echo
  66. '<form action="db-pref.php" method="post">'.
  67. '<p class="field"><label for="db_host" class="float">'.__('Server address').' :</label>'.
  68. form::field('db_host',30,255,$db_host).'</p>'.
  69. '<p class="field"><label for="db_user" class="float">'.__('User ID').' :</label>'.
  70. form::field('db_user',30,255,$db_user).'</p>'.
  71. '<p class="field"><label for="db_pass" class="float">'.__('Password').' :</label>'.
  72. form::field('db_pass',30,255,$db_pass).'</p>'.
  73. '<p class="field"><label for="db_name" class="float">'.__('Database name').' :</label>'.
  74. form::field('db_name',30,255,$db_name).'</p>'.
  75. '<p class="field"><label for="db_prefix" class="float">'.__('Tables prefix').' :</label>'.
  76. form::field('db_prefix',30,255,$db_prefix).'</p>'.
  77. '<p class="field"><input type="submit" class="submit" value="'.__('Create tables').' &#187;" />'.
  78. form::hidden('check','1').'</p>';
  79. '</form>';
  80. ?>
  81. <?php require dirname(__FILE__).'/__bottom.php'; ?>