00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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;
00037 }
00038 else
00039 {
00040 $os=1;
00041 }
00042 return $os;
00043 }
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 function config_file_form($p_array=null)
00056 {
00057 $os=is_unix();
00058 if ( $p_array == null )
00059 {
00060
00061
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
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
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 }