noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
setup.php
Go to the documentation of this file.
00001 <!doctype html><HTML><HEAD>
00002     <TITLE>Noaliss - Mise à jour</TITLE>
00003     <META http-equiv="Content-Type" content="text/html; charset=UTF8">
00004     </title>
00005 <head>
00006 <LINK REL="stylesheet" type="text/css" href="../style-classic.css" media="screen">
00007 <link rel="icon" type="image/ico" href="../favicon.ico" />
00008  <META http-equiv="Content-Type" content="text/html; charset=UTF8">
00009  <script type="text/javascript" charset="<div>utf-8</div>" language="javascript" src="../js/prototype.js"></script>
00010  <script type="text/javascript" charset="utf-8" language="javascript" src="../js/infobulle.js"></script>
00011 </head>
00012 <body>
00013 <p align="center">
00014   <IMG SRC="../image/logo6720.png" alt="NOALYSS">
00015 </p>
00016 <?php
00017 
00018 /*
00019  *   This file is part of NOALYSS.
00020  *
00021  *   NOALYSS is free software; you can redistribute it and/or modify
00022  *   it under the terms of the GNU General Public License as published by
00023  *   the Free Software Foundation; either version 2 of the License, or
00024  *   (at your option) any later version.
00025  *
00026  *   NOALYSS is distributed in the hope that it will be useful,
00027  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00028  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00029  *   GNU General Public License for more details.
00030  *
00031  *   You should have received a copy of the GNU General Public License
00032  *   along with NOALYSS; if not, write to the Free Software
00033  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00034 */
00035 /* $Revision*/
00036 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00037 /*!\file
00038  * \brief This file permit to upgrade a version of NOALYSS , it should be
00039  *        used and immediately delete after an upgrade.
00040  *        This file is included in each release  for a new upgrade
00041  *
00042  */
00043 ?>
00044 <DIV id="bulle" class="infobulle"></DIV>
00045         <script type="text/javascript" language="javascript"  src="../js/infobulle.js"> </script>
00046                  <script type="text/javascript" charset="utf-8" language="javascript" src="setup.js"></script>
00047 
00048 <?php
00049 
00050 $failed="<span style=\"font-size:18px;color:red\">&#x2716;</span>";
00051 $succeed="<span style=\"font-size:18px;color:green\">&#x2713;</span>";
00052 $inc_path=get_include_path();
00053 global $os;
00054 $inc_path=get_include_path();
00055         global $os;
00056         if ( strpos($inc_path,";") != 0 ) {
00057           $new_path=$inc_path.';../../include;addon';
00058           $os=0;                        /* $os is 0 for windoz */
00059         } else {
00060           $new_path=$inc_path.':../../include:addon';
00061           $os=1;                        /* $os is 1 for unix */
00062         }
00063 /**
00064  *@brief create correctly the htaccess file
00065  */
00066 function create_htaccess()
00067 {
00068         global $os;
00069 
00070 
00071         /* If htaccess file doesn't exists we create them here
00072          * if os == 1 then windows, 0 means Unix
00073          */
00074         $file='..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'.htaccess';
00075         if (! file_exists($file))
00076         {
00077                 $hFile=@fopen($file,'w+');
00078                 if ( ! $hFile )     exit('Impossible d\'&eacute;crire dans le r&eacute;pertoire include');
00079                 fwrite($hFile,'order deny,allow'."\n");
00080                 fwrite($hFile,'deny from all'."\n");
00081                 fclose($hFile);
00082         }
00083         $file='..'.DIRECTORY_SEPARATOR.'.htaccess';
00084         if (! file_exists($file))
00085         {
00086 
00087                 $hFile=@fopen($file,'w+');
00088                 if ( ! $hFile )     exit('Impossible d\'&eacute;crire dans le r&eacute;pertoire html');
00089                 $array=array("php_flag  magic_quotes_gpc off",
00090                                  "php_value max_execution_time 240",
00091                                  "php_value memory_limit 20M",
00092                                  "AddDefaultCharset utf-8",
00093                                  "php_flag  register_globals off",
00094                                  "php_value error_reporting 10239",
00095                                  "php_value post_max_size 20M",
00096                                  "php_flag short_open_tag on",
00097                                  "php_value upload_max_filesize 20M",
00098                                  "php_value session.use_trans_sid 1",
00099                                  "php_value session.use_cookies 1",
00100                                  "php_flag session.use_only_cookies on");
00101 
00102                 if ( $os == 0 )
00103                   fwrite($hFile,'php_value include_path .;../../include;../include;addon'."\n");
00104                 else
00105                   fwrite($hFile,'php_value include_path .:../../include:../include:addon'."\n");
00106                 foreach ($array as $value ) fwrite($hFile,$value."\n");
00107                 fclose($hFile);
00108         }
00109 
00110 }
00111 
00112 /* The config file is created here */
00113 if (isset($_POST['save_config'])) {
00114   require_once('../../include/config_file.php');
00115   $url=config_file_create($_POST,1,$os);
00116 echo '
00117 <form method="post" >
00118     Les informations sont sauv&eacute;es vous pouvez continuer
00119 <input type="submit" class="button" value="Continuer">
00120 </form>';
00121  exit();
00122  }
00123 if ( is_writable ('..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'constant.php') == false ) {
00124     echo '<h2 class="notice"> Ecriture non possible </h2><p class="warning"> On ne peut pas &eacute;crire dans le r&eacute;pertoire de NOALYSS, changez-en les droits </p>';
00125     exit();
00126   }
00127 
00128 
00129 if ( ! file_exists('..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'config.inc.php')) {
00130   echo '<h1 class="info">Entrez les informations n&eacute;cessaires &agrave; noalyss</h1>';
00131   echo '<form method="post">';
00132   require_once('../../include/config_file.php');
00133   echo config_file_form();
00134   echo '<div style="position:float;float:left;"></div>';
00135   echo HtmlInput::submit('save_config','Sauver la configuration');
00136   echo "</div>";
00137   echo '</form>';
00138   exit();
00139 }
00140 
00141 //----------------------------------------------------------------------
00142 // End functions
00143 //
00144 //----------------------------------------------------------------------
00145 
00146 // Verify some PHP parameters
00147 // magic_quotes_gpc = Off
00148 // magic_quotes_runtime = Off
00149 // magic_quotes_sybase = Off
00150 // include_path
00151 require_once '../../include/constant.php';
00152 require_once('config_file.php');
00153 require_once('class_database.php');
00154 if ( defined ("MULTI") && MULTI==1) { create_htaccess();}
00155 
00156 echo "<h1>Configuration</h1>";
00157 ?>
00158 <h2>Info</h2>
00159 Vous utilisez le domaine <?php echo domaine; ?>
00160 <h2>PHP</h2>
00161 <?php
00162 
00163 $flag_php=0;
00164 
00165 //ini_set("memory_limit","200M");
00166 echo "<ul style=\"list-style-type: square;\">";
00167 foreach (array('magic_quotes_gpc','magic_quotes_runtime') as $a) {
00168 echo "<li>";
00169   if ( ini_get($a) == false ) print $a.': '.$succeed;
00170   else {
00171         print $a.': '.$failed;
00172         print ("<h2 class=\"error\">$a a une mauvaise valeur !</h2>");
00173         $flag_php++;
00174   }
00175 
00176 echo "</li>";
00177 }
00178 $module=get_loaded_extensions();
00179 
00180 echo "<li>";
00181 if ( in_array('pgsql',$module) == false )
00182 {
00183   echo 'module PGSQL '.$failed;
00184   print '<span class="warning">D&eacute;sol&eacute; mais soit vous n\'avez pas install&eacute; ou activé l\'extension(pgsql)  pour postgresql soit php n\'a pas pas &eacute;t&eacute; compil&eacute; avec les bonnes options </span>';
00185   $flag_php++;
00186 } else echo 'module PGSQL '.$succeed;
00187 echo "</li>";
00188 
00189 echo "<li>";
00190 if ( in_array('bcmath',$module) == false )
00191 {
00192   echo 'module BCMATH ok '.$failed;
00193   print '<span class="warning">D&eacute;sol&eacute; mais soit vous n\'avez pas install&eacute; ou activé l\'extension (bcmath)  pour bcmath soit php n\'a pas pas &eacute;t&eacute; compil&eacute; avec les bonnes options </span>';
00194   $flag_php++;
00195 } else echo 'module BCMATH '.$succeed;
00196 echo "</li>";
00197 
00198 echo "<li>";
00199 if ( in_array('gettext',$module) == false )
00200 {
00201   echo 'module GETTEXT '.$failed;
00202   print '<span class="warning">D&eacute;sol&eacute; mais soit vous n\'avez pas install&eacute; ou activé l\'extension  (gettext) pour gettext soit php n\'a pas pas &eacute;t&eacute; compil&eacute; avec les bonnes options </span>';
00203   $flag_php++;
00204 } else echo 'module GETTEXT '.$succeed;
00205 echo "</li>";
00206 
00207 echo "<li>";
00208 if ( in_array('zip',$module) == false )
00209 {
00210   echo 'module ZIP '.$failed;
00211   print '<span class="warning">D&eacute;sol&eacute; mais soit vous n\'avez pas install&eacute; ou activé l\'extension (zip) pour zip soit php n\'a pas pas &eacute;t&eacute; compil&eacute; avec les bonnes options </span>';
00212   $flag_php++;
00213 } else echo 'module ZIP '.$succeed;
00214 echo "</li>";
00215 
00216 if ( ini_get("max_execution_time") < 60 )  {
00217         echo "<li>";
00218         echo 'Avertissement : '.$failed;
00219         print '<span class="info"> max_execution_time devrait être de 60 minimum</span>';
00220         echo "</li>";
00221 }
00222 
00223 if ( ini_get("register_globals") == true)  {
00224         echo "<li>";
00225         echo 'Avertissement : '.$failed;
00226         print '<span class="warning"> register_globals doit être à off</span>';
00227         echo "</li>";
00228         $flag_php++;
00229 }
00230 
00231 if ( ini_get("session.use_trans_sid") == false )  {
00232         echo "<li>";
00233         echo 'Avertissement : '.$failed;
00234         print '<span class="warning"> avertissement session.use_trans_sid should be set to true </span>';
00235         echo "</li>";
00236 }
00237 
00238 echo "</li>";
00239 
00240  echo "</ul>";
00241 if ( $flag_php==0 ) {
00242         echo '<p class="info"> php.ini est bien configur&eacute; '.$succeed.'</p>';
00243 } else {
00244         echo '<p class="warning"> php mal configur&eacute; '.$failed.'</p>';
00245 }
00246 /* check user */
00247 if ( (defined("MULTI") && MULTI==1)|| !defined("MULTI"))
00248 {
00249 
00250         $cn=new Database(-1,'template');
00251 } else
00252 {
00253         $cn=new Database();
00254 }
00255 
00256 ?>
00257 <h2>Base de données</h2>
00258 <?php
00259  // Verify Psql version
00260  //--
00261 $sql="select setting from pg_settings where name='server_version'";
00262 $version=$cn->get_value($sql);
00263 
00264 var_dump($version);
00265 
00266 if ( $version[0] < 8 ||
00267      ($version[0]=='8' && $version[2]<4)
00268      )
00269   {
00270 ?>
00271   <p><?php echo $failed?> Vous devez absolument utiliser au minimum une version 8.4 de PostGresql, si votre distribution n'en
00272 offre pas, installez en une en la compilant. </p><p>Lisez attentivement la notice sur postgresql.org pour migrer
00273 vos bases de donn&eacute;es
00274 </p>
00275 <?php exit(); //'
00276 }
00277 
00278 ?>
00279 <h3>Paramètre base de données</h3>
00280 <?php
00281 // Language plsql is installed
00282 //--
00283 $sql="select lanname from pg_language where lanname='plpgsql'";
00284 $Res=$cn->count_sql($sql);
00285 if ( $Res==0) { ?>
00286 <p><?php echo $failed?> Vous devez installer le langage plpgsql pour permettre aux fonctions SQL de fonctionner.</p>
00287 <p>Pour cela, sur la ligne de commande en tant qu\'utilisateur postgres, faites createlang plpgsql template1
00288 </p>
00289 
00290 <?php exit(); }
00291 
00292 include_once('ac_common.php');
00293 require_once('class_dossier.php');
00294 
00295 // Memory setting
00296 //--
00297 $sql="select name,setting
00298       from pg_settings
00299       where
00300       name in ('effective_cache_size','shared_buffers')";
00301 $cn->exec_sql($sql);
00302 $flag=0;
00303 for ($e=0;$e<$cn->size();$e++) {
00304   $a=$cn->fetch($e);
00305   switch ($a['name']){
00306   case 'effective_cache_size':
00307     if ( $a['setting'] < 1000 ){
00308 
00309       print '<p class="warning">'.$failed.'Attention le param&egrave;tre effective_cache_size est de '.
00310         $a['setting']." au lieu de 1000 </p>";
00311       $flag++;
00312     }
00313     break;
00314   case 'shared_buffers':
00315     if ( $a['setting'] < 640 ){
00316       print '<p class="warning">'.$failed.'Attention le param&egrave;tre shared_buffer est de '.
00317         $a['setting']."au lieu de 640</p>";
00318       $flag++;
00319     }
00320     break;
00321   }
00322  }
00323 if ( $flag == 0 ) {
00324   echo '<p class="info"> La base de donn&eacute;es est bien configur&eacute;e '.$succeed.'</p>';
00325  } else {
00326   echo '<p class="warning">'.$failed.'Il y a '.$flag.' param&egrave;tre qui sont trop bas</p>';
00327  }
00328 if ( ! isset($_POST['go']) ) {
00329 ?>
00330 <FORM action="setup.php" METHOD="post">
00331 <input type="submit" name="go" value="Pr&ecirc;t &agrave; commencer la mise &agrave; jour ou l'installation?">
00332 </form>
00333 <?php
00334 }
00335 if ( ! isset($_POST['go']) )
00336         exit();
00337 // Check if account_repository exists
00338         if (!defined("MULTI") || (defined("MULTI") && MULTI == 1))
00339                 $account = $cn->count_sql("select * from pg_database where datname=lower('" . domaine . "account_repository')");
00340         else
00341                 $account=1;
00342 
00343 // Create the account_repository
00344 if ($account == 0 ) {
00345 
00346   echo "Creation of ".domaine."account_repository";
00347   if ( ! DEBUG) ob_start();
00348   $cn->exec_sql("create database ".domaine."account_repository encoding='utf8'");
00349   $cn=new Database();
00350   $cn->start();
00351   $cn->execute_script("sql/account_repository/schema.sql");
00352   $cn->execute_script("sql/account_repository/data.sql");
00353   $cn->execute_script("sql/account_repository/constraint.sql");
00354   $cn->commit($cn);
00355 
00356  if ( ! DEBUG) ob_end_clean();
00357 
00358   echo "Creation of Modele1";
00359   if ( ! DEBUG) ob_start();
00360   $cn->exec_sql("create database ".domaine."mod1 encoding='utf8'");
00361 
00362   $cn=new Database(1,'mod');
00363   $cn->start();
00364   $cn->execute_script('sql/mod1/schema.sql');
00365   $cn->execute_script('sql/mod1/data.sql');
00366   $cn->execute_script('sql/mod1/constraint.sql');
00367   $cn->commit();
00368 
00369   if ( ! DEBUG) ob_end_clean();
00370 
00371   echo "Creation of Modele2";
00372   $cn->exec_sql("create database ".domaine."mod2 encoding='utf8'");
00373   $cn=new Database(2,'mod');
00374   $cn->start();
00375   if ( ! DEBUG) { ob_start();  }
00376   $cn->execute_script('sql/mod1/schema.sql');
00377   $cn->execute_script('sql/mod2/data.sql');
00378   $cn->execute_script('sql/mod1/constraint.sql');
00379   $cn->commit();
00380 
00381  if ( ! DEBUG) ob_end_clean();
00382 
00383  }// end if
00384 // Add a french accountancy model
00385 //--
00386 $cn=new Database();
00387 
00388 echo "<h1>Mise a jour du systeme</h1>";
00389 echo "<h2 > Mise &agrave; jour dossier</h2>";
00390 if  (defined("MULTI") && MULTI == 0)
00391 {
00392         $db = new Database();
00393         if ($db->exist_table("version") == false)
00394         {
00395                 echo '<p class="warning">' . $failed . 'La base de donnée ' . dbname . ' est vide, veuillez y restaurer un modèle de base de données plus le script mono.sql
00396                                 , ce script se trouve dans noalyss/contrib/mono.sql</p>';
00397                 exit();
00398         }
00399         echo "<h3>Patching " . dbname . '</h3>';
00400         $db->apply_patch(dbname);
00401         echo "<p class=\"info\">Tout est install&eacute; $succeed";
00402         ?>
00403                 <A style="" class="button" HREF="../index.php">Connectez-vous à NOALYSS</A>
00404         <?php
00405         exit();
00406 }
00407 
00408 /*
00409  * If multi folders
00410  */
00411 $Resdossier=$cn->exec_sql("select dos_id, dos_name from ac_dossier");
00412 $MaxDossier=$cn->size($Resdossier);
00413 
00414 //----------------------------------------------------------------------
00415 // Upgrade the folders
00416 //----------------------------------------------------------------------
00417 
00418 for ($e=0;$e < $MaxDossier;$e++) {
00419    $db_row=Database::fetch_array($Resdossier,$e);
00420   echo "<h3>Patching ".$db_row['dos_name'].'</h3>';
00421 
00422   $name=$cn->format_name($db_row['dos_id'],'dos');
00423 
00424   if ( $cn->exist_database($name)> 0 )
00425   {
00426     $db=new Database($db_row['dos_id'],'dos');
00427     $db->apply_patch($db_row['dos_name']);
00428     Dossier::synchro_admin($db_row['dos_id']);
00429 
00430   } else
00431   {
00432       echo_warning(_("Dossier inexistant")." $name");
00433   }
00434  }
00435 
00436 //----------------------------------------------------------------------
00437 // Upgrade the template
00438 //----------------------------------------------------------------------
00439 $Resdossier=$cn->exec_sql("select mod_id, mod_name from modeledef");
00440 $MaxDossier=$cn->size();
00441 echo "<h2>Mise &agrave; jour mod&egrave;le</h2>";
00442 
00443 for ($e=0;$e < $MaxDossier;$e++) {
00444   $db_row=Database::fetch_array($Resdossier,$e);
00445   echo "<h3>Patching ".$db_row['mod_name']."</h3>";
00446   $name=$cn->format_name($db_row['mod_id'],'mod');
00447 
00448   if ( $cn->exist_database($name)> 0 )
00449   {
00450     $db=new Database($db_row['mod_id'],'mod');
00451     $db->apply_patch($db_row['mod_name']);
00452    } else
00453   {
00454       echo_warning(_("Modèle inexistant")." $name");
00455   }
00456  }
00457 
00458 //----------------------------------------------------------------------
00459 // Upgrade the account_repository
00460 //----------------------------------------------------------------------
00461  echo "<h2>Mise &agrave; jour Repository</h2>";
00462  $cn=new Database();
00463  if ( DEBUG == false ) ob_start();
00464  $MaxVersion=DBVERSIONREPO-1;
00465  for ($i=4;$i<= $MaxVersion;$i++)
00466    {
00467         if ( $cn->get_version() <= $i ) {
00468           $cn->execute_script('sql/patch/ac-upgrade'.$i.'.sql');
00469         }
00470    }
00471 
00472  if (! DEBUG) ob_end_clean();
00473  echo "<p class=\"info\">Tout est install&eacute; $succeed";
00474 ?>
00475 </p>
00476 <A style="" class="button" HREF="../index.php">Connectez-vous à NOALYSS</A>
 All Data Structures Namespaces Files Functions Variables Enumerations