db-install.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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',4);
  23. require dirname(__FILE__).'/prepend.php';
  24. $con = new connection($ses->f('db_user'),$ses->f('db_pass'),
  25. $ses->f('db_host'),$ses->f('db_name'));
  26. # On vérifie si les tables existent
  27. $strReq = 'SHOW TABLES LIKE \''.$ses->f('db_prefix').'%s\' ';
  28. $rs = $con->select(sprintf($strReq,'categorie'));
  29. $installed['categorie'] = !$rs->isEmpty();
  30. $rs = $con->select(sprintf($strReq,'comment'));
  31. $installed['comment'] = !$rs->isEmpty();
  32. $rs = $con->select(sprintf($strReq,'post'));
  33. $installed['post'] = !$rs->isEmpty();
  34. $rs = $con->select(sprintf($strReq,'user'));
  35. $installed['user'] = !$rs->isEmpty();
  36. $installed = $installed['categorie'] && $installed['comment'] && $installed['post'] && $installed['user'];
  37. if ($installed)
  38. {
  39. $ses->reg('step',20);
  40. }
  41. else
  42. {
  43. $sql_check = new checklist();
  44. $xsql = new xmlsql($con,implode('',file(dirname(__FILE__).'/db-create.xml')));
  45. $xsql->replace('{{PREFIX}}',$ses->f('db_prefix'));
  46. $xsql->execute($sql_check);
  47. $con->close();
  48. if ($sql_check->checkAll()) {
  49. $ses->reg('step',5);
  50. }
  51. }
  52. require dirname(__FILE__).'/__top.php';
  53. if ($installed)
  54. {
  55. echo
  56. '<p>'.__('DotClear seems to be present on your site. '.
  57. 'You may want to upgrade.').'</p>'.
  58. '<p class="important">'.__('Don\'t forget to upload your old dotclear.ini '.
  59. 'in conf/ directory before upgrade.').'</p>'.
  60. '<form action="upgrade.php" method="post">'.
  61. '<p><input type="submit" class="submit" value="'.__('Upgrade').' &#187;" /></p>'.
  62. '</form>';
  63. }
  64. else
  65. {
  66. echo '<h2>'.__('Tables creation').'</h2>';
  67. echo $sql_check->getHTML($img_chk_on,$img_chk_off,$img_chk_wrn);
  68. if (!$sql_check->checkAll())
  69. {
  70. echo '<p class="important">'.
  71. __('Unable to create all tables. Please check if the tables don\'t exist yet.').'</p>';
  72. }
  73. else
  74. {
  75. echo '<p><strong>'.__('Tables successfully created.').'</strong></p>';
  76. if ($sql_check->checkWarnings()) {
  77. echo
  78. '<p>'.__('DotClear will run properly even if warnings are issued.').'</p>';
  79. }
  80. echo
  81. '<form action="db-user.php" method="post">'.
  82. '<p><input type="submit" class="submit" value="'.__('Create user').' &#187;" /></p>'.
  83. '</form>';
  84. }
  85. }
  86. ?>
  87. <?php require dirname(__FILE__).'/__bottom.php'; ?>