noalyss Version-9
config_file.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21
22/*!
23 \file
24 * \brief functions concerning the config file config.inc.php. The domain is not set into the form for security issues
25 */
26
27
28function is_unix()
29{
30 $inc_path=get_include_path();
31
32 if ( strpos($inc_path,";") != 0 )
33 {
34 $os=0; /* $os is 0 for windoz */
35 }
36 else
37 {
38 $os=1; /* $os is 1 for unix */
39 }
40 return $os;
41}
42
43
44/*
45 * !\brief
46 *\param array with the index
47 * - ctmp temporary folder
48 * - cpath path to postgresql
49 * - cuser postgresql user
50 * - cpasswd password of cuser
51 * - cport port for postgres
52 *\return string with html code
53 */
55{
56 $os=is_unix();
57 if ( $p_array == null )
58 {
59
60 /* default value */
61 $ctmp=($os==1)?'/tmp':'c:/tmp';
62 $cpath=($os==1)?'/usr/bin':'c:/noalyss/postgresql/bin';
63 $cuser='noalyss_sql';
64 $cpasswd='dany';
65 $cport=5432;
66 $cdomain='';
67 $clocale=1;
68 $multi="N";
69 $cdbname="";
70 $chost="localhost";
71 $cadmin='admin';
73
74 }
75 else extract ($p_array, EXTR_SKIP);
76
77 $ictmp=new IText('ctmp',$ctmp);
78 $ictmp->size=25;
79
80 $iclocale=new ISelect('clocale');
81 $iclocale->value=array(
82 array("value"=>1,"label"=>"Activé"),
83 array("value"=>0,"label"=>"Désactivé")
84 );
85 $iclocale->selected=1;
86
87 $icpath=new IText("cpath",$cpath);
88 $icpath->size=30;
89
90 $icuser=new IText('cuser',$cuser);
91 $icpasswd=new IText('cpasswd',$cpasswd);
92 $icport=new IText("cport",$cport);
93 $ichost=new IText("chost",$chost);
94
95 $icadmin=new IText('cadmin',$cadmin);
96 $icadmin->set_require(true);
97 /*
98 * For version MONO
99 */
100 $smulti=new ICheckBox('multi');
101 $smulti->javascript=' onchange="show_dbname(this)" ';
102 $smulti->value = 'Y';
103 if ( isset($multi) && $multi == 'Y') {
104 $smulti->selected=true;
105
106 }
107 $icdbname=new IText('cdbname');
108 $icdbname->value=$cdbname;
109
110 $icpassword_admin=new IText('cpassword_admin');
111 $icpassword_admin->value=$cpassword_admin;
112 $icpassword_admin->set_require(true);
113
114 require NOALYSS_TEMPLATE.'/template_config_form.php';
115}
116/**
117 * @brief Display the content of the config.inc.php with variables
118 * @param type $p_array
119 * @param type $from_setup
120 * @param type $p_os
121 */
122function display_file_config($p_array, $from_setup = 1, $p_os = 1)
123{
124 extract($p_array, EXTR_SKIP);
125 print ('<?php ');
126 echo PHP_EOL;
127 print ('date_default_timezone_set (\'Europe/Brussels\');');
128 echo PHP_EOL;
129 print ("\$_ENV['TMP']='" . $ctmp . "';");
130 echo PHP_EOL;
131 print ('define("PG_PATH","' . $cpath . '");');
132 echo PHP_EOL;
133 if ($p_os == 1) {
134 print ('define("PG_RESTORE","' . $cpath . DIRECTORY_SEPARATOR . 'pg_restore ");');
135 echo PHP_EOL;
136 print ('define("PG_DUMP","' . $cpath . DIRECTORY_SEPARATOR . 'pg_dump ");');
137 echo PHP_EOL;
138 print ('define ("PSQL","' . $cpath . DIRECTORY_SEPARATOR . 'psql");');
139 } else {
140 print ('define("PG_RESTORE","pg_restore.exe");');
141 echo PHP_EOL;
142 print ('define("PG_DUMP","pg_dump.exe");');
143 echo PHP_EOL;
144 print ('define ("PSQL","psql.exe");');
145 }
146 echo PHP_EOL;
147 print ('define ("noalyss_user","' . $cuser . '");');
148 echo PHP_EOL;
149 print ('define ("noalyss_password","' . $cpasswd . '");');
150 echo PHP_EOL;
151 print ('define ("noalyss_psql_port","' . $cport . '");');
152 echo PHP_EOL;
153 print ('define ("noalyss_psql_host","' . $chost . '");');
154 echo PHP_EOL;
155 echo PHP_EOL;
156 print ("// If you change the NOALYSS_ADMINISTRATOR , you will need to rerun http://..../noalyss/html/install.php");
157 echo PHP_EOL;
158 print ("// But it doesn't change the password");
159 echo PHP_EOL;
160 print ('define ("NOALYSS_ADMINISTRATOR","' . $cadmin . '");');
161 echo PHP_EOL;
162 print ("// For changing the password of admin, go to preference or update in db");
163 echo PHP_EOL;
164 print ("// this password is only used when executing install.php ");
165 echo PHP_EOL;
166 print ('define ("NOALYSS_ADMIN_PASSWORD","' . $cpassword_admin . '");');
167 echo PHP_EOL;
168
169 print ('define ("LOCALE",' . $clocale . ');');
170 echo PHP_EOL;
171 echo "
172 /*
173 * DEBUGNOALYSS let you see more information when you develop.
174 * 0 = for production
175 * 1 = display all errors
176 * 2 = display all errors + more information
177 */
178";
179
180 echo PHP_EOL;
181 print ('define ("DEBUGNOALYSS",0);');
182 echo PHP_EOL;
183
184 print ('define ("domaine","");');
185 echo PHP_EOL;
186 if (isset($multi)) {
187 print ('define ("MULTI",0);');
188 }
189 if (!isset($multi)) {
190 print ('define ("MULTI",1);');
191 }
192 echo PHP_EOL;
193 print ('define ("dbname","' . $cdbname . '");');
194 echo PHP_EOL;
195
196 print (' // Uncomment to log your input');
197 echo PHP_EOL;
198 print ('// define ("LOGINPUT",TRUE);');
199 echo PHP_EOL;
200 echo PHP_EOL;
201 echo PHP_EOL;
202 print (' // Do not change below !!!');
203 echo PHP_EOL;
204 print (' // These variable are computed but could be changed in ');
205 echo PHP_EOL;
206 print (' // very special configuration');
207 echo PHP_EOL;
208 print ('// define ("NOALYSS_HOME","");');
209 echo PHP_EOL;
210 print ('// define ("NOALYSS_PLUGIN","");');
211 echo PHP_EOL;
212 print ('// define ("NOALYSS_INCLUDE","");');
213 echo PHP_EOL;
214 print ('// define ("NOALYSS_TEMPLATE","");');
215 echo PHP_EOL;
216 print ('// define ("NOALYSS_INCLUDE","");');
217 echo PHP_EOL;
218 print ('// define ("NOALYSS_TEMPLATE","");');
219 echo PHP_EOL;
220 print ("// Fix an issue with PDF when exporting receipt in PDF in ANCGL");
221 print ('// define ("FIX_BROKEN_PDF","NO");');
222 echo PHP_EOL;
223 print ("// Uncomment if you want to convert to PDF");
224 echo PHP_EOL;
225 print ("// With the unoconv tool");
226 echo PHP_EOL;
227 print ("//define ('OFFICE','HOME=/tmp unoconv ');");
228 echo PHP_EOL;
229 print ("//define ('GENERATE_PDF','YES');");
230 echo PHP_EOL;
231 print ("// Uncomment if you don't want ");
232 echo PHP_EOL;
233 print ("// to be informed when a new release is ");
234 echo PHP_EOL;
235 print ("// published");
236 echo PHP_EOL;
237 print ('// define ("SITE_UPDATE","");');
238 echo PHP_EOL;
239 print ('// define ("SITE_UPDATE_PLUGIN","");');
240 echo PHP_EOL;
241 print ('// To allow to access the Info system');
242 echo PHP_EOL;
243 print ('// define ("SYSINFO_DISPLAY",true);');
244 echo PHP_EOL;
245 print ('// For developpement');
246 echo PHP_EOL;
247 print ('// define ("NOALYSS VERSION",9999);');
248 echo PHP_EOL;
249 print (' // If you want to override the parameters you have to define OVERRIDE_PARAM');
250 echo PHP_EOL;
251 print ('// and give your own parameters for max_execution_time and memory_limit');
252 echo PHP_EOL;
253 print ("// define ('OVERRIDE_PARAM',1);");
254 echo PHP_EOL;
255 print ("// ini_set ('max_execution_time',240);");
256 echo PHP_EOL;
257 print ("// ini_set ('memory_limit','256M');");
258 echo PHP_EOL;
259 print ("// In recent distribution linux, pdftk is a snap, you should set the path");
260 echo PHP_EOL;
261 print ("// for exporting document in PDF");
262 echo PHP_EOL;
263 print ("// \$pdftk = /usr/bin/pdftk ");
264 echo PHP_EOL;
265 print ("// \$pdftk = /snap/bin/pdftk ");
266 echo PHP_EOL;
267 print ("// uncomment to activate the captcha on login page");
268 echo PHP_EOL;
269 print ("// define('NOALYSS_CAPTCHA',true);");
270 echo PHP_EOL;
271 print ("// Uncomment if you want to activate the possibility to reinitialize;");
272 echo PHP_EOL;
273 print ("// password by email");
274 echo PHP_EOL;
275 print ("// define ('RECOVER','1');");
276 echo PHP_EOL;
277 print ("// Uncomment and define if you want to Name of the sender of the email ");
278 echo PHP_EOL;
279 print ("// if you activate the possibility to reinitialize password by email");
280 echo PHP_EOL;
281 print ("// define('ADMIN_WEB', 'www-data@localhost');");
282 echo PHP_EOL;
283 print ("// Define a random session key if you work with different version of NOALYSS");
284 echo PHP_EOL;
285 printf("define ('SESSION_KEY','%s');", generate_random_string(10));
286 echo PHP_EOL;
287 printf("// When sending an email , the domain of this email must be in comma separated list ,");
288 echo PHP_EOL;
289 print ("// if the list is an empty string then all the domain are allowed");
290 echo PHP_EOL;
291 printf("// define ('ALLOWED_EMAIL_DOMAIN','');");
292 echo PHP_EOL;
293
294}
295/*!
296 * \brief create the config file
297 */
298function config_file_create($p_array,$from_setup,$p_os=1)
299{
300 extract ($p_array, EXTR_SKIP);
301 $hFile= fopen(NOALYSS_INCLUDE.'/config.inc.php','w');
302 ob_start();
303 display_file_config($p_array,$from_setup,$p_os);
304 $r=ob_get_clean();
305 fputs($hFile, $r);
306 fclose($hFile);
307}
308?>
generate_random_string($p_length, $special=1)
Create randomly a string.
Definition: ac_common.php:1420
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
Html Input.
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
Html Input.
Definition: itext.class.php:30
is_unix()
Definition: config_file.php:28
display_file_config($p_array, $from_setup=1, $p_os=1)
Display the content of the config.inc.php with variables.
config_file_form($p_array=null)
Definition: config_file.php:54
config_file_create($p_array, $from_setup, $p_os=1)
create the config file
$os
Definition: constant.php:75
$inc_path
Definition: constant.php:41
print
Type of printing.
$ctmp
Definition: install.php:204
$cadmin
Definition: install.php:207
$cpassword_admin
Definition: install.php:208
$cpath
Definition: install.php:205
$multi
Definition: install.php:202