noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 13/16: Improve installation system


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 13/16: Improve installation system
Date: Tue, 20 Oct 2015 14:26:35 +0000

sparkyx pushed a commit to branch master
in repository noalyss.

commit ac90cfcb82828e5ec42ffd1eeb25e1699b06571b
Author: Dany De Bontridder <address@hidden>
Date:   Tue Oct 20 15:34:29 2015 +0200

    Improve installation system
---
 html/admin-noalyss.php                    |    5 +
 html/index.php                            |   10 +-
 html/{admin/setup.php => install.php}     |  217 +++++++++++++++--------------
 html/js/setup.js                          |   14 +--
 include/lib/class_database.php            |   15 ++-
 include/lib/config_file.php               |  171 ++++++++++++----------
 include/template/template_config_form.php |   22 +++-
 include/upgrade.inc.php                   |    2 +-
 8 files changed, 256 insertions(+), 200 deletions(-)

diff --git a/html/admin-noalyss.php b/html/admin-noalyss.php
index 45740f7..5f6ac73 100644
--- a/html/admin-noalyss.php
+++ b/html/admin-noalyss.php
@@ -31,5 +31,10 @@ if (file_exists("../include/config.inc.php") ) {
     define ('ALLOWED',1);
     require_once '../include/constant.php';
     require_once NOALYSS_INCLUDE.'/admin_repo.inc.php';
+} else {
+    // Redirect to install file , if this file exists then 
+    // we can't connect to anything
+    echo '<HTML><head><META HTTP-EQUIV="REFRESH" 
content="0;url=install.php"></head><body> Connecting... </body></html>';
+
 }
 ?>
