[ Index ]
 

Code source de WikiNi 0.4.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/setup/ -> install.php (source)

   1  <?php
   2  /*
   3  install.php
   4  Copyright (c) 2002, Hendrik Mans <hendrik@mans.de>
   5  Copyright 2002, 2003 David DELON
   6  Copyright 2002, 2003 Patrick PAUL
   7  Copyright 2003  Eric FELDSTEIN
   8  Copyright 2006 Didier LOISEAU
   9  All rights reserved.
  10  Redistribution and use in source and binary forms, with or without
  11  modification, are permitted provided that the following conditions
  12  are met:
  13  1. Redistributions of source code must retain the above copyright
  14  notice, this list of conditions and the following disclaimer.
  15  2. Redistributions in binary form must reproduce the above copyright
  16  notice, this list of conditions and the following disclaimer in the
  17  documentation and/or other materials provided with the distribution.
  18  3. The name of the author may not be used to endorse or promote products
  19  derived from this software without specific prior written permission.
  20  
  21  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  22  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  23  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  25  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  26  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  30  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31  */
  32  if (!defined('WIKINI_VERSION'))
  33  {
  34      die ("acc&egrave;s direct interdit");
  35  }
  36  if (empty($_POST['config']))
  37  {
  38      header('Location: ' . myLocation());
  39      die ('probl&egrave;me dans la proc&eacute;dure d\'installation');
  40  }
  41  
  42  // fetch configuration
  43  $config = $config2 = $_POST["config"];
  44  
  45  // merge existing (or default) configuration with new one
  46  $config = array_merge($wakkaConfig, $config);
  47  
  48  // test configuration
  49  echo "<b>Test de la configuration</b><br>\n";
  50  test("Test connexion MySQL ...", $dblink = @mysql_connect($config["mysql_host"], $config["mysql_user"], $config["mysql_password"]));
  51  test("Recherche base de donn&eacute;es ...", @mysql_select_db($config["mysql_database"], $dblink), "La base de donn&eacute;es que vous avez choisie n'existe pas, vous devez la cr&eacute;er avant d'installer WikiNi !");
  52  echo "<br>\n" ;
  53  
  54  // do installation stuff
  55  if (!$version = trim($wakkaConfig["wikini_version"])) $version = "0";
  56  switch ($version)
  57  {
  58  // new installation
  59  case "0":
  60      echo "<b>Installation</b><br>\n";
  61      test("Creation table page...",
  62          @mysql_query(
  63              "CREATE TABLE ".$config["table_prefix"]."pages (".
  64                "id int(10) unsigned NOT NULL auto_increment,".
  65                "tag varchar(50) NOT NULL default '',".
  66                "time datetime NOT NULL default '0000-00-00 00:00:00',".
  67                "body text NOT NULL,".
  68                "body_r text NOT NULL,".
  69                "owner varchar(50) NOT NULL default '',".
  70                "user varchar(50) NOT NULL default '',".
  71                "latest enum('Y','N') NOT NULL default 'N',".
  72                "handler varchar(30) NOT NULL default 'page',".
  73                "comment_on varchar(50) NOT NULL default '',".
  74                "PRIMARY KEY  (id),".
  75                "FULLTEXT KEY tag (tag,body),".
  76                "KEY idx_tag (tag),".
  77                "KEY idx_time (time),".
  78                "KEY idx_latest (latest),".
  79                "KEY idx_comment_on (comment_on)".
  80              ") TYPE=MyISAM;", $dblink), "D&eacute;j&agrave; cr&eacute;&eacute;e ?", 0);
  81      test("Creation table ACL ...",
  82          @mysql_query(
  83              "CREATE TABLE ".$config["table_prefix"]."acls (".
  84                "page_tag varchar(50) NOT NULL default '',".
  85              "privilege varchar(20) NOT NULL default '',".
  86                "list text NOT NULL,".
  87               "PRIMARY KEY  (page_tag,privilege)".
  88              ") TYPE=MyISAM", $dblink), "D&eacute;j&agrave; cr&eacute;&eacute;e ?", 0);
  89      test("Creation table link ...",
  90          @mysql_query(
  91              "CREATE TABLE ".$config["table_prefix"]."links (".
  92              "from_tag char(50) NOT NULL default '',".
  93                "to_tag char(50) NOT NULL default '',".
  94                "UNIQUE KEY from_tag (from_tag,to_tag),".
  95                "KEY idx_from (from_tag),".
  96                "KEY idx_to (to_tag)".
  97              ") TYPE=MyISAM", $dblink), "D&eacute;j&agrave; cr&eacute;&eacute;e ?", 0);
  98      test("Creation table referrer ...",
  99          @mysql_query(
 100              "CREATE TABLE ".$config["table_prefix"]."referrers (".
 101                "page_tag char(50) NOT NULL default '',".
 102                "referrer char(150) NOT NULL default '',".
 103                "time datetime NOT NULL default '0000-00-00 00:00:00',".
 104                "KEY idx_page_tag (page_tag),".
 105                "KEY idx_time (time)".
 106              ") TYPE=MyISAM", $dblink), "D&eacute;j&agrave; cr&eacute;&eacute;e ?", 0);
 107      test("Creation table user ...",
 108          @mysql_query(
 109              "CREATE TABLE ".$config["table_prefix"]."users (".
 110                "name varchar(80) NOT NULL default '',".
 111                "password varchar(32) NOT NULL default '',".
 112                "email varchar(50) NOT NULL default '',".
 113                "motto text NOT NULL,".
 114                "revisioncount int(10) unsigned NOT NULL default '20',".
 115                "changescount int(10) unsigned NOT NULL default '50',".
 116                "doubleclickedit enum('Y','N') NOT NULL default 'Y',".
 117                "signuptime datetime NOT NULL default '0000-00-00 00:00:00',".
 118                "show_comments enum('Y','N') NOT NULL default 'N',".
 119                "PRIMARY KEY  (name),".
 120                "KEY idx_name (name),".
 121                "KEY idx_signuptime (signuptime)".
 122              ") TYPE=MyISAM", $dblink), "D&eacute;j&agrave; cr&eacute;&eacute;e ?", 0);
 123      //insertion des pages de documentation et des pages standards 
 124      $d = dir("setup/doc/");
 125      while ($doc = $d->read()){
 126          if ($doc != "." && $doc != ".." && !is_dir($doc)){
 127              $pagecontent = implode ('', file("setup/doc/$doc"));
 128              if ($doc=='_root_page.txt'){
 129                  $pagename = $config["root_page"];
 130              }else{
 131                  $pagename = substr($doc,0,strpos($doc,'.txt'));
 132              }
 133  
 134              $sql = "Select tag from ".$config["table_prefix"]."pages where tag='$pagename'";
 135          
 136              // Insert documentation page if not present (a previous failed installation ?)
 137              if (($r=@mysql_query($sql, $dblink)) && (mysql_num_rows($r)==0)) {
 138              
 139                  $sql = "Insert into ".$config["table_prefix"]."pages ".
 140                  "set tag = '$pagename', ".
 141                  "body = '".mysql_escape_string($pagecontent)."', ".
 142                  "user = 'WikiNiInstaller', ".
 143                  "time = now(), ".
 144                  "latest = 'Y'";
 145  
 146                  test("Insertion de la page $pagename ...", @mysql_query($sql, $dblink),"?",0);
 147  
 148                  // update table_links 
 149                  $wiki = new Wiki($config);
 150                  $wiki->SetPage($wiki->LoadPage($pagename,"",0));
 151                  $wiki->ClearLinkTable();
 152                  $wiki->StartLinkTracking();
 153                  $wiki->TrackLinkTo($pagename);
 154                  $dummy = $wiki->Header();
 155                  $dummy .= $wiki->Format($pagecontent);
 156                  $dummy .= $wiki->Footer();
 157                  $wiki->StopLinkTracking();
 158                  $wiki->WriteLinkTable();
 159                  $wiki->ClearLinkTable();
 160              }
 161              else
 162              {
 163                  test("Insertion de la page $pagename ...", 0 ,"Existe d&eacute;j&agrave;.",0);
 164              }    
 165  
 166          }
 167      }
 168      break;
 169      
 170      // The funny upgrading stuff. Make sure these are in order! //
 171  case "0.1":
 172      echo "<b>En cours de mise &agrave; jour de WikiNi 0.1</b><br>\n";
 173      test("Just very slightly altering the pages table...", 
 174          @mysql_query("alter table ".$config["table_prefix"]."pages add body_r text not null default '' after body", $dblink), "Already done? Hmm!", 0);
 175      test("Claiming all your base...", 1);
 176  }
 177  
 178  ?>
 179  
 180  <p>
 181  A l'&eacute;tape suivante, le programme d'installation va essayer
 182  d'&eacute;crire le fichier de configuration <tt><?php echo  $wakkaConfigLocation ?></tt>.
 183  Assurez vous que le serveur web a bien le droit d'&eacute;crire dans ce fichier, sinon vous devrez le modifier manuellement.  </p>
 184  
 185  <form action="<?php echo  myLocation(); ?>?installAction=writeconfig" method="POST">
 186  <input type="hidden" name="config" value="<?php echo  htmlentities(serialize($config)) ?>">
 187  <input type="submit" value="Continuer">
 188  </form>


Généré le : Mon Nov 26 12:05:46 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics