noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
config_file.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00021 
00022 /*!\file
00023  * \brief functions concerning the config file config.inc.php. The domain is not set into the form for security issues
00024  */
00025 
00026 require_once("class_itext.php");
00027 require_once '../../include/class_iselect.php';
00028 require_once '../../include/class_icheckbox.php';
00029 
00030 function is_unix()
00031 {
00032     $inc_path=get_include_path();
00033 
00034     if ( strpos($inc_path,";") != 0 )
00035     {
00036         $os=0;                  /* $os is 0 for windoz */
00037     }
00038     else
00039     {
00040         $os=1;                  /* $os is 1 for unix */
00041     }
00042     return $os;
00043 }
00044 
00045 
00046 /*!\brief
00047  *\param array with the index
00048  *  - ctmp temporary folder
00049  *  - cpath path to postgresql
00050  *  - cuser postgresql user
00051  *  - cpasswd password of cuser
00052  *  - cport port for postgres
00053  *\return string with html code
00054  */
00055 function config_file_form($p_array=null)
00056 {
00057         $os=is_unix();
00058     if ( $p_array == null )
00059     {
00060 
00061         /* default value */
00062         $ctmp=($os==1)?'/tmp':'c:/tmp';
00063         $cpath=($os==1)?'/usr/bin':'c:/noalyss/postgresql/bin';
00064         $cuser='noalyss_sql';
00065         $cpasswd='dany';
00066         $cport=5432;
00067         $cdomain='';
00068         $clocale=1;
00069                 $multi=1;
00070                 $cdbname="database_noalyss";
00071 
00072     }
00073     else extract ($p_array);
00074 
00075     $ictmp=new IText('ctmp',$ctmp);
00076     $ictmp->size=25;
00077 
00078     $iclocale=new ISelect('clocale');
00079         $iclocale->value=array(
00080                 array("value"=>1,"label"=>"Activé"),
00081                 array("value"=>0,"label"=>"Désactivé")
00082         );
00083         $iclocale->selected=1;
00084 
00085         $icpath=new IText("cpath",$cpath);
00086         $icpath->size=30;
00087 
00088         $icuser=new IText('cuser',$cuser);
00089         $icpasswd=new IText('cpasswd',$cpasswd);
00090         $icport=new IText("cport",$cport);
00091         /*
00092          * For version MONO
00093          */
00094         $smulti=new ICheckBox('multi');
00095         $smulti->javascript=' onchange="show_dbname(this)" ';
00096 
00097         $icdbname=new IText('cdbname');
00098 
00099         require 'template_config_form.php';
00100 }
00101 /*!\brief create the config file
00102  */
00103 function config_file_create($p_array,$from_setup=1,$p_os=1)
00104 {
00105     extract ($p_array);
00106     $add=($from_setup==1)?'..'.DIRECTORY_SEPARATOR:'';
00107     $hFile=  fopen($add.'..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'config.inc.php','w');
00108     fputs($hFile,'<?php ');
00109     fputs($hFile,"\r\n");
00110     fputs($hFile, 'date_default_timezone_set (\'Europe/Brussels\');');
00111     fputs($hFile,"\r\n");
00112     fputs($hFile, "\$_ENV['TMP']='".$ctmp."';");
00113     fputs($hFile,"\r\n");
00114     fputs($hFile, 'define("PG_PATH","'.$cpath.'");');
00115     fputs($hFile,"\r\n");
00116     if ( $p_os == 1 )
00117     {
00118         fputs($hFile, 'define("PG_RESTORE","'.$cpath.DIRECTORY_SEPARATOR.'pg_restore ");');
00119         fputs($hFile,"\r\n");
00120         fputs($hFile, 'define("PG_DUMP","'.$cpath.DIRECTORY_SEPARATOR.'pg_dump ");');
00121         fputs($hFile,"\r\n");
00122         fputs($hFile, 'define ("PSQL","'.$cpath.DIRECTORY_SEPARATOR.'psql");');
00123     }
00124     else
00125     {
00126         fputs($hFile, 'define("PG_RESTORE","pg_restore.exe");');
00127         fputs($hFile,"\r\n");
00128         fputs($hFile, 'define("PG_DUMP","pg_dump.exe");');
00129         fputs($hFile,"\r\n");
00130         fputs($hFile, 'define ("PSQL","psql.exe");');
00131     }
00132     fputs($hFile,"\r\n");
00133     fputs($hFile, 'define ("noalyss_user","'.$cuser.'");');
00134     fputs($hFile,"\r\n");
00135     fputs($hFile, 'define ("noalyss_password","'.$cpasswd.'");');
00136     fputs($hFile,"\r\n");
00137     fputs($hFile, 'define ("noalyss_psql_port","'.$cport.'");');
00138     fputs($hFile,"\r\n");
00139     fputs($hFile, 'define ("noalyss_psql_host","127.0.0.1");');
00140     fputs($hFile,"\r\n");
00141 
00142     fputs($hFile, 'define ("LOCALE",'.$clocale.');');
00143     fputs($hFile,"\r\n");
00144 
00145     fputs($hFile, 'define ("domaine","");');
00146     fputs($hFile,"\r\n");
00147     if (isset ($multi)) fputs($hFile, 'define ("MULTI",0);');
00148     if (! isset ($multi))       fputs($hFile, 'define ("MULTI",1);');
00149         fputs($hFile,"\r\n");
00150     fputs($hFile, 'define ("dbname","'.$cdbname.'");');
00151     fputs($hFile,"\r\n");
00152 
00153     fputs($hFile,'?>');
00154     fclose($hFile);
00155 }
 All Data Structures Namespaces Files Functions Variables Enumerations