diff --git a/html/index.php b/html/index.php
index dc0c14b..f35ae1e 100644
--- a/html/index.php
+++ b/html/index.php
@@ -134,7 +134,7 @@
 
 if ( ! 
file_exists('..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'config.inc.php'))
 {
-    header("Location: setup.php",true, 307);
+    header("Location: install.php",true, 307);
     exit(0);
 }
 
@@ -209,7 +209,13 @@ $my_domain="";
 require_once '../include/constant.php';
 require_once '../include/config.inc.php';
 require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
-
+if (file_exists("install.php")) {
+    /*
+     * This file shouldn't exist
+     */
+    echo _("Le fichier install.php est encore présent, vous devez l'effacer 
avant d'utiliser NOALYSS");
+    return;
+}
 if ( strlen(domaine) > 0 )
 {
     $my_domain="Domaine : ".domaine;
diff --git a/html/admin/setup.php b/html/install.php
similarity index 76%
rename from html/admin/setup.php
rename to html/install.php
index fc2c906..1b5d088 100644
--- a/html/admin/setup.php
+++ b/html/install.php
@@ -3,13 +3,14 @@ session_start();
 ?>
 <!doctype html>
 <HTML><HEAD>
-    <TITLE>Noalyss - Mise à jour</TITLE>
+    <TITLE>Noalyss - Install</TITLE>
     <META http-equiv="Content-Type" content="text/html; charset=UTF8">
     </title>
 <head>
-<link rel="icon" type="image/ico" href="../favicon.ico" />
+<link rel="icon" type="image/ico" href="favicon.ico" />
  <META http-equiv="Content-Type" content="text/html; charset=UTF8">
- <script type="text/javascript" charset="<div>utf-8</div>" 
language="javascript" src="../js/prototype.js"></script>
+ <script type="text/javascript" charset="utf-8" language="javascript" 
src="js/prototype.js"></script>
+ <link type="text/css" REL="stylesheet" href="style-classic.css"/>
  <style>
      body {
          font : 100%;
@@ -43,7 +44,7 @@ session_start();
         border:0px;
         text-decoration:none;
         font-family: helvetica,arial,sans-serif;
-        background-image: url("../image/bg-submit2.gif");
+        background-image: url("image/bg-submit2.gif");
         background-repeat: repeat-x;
         background-position: left;
         text-decoration:none;
@@ -70,7 +71,7 @@ session_start();
 </head>
 <body>
 <p align="center">
-  <IMG SRC="../image/logo6820.png" style="width: 415px;height: 200px" 
alt="NOALYSS">
+  <IMG SRC="image/logo6820.png" style="width: 365px;height: 150px" 
alt="NOALYSS">
 </p>
 
 <?php
@@ -114,15 +115,16 @@ if ( ! isset($_GET['lang'])){
 <?php
     exit();
 }
-require_once '../../include/constant.php';
+require_once '../include/constant.php';
 include_once NOALYSS_INCLUDE.'/lib/ac_common.php';
+include_once NOALYSS_INCLUDE.'/lib/class_html_input.php';
 if ( $_GET['lang'] == "en_US.utf8" || $_GET['lang']=='fr_FR.utf8')
 {
-    $_SESSION['g_lang']='en_US.utf8';
+    $_SESSION['g_lang']=$_GET['lang'];
     set_language();
 }
 ?>
- <script type="text/javascript" charset="utf-8" language="javascript" 
src="../js/infobulle.js">
+ <script type="text/javascript" charset="utf-8" language="javascript" 
src="js/infobulle.js">
 </script>
 <script>
 content[200]="<?php echo _("Indiquez ici le récuterpertoire où les documents 
temporaires peuvent être sauvés exemple c:/temp, /tmp")?>";
@@ -133,6 +135,7 @@ content[204]="<?php echo _("Mot de passe de l'utilisateur 
de Postgresql")?>";
 content[205]="<?php echo _("Port de postgresql")?>";
 content[206]="<?php echo _("En version mono dossier, le nom de la base de 
données doit être mentionné")?>";
 content[207]="<?php echo _("Vous devez choisir si NOALYSS est installé sur 
l'un de vos servers ou sur un server mutualisé qui ne donne qu'une seule base 
de données")?>";
+content[208]="<?php echo _("Serveur postgresql")?>";
 
 </script>
 
@@ -203,28 +206,87 @@ function create_htaccess()
        }
 
 }
-
-/* The config file is created here */
-if (isset($_POST['save_config'])) {
-  require_once NOALYSS_INCLUDE.'/lib/config_file.php';
-  $url=config_file_create($_POST,1,$os);
-echo '
-<form method="post" action="?lang='.$_GET['lang'].'" >'.
-    _('Les informations sont sauv&eacute;es vous pouvez continuer').
-'<input type="submit" class="button" value="'._('Continuer').'">
-</form>';
- exit();
- }
+// Retrieve informations from the very screen
+// 
+$db_user=HtmlInput::default_value_request("cuser", "");
+$db_password=HtmlInput::default_value_request("cpasswd", "");
+$db_host=HtmlInput::default_value_request("chost", "");
+$db_port=HtmlInput::default_value_request("cport", "");
+$multi=HtmlInput::default_value_request("multi", "N");
+$locale=HtmlInput::default_value_request("clocale", "1");
+$ctmp=HtmlInput::default_value_request("ctmp", "/tmp");
+$cpath=HtmlInput::default_value_request("cpath", "/usr/bin");
+$db_name=HtmlInput::default_value_request("cdbname", "");
+
+//-------------------------------------------------------------------------
+// warn only if we can not write in include 
+//-------------------------------------------------------------------------
 if ( is_writable 
('..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'constant.php')
 == false ) {
     echo '<h2 class="notice"> '._("Ecriture non possible").' </h2>'.
             '<p class="warning"> '.
             _("On ne peut pas écrire dans le répertoire de NOALYSS, changez-en 
les droits ")
             .'</p>';
-    exit();
   }
+  
+//----------------------------------------------------------------------------
+// We try to connect with the supplied information
+// If we succeed we continue the check
+// otherwise we turn back to the first screen
+// The config file is created here 
+//----------------------------------------------------------------------------
+
+if (isset($_POST['save_config'])) {
+  require_once NOALYSS_INCLUDE.'/lib/config_file.php';
+  // Try to connect , if it doesn't work that do not create the config file 
+  if ($multi=="N") {
+    $cnx = Database::connect($db_user, $db_password,'template1', $db_host, 
$db_port); 
+  }else {
+    $cnx = Database::connect($db_user, $db_password,$db_name, $db_host, 
$db_port); 
+  }
+  // ----- 
+  // If conx successfull save the file or display it
+  // -----
+  if ( $cnx !== false ) {
+      // Create the db
+      if (is_writable(NOALYSS_INCLUDE)) { 
+        $url=config_file_create($_POST,1,$os); 
+        echo '
+            <form method="post" action="?lang='.$_GET['lang'].'" >'.
+           _('Les informations sont sauv&eacute;es vous pouvez continuer').
+          '<input type="submit" class="button" value="'._('Continuer').'">
+            </form>';
+        return;
+      } else {
+          echo '<p class="warning">';
+          echo _('Fichier non sauvé');
+          echo '</p>';
+          echo '<p>';
+          printf ( _('Créez ce fichier %s avec les informations suivantes '),
+                  NOALYSS_INCLUDE.'/config.inc.php');
+          echo '</p>';
+          echo '<p>';
+          print (_('Puis cliquez sur ce lien'))." ";
+          echo '<a 
href="install.php?lang='.$_GET['lang'].'">'._('Installation')."</a>";
+          echo '</p>';
+          echo '<textarea cols="80" rows="50" style="height:auto">';
+          echo display_file_config($_POST,1,$os);
+          echo '</textarea>';
+          return;
+      }
+  } else {
+      echo '<h1 class="warning">';
+      echo _('Impossible de se connecter à Postgresql, vérifiez les 
informations de connection');
+      echo '</h1>';
+  }
+ }
 
 
-if ( ! 
file_exists('..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'config.inc.php'))
 {
+//------------------------------------------------------------------------
+// Check that the file config.inc.php exists , if not then propose to 
+// enter information and exit
+//
+//------------------------------------------------------------------------
+if ( ! file_exists(NOALYSS_INCLUDE.'/config.inc.php')) {
   echo '<h1 class="info">'._('Entrez les informations nécessaires à 
noalyss').'</h1>';
   echo '<form method="post">';
   require_once NOALYSS_INCLUDE.'/lib/config_file.php';
@@ -232,7 +294,7 @@ if ( ! 
file_exists('..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'include'.D
   echo config_file_form();
   echo '<div style="position:float;float:left;"></div>';
   echo '<p style="text-align:center">',
-        HtmlInput::submit('save_config',_('Sauver la 
configuration'),"","button"),
+        HtmlInput::submit('save_config',_('Continuer'),"","button"),
           '</p>';
   echo "</div>";
   echo '</form>';
@@ -249,10 +311,11 @@ if ( ! 
file_exists('..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'include'.D
 // magic_quotes_runtime = Off
 // magic_quotes_sybase = Off
 // include_path
-require_once NOALYSS_INCLUDE.'/config_file.php';
+require_once NOALYSS_INCLUDE.'/lib/config_file.php';
 require_once NOALYSS_INCLUDE.'/lib/class_database.php';
 
-if ( defined ("MULTI") && MULTI==1) { create_htaccess();}
+// we shouldn't use it 
+// if ( defined ("MULTI") && MULTI==1) { create_htaccess();}
 
 echo '<h1 class="title">'._('Configuration').'</h1>';
 ?>
@@ -466,7 +529,7 @@ if ( $flag == 0 ) {
 if ( ! isset($_POST['go']) ) {
 ?>
 <span style="text-align: center">
-    <FORM METHOD="post" action="admin-noalyss.php?lang=<?php echo 
$_GET['lang']?>">
+    <FORM METHOD="post" action="install.php?lang=<?php echo $_GET['lang']?>">
 <input type="submit" class="button" name="go" value="<?php echo _("Commencer 
la mise à jour ou l'installation");?>">
 </form>
 </span>
@@ -475,10 +538,10 @@ if ( ! isset($_POST['go']) ) {
 if ( ! isset($_POST['go']) )
        exit();
 // Check if account_repository exists
-       if (!defined("MULTI") || (defined("MULTI") && MULTI == 1))
-               $account = $cn->count_sql("select * from pg_database where 
datname=lower('" . domaine . "account_repository')");
-       else
-               $account=1;
+if (!defined("MULTI") || (defined("MULTI") && MULTI == 1))
+        $account = $cn->count_sql("select * from pg_database where 
datname=lower('" . domaine . "account_repository')");
+else
+        $account=1;
 
 // Create the account_repository
 if ($account == 0 ) {
@@ -488,9 +551,9 @@ if ($account == 0 ) {
   $cn->exec_sql("create database ".domaine."account_repository 
encoding='utf8'");
   $cn=new Database();
   $cn->start();
-  $cn->execute_script("sql/account_repository/schema.sql");
-  $cn->execute_script("sql/account_repository/data.sql");
-  $cn->execute_script("sql/account_repository/constraint.sql");
+  $cn->execute_script(NOALYSS_INCLUDE."/sql/account_repository/schema.sql");
+  $cn->execute_script(NOALYSS_INCLUDE."/sql/account_repository/data.sql");
+  
$cn->execute_script(NOALYSS_INCLUDE."/sql/account_repository/constraint.sql");
   $cn->commit($cn);
 
  if ( ! DEBUG) ob_end_clean();
@@ -501,9 +564,9 @@ if ($account == 0 ) {
 
   $cn=new Database(1,'mod');
   $cn->start();
-  $cn->execute_script('sql/mod1/schema.sql');
-  $cn->execute_script('sql/mod1/data.sql');
-  $cn->execute_script('sql/mod1/constraint.sql');
+  $cn->execute_script(NOALYSS_INCLUDE.'/sql/mod1/schema.sql');
+  $cn->execute_script(NOALYSS_INCLUDE.'/sql/mod1/data.sql');
+  $cn->execute_script(NOALYSS_INCLUDE.'/sql/mod1/constraint.sql');
   $cn->commit();
 
   if ( ! DEBUG) ob_end_clean();
@@ -513,9 +576,9 @@ if ($account == 0 ) {
   $cn=new Database(2,'mod');
   $cn->start();
   if ( ! DEBUG) { ob_start();  }
-  $cn->execute_script('sql/mod1/schema.sql');
-  $cn->execute_script('sql/mod2/data.sql');
-  $cn->execute_script('sql/mod1/constraint.sql');
+  $cn->execute_script(NOALYSS_INCLUDE.'/sql/mod1/schema.sql');
+  $cn->execute_script(NOALYSS_INCLUDE.'/sql/mod2/data.sql');
+  $cn->execute_script(NOALYSS_INCLUDE.'/sql/mod1/constraint.sql');
   $cn->commit();
 
  if ( ! DEBUG) ob_end_clean();
@@ -553,13 +616,15 @@ if  (defined("MULTI") && MULTI == 0)
         for ($i=4;$i<= $MaxVersion;$i++)
         {
             if ( $db->get_value (' select val from repo_version') <= $i ) {
-                $db->execute_script('sql/patch/ac-upgrade'.$i.'.sql');
+                
$db->execute_script(NOALYSS_INCLUDE.'/sql/patch/ac-upgrade'.$i.'.sql');
             }
         }
-
+        echo "<h2 class=\"warning\">";
+        printf (" VOUS DEVEZ EFFACER CE FICHIER %s",__FILE__);
+        echo "</h2>";
        ?>
 <p style="text-align: center">
-               <A style="" class="button" HREF="../index.php"><?php echo 
_('Connectez-vous à NOALYSS')?></A>
+               <A style="" class="button" HREF="./index.php"><?php echo 
_('Connectez-vous à NOALYSS')?></A>
                 </p>
        <?php
        exit();
@@ -568,68 +633,14 @@ if  (defined("MULTI") && MULTI == 0)
 /*
  * If multi folders
  */
-$Resdossier=$cn->exec_sql("select dos_id, dos_name from ac_dossier");
-$MaxDossier=$cn->size($Resdossier);
-
-//----------------------------------------------------------------------
-// Upgrade the folders
-//----------------------------------------------------------------------
-
-for ($e=0;$e < $MaxDossier;$e++) {
-   $db_row=Database::fetch_array($Resdossier,$e);
-  echo "<h3>Patching ".$db_row['dos_name'].'</h3>';
+define ('ALLOWED',1);
+$_GET['sb']="upg_all";
+$rep=new Database();
+require NOALYSS_INCLUDE."/upgrade.inc.php";
+echo "<h2 class=\"warning\">";
+printf (" VOUS DEVEZ EFFACER CE FICHIER %s",__FILE__);
+echo "</h2>";
 
-  $name=$cn->format_name($db_row['dos_id'],'dos');
-
-  if ( $cn->exist_database($name)> 0 )
-  {
-    $db=new Database($db_row['dos_id'],'dos');
-    $db->apply_patch($db_row['dos_name']);
-    Dossier::synchro_admin($db_row['dos_id']);
-
-  } else
-  {
-      echo_warning(_("Dossier inexistant")." $name");
-  }
- } 
-
-//----------------------------------------------------------------------
-// Upgrade the template
-//----------------------------------------------------------------------
-$Resdossier=$cn->exec_sql("select mod_id, mod_name from modeledef");
-$MaxDossier=$cn->size();
-echo "<h2>"._("Mise à modèle")."</h2>";
-
-for ($e=0;$e < $MaxDossier;$e++) {
-  $db_row=Database::fetch_array($Resdossier,$e);
-  echo "<h3>Patching ".$db_row['mod_name']."</h3>";
-  $name=$cn->format_name($db_row['mod_id'],'mod');
-
-  if ( $cn->exist_database($name)> 0 )
-  {
-    $db=new Database($db_row['mod_id'],'mod');
-    $db->apply_patch($db_row['mod_name']);
-   } else
-  {
-      echo_warning(_("Modèle inexistant")." $name");
-  }
- }
-
-//----------------------------------------------------------------------
-// Upgrade the account_repository
-//----------------------------------------------------------------------
- echo "<h2>"._("Mise à jour de la base de données Paramètrage")."</h2>";
- $cn=new Database();
- if ( DEBUG == false ) ob_start();
- $MaxVersion=DBVERSIONREPO-1;
- for ($i=4;$i<= $MaxVersion;$i++)
-   {
-       if ( $cn->get_version() <= $i ) {
-         $cn->execute_script('sql/patch/ac-upgrade'.$i.'.sql');
-       }
-   }
-
- if (! DEBUG) ob_end_clean();
  echo "<p class=\"info\">"._("Tout est install&eacute;")." ". $succeed;
 ?>
 </p>
diff --git a/html/js/setup.js b/html/js/setup.js
index 82b90e1..ed2c36c 100644
--- a/html/js/setup.js
+++ b/html/js/setup.js
@@ -6,16 +6,4 @@
  */
 
 
-function show_dbname(obj) {
-       try {
-               if (obj.checked === true)
-               {
-                       
this.document.getElementById('div_db').style.visibility= 'visible';
-               }
-               else {
-                        
this.document.getElementById('div_db').style.visibility= 'hidden';
-               }
-       } catch (e) {
-               alert_box(e.getMessage);
-       }
-}
+
diff --git a/include/lib/class_database.php b/include/lib/class_database.php
index 7d65e0d..530ec82 100644
--- a/include/lib/class_database.php
+++ b/include/lib/class_database.php
@@ -114,7 +114,20 @@ class Database
         pg_exec($this->db, 'set DateStyle to ISO, MDY;');
         ob_end_clean();
     }
-
+    /**
+     * Connect to a database return an connx to db or false if it fails
+     * 
+     * @param string $p_user Username 
+     * @param type $p_password User's password
+     * @param $p_dbname name of the database to connect
+     * @param type $p_host Host of DB
+     * @param type $p_port Port of DB
+     */
+    static function connect($p_user,$p_password,$p_dbname,$p_host,$p_port) {
+        $a=pg_connect("dbname=$p_dbname host='$p_host' user='$p_user'
+                      password='$p_password' port=$p_port");
+        return $a;
+    }
     public function verify()
     {
         // Verify that the elt we want to add is correct
diff --git a/include/lib/config_file.php b/include/lib/config_file.php
index 432ff9c..d2091d1 100644
--- a/include/lib/config_file.php
+++ b/include/lib/config_file.php
@@ -66,8 +66,9 @@ function config_file_form($p_array=null)
         $cport=5432;
         $cdomain='';
         $clocale=1;
-               $multi=1;
-               $cdbname="database_noalyss";
+       $multi=1;
+       $cdbname="database_noalyss";
+        $chost="localhost";
 
     }
     else extract ($p_array);
@@ -88,6 +89,7 @@ function config_file_form($p_array=null)
        $icuser=new IText('cuser',$cuser);
        $icpasswd=new IText('cpasswd',$cpasswd);
        $icport=new IText("cport",$cport);
+       $ichost=new IText("chost",$chost);
        /*
         * For version MONO
         */
@@ -96,97 +98,110 @@ function config_file_form($p_array=null)
 
        $icdbname=new IText('cdbname');
 
-       require 'template_config_form.php';
+       require NOALYSS_INCLUDE.'/template/template_config_form.php';
 }
-/*!\brief create the config file
+/**
+ * Display the  content of the config.inc.php with variables
+ * @param type $p_array
+ * @param type $from_setup
+ * @param type $p_os
  */
-function config_file_create($p_array,$from_setup=1,$p_os=1)
+function display_file_config($p_array,$from_setup=1,$p_os=1) 
 {
-    extract ($p_array);
-    $add=($from_setup==1)?'..'.DIRECTORY_SEPARATOR:'';
-    $hFile=  
fopen($add.'..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'config.inc.php','w');
-    fputs($hFile,'<?php ');
-    fputs($hFile,"\r\n");
-    fputs($hFile, 'date_default_timezone_set (\'Europe/Brussels\');');
-    fputs($hFile,"\r\n");
-    fputs($hFile, "\$_ENV['TMP']='".$ctmp."';");
-    fputs($hFile,"\r\n");
-    fputs($hFile, 'define("PG_PATH","'.$cpath.'");');
-    fputs($hFile,"\r\n");
+    extract($p_array);
+    print ('<?php ');
+    print ("\r\n");
+    print ( 'date_default_timezone_set (\'Europe/Brussels\');');
+    print ("\r\n");
+    print ( "\$_ENV['TMP']='".$ctmp."';");
+    print ("\r\n");
+    print ( 'define("PG_PATH","'.$cpath.'");');
+    print ("\r\n");
     if ( $p_os == 1 )
     {
-        fputs($hFile, 
'define("PG_RESTORE","'.$cpath.DIRECTORY_SEPARATOR.'pg_restore ");');
-        fputs($hFile,"\r\n");
-        fputs($hFile, 'define("PG_DUMP","'.$cpath.DIRECTORY_SEPARATOR.'pg_dump 
");');
-        fputs($hFile,"\r\n");
-        fputs($hFile, 'define ("PSQL","'.$cpath.DIRECTORY_SEPARATOR.'psql");');
+        print ( 'define("PG_RESTORE","'.$cpath.DIRECTORY_SEPARATOR.'pg_restore 
");');
+        print ("\r\n");
+        print ( 'define("PG_DUMP","'.$cpath.DIRECTORY_SEPARATOR.'pg_dump ");');
+        print ("\r\n");
+        print ( 'define ("PSQL","'.$cpath.DIRECTORY_SEPARATOR.'psql");');
     }
     else
     {
-        fputs($hFile, 'define("PG_RESTORE","pg_restore.exe");');
-        fputs($hFile,"\r\n");
-        fputs($hFile, 'define("PG_DUMP","pg_dump.exe");');
-        fputs($hFile,"\r\n");
-        fputs($hFile, 'define ("PSQL","psql.exe");');
+        print ( 'define("PG_RESTORE","pg_restore.exe");');
+        print ("\r\n");
+        print ( 'define("PG_DUMP","pg_dump.exe");');
+        print ("\r\n");
+        print ( 'define ("PSQL","psql.exe");');
     }
-    fputs($hFile,"\r\n");
-    fputs($hFile, 'define ("noalyss_user","'.$cuser.'");');
-    fputs($hFile,"\r\n");
-    fputs($hFile, 'define ("noalyss_password","'.$cpasswd.'");');
-    fputs($hFile,"\r\n");
-    fputs($hFile, 'define ("noalyss_psql_port","'.$cport.'");');
-    fputs($hFile,"\r\n");
-    fputs($hFile, 'define ("noalyss_psql_host","127.0.0.1");');
-    fputs($hFile,"\r\n");
-
-    fputs($hFile, 'define ("LOCALE",'.$clocale.');');
-    fputs($hFile,"\r\n");
-
-    fputs($hFile, 'define ("domaine","");');
-    fputs($hFile,"\r\n");
+    print ("\r\n");
+    print ( 'define ("noalyss_user","'.$cuser.'");');
+    print ("\r\n");
+    print ( 'define ("noalyss_password","'.$cpasswd.'");');
+    print ("\r\n");
+    print ( 'define ("noalyss_psql_port","'.$cport.'");');
+    print ("\r\n");
+    print ( 'define ("noalyss_psql_host","'.$chost.'");');
+    print ("\r\n");
+
+    print ( 'define ("LOCALE",'.$clocale.');');
+    print ("\r\n");
+
+    print ( 'define ("domaine","");');
+    print ("\r\n");
     if (isset($multi))
     {
-        fputs($hFile, 'define ("MULTI",0);');
+        print ( 'define ("MULTI",0);');
     }
     if (!isset($multi))
     {
-        fputs($hFile, 'define ("MULTI",1);');
+        print ( 'define ("MULTI",1);');
     }
-    fputs($hFile,"\r\n");
-    fputs($hFile, 'define ("dbname","'.$cdbname.'");');
-    fputs($hFile,"\r\n");
+    print ("\r\n");
+    print ( 'define ("dbname","'.$cdbname.'");');
+    print ("\r\n");
     
-    fputs($hFile,' // Uncomment to DEBUG');
-    fputs($hFile,"\r\n");
-    fputs($hFile, '// define ("DEBUG",TRUE);');
-    fputs($hFile,"\r\n");
-    fputs($hFile,' // Uncomment to log your input');
-    fputs($hFile,"\r\n");   
-    fputs($hFile, '// define ("LOGINPUT",TRUE);');
-    fputs($hFile,"\r\n");
-    fputs($hFile,"\r\n");
-    fputs($hFile,"\r\n");
-    fputs($hFile,' // Do not change below !!!');
-    fputs($hFile,"\r\n");
-    fputs($hFile,' // These variable are computed but could be changed in ');
-    fputs($hFile,"\r\n");
-    fputs($hFile,' // very special configuration');
-    fputs($hFile,"\r\n");
-    fputs($hFile, '// define ("NOALYSS_HOME","");');
-    fputs($hFile,"\r\n");
-    fputs($hFile, '// define ("NOALYSS_PLUGIN","");');
-    fputs($hFile,"\r\n");
-    fputs($hFile, '// define ("NOALYSS_INCLUDE","");');
-    fputs($hFile,"\r\n");
-    fputs($hFile, '// define ("NOALYSS_TEMPLATE","");');
-    fputs($hFile,"\r\n");
-    fputs($hFile,"\r\n");
-    fputs($hFile,"\r\n");
-    fputs($hFile, "// Uncomment if you don't want "."\r\n");
-    fputs($hFile, "// to be informed when a new release is "."\r\n");
-    fputs($hFile, "// published"."\r\n");
-    fputs($hFile, '// define ("SITE_UPDATE","");'."\r\n");
-    fputs($hFile, '// define ("SITE_UPDATE_PLUGIN","");'."\r\n");
-    fputs($hFile,'?>');
+    print (' // Uncomment to DEBUG');
+    print ("\r\n");
+    print ( '// define ("DEBUG",TRUE);');
+    print ("\r\n");
+    print (' // Uncomment to log your input');
+    print ("\r\n");   
+    print ( '// define ("LOGINPUT",TRUE);');
+    print ("\r\n");
+    print ("\r\n");
+    print ("\r\n");
+    print (' // Do not change below !!!');
+    print ("\r\n");
+    print (' // These variable are computed but could be changed in ');
+    print ("\r\n");
+    print (' // very special configuration');
+    print ("\r\n");
+    print ( '// define ("NOALYSS_HOME","");');
+    print ("\r\n");
+    print ( '// define ("NOALYSS_PLUGIN","");');
+    print ("\r\n");
+    print ( '// define ("NOALYSS_INCLUDE","");');
+    print ("\r\n");
+    print ( '// define ("NOALYSS_TEMPLATE","");');
+    print ("\r\n");
+    print ("\r\n");
+    print ("\r\n");
+    print ( "// Uncomment if you don't want "."\r\n");
+    print ( "// to be informed when a new release is "."\r\n");
+    print ( "// published"."\r\n");
+    print ( '// define ("SITE_UPDATE","");'."\r\n");
+    print ( '// define ("SITE_UPDATE_PLUGIN","");'."\r\n");
+    print ('?>');
+}
+/*!\brief create the config file
+ */
+function config_file_create($p_array,$p_os=1)
+{
+    extract ($p_array);
+    $hFile=  fopen(NOALYSS_INCLUDE.'/config.inc.php','w');
+    ob_start();
+    display_file_config($p_array,$from_setup,$p_os);
+    $r=ob_get_clean();
+    fputs($hFile, $r);
     fclose($hFile);
 }
diff --git a/include/template/template_config_form.php 
b/include/template/template_config_form.php
index 9176963..6007d00 100644
--- a/include/template/template_config_form.php
+++ b/include/template/template_config_form.php
@@ -52,7 +52,11 @@
                <TD><?php echo $icpasswd->input();echo 
HtmlInput::infobulle(204)?></TD>
 </TR>
 <TR>
-       <TD><?php echo _('Port de postgresql');?> </TD>
+       <TD><?php echo _('Adresse Serveur Postgresql');?> </TD>
+       <TD><?php echo $ichost->input();echo HtmlInput::infobulle(208)?></TD>
+</TR>
+<TR>
+       <TD><?php echo _('Port de Postgresql');?> </TD>
        <TD><?php echo $icport->input();echo HtmlInput::infobulle(205)?></TD>
 </TR>
 <tr>
@@ -77,4 +81,18 @@
        }
        ?>
 </div>
-
+<script>
+function show_dbname(obj) {
+       try {
+               if (obj.checked === true)
+               {
+                       
this.document.getElementById('div_db').style.visibility= 'visible';
+               }
+               else {
+                        
this.document.getElementById('div_db').style.visibility= 'hidden';
+               }
+       } catch (e) {
+               alert_box(e.getMessage);
+       }
+}
+</script>
\ No newline at end of file
diff --git a/include/upgrade.inc.php b/include/upgrade.inc.php
index 015fd82..f633070 100644
--- a/include/upgrade.inc.php
+++ b/include/upgrade.inc.php
@@ -56,7 +56,7 @@ if ($sb === "upg_all" && 
(!defined('MULTI')||(defined('MULTI')&&MULTI==1)))
     {
         if ($cn->get_version()<=$i)
         {
-            $cn->execute_script('sql/patch/ac-upgrade'.$i.'.sql');
+            
$cn->execute_script(NOALYSS_INCLUDE.'/sql/patch/ac-upgrade'.$i.'.sql');
         }
     }
     //----------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]