[ Index ]
 

Code source de Dotclear 1.2.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/install/ -> upgrade.php (source)

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


Généré le : Fri Feb 23 21:40:15 2007 par Balluche grâce à PHPXref 0.7