upgrade.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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',20);
  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. $sql_check = new checklist();
  27. $xsql = new xmlsql($con,implode('',file(dirname(__FILE__).'/db-upgrade.xml')));
  28. $xsql->replace('{{PREFIX}}',$ses->f('db_prefix'));
  29. $xsql->execute($sql_check);
  30. if ($sql_check->checkAll())
  31. {
  32. $blog = new blog($con,$ses->f('db_prefix'),NULL);
  33. # Mise à jour de la table post (titre_url)
  34. if ($sql_check->checkItem('post_titre_url') === true)
  35. {
  36. $rs = $con->select('SELECT post_id, post_titre FROM '.$ses->f('db_prefix').'post');
  37. $up_t_url = true;
  38. $up_t_url_msg = $up_t_url_err = __('Update URLed titles');
  39. while (!$rs->EOF()) {
  40. if ($rs->f('post_titre_url') == '') {
  41. $updReq = 'UPDATE '.$ses->f('db_prefix').'post SET '.
  42. 'post_titre_url = \''.$con->escapeStr($blog->str2url($rs->f('post_titre'))).'\' '.
  43. 'WHERE post_id = '.$rs->f('post_id').' ';
  44. if ($con->execute($updReq) === false) {
  45. $up_t_url = false;
  46. $up_t_url_err .= ' failed - '.$con->error();
  47. break(1);
  48. }
  49. }
  50. $rs->moveNext();
  51. }
  52. $sql_check->addItem('up_t_url',$up_t_url,$up_t_url_msg,$up_t_url_err);
  53. }
  54. # Réordonne les catégories
  55. $sql_check->addItem('reord_cat',$blog->reordCats(true),
  56. __('Reord categories'),__('Reord categories failed')
  57. );
  58. # Mise à jour du fichier dotclear.ini
  59. $ini_file = dirname(__FILE__).'/../conf/dotclear.ini';
  60. if (!file_exists($ini_file))
  61. {
  62. copy($ini_file.'.in',$ini_file);
  63. @unlink($ini_file.'.in');
  64. chmod($ini_file,0666);
  65. $sql_check->addItem('ini_file',true,
  66. __('Update of dotclear.ini'),'');
  67. }
  68. else
  69. {
  70. $objIni = new iniFile(dirname(__FILE__).'/../conf/dotclear.ini');
  71. $objIni->createVar('dc_comments_ttl',0,
  72. 'Temps de vie (en jours) des commentaires et trackbacks (0 = infini)');
  73. $objIni->createVar('dc_upload_size',251200,
  74. "Format maximum d'une image largeur x hauteur\nexemples : 600x600, 600, 600x, x600");
  75. $objIni->createVar('dc_time_delta',0,
  76. "Décalage horaire global (entre -12 et 12)");
  77. $objIni->createVar('dc_blog_desc','',
  78. 'Description courte du weblog (pour les fils RSS et Atom');
  79. $objIni->createVar('dc_comments_pub',1,
  80. 'Publier directement les nouveaux commentaires');
  81. $objIni->createVar('dc_short_feeds',0,
  82. 'Flux RSS et Atom au format court');
  83. $sql_check->addItem('ini_file',$objIni->saveFile(),
  84. __('Update of dotclear.ini'),__('Update of dotclear.ini failed')
  85. );
  86. }
  87. # Création du fichier de configuration
  88. $configfile = dirname(__FILE__).'/../conf/config.php';
  89. $config = implode('',file($configfile.'.in'));
  90. $config = str_replace('%%DB_USER%%',$ses->f('db_user'),$config);
  91. $config = str_replace('%%DB_PASS%%',$ses->f('db_pass'),$config);
  92. $config = str_replace('%%DB_HOST%%',$ses->f('db_host'),$config);
  93. $config = str_replace('%%DB_BASE%%',$ses->f('db_name'),$config);
  94. $config = str_replace('%%DB_PREFIX%%',$ses->f('db_prefix'),$config);
  95. if (($fp = @fopen($configfile,'w')) !== false) {
  96. fwrite($fp,$config,strlen($config));
  97. fclose($fp);
  98. $wconf = true;
  99. files::secureFile($configfile);
  100. } else {
  101. $wconf = false;
  102. }
  103. $sql_check->addItem('conf',$wconf,
  104. __('Creation of config file.'),
  105. __('Creation of config file failed.')
  106. );
  107. # On recompte tout
  108. $blog->countAll();
  109. }
  110. $con->close();
  111. if ($sql_check->checkAll()) {
  112. $ses->destroy();
  113. }
  114. require dirname(__FILE__).'/__top.php';
  115. echo '<h2>'.__('Upgrade DotClear').'</h2>';
  116. echo $sql_check->getHTML($img_chk_on,$img_chk_off,$img_chk_wrn);
  117. if ($sql_check->checkAll()) {
  118. echo '<p><strong>'.__('DotClear successfully upgraded.').'</strong></p>';
  119. echo '<p><a href="../'.DC_ECRIRE.'/">'.__('Log in').'</a></p>';
  120. if ($sql_check->checkWarnings()) {
  121. echo
  122. '<p><strong>'.__('Note:').'</strong> '.
  123. __('DotClear will run properly even if warnings are issued.').'</p>';
  124. }
  125. } else {
  126. echo '<p class="important">Unable to upgrade DotClear</p>';
  127. }
  128. ?>
  129. <?php require dirname(__FILE__).'/__bottom.php'; ?>