[ PHPXref.com ] [ Generated: Sun Jul 20 21:12:30 2008 ] [ YACS 6.3.1 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> setup.php (source)

   1  <?php
   2  /**

   3   * the main setup script

   4   *

   5   * @todo validate that this work at ovh sub-domain

   6   *

   7   * This page is used for the very first installation of the server

   8   *

   9   * This script looks for following items:

  10   * - [code]shared/parameters.include.php[/code]

  11   * - [code]shared/hooks.include.php[/code]

  12   * - [code]skins/parameters.include.php[/code]

  13   *

  14   * If all of these items are absent, the script assumes this is a first installation,

  15   * welcomes the surfer, and offers to jump to [script]control/configure.php[/script].

  16   *

  17   * Also, the script performs several test to ensure:

  18   * - that the version of PHP is greater or equal than 4.1

  19   * - that the MySQL PHP extension is available

  20   * - that the XML parser of PHP is available

  21   * - that it can write to local files (configuration and log files)

  22   *

  23   * If one of these tests fails, the script advises the user on the right thing to do.

  24   * For example, it will offer to chmod the YACS installation directory is necessary.

  25   *

  26   * On first installation this script will behave like a setup assistant,

  27   * and the user will have to pass through successive screens:

  28   * - the configuration panel ([script]control/configure.php[/script]), to record database and other essential parameters

  29   * - the extension scanner ([script]control/scan.php[/script]), to load all hooks

  30   * - the database setup ([script]control/setup.php[/script]), to create tables in the database

  31   * - the populate screen ([script]control/populate.php[/script]), to create a basic set of records in the database

  32   * - the configuration panel for skins ([script]scripts/configure.php[/script]), to set rendering parameters

  33   *

  34   * @see control/configure.php

  35   * @see control/scan.php

  36   * @see control/setup.php

  37   * @see control/populate.php

  38   * @see scripts/configure.php

  39   *

  40   * If at least one file is missing, the script assumes there is an on-going installation,

  41   * and proposes to jump to the control panel at [script]control/index.php[/script].

  42   * In this case the control panel will redirect to the adequate script depending of the missing element.

  43   *

  44   * If all files are present, but there is no [code]switch.on[/code] nor [code]switch.off[/code] file, the script

  45   * assumes the installation ends correctly, creates [code]switch.on[/code], and offers to jump to the

  46   * control panel at [script]control/index.php[/script].

  47   * Also, if there is no index page at the upper directory level, the script will silently attempt

  48   * to duplicate index.php there.

  49   *

  50   * Else the script assumes there is no need for an installation,

  51   * and offers to jump to the control panel at [script]control/index.php[/script].

  52   *

  53   * @see control/index.php

  54   *

  55   * @author Bernard Paques [email]bernard.paques@bigfoot.com[/email]

  56   * @reference

  57   * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License

  58   */
  59  
  60  // include explicitly some libraries

  61  if(!file_exists('shared/global.php'))
  62      exit('No shared library. Please copy the entire set of files in the provided archive.');
  63  include_once  'shared/global.php';
  64  include_once  'shared/surfer.php';
  65  
  66  // load the skin

  67  load_skin('setup');
  68  
  69  // check key files

  70  $missing = 0;
  71  if(!file_exists('shared/parameters.include.php'))
  72      $missing++;
  73  if(!file_exists('shared/hooks.include.php'))
  74      $missing++;
  75  if(!file_exists('skins/parameters.include.php'))
  76      $missing++;
  77  
  78  // first installation

  79  if($missing == 3) {
  80  
  81      // title

  82      $local['title_en'] = 'First installation';
  83      $local['title_fr'] = 'Premi&egrave;re installation';
  84      $context['page_title'] = get_local('title');
  85  
  86      // ensure we have a minimum version of PHP

  87      if(version_compare(phpversion(),'4.1','<')) {
  88  
  89          // provide instructions

  90          $local['splash_en'] = 'ERROR: YACS requires at least PHP version 4.1.'
  91              .' The server runs version '.phpversion().'.';
  92          $local['splash_fr'] = 'ERREUR : YACS requi&egrave;re PHP version 4.1 au minimum.'
  93              .' Le serveur ex&eacute;cute la version '.phpversion().'.';
  94          $context['error'] .= '<p>'.get_local('splash')."</p>\n";
  95  
  96          $local['label_en'] = 'Check the provided <a href="readme.txt">readme.txt</a> file to find more help on this topic.';
  97          $local['label_fr'] = 'V&eacute;rifier le fichier <a href="readme.txt">readme.txt</a> pour obtenir plus d\'aide.';
  98          $context['text'] .= '<p>'.get_local('label')."</p>\n";
  99  
 100          $local['label_en'] = 'Check PHP version again';
 101          $local['label_fr'] = 'V&eacute;rifier de nouveau la version de PHP';
 102          $context['text'] .= '<p><a href="setup.php">'.get_local('label')."</a></p>\n";
 103  
 104      // ensure we have MySQL

 105      } elseif(!function_exists('mysql_connect')) {
 106  
 107          // provide instructions

 108          $local['splash_en'] = 'ERROR: YACS requires the MySQL PHP extension.';
 109          $local['splash_fr'] = 'ERREUR : YACS requi&egrave;re l\'extension PHP de support de MySQL.';
 110          $context['error'] .= '<p>'.get_local('splash')."</p>\n";
 111  
 112          $local['label_en'] = 'Check the provided <a href="readme.txt">readme.txt</a> file to find more help on this topic.';
 113          $local['label_fr'] = 'V&eacute;rifier le fichier <a href="readme.txt">readme.txt</a> pour obtenir plus d\'aide.';
 114          $context['text'] .= '<p>'.get_local('label')."</p>\n";
 115  
 116          $local['label_en'] = 'Check the MySQL PHP extension again';
 117          $local['label_fr'] = 'V&eacute;rifier de nouveau la pr&eacute;sence de l\'extension MySQL de PHP';
 118          $context['text'] .= '<p><a href="setup.php">'.get_local('label')."</a></p>\n";
 119  
 120      // ensure we can handle XML

 121      } elseif(!function_exists('xml_parser_create')) {
 122  
 123          // provide instructions

 124          $local['splash_en'] = 'ERROR: YACS requires the XML PHP extension.';
 125          $local['splash_fr'] = 'ERREUR : YACS requi&egrave;re l\'extension PHP de support de XML.';
 126          $context['error'] .= '<p>'.get_local('splash')."</p>\n";
 127  
 128          $local['label_en'] = 'Check the provided <a href="readme.txt">readme.txt</a> file to find more help on this topic.';
 129          $local['label_fr'] = 'V&eacute;rifier le fichier <a href="readme.txt">readme.txt</a> pour obtenir plus d\'aide.';
 130          $context['text'] .= '<p>'.get_local('label')."</p>\n";
 131  
 132          $local['label_en'] = 'Check the XML PHP extension again';
 133          $local['label_fr'] = 'V&eacute;rifier de nouveau la pr&eacute;sence de l\'extension XML de PHP';
 134          $context['text'] .= '<p><a href="setup.php">'.get_local('label')."</a></p>\n";
 135  
 136      } else {
 137  
 138          // show evidence of safe mode

 139          if(ini_get('safe_mode')) {
 140              $local['label_en'] = 'WARNING: This server runs in safe mode, and YACS may be prevented to perform a number of key operations.';
 141              $local['label_fr'] = 'ATTENTION : Ce serveur est configur&eacute; en safe mode, ce qui peut empÍcher l\'&eacute;x&ecute;cution correcte de nombre de fonctions importantes.';
 142              $context['text'] .= '<p>'.get_local('label')."</p>\n";
 143          }
 144  
 145          // test our ability to write to files

 146          $can_write = TRUE;
 147  
 148          // actual attempt to write to representative files

 149          $files = array();
 150          $files[] = './switch.on';
 151          $files[] = './agents/debug.txt';
 152          $files[] = './agents/log.txt';
 153          $files[] = './agents/parameters.include.php';
 154          $files[] = './articles/ie_bookmarklet.html';
 155          $files[] = './articles/ie_bookmarklet.reg';
 156          $files[] = './collections/parameters.include.php';
 157          $files[] = './feeds/parameters.include.php';
 158          $files[] = './letters/parameters.include.php';
 159          $files[] = './scripts/parameters.include.php';
 160          $files[] = './servers/parameters.include.php';
 161          $files[] = './services/parameters.include.php';
 162          $files[] = './shared/hooks.xml';
 163          $files[] = './shared/hooks.include.php';
 164          $files[] = './shared/parameters.include.php';
 165          $files[] = './skins/parameters.include.php';
 166          foreach($files as $file) {
 167  
 168              // test has to work even if file already exists

 169              if($handle = @fopen($file, 'ab')) {
 170                  @fclose($handle);
 171  
 172                  // delete empty file, but don't kill files that exist previously

 173                  if(filesize($file) < 10)
 174                      unlink($file);
 175  
 176              } else {
 177                  $local['label_en'] = 'Unable to write to file '.$file;
 178                  $local['label_fr'] = 'Impossible d\'&eacute;crire dans le fichier '.$file;
 179                  $context['text'] .= get_local('label').BR;
 180                  $can_write = FALSE;
 181              }
 182          }
 183  
 184          // please chmod files

 185          if(!$can_write) {
 186  
 187              // provide instructions

 188              $local['splash_en'] = 'ERROR: YACS cannot write to files.'
 189                  .' If you are running some Unix, please ensure that permissions have been properly set.'
 190                  .' This issue can also be due to server running in safe mode.';
 191              $local['splash_fr'] = 'ERREUR : YACS ne peut pas &eacute;crire de fichier.'
 192                  .' Si vous utilisez quelque version d\'Unix, merci de v&eacute;rifier que les permissions sont positionn&eacute;es correctement.'
 193                  .' Le probl&egrave;me se rencontre aussi sur les serveurs en safe mode.';
 194              $context['error'] .= '<p>'.get_local('splash')."</p>\n";
 195  
 196              $local['label_en'] = 'Check the provided <a href="readme.txt">readme.txt</a> file to find more help on this topic.';
 197              $local['label_fr'] = 'V&eacute;rifier le fichier <a href="readme.txt">readme.txt</a> pour obtenir plus d\'aide.';
 198              $context['text'] .= '<p>'.get_local('label')."</p>\n";
 199  
 200              $local['label_en'] = 'Check again our ability to write to files';
 201              $local['label_fr'] = 'V&eacute;rifier de nouveau la possibilit&eacute; d\'&eacute;crire des fichiers';
 202              $context['text'] .= '<p><a href="setup.php">'.get_local('label')."</a></p>\n";
 203  
 204          // link to the configuration page

 205          } else {
 206  
 207              // title

 208              $local['title_en'] = 'Welcome in the YACS setup assistant';
 209              $local['title_fr'] = 'Bienvenue dans l\'assistant d\'installation de YACS';
 210              $context['page_title'] = get_local('title');
 211  
 212              // splash screen

 213              $local['splash_en'] = 'Thank you for having selected to install the YACS environment.'
 214                  .' You will now have to pass through several steps in order to achieve the setup of your server:'."\n"
 215                  .'<ul>'."\n"
 216                  .'<li>Configure parameters related to the database.</li>'."\n"
 217                  .'<li>Load extension hooks.</li>'."\n"
 218                  .'<li>Create tables in the database.</li>'."\n"
 219                  .'<li>Add one user profile and populate the database.</li>'."\n"
 220                  .'<li>Configure the skin of your server.</li>'."\n"
 221                  .'</ul>'."\n"
 222                  .' In normal conditions this will take only some minutes.'
 223                  .' Please check the provided <a href="readme.txt">readme.txt</a> file to ensure prerequisites are fulfilled.'
 224                  .' If you have any problems, please consult <a href="http://www.yetanothercommunitysystem.com/">www.yetanothercommunitysystem.com</a> for additional support.';
 225              $local['splash_fr'] = 'Merci d\'avoir choisi d\'installer l\'environnement YACS.'
 226                  .' Vous allez &agrave; pr&eacute;sent passer &agrave; travers plusieurs &eacute;tapes successives pour terminer cette installation&nbsp;:'."\n"
 227                  .'<ul>'."\n"
 228                  .'<li>Indiquer les param&egrave;tres de connexion au serveur de donn&eacute;es.</li>'."\n"
 229                  .'<li>Rechercher les extensions logicielles &eacute;ventuelles.</li>'."\n"
 230                  .'<li>Cr&eacute;er les tables de la base de donn&eacute;es.</li>'."\n"
 231                  .'<li>Cr&eacute;er un profil utilisateur et initialiser la base de donn&eacute;es.</li>'."\n"
 232                  .'<li>Indiquer les param&egrave;tres de l\'interface de votre serveur.</li>'."\n"
 233                  .'</ul>'."\n"
 234                  .' En conditions normales, ceci devrait prendre seulement quelques minutes.'
 235                  .' Merci de v&eacute;rifier le fichier <a href="readme.txt">readme.txt</a> pour vous assurer des pr&eacute;requis &agrave; l\'installation.'
 236                  .' Si vous &ecirc;tes bloqu&eacute;, consulter  <a href="http://www.yetanothercommunitysystem.com/">www.yetanothercommunitysystem.com</a> pour obtenir du support.';
 237              $context['text'] .= '<p>'.get_local('splash')."</p>\n";
 238  
 239              // add a button to start the installation process

 240              $local['label_en'] = 'Start the installation process';
 241              $local['label_fr'] = 'Commencer l\'installation';
 242              $context['text'] .= '<form method="get" action="control/configure.php" id="main_form">'."\n"
 243                  .'<p><input type="submit" name="confirmed" value="'.get_local('label').'" /></p>'."\n"
 244                  .'</form>'."\n";
 245  
 246          }
 247      }
 248  
 249  // on-going installation

 250  } elseif($missing) {
 251  
 252      // title

 253      $local['title_en'] = 'Incomplete installation';
 254      $local['title_fr'] = 'Installation incompl&egrave;te';
 255      $context['page_title'] = get_local('title');
 256  
 257      // splash screen

 258      $local['splash_en'] = 'Some configuration files are missing.'
 259          .' Please follow the link to complete the installation process.';
 260      $local['splash_fr'] = 'Certains fichiers de configuration sont absents.'
 261          .' Suivez le lien ci-dessous pour compl&eacute;ter l\'installation.';
 262      $context['text'] .= '<p>'.get_local('splash')."</p>\n";
 263  
 264      // to the control panel

 265      $local['link_en'] = 'Control panel';
 266      $local['link_fr'] = 'Panneau de contr&ocirc;le';
 267      $context['text'] .= '<p><a href="control/index.php">'.get_local('link')."</a></p>\n";
 268  
 269  // end of the installation

 270  } elseif(!file_exists('switch.on') && !file_exists('switch.off')) {
 271  
 272      // the title of the page

 273      $local['title_en'] = 'End of installation';
 274      $local['title_fr'] = 'Installation termin&eacute;e';
 275      $context['page_title'] = get_local('title');
 276  
 277      // create the switch

 278      $content = '---------------------------------------------'."\n"
 279          .'YACS will process requests if this file is named switch.on,'."\n"
 280          .'and will redirect everything to control/closed.php if its name is changed to switch.off.'."\n"
 281          ."\n"
 282          .'Associates can use the script control/switch.php to stop and restart remotely.'."\n"
 283          .'---------------------------------------------'."\n";
 284      if(!@file_put_contents('switch.on', $content)) {
 285  
 286          // not enough rights to write the file

 287          $local['label_en'] = 'ERROR: YACS cannot create the file switch.on to activate the server.';
 288          $local['label_fr'] = 'ERREUR : YACS ne peut pas cr&eacute;er le fichier switch.on pour activer le serveur.';
 289          $context['error'] .= '<p>'.get_local('label')."</p>\n";
 290  
 291          // allow for a manual update

 292          $local['label_en'] = 'To actually switch on the server, please copy and paste following lines by yourself in file switch.on:';
 293          $local['label_fr'] = 'Pour d&eacute;marrer le serveur merci de copier et de coller les lignes suivantes dans le fichier switch.on :';
 294          $context['text'] .= '<p style="text-decoration: blink;">'.get_local('label')."</p>\n";
 295  
 296          // content of the switch file

 297          $context['text'] .= '<pre>'.$content."</pre>\n";
 298  
 299      }
 300  
 301      // if there is no index at the upper level

 302      if(!file_exists($context['path_to_root'].'../index.php') && ($content = @file_get_contents($context['path_to_root'].'index.php'))) {
 303  
 304          // silently attempt to duplicate our index

 305          @file_put_contents($context['path_to_root'].'../index.php', $content);
 306  
 307          // remember this for the next incremental update

 308          $content = '<?php'."\n"
 309              .'// This file has been created by the setup script setup.php'."\n"
 310              .'// on '.gmdate("F j, Y, g:i a").' GMT, for '.Surfer::get_name().'. Please do not modify it manually.'."\n"
 311              .'$context[\'home_at_root\']=\'Y\';'."\n"
 312              .'$context[\'reference_server\']=\''.addcslashes('www.yetanothercommunitysystem.com', "\\'")."';\n"
 313              .'?>'."\n";
 314          @file_put_contents($context['path_to_root'].'scripts/parameters.include.php', $content);
 315  
 316      }
 317  
 318      // the splash message

 319      $local['splash_en'] = "Congratulations!\n"
 320          ."You have successfully passed through the several installation steps.\n"
 321          ."We have checked following items:\n"
 322          ."<ul>\n"
 323          ."<li>Configuration parameters have been provided.</li>\n"
 324          ."<li>A connection to the database server has been established.</li>\n"
 325          ."<li>The database exists and may be accessed.</li>\n"
 326          ."<li>At least one user profile exists.</li>\n"
 327          ."<li>Additional configuration parameters have been provided for the skin of the server.</li>\n"
 328          ."</ul>\n"
 329          ."What do you want to do now?"
 330          .'<ul>'."\n"
 331          .'<li>Select '.Skin::build_link('skins/index.php', 'another skin').' for your site.</li>'."\n"
 332          .'<li>Populate your site with the '.Skin::build_link('control/populate.php', 'Content Assistant').'.</li>'."\n"
 333          .'<li>Manage everything from the '.Skin::build_link('control/index.php', 'Control Panel').'.</li>'."\n"
 334          .'<li>Check the '.Skin::build_link('index.php', 'main page').' of this site.</li>'."\n"
 335          .'<li>Review your '.Skin::build_link('users/view.php', 'user profile').'.</li>'."\n"
 336          .'<li>Create a '.Skin::build_link('articles/edit.php', 'new article').'.</li>'."\n"
 337          .'<li>Look at the '.Skin::build_link('help.php', 'help index page').'.</li>'."\n"
 338          .'<li>Visit '.Skin::build_link('http://www.yetanothercommunitysystem.com/', 'www.yetanothercommunitysystem.com', 'external').' to learn more.</li>'."\n"
 339          .'</ul>'."\n"
 340          .'<p>Dear web master, you now have one more site to manage.'
 341          .' Once again, thank you for having selected to use YACS.</p>'."\n";
 342      $local['splash_fr'] = "Bravo !\n"
 343          ."Vous avez pass&eacute; avec succ&egrave;s les diff&eacute;rentes &eacute;tapes de l'installation.\n"
 344          ."Les points suivants ont &eacute;t&eacute; v&eacute;rifi&eacute;s :\n"
 345          ."<ul>\n"
 346          ."<li>Les param&egrave;tres de configuration ont &eacute;t&eacute; enregistr&eacute;s.</li>\n"
 347          ."<li>Une connexion au serveur de donn&eacute;es a &eacute;t&eacute; &eacute;tablie.</li>\n"
 348          ."<li>La base de donn&eacute;es existe et est accessible.</li>\n"
 349          ."<li>Un compte utilisateur existe.</li>\n"
 350          ."<li>Des param&egrave;tres additionnels ont &eacute;t&eacute; fournis pour la configuration de l'interface utilisateur.</li>\n"
 351          .'</ul>'."\n"
 352          ."Que souhaitez-vous faire &agrave; pr&eacute;sent ?"
 353          .'<ul>'."\n"
 354          .'<li>S&eacute;lectionner '.Skin::build_link('skins/index.php', 'un autre style').' pour votre site.</li>'."\n"
 355          .'<li>Structurer votre serveur gr&acirc;e &agrave; l\''.Skin::build_link('control/populate.php', 'Assistant de Contenu').'.</li>'."\n"
 356          .'<li>G&eacute;rer toutes les fonctions depuis le '.Skin::build_link('control/index.php', 'Panneau de Configuration').'.</li>'."\n"
 357          .'<li>Contr&ocirc;ler la '.Skin::build_link('index.php', 'page principale').' de votre site.</li>'."\n"
 358          .'<li>Compl&eacute;ter votre '.Skin::build_link('users/view.php', 'profil d\'utilisateur').'.</li>'."\n"
 359          .'<li>Cr&eacute;er un '.Skin::build_link('articles/edit.php', 'nouvel article').'.</li>'."\n"
 360          .'<li>Consulter l\''.Skin::build_link('help.php', 'aide en ligne').'.</li>'."\n"
 361          .'<li>Visiter '.Skin::build_link('http://www.yetanothercommunitysystem.com/', 'www.yetanothercommunitysystem.com', 'external').' pour en savoir plus.</li>'."\n"
 362          .'</ul>'."\n"
 363          .'<p>Cher webmestre, vous avez &agrave; pr&eacute;sent un site de plus &agrave; g&eacute;rer.'
 364          .' Encore une fois, merci d\'avoir choisi d\'utiliser YACS.</p>'."\n";
 365      $context['text'] .= get_local('splash')."\n";
 366  
 367  // no need for installation

 368  } else {
 369  
 370      // the title of the page

 371      $local['title_en'] = 'No need for setup';
 372      $local['title_fr'] = 'Aucun besoin d\'installation';
 373      $context['page_title'] = get_local('title');
 374  
 375      // the splash message

 376      $local['splash_en'] = 'Since basic configuration files exist on your server,'
 377          .' it is likely that the installation has been achieved successfully.'
 378          .' Click on the link below to modify the running parameters of your server.';
 379      $local['splash_fr'] = 'Votre environnement dispose des fichiers de configuration essentiels.'
 380          .' Il est donc probable que l\'installation est d&eacute;j&agrave; compl&egrave;te.'
 381          .' Cliquer sur le lien ci-dessous pour modifier les param&egrave;tres de votre environnement.';
 382      $context['text'] .= '<p>'.get_local('splash')."</p>\n";
 383  
 384      // to the control panel

 385      $local['link_en'] = 'Go to the control panel';
 386      $local['link_fr'] = 'Aller au panneau de contr&ocirc;le';
 387      $context['text'] .= '<p><a href="control/index.php">'.get_local('link')."</a></p>\n";
 388  
 389  }
 390  
 391  // render the skin

 392  render_skin();
 393  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]