[ Index ]
 

Code source de Plume CMS 1.2.2

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/manager/install/ -> upgrade.php (source)

   1  <?php
   2  /*
   3  # ***** BEGIN LICENSE BLOCK *****
   4  # This file is part of Plume CMS, a website management application.
   5  # Copyright (C) 2001-2006 Loic d'Anterroches and contributors.
   6  #
   7  # Plume CMS 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  # Plume CMS 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 this program; if not, write to the Free Software
  19  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  20  #
  21  # ***** END LICENSE BLOCK ***** */
  22  require_once dirname(__FILE__).'/prepend.php';
  23  
  24  $_px_p = 100; //percentage of wizard done.
  25  
  26  if (empty($_SESSION['step1'])) {
  27      header('Location: index.php');
  28      exit;
  29  }
  30  include_once $_PX_config['manager_path'].'/conf/config.php';
  31  $l = new l10n($_PX_config['lang'], 'install');
  32  
  33  
  34  $checklist = new checklist();
  35  
  36  
  37  //-- Update of the main configuration file --//
  38  $file = dirname(__FILE__).'/../conf/config.php';
  39  $cfg = new configfile($file);
  40  $cfg->prefix = '_PX_config';
  41  $test = true;
  42  $b_mess = $g_mess = '';
  43  if ($cfg->addVar('encoding', (string) 'utf-8', 'Encoding of the pages in all PLUME CMS.')) {
  44      $g_mess = __('The encoding configuration variable has been added to the configuration file.');
  45      $update = true;
  46  } else {
  47      $g_mess = __('The encoding configuration variable is already set in the configuration file.');
  48      $update = false;
  49  }
  50  if ($update && !$cfg->saveFile()) {
  51      $b_mess = __('Impossible to set the encoding configuration variable in the configuration file.');
  52      $test = false;
  53  }
  54  $checklist->addTest('encoding', $test, $g_mess, $b_mess);
  55  
  56  $cfg = new configfile($file);
  57  $cfg->prefix = '_PX_config';
  58  $test = true;
  59  $b_mess = $g_mess = '';
  60  if ($cfg->addVar('log404errors', (bool) false, 'Create a log of the 404 errors')) {
  61      $g_mess = __('The 404 error logging configuration variable has been added to the configuration file.');
  62      $update = true;
  63  } else {
  64      $g_mess = __('The 404 error logging configuration variable is already set in the configuration file.');
  65      $update = false;
  66  }
  67  if ($update && !$cfg->saveFile()) {
  68      $b_mess = __('Impossible to set the 404 error logging configuration variable in the configuration file.');
  69      $test = false;
  70  }
  71  $checklist->addTest('log404errors', $test, $g_mess, $b_mess);
  72  
  73  $cfg = new configfile($file);
  74  $cfg->prefix = '_PX_config';
  75  $test = true;
  76  $b_mess = $g_mess = '';
  77  if ($cfg->addVar('article_textarea_page', (string) '15', 'Default size of the textarea when adding a page')) {
  78      $g_mess = __('The default size of the page textarea has been added to the configuration file.');
  79      $update = true;
  80  } else {
  81      $g_mess = __('The default size of the page textarea is already set in the configuration file.');
  82      $update = false;
  83  }
  84  if ($update && !$cfg->saveFile()) {
  85      $b_mess = __('Impossible to set the default size of the page textarea in the configuration file.');
  86      $test = false;
  87  }
  88  $checklist->addTest('article_textarea_page', $test, $g_mess, $b_mess);
  89  
  90  $cfg = new configfile($file);
  91  $cfg->prefix = '_PX_config';
  92  $test = true;
  93  $b_mess = $g_mess = '';
  94  if ($cfg->addVar('article_textarea_description', (string) '7', 'Default size of the description textarea of an article')) {
  95      $g_mess = __('The default size of the article description textarea has been added to the configuration file.');
  96      $update = true;
  97  } else {
  98      $g_mess = __('The default size of the article description textarea is already set in the configuration file.');
  99      $update = false;
 100  }
 101  if ($update && !$cfg->saveFile()) {
 102      $b_mess = __('Impossible to set the default size of the article description textarea in the configuration file.');
 103      $test = false;
 104  }
 105  $checklist->addTest('article_textarea_description', $test, $g_mess, $b_mess);
 106  
 107  $cfg = new configfile($file);
 108  $cfg->prefix = '_PX_config';
 109  $test = true;
 110  $b_mess = $g_mess = '';
 111  if ($cfg->addVar('news_textarea_content', (string) '12', 'Default size of the content textarea of a news')) {
 112      $g_mess = __('The default size of the news content textarea has been added to the configuration file.');
 113      $update = true;
 114  } else {
 115      $g_mess = __('The default size of the news content textarea is already set in the configuration file.');
 116      $update = false;
 117  }
 118  if ($update && !$cfg->saveFile()) {
 119      $b_mess = __('Impossible to set the default size of the news content textarea in the configuration file.');
 120      $test = false;
 121  }
 122  $checklist->addTest('news_textarea_content', $test, $g_mess, $b_mess);
 123  
 124  $cfg = new configfile($file);
 125  $cfg->prefix = '_PX_config';
 126  $test = true;
 127  $b_mess = $g_mess = '';
 128  if ($cfg->addVar('category_textarea', (string) '7', 'Default size of the description of a category')) {
 129      $g_mess = __('The default size of the category description textarea has been added to the configuration file.');
 130      $update = true;
 131  } else {
 132      $g_mess = __('The default size of the category description textarea is already set in the configuration file.');
 133      $update = false;
 134  }
 135  if ($update && !$cfg->saveFile()) {
 136      $b_mess = __('Impossible to set the default size of the category description textarea in the configuration file.');
 137      $test = false;
 138  }
 139  $checklist->addTest('category_textarea', $test, $g_mess, $b_mess);
 140  
 141  $cfg = new configfile($file);
 142  $cfg->prefix = '_PX_config';
 143  $test = true;
 144  $b_mess = $g_mess = '';
 145  if ($cfg->addVar('comment_default_status', (int) 1, 'Default status of a comment, 1: online, 5: waiting for validation')) {
 146      $g_mess = __('The default status of a comment has been added to the configuration file.');
 147      $update = true;
 148  } else {
 149      $g_mess = __('The default status of a comment is already set in the configuration file.');
 150      $update = false;
 151  }
 152  if ($update && !$cfg->saveFile()) {
 153      $b_mess = __('Impossible to set the default status of a comment in the configuration file.');
 154      $test = false;
 155  }
 156  $checklist->addTest('comment_default_status', $test, $g_mess, $b_mess);
 157  
 158  $cfg = new configfile($file);
 159  $cfg->prefix = '_PX_config';
 160  $test = true;
 161  $b_mess = $g_mess = '';
 162  if ($cfg->addVar('secret_key', (string) Misc::getRandomString(), 'Secret key for your Plume installation, do not give it to anybody!')) {
 163      $g_mess = __('The secret key has been added to the configuration file.');
 164      $update = true;
 165  } else {
 166      $g_mess = __('The secret key is already set in the configuration file.');
 167      $update = false;
 168  }
 169  if ($update && !$cfg->saveFile()) {
 170      $b_mess = __('Impossible to set the secret key in the configuration file.');
 171      $test = false;
 172  }
 173  $checklist->addTest('secret_key', $test, $g_mess, $b_mess);
 174  
 175  
 176  //-- Copy the 404.php template if needed for each website --//
 177  /** Kept for users having a really old version.
 178  $u = new User(1); //rootuser
 179  $m = new Manager();
 180  $m->setUser($u);
 181  $test = true;
 182  if (($webs = $m->getSites()) !== false) {
 183      $src = dirname(__FILE__).'/../templates/_dist/default/templates/404.php';
 184      while (!$webs->EOF()) {
 185          $dest = dirname(__FILE__).'/../templates/'.$webs->f('website_id').'/404.php';
 186          $copy = files::copyfile($src, $dest);
 187          if (files::is_success($copy)) {
 188              $w_mess = '';
 189              $g_mess = sprintf(__('Copy of the template <em>%s</em> to <em>%s</em>'), files::real_path($src), files::real_path($dest));
 190              $test = true;
 191          } else {
 192              $g_mess = '';
 193              $w_mess = sprintf(__('Error in the copy of the template <em>%s</em> to <em>%s</em>'), files::real_path($src), files::real_path($dest));
 194              $test = 2;
 195          }
 196          $checklist->addTest('404template'.$webs->f('website_id'), $test, $g_mess, '', $w_mess);
 197          $webs->moveNext();
 198      }
 199  } else {
 200      $test = 2;
 201      $w_mess = __('Unable to get the list of websites to copy the new 404.php template. Please do it manually.');
 202      $checklist->addTest('404template', $test, '', '', $w_mess);
 203  }
 204  */
 205  
 206  //-- Set the theme_id for each config file --//
 207  $u = new User(1); //rootuser
 208  $m = new Manager();
 209  $m->setUser($u);
 210  $test = true;
 211  if (($webs = $m->getSites()) !== false) {
 212      while (!$webs->EOF()) {
 213          $file = dirname(__FILE__).'/../conf/configweb_'.$webs->f('website_id').'.php';
 214          $cfg = new configfile($file);
 215          $cfg->prefix = '_PX_website_config';
 216          $test = true;
 217          $b_mess = $g_mess = '';
 218          if ($cfg->addVar('theme_id', (string) $webs->f('website_id'), 'Theme used for the public rendering of the website.')) {
 219              $g_mess = sprintf(__('The theme id has been set for the website %s.'), $webs->f('website_name'));
 220              $update = true;
 221          } else {
 222              $g_mess = sprintf(__('The theme id was already set for the website %s.'), $webs->f('website_name'));
 223              $update = false;
 224          }
 225          if ($update && !$cfg->saveFile()) {
 226              $b_mess = sprintf(__('Impossible to set the theme id for the website %s.'), $webs->f('website_name'));
 227              $test = false;
 228          }
 229          $checklist->addTest('theme_id-'.$webs->f('website_id'), $test, $g_mess, $b_mess);
 230          $webs->moveNext();
 231      }
 232  }
 233  
 234  
 235  //-- Set the validation or not of the comments for each config file --//
 236  $u = new User(1); //rootuser
 237  $m = new Manager();
 238  $m->setUser($u);
 239  $test = true;
 240  if (($webs = $m->getSites()) !== false) {
 241      while (!$webs->EOF()) {
 242          $file = dirname(__FILE__).'/../conf/configweb_'.$webs->f('website_id').'.php';
 243          $cfg = new configfile($file);
 244          $cfg->prefix = '_PX_website_config';
 245          $test = true;
 246          $b_mess = $g_mess = '';
 247          if ($cfg->addVar('comment_default_status', (int) 1, 'Default status of a comment, 1: online 5:waiting for validation.')) {
 248              $g_mess = sprintf(__('The default comment status has been set for the website %s.'), $webs->f('website_name'));
 249              $update = true;
 250          } else {
 251              $g_mess = sprintf(__('The default comment status was already set for the website %s.'), $webs->f('website_name'));
 252              $update = false;
 253          }
 254          if ($update && !$cfg->saveFile()) {
 255              $b_mess = sprintf(__('Impossible to set the default comment status for the website %s.'), $webs->f('website_name'));
 256              $test = false;
 257          }
 258          $checklist->addTest('comment_default_status-'.$webs->f('website_id'), $test, $g_mess, $b_mess);
 259          $webs->moveNext();
 260      }
 261  }
 262  
 263  //-- Set the openness or not of the comments --//
 264  $u = new User(1); //rootuser
 265  $m = new Manager();
 266  $m->setUser($u);
 267  $test = true;
 268  if (($webs = $m->getSites()) !== false) {
 269      while (!$webs->EOF()) {
 270          $file = dirname(__FILE__).'/../conf/configweb_'.$webs->f('website_id').'.php';
 271          $cfg = new configfile($file);
 272          $cfg->prefix = '_PX_website_config';
 273          $test = true;
 274          $b_mess = $g_mess = '';
 275          if ($cfg->addVar('comment_support', (int) 1, 'Support of the comments: 1 - open, 2 - select per individual resource, 3 - closed.')) {
 276              $g_mess = sprintf(__('The support of comments has been set for the website %s.'), $webs->f('website_name'));
 277              $update = true;
 278          } else {
 279              $g_mess = sprintf(__('The support of comments was already set for the website %s.'), $webs->f('website_name'));
 280              $update = false;
 281          }
 282          if ($update && !$cfg->saveFile()) {
 283              $b_mess = sprintf(__('Impossible to set the support of comments for the website %s.'), $webs->f('website_name'));
 284              $test = false;
 285          }
 286          $checklist->addTest('comment_support-'.$webs->f('website_id'), $test, $g_mess, $b_mess);
 287          $webs->moveNext();
 288      }
 289  }
 290  
 291  
 292  //-- Upgrade of the database --//
 293  $con = pxDBConnect();
 294  $xml = implode("\n", file('./db-upgrade.xml'));
 295  $sql = new xmlsql($con, $xml);
 296  
 297  //-- MySQL version --//
 298  $rsV = $con->select('SELECT VERSION() AS version');
 299  $mysql_version = preg_replace('/-log$/','',$rsV->f(0));
 300  $extra = '';
 301  if (version_compare($mysql_version, '3.23', '>=')) {
 302      $extra = 'TYPE=MyISAM';
 303  }
 304  
 305  $sql->replace('{{TYPE}}', $extra);
 306  $sql->replace('{{PREFIX}}',$_PX_config['db']['table_prefix']);
 307  $sql->execute($checklist);
 308  
 309  $file = dirname(__FILE__).'/../conf/config.php';
 310  
 311  //-- Switch from latin1 to utf-8 if needed --//
 312  if (strtolower($_PX_config['encoding']) == 'iso-8859-1') {
 313      include dirname(__FILE__).'/dbconvert.php';
 314      $cfg = new configfile($file);
 315      $cfg->prefix = '_PX_config';
 316      $test = true;
 317      $b_mess = $g_mess = '';
 318      $cfg->editVar('encoding', (string) 'utf-8');
 319      $g_mess = __('The encoding has been set to utf-8 in the configuration file.');
 320      if (!$cfg->saveFile()) {
 321          $b_mess = __('Impossible to set encoding to utf-8 in the configuration file.');
 322          $test = false;
 323      }
 324      $checklist->addTest('secret_key', $test, $g_mess, $b_mess);
 325  }
 326  
 327  //-- Store the MySQL version -- //
 328  $cfg = new configfile($file);
 329  $cfg->prefix = '_PX_config';
 330  $test = true;
 331  $b_mess = $g_mess = '';
 332  if ($cfg->addVar('db_version', '4.0', 'Version of the database engine. For compatibility when upgrading from a 1.0.x version of Plume, the version is set to 4.0. Go on the website to see how to take full benefit of the unicode support in MySQL 4.1+')) {
 333      $g_mess = __('The version of the database engine has been added to the configuration file.');
 334      $update = true;
 335  } else {
 336      $g_mess = __('The version of the database engine is already set in the configuration file.');
 337      $update = false;
 338  }
 339  if ($update && !$cfg->saveFile()) {
 340      $b_mess = __('Impossible to set the version of the database engine in the configuration file.');
 341      $test = false;
 342  }
 343  $checklist->addTest('db_version', $test, $g_mess, $b_mess);
 344  
 345  
 346  $check = $checklist->checkAll();
 347  $m->user->logout();
 348  
 349  include dirname(__FILE__).'/_top.php';
 350  
 351  echo '<h2>'.__('Upgrade of the installation').'</h2>'."\n\n";
 352  
 353  if ($check) {
 354      echo '<h3>'.__('Congratulations, PLUME CMS has been upgraded!').'</h3>'."\n\n";
 355  } else {
 356      echo "\n\n" .'<p class="important">'. __('Some errors occured during the upgrade procedure. Please check carefully the messages to see if you need to finish the upgrade manually.') .'</p>'. "\n\n";
 357  }
 358  
 359  echo $checklist->getHtml('../themes/default/images');
 360  
 361  echo '<p>'.sprintf(__('You can now access the manager. <a href="%s">Access the manager</a>.'), '../login.php?logout=1').'</p>'."\n";
 362  
 363  include dirname(__FILE__).'/_bottom.php';
 364  ?>


Généré le : Mon Nov 26 11:57:01 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics