source: branches/2.3/setup/manageheader.php @ 3991

Revision 3991, 30.2 KB checked in by rafaelraymundo, 13 years ago (diff)

Ticket #1739 - Login com certificado em atributo customizável

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2  /**************************************************************************\
3  * eGroupWare                                                               *
4  * http://www.egroupware.org                                                *
5  * --------------------------------------------                             *
6  *  This program is free software; you can redistribute it and/or modify it *
7  *  under the terms of the GNU General Public License as published by the   *
8  *  Free Software Foundation; either version 2 of the License, or (at your  *
9  *  option) any later version.                                              *
10  \**************************************************************************/
11
12  /* $Id: manageheader.php,v 1.1 2006/09/15 14:36:29 niltonneto Exp $ */
13
14        $phpgw_info = array();
15        $GLOBALS['phpgw_info']['flags'] = array(
16                'nocachecontrol' => True,
17                'noheader' => True,
18                'nonavbar' => True,
19                'currentapp' => 'home',
20                'noapi' => True
21        );
22        include('./inc/functions.inc.php');
23
24        $GLOBALS['phpgw_info']['server']['versions']['current_header'] = $setup_info['phpgwapi']['versions']['current_header'];
25        $GLOBALS['phpgw_info']['server']['versions']['phpgwapi'] = $setup_info['phpgwapi']['version'];
26        unset($setup_info);
27
28        /* Fetch the current real path.
29         * If this is in the server document root, then it is probably ok.
30         * Otherwise, don't guess, just show the usual instructive default.
31         */
32        $realpath = realpath('..');
33        if(!ereg('^' . $_SERVER['DOCUMENT_ROOT'],$realpath))
34        {
35                if(PHP_OS == 'Windows')
36                {
37                        $realpath = 'Drive:\\\\Path';
38                }
39                else
40                {
41                        $realpath = '/path/to/egroupware';
42                }
43        }
44
45        $adddomain = get_var('adddomain',Array('POST'));
46
47        $db_fullnames = array(
48                'pgsql'  => 'PostgreSQL',
49                'mysql'  => 'MySQL',
50                'mssql'  => 'MS SQL Server',
51                'oracle' => 'Oracle'
52        );
53
54        $default_db_ports = array(
55                'pgsql'  => 5432,
56                'mysql'  => 3306,
57                'mssql'  => 1433,
58                'oracle' => 1521
59        );
60
61        function check_form_values()
62        {
63                // PHP will automatically replace any dots in incoming
64                // variable names with underscores.
65
66                $errors = '';
67                $domains = get_var('domains',Array('POST'));
68                @reset($domains);
69                while(list($k,$v) = @each($domains))
70                {
71                        $variableName = str_replace('.','_',$k);
72                        $deletedomain = get_var('deletedomain',Array('POST'));
73                        if(isset($deletedomain[$variableName]))
74                        {
75                                continue;
76                        }
77                        $dom = get_var('setting_'.$variableName,Array('POST'));
78                        if(!$dom['config_pass'] && !$dom['config_password'])
79                        {
80                                $errors .= '<br>' . lang("You didn't enter a config password for domain %1",$v);
81                        }
82                        if(!$dom['config_user'])
83                        {
84                                $errors .= '<br>' . lang("You didn't enter a config username for domain %1",$v);
85                        }
86                }
87
88                $setting = get_var('setting',Array('POST'));
89               
90                if(!$setting['HEADER_ADMIN_PASSWORD'] && !$setting['HEADER_ADMIN_PASS'])
91                {
92                        $errors .= '<br>' . lang("You didn't enter a header admin password");
93                }
94                if(!$setting['HEADER_ADMIN_USER'])
95                {
96                        $errors .= '<br>' . lang("You didn't enter a header admin username");
97                }
98
99                if($errors)
100                {
101                        $GLOBALS['phpgw_setup']->html->show_header('Error',True);
102                        echo $errors;
103                        echo '<p><input type="submit" value="'.lang('Back to the previous screen').'" onClick="history.back()"></p>';
104                        exit;
105                }
106        }
107
108        /* authentication phase */
109        $GLOBALS['phpgw_info']['setup']['stage']['header'] = $GLOBALS['phpgw_setup']->detection->check_header();
110
111        // added these to let the app work, need to templatize still
112        $tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
113        $setup_tpl = CreateObject('setup.Template',$tpl_root);
114        $setup_tpl->set_file(array(
115                'T_head' => 'head.tpl',
116                'T_footer' => 'footer.tpl',
117                'T_alert_msg' => 'msg_alert_msg.tpl',
118                'T_login_main' => 'login_main.tpl',
119                'T_login_stage_header' => 'login_stage_header.tpl',
120                'T_setup_manage' => 'manageheader.tpl'
121        ));
122        $setup_tpl->set_block('T_login_stage_header','B_multi_domain','V_multi_domain');
123        $setup_tpl->set_block('T_login_stage_header','B_single_domain','V_single_domain');
124        $setup_tpl->set_block('T_setup_manage','manageheader','manageheader');
125        $setup_tpl->set_block('T_setup_manage','domain','domain');
126
127        /* Detect current mode */
128        switch($GLOBALS['phpgw_info']['setup']['stage']['header'])
129        {
130                case '1':
131                        $GLOBALS['phpgw_info']['setup']['HeaderFormMSG'] = lang('Create your header.inc.php');
132                        $GLOBALS['phpgw_info']['setup']['PageMSG'] = lang('You have not created your header.inc.php yet!<br> You can create it now.');
133                        break;
134                case '2':
135                        $GLOBALS['phpgw_info']['setup']['HeaderFormMSG'] = lang('Your header admin password is NOT set. Please set it now!');
136                        $GLOBALS['phpgw_info']['setup']['PageMSG'] = lang('Your header admin password is NOT set. Please set it now!');
137                        break;
138                case '3':
139                        $GLOBALS['phpgw_info']['setup']['HeaderFormMSG'] = lang('You need to add some domains to your header.inc.php.');
140                        $GLOBALS['phpgw_info']['setup']['PageMSG'] = lang('You need to add some domains to your header.inc.php.');
141                        $GLOBALS['phpgw_info']['setup']['HeaderLoginMSG'] = lang('You need to add some domains to your header.inc.php.');
142                        if(!$GLOBALS['phpgw_setup']->auth('Header'))
143                        {
144                                $GLOBALS['phpgw_setup']->html->show_header('Please login',True);
145                                $GLOBALS['phpgw_setup']->html->login_form();
146                                $GLOBALS['phpgw_setup']->html->show_footer();
147                                exit;
148                        }
149                        break;
150                case '4':
151                        $GLOBALS['phpgw_info']['setup']['HeaderFormMSG'] = lang('Your header.inc.php needs upgrading.');
152                        $GLOBALS['phpgw_info']['setup']['PageMSG'] = lang('Your header.inc.php needs upgrading.<br><blink><b class="msg">WARNING!</b></blink><br><b>MAKE BACKUPS!</b>');
153                        $GLOBALS['phpgw_info']['setup']['HeaderLoginMSG'] = lang('Your header.inc.php needs upgrading.');
154                        if(!$GLOBALS['phpgw_setup']->auth('Header'))
155                        {
156                                $GLOBALS['phpgw_setup']->html->show_header('Please login',True);
157                                $GLOBALS['phpgw_setup']->html->login_form();
158                                $GLOBALS['phpgw_setup']->html->show_footer();
159                                exit;
160                        }
161                        break;
162                case '10':
163                        if(!$GLOBALS['phpgw_setup']->auth('Header'))
164                        {
165                                $GLOBALS['phpgw_setup']->html->show_header('Please login',True);
166                                $GLOBALS['phpgw_setup']->html->login_form();
167                                $GLOBALS['phpgw_setup']->html->show_footer();
168                                exit;
169                        }
170                        $GLOBALS['phpgw_info']['setup']['HeaderFormMSG'] = lang('Edit your header.inc.php');
171                        $GLOBALS['phpgw_info']['setup']['PageMSG'] = lang('Edit your existing header.inc.php');
172                        break;
173        }
174
175        $action = @get_var('action',Array('POST'));
176        list($action) = @each($action);
177
178        switch($action)
179        {
180                case 'download':
181                        check_form_values();
182                        $header_template = CreateObject('setup.Template','../');
183                        $b = CreateObject('phpgwapi.browser');
184                        $b->content_header('header.inc.php','application/octet-stream');
185                        /*
186                        header('Content-disposition: attachment; filename="header.inc.php"');
187                        header('Content-type: application/octet-stream');
188                        header('Pragma: no-cache');
189                        header('Expires: 0');
190                        */
191                        $newheader = $GLOBALS['phpgw_setup']->html->generate_header();
192                        echo $newheader;
193                        break;
194                case 'view':
195                        check_form_values();
196                        $header_template = CreateObject('setup.Template','../');
197                        $GLOBALS['phpgw_setup']->html->show_header('Generated header.inc.php', False, 'header');
198                        echo '<table width="90%"><tr><td>';
199                        echo '<br>' . lang('Save this text as contents of your header.inc.php') . '<br><hr>';
200                        $newheader = $GLOBALS['phpgw_setup']->html->generate_header();
201                        echo '<pre>';
202                        echo htmlentities($newheader);
203                        echo '</pre><hr>';
204                        echo '<form action="index.php" method="post">';
205                        echo '<br>' . lang('After retrieving the file, put it into place as the header.inc.php.  Then, click "continue".') . '<br>';
206                        echo '<input type="hidden" name="FormLogout" value="header">';
207                        echo '<input type="submit" name="junk" value="'.lang('Continue').'">';
208                        echo '</form>';
209                        echo '</td></tr></table>';
210                        $GLOBALS['phpgw_setup']->html->show_footer();
211                        break;
212                case 'write':
213                        check_form_values();
214                        $header_template = CreateObject('setup.Template','../');
215                        if(is_writeable('../header.inc.php') || (!file_exists('../header.inc.php') && is_writeable('../')))
216                        {
217                                $newheader = $GLOBALS['phpgw_setup']->html->generate_header();
218                                $fsetup = fopen('../header.inc.php','wb');
219                                fwrite($fsetup,$newheader);
220                                fclose($fsetup);
221                                $GLOBALS['phpgw_setup']->html->show_header('Saved header.inc.php', False, 'header');
222                                echo '<div align="center"><form action="index.php" method="post">';
223                                echo '' . lang('Created header.inc.php!');
224                                echo '<br><br><input type="hidden" name="FormLogout" value="header">';
225                                echo '<input type="submit" name="junk" value="'.lang('Continue').'"><br><br></div>';
226                                echo '</form>';
227                                echo '</body></html>';
228                                break;
229                        }
230                        else
231                        {
232                                $GLOBALS['phpgw_setup']->html->show_header('Error generating header.inc.php', False, 'header');
233                                echo lang('Could not open header.inc.php for writing!') . '<br>' . "\n";
234                                echo lang('Please check read/write permissions on directories, or back up and use another option.') . '<br>';
235                                echo '</td></tr></table></body></html>';
236                                break;
237                        }
238                        break;
239                default:
240                        $GLOBALS['phpgw_setup']->html->show_header($GLOBALS['phpgw_info']['setup']['HeaderFormMSG'], False, 'header');
241                       
242                        $detected = '';
243
244                        if(!get_var('ConfigLang',array('POST','COOKIE')))
245                        {
246                                $detected .= '<br><form action="manageheader.php" method="Post">Please Select your language '.lang_select(True,'en')."</form>\n";
247                        }
248
249                        $detected .= '<table border="0" width="100%" cellspacing="0" cellpadding="0">' . "\n";
250
251                        $detected .= '<tr><td colspan="2"><p>' . $GLOBALS['phpgw_info']['setup']['PageMSG'] . '<br />&nbsp;</p></td></tr>';
252                       
253                        $detected .= '<tr class="th"><td colspan="2">' . lang('Analysis') . '</td></tr><tr><td colspan="2">'. "\n";
254
255                        $supported_db = array();
256                        if(extension_loaded('pgsql') || function_exists('pg_connect'))
257                        {
258                                $detected .= lang('You appear to have PostgreSQL support enabled') . '<br>' . "\n";
259                                $supported_db[]  = 'pgsql';
260                        }
261                        else
262                        {
263                                $detected .= lang('No PostgreSQL support found. Disabling') . '<br>' . "\n";
264                        }
265                        if(extension_loaded('mysql') || function_exists('mysql_connect'))
266                        {
267                                $detected .= lang('You appear to have MySQL support enabled') . '<br>' . "\n";
268                                $supported_db[] = 'mysql';
269                        }
270                        else
271                        {
272                                $detected .= lang('No MySQL support found. Disabling') . '<br>' . "\n";
273                        }
274                        if(extension_loaded('mssql') || function_exists('mssql_connect'))
275                        {
276                                $detected .= lang('You appear to have Microsoft SQL Server support enabled') . '<br>' . "\n";
277                                $supported_db[] = 'mssql';
278                        }
279                        else
280                        {
281                                $detected .= lang('No Microsoft SQL Server support found. Disabling') . '<br>' . "\n";
282                        }
283/*
284                        if(extension_loaded('oci8'))
285                        {
286                                $detected .= lang('You appear to have Oracle V8 (OCI) support enabled') . '<br>' . "\n";
287                                $supported_db[] = 'oracle';
288                        }
289                        else
290                        {
291                                if(extension_loaded('oracle'))
292                                {
293                                        $detected .= lang('You appear to have Oracle support enabled') . '<br>' . "\n";
294                                        $supported_db[] = 'oracle';
295                                }
296                                else
297                                {
298                                        $detected .= lang('No Oracle-DB support found. Disabling') . '<br>' . "\n";
299                                }
300                        }
301*/
302                        if(!count($supported_db))
303                        {
304                                $detected .= '<b><p align="center" class="msg">'
305                                        . lang('Did not find any valid DB support!')
306                                        . "<br>\n"
307                                        . lang('Try to configure your php to support one of the above mentioned DBMS, or install eGroupWare by hand.')
308                                        . '</p></b><td></tr></table></body></html>';
309                                echo $detected;
310                                exit;
311                        }
312
313                        if(!function_exists('version_compare'))
314                        {
315                                $detected .= '<b><p align="center" class="msg">'
316                                        . lang('You appear to be using PHP earlier than 4.1.0. eGroupWare now requires 4.1.0 or later'). "\n"
317                                        . '</p></b><td></tr></table></body></html>';
318                                echo $detected;
319                                exit;
320                        }
321                        else
322                        {
323                                $detected .= lang('You appear to be using PHP4. Enabling PHP4 sessions support') . '<br>' . "\n";
324                                $supported_sessions_type[] = 'php4';    // makeing php4 sessions the default
325                                $supported_sessions_type[] = 'db';
326                        }
327
328                        @reset($default_db_ports);
329                        $js_default_db_ports = 'var default_db_ports = new Array();'."\n";
330                        while(list($k,$v) = @each($default_db_ports))
331                        {
332                                $js_default_db_ports .= '  default_db_ports["'.$k.'"]="'.$v.'";'."\n";
333                        }
334                        $setup_tpl->set_var('js_default_db_ports',$js_default_db_ports);
335
336                        /*
337                        if(extension_loaded('xml') || function_exists('xml_parser_create'))
338                        {
339                                $detected .= lang('You appear to have XML support enabled') . '<br>' . "\n";
340                                $xml_enabled = 'True';
341                        }
342                        else
343                        {
344                                $detected .= lang('No XML support found. Disabling') . '<br>' . "\n";
345                        }
346                        */
347
348                        $no_guess = False;
349                        if(file_exists('../header.inc.php') && is_file('../header.inc.php') && is_readable('../header.inc.php'))
350                        {
351                                $detected .= lang('Found existing configuration file. Loading settings from the file...') . '<br>' . "\n";
352                                $GLOBALS['phpgw_info']['flags']['noapi'] = True;
353                                $no_guess = true;
354                                /* This code makes sure the newer multi-domain supporting header.inc.php is being used */
355                                if(!isset($GLOBALS['phpgw_domain']))
356                                {
357                                        $detected .= lang('You need to add some domains to your header.inc.php.') . '<br>' . "\n";
358                                        $GLOBALS['phpgw_domain']['default'] = array();
359                                        $setup_tpl->set_var('lang_domain',lang('Domain'));
360                                        $setup_tpl->set_var('lang_delete',lang('Delete'));
361                                        $setup_tpl->set_var('db_domain','default');
362                                        $setup_tpl->set_var('db_host','localhost');
363                                        $setup_tpl->set_var('db_name','expresso');
364                                        $setup_tpl->set_var('db_user','postgres');
365                                        $setup_tpl->set_var('db_pass','');
366                                        $setup_tpl->set_var('config_user','changeme');
367                                        $setup_tpl->set_var('config_pass','');
368                                        while(list($k,$v) = @each($supported_db))
369                                        {
370                                                $dbtype_options .= '<option value="' . $v . '">' . $db_fullnames[$v] . "\n";
371                                                if (!isset($default_port))
372                                                        $default_port = $default_db_ports[$v];
373                                        }
374                                        $setup_tpl->set_var('dbtype_options',$dbtype_options);
375                                        $setup_tpl->set_var('db_port',$default_port);
376                                        $setup_tpl->parse('domains','domain',True);
377                                }
378                                else
379                                {
380                                        if(@$GLOBALS['phpgw_info']['server']['header_version'] != @$GLOBALS['phpgw_info']['server']['current_header_version'])
381                                        {
382                                                $detected .= lang("You're using an old header.inc.php version...") . '<br>' . "\n";
383                                                $detected .= lang('Importing old settings into the new format....') . '<br>' . "\n";
384                                        }
385                                        reset($GLOBALS['phpgw_domain']);
386                                        $default_domain = each($GLOBALS['phpgw_domain']);
387                                        $GLOBALS['phpgw_info']['server']['default_domain'] = $default_domain[0];
388                                        unset($default_domain); // we kill this for security reasons
389                                        $GLOBALS['phpgw_info']['server']['config_passwd'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['config_passwd'];
390                                        $GLOBALS['phpgw_info']['server']['config_user'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['config_user'];
391
392                                        if(@$adddomain)
393                                        {
394                                                $GLOBALS['phpgw_domain'][lang('new')] = array();
395                                        }
396
397                                        reset($GLOBALS['phpgw_domain']);
398                                        while(list($key,$val) = each($GLOBALS['phpgw_domain']))
399                                        {
400                                                $setup_tpl->set_var('lang_domain',lang('Domain'));
401                                                $setup_tpl->set_var('lang_delete',lang('Delete'));
402                                                $setup_tpl->set_var('db_domain',$key);
403                                                $setup_tpl->set_var('db_host',$GLOBALS['phpgw_domain'][$key]['db_host']);
404                                                /* Set default here if the admin didn't set a port yet */
405                                                $setup_tpl->set_var('db_port',$GLOBALS['phpgw_domain'][$key]['db_port']
406                                                        ? $GLOBALS['phpgw_domain'][$key]['db_port']
407                                                        : @$default_db_ports[$GLOBALS['phpgw_domain'][$key]['db_type']]
408                                                );
409                                                $setup_tpl->set_var('db_name',$GLOBALS['phpgw_domain'][$key]['db_name']);
410                                                $setup_tpl->set_var('db_user',$GLOBALS['phpgw_domain'][$key]['db_user']);
411                                                $setup_tpl->set_var('db_pass',$GLOBALS['phpgw_domain'][$key]['db_pass']);
412                                                $setup_tpl->set_var('db_type',$GLOBALS['phpgw_domain'][$key]['db_type']);
413                                                if(!@isset($GLOBALS['phpgw_domain'][$key]['config_user']))
414                                                {
415                                                        $setup_tpl->set_var('config_user','admin');
416                                                }
417                                                else
418                                                {
419                                                        $setup_tpl->set_var('config_user',$GLOBALS['phpgw_domain'][$key]['config_user']);
420                                                }
421                                                $setup_tpl->set_var('config_pass','');
422                                                $setup_tpl->set_var('config_password',$GLOBALS['phpgw_domain'][$key]['config_passwd']);
423
424                                                $selected = '';
425                                                $dbtype_options = '';
426                                                $found_dbtype = False;
427                                                @reset($supported_db);
428                                                while(list($k,$v) = @each($supported_db))
429                                                {
430                                                        if($v == $GLOBALS['phpgw_domain'][$key]['db_type'])
431                                                        {
432                                                                $selected = ' selected ';
433                                                                $found_dbtype = true;
434                                                        }
435                                                        else
436                                                        {
437                                                                $selected = '';
438                                                        }
439                                                        $dbtype_options .= '<option ' . $selected . 'value="' . $v . '">' . $db_fullnames[$v] . "\n";
440                                                }
441                                                $setup_tpl->set_var('dbtype_options',$dbtype_options);
442
443                                                $setup_tpl->parse('domains','domain',True);
444                                        }
445                                        $setup_tpl->set_var('domain','');
446                                }
447                                if(defined('PHPGW_SERVER_ROOT'))
448                                {
449                                        $GLOBALS['phpgw_info']['server']['server_root']  = (PHPGW_SERVER_ROOT  == '..') ? $realpath : PHPGW_SERVER_ROOT;
450                                        $GLOBALS['phpgw_info']['server']['include_root'] = (PHPGW_INCLUDE_ROOT == '..') ? $realpath : PHPGW_SERVER_ROOT;
451                                }
452                                elseif(!@isset($GLOBALS['phpgw_info']['server']['include_root']) && @$GLOBALS['phpgw_info']['server']['header_version'] <= 1.6)
453                                {
454                                        $GLOBALS['phpgw_info']['server']['include_root'] = @$GLOBALS['phpgw_info']['server']['server_root'];
455                                }
456                                elseif(!@isset($GLOBALS['phpgw_info']['server']['header_version']) && @$GLOBALS['phpgw_info']['server']['header_version'] <= 1.6)
457                                {
458                                        $GLOBALS['phpgw_info']['server']['include_root'] = @$GLOBALS['phpgw_info']['server']['server_root'];
459                                }
460                        }
461                        else
462                        {
463                                $detected .= lang('Sample configuration not found. using built in defaults') . '<br>' . "\n";
464                                $GLOBALS['phpgw_info']['server']['server_root']  = $realpath;
465                                $GLOBALS['phpgw_info']['server']['include_root'] = $realpath;
466                                /* This is the basic include needed on each page for eGroupWare application compliance */
467                                $GLOBALS['phpgw_info']['flags']['htmlcompliant'] = True;
468
469                                /* These are the settings for the database system */
470                                $setup_tpl->set_var('lang_domain',lang('Domain'));
471                                $setup_tpl->set_var('lang_delete',lang('Delete'));
472                                $setup_tpl->set_var('db_domain','default');
473                                $setup_tpl->set_var('db_host','localhost');
474                                $setup_tpl->set_var('db_name','expresso');
475                                $setup_tpl->set_var('db_user','postgres');
476                                $setup_tpl->set_var('db_pass','');
477                                $setup_tpl->set_var('config_user','admin');
478                                $setup_tpl->set_var('config_pass','');
479                                $setup_tpl->set_var('use_https_0',' checked');
480
481                                while(list($k,$v) = each($supported_db))
482                                {
483                                        $dbtype_options .= '<option value="' . $v . '">' . $db_fullnames[$v] . "\n";
484                                        if (!isset($default_port))
485                                                $default_port = $default_db_ports[$v];
486                                }
487                                $setup_tpl->set_var('db_port',$default_port);
488                                $setup_tpl->set_var('dbtype_options',$dbtype_options);
489
490                                $setup_tpl->parse('domains','domain',True);
491                                $setup_tpl->set_var('domain','');
492
493                                $setup_tpl->set_var('comment_l','<!-- ');
494                                $setup_tpl->set_var('comment_r',' -->');
495
496                                /* These are a few of the advanced settings */
497                                $GLOBALS['phpgw_info']['server']['db_persistent'] = True;
498                                $GLOBALS['phpgw_info']['server']['mcrypt_enabled'] = extension_loaded('mcrypt');
499                                $GLOBALS['phpgw_info']['server']['versions']['mcrypt'] = '';
500
501                                srand((double)microtime()*1000000);
502                                $random_char = array(
503                                        '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f',
504                                        'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
505                                        'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L',
506                                        'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
507                                );
508
509                                for($i=0; $i<30; $i++)
510                                {
511                                        $GLOBALS['phpgw_info']['server']['mcrypt_iv'] .= $random_char[rand(1,count($random_char))];
512                                }
513                        }
514
515                        // now guessing better settings then the default ones
516                        if(!$no_guess)
517                        {
518                                $detected .= lang('Now guessing better values for defaults...') . '<br>' . "\n";
519                                $this_dir = dirname($_SERVER['SCRIPT_FILENAME']);
520                                $updir    = str_replace('/setup','',$this_dir);
521                                $GLOBALS['phpgw_info']['server']['server_root'] = $updir;
522                                $GLOBALS['phpgw_info']['server']['include_root'] = $updir;
523                        }
524
525                        $setup_tpl->set_var('detected',$detected);
526                        /* End of detected settings, now display the form with the detected or prior values */
527
528                        $setup_tpl->set_var('server_root',@$GLOBALS['phpgw_info']['server']['server_root']);
529                        $setup_tpl->set_var('include_root',@$GLOBALS['phpgw_info']['server']['include_root']);
530                        if(!@isset($GLOBALS['phpgw_info']['server']['header_admin_user']))
531                        {
532                                $setup_tpl->set_var('header_admin_user','admin');
533                        }
534                        else
535                        {
536                                $setup_tpl->set_var('header_admin_user',@$GLOBALS['phpgw_info']['server']['header_admin_user']);
537                        }
538                        $setup_tpl->set_var('header_admin_pass',@$GLOBALS['phpgw_info']['server']['header_admin_password']);
539                        $setup_tpl->set_var('header_admin_password','');
540
541
542                        if(@$GLOBALS['phpgw_info']['server']['db_persistent'])
543                        {
544                                $setup_tpl->set_var('db_persistent_yes',' selected');
545                        }
546                        else
547                        {
548                                $setup_tpl->set_var('db_persistent_no',' selected');
549                        }
550
551                        $selected = '';
552                        $session_options = '';
553                        while(list($k,$v) = each($supported_sessions_type))
554                        {
555                                if($v == @$GLOBALS['phpgw_info']['server']['sessions_type'])
556                                {
557                                        $selected = ' selected ';
558                                }
559                                else
560                                {
561                                        $selected = '';
562                                }
563                                $session_options .= '<option ' . $selected . 'value="' . $v . '">' . $v . "\n";
564                        }
565                        $setup_tpl->set_var('session_options',$session_options);
566
567                        if(@$GLOBALS['phpgw_info']['server']['mcrypt_enabled'])
568                        {
569                                $setup_tpl->set_var('mcrypt_enabled_yes',' selected');
570                        }
571                        else
572                        {
573                                $setup_tpl->set_var('mcrypt_enabled_no',' selected');
574                        }
575
576                        $setup_tpl->set_var('mcrypt',$GLOBALS['phpgw_info']['server']['versions']['mcrypt']);
577                        $setup_tpl->set_var('mcrypt_iv',$GLOBALS['phpgw_info']['server']['mcrypt_iv']);
578
579                        $setup_tpl->set_var('lang_setup_acl',lang('Limit access to setup to the following addresses, networks or hostnames (e.g. 127.0.0.1,10.1.1,myhost.dnydns.org)'));
580                        $setup_tpl->set_var('setup_acl',$GLOBALS['phpgw_info']['server']['setup_acl']);
581
582                        if(@$GLOBALS['phpgw_info']['server']['show_domain_selectbox'])
583                        {
584                                $setup_tpl->set_var('domain_selectbox_yes',' selected');
585                        }
586                        else
587                        {
588                                $setup_tpl->set_var('domain_selectbox_no',' selected');
589                        }
590
591                        // ExpressoLivre
592                        switch($GLOBALS['phpgw_info']['server']['use_https'])
593                        {
594                                case '0':
595                                default:
596                                        $setup_tpl->set_var('use_https_0',' checked');
597                                        $setup_tpl->set_var('div_cert',' style="display:none" ');
598                                        $setup_tpl->set_var('div_atributo_cpf',' style="display:none" ');
599                                        $setup_tpl->set_var('div_criptox',' style="display:none" ');
600                                       
601                                        break;
602                                case '1':
603                                        $setup_tpl->set_var('use_https_1',' checked');
604                                        $setup_tpl->set_var('div_cert',' ');
605                                        break;
606                                case '2':
607                                        $setup_tpl->set_var('use_https_2',' checked');
608                                        $setup_tpl->set_var('div_cert',' ');
609                                        break;
610                        }
611                       
612                        switch($GLOBALS['phpgw_info']['server']['certificado'])
613                        {
614                                case '0':
615                                default:
616                                        $setup_tpl->set_var('certificado_0',' checked');
617                                        $setup_tpl->set_var('div_atributo_cpf',' style="display:none" ');
618                                        $setup_tpl->set_var('div_cripto',' style="display:none" ');
619                                        $setup_tpl->set_var('div_criptox',' style="display:none" ');
620                                        $setup_tpl->set_var('cripto_options',' style="display:none" ');
621                                        break;
622                                case '1':
623                                        $setup_tpl->set_var('certificado_1',' checked');
624                                        $setup_tpl->set_var('div_criptox',' style="" ');
625                                        break;
626                        }
627
628                        if($GLOBALS['phpgw_info']['server']['certificado_atributo_cpf'])
629                        {
630                                $setup_tpl->set_var('certificado_atributo_cpf',$GLOBALS['phpgw_info']['server']['certificado_atributo_cpf']);
631                        }
632
633                        switch($GLOBALS['phpgw_info']['server']['captcha'])
634                        {
635                                case '0':
636                                default:
637                                        $setup_tpl->set_var('captcha_0',' checked');
638                                        $setup_tpl->set_var('div_badlogin',' style="display:none" ');
639                                        break;
640                                case '1':
641                                        $setup_tpl->set_var('captcha_1',' checked');
642                                        break;
643                                default:
644                                        $setup_tpl->set_var('captcha_0',' checked');
645                                        $setup_tpl->set_var('div_badlogin',' style="display:none" ');
646                        }
647
648
649                        if($GLOBALS['phpgw_info']['server']['num_badlogin'])
650                        {
651                                $setup_tpl->set_var('num_badlogin',$GLOBALS['phpgw_info']['server']['num_badlogin']);
652                        }                       
653                        else
654                        {
655                                $setup_tpl->set_var('num_badlogin','0');
656                        }
657                       
658                       
659                        switch($GLOBALS['phpgw_info']['server']['use_assinar_criptografar'])
660                        {
661                                case '0':
662                                default:
663                                        $setup_tpl->set_var('use_assinar_criptografar_0',' checked');
664                                        $setup_tpl->set_var('cripto_options',' style="display:none" ');
665                                        break;
666                                case '1':
667                                        $setup_tpl->set_var('use_assinar_criptografar_1',' checked');
668                                        break;
669                        }
670                       
671                        if($GLOBALS['phpgw_info']['server']['num_max_certs_to_cipher'])
672                        {
673                                $setup_tpl->set_var('num_max_certs_to_cipher',$GLOBALS['phpgw_info']['server']['num_max_certs_to_cipher']);
674                        }
675                        else
676                        {
677                                $setup_tpl->set_var('num_max_certs_to_cipher','0');
678                        }
679
680                        if($GLOBALS['phpgw_info']['server']['atributoexpiracao'])
681                        {
682                                $setup_tpl->set_var('atributoexpiracao',$GLOBALS['phpgw_info']['server']['atributoexpiracao']);
683                        }       
684                        if($GLOBALS['phpgw_info']['server']['atributousuarios'])
685                        {
686                                $setup_tpl->set_var('atributousuarios',$GLOBALS['phpgw_info']['server']['atributousuarios']);
687                        }       
688
689                        if(@$GLOBALS['phpgw_info']['server']['sugestoes_email_to'])
690                        {
691                                $setup_tpl->set_var('sugestoes_email_to',$GLOBALS['phpgw_info']['server']['sugestoes_email_to']);
692                        }
693
694                        if(@$GLOBALS['phpgw_info']['server']['domain_name'])
695                        {
696                                $setup_tpl->set_var('domain_name',$GLOBALS['phpgw_info']['server']['domain_name']);
697                        }
698
699                        if(@$GLOBALS['phpgw_info']['server']['use_prefix_organization'])
700                        {
701                                $setup_tpl->set_var('use_prefix_organization_checked',' checked');
702                        }
703                       
704                        $errors = '';
705                        if(!$found_dbtype)
706                        {
707                                /*
708                                $errors .= '<br><font color="red">' . lang('Warning!') . '<br>'
709                                        . lang('The db_type in defaults (%1) is not supported on this server. using first supported type.',$GLOBALS['phpgw_info']['server']['db_type'])
710                                        . '</font>';
711                                */
712                        }
713
714                        if(is_writeable('../header.inc.php') ||
715                                (!file_exists('../header.inc.php') && is_writeable('../')))
716                        {
717                                $errors .= '<br><input type="submit" name="action[write]" value="'.lang('Write config').'">&nbsp;'
718                                        . lang('or') . '&nbsp;<input type="submit" name="action[download]" value="'.lang('Download').'">&nbsp;'
719                                        . lang('or') . '&nbsp;<input type=submit name="action[view]" value="'.lang('View').'"> '.lang('the file').'.</form>';
720                        }
721                        else
722                        {
723                                $errors .= '<br>'
724                                        . lang('Cannot create the header.inc.php due to file permission restrictions.<br> Instead you can %1 the file.',
725                                        '<input type="submit" name="action[download]" value="'.lang('Download').'">' . lang('or') . '&nbsp;<input type="submit" name="action[view]" value="'.lang('View').'">')
726                                        . '</form>';
727                        }
728                        // set domain and password for the continue button
729                        @reset($GLOBALS['phpgw_domain']);
730                        list($firstDomain) = @each($GLOBALS['phpgw_domain']);
731                        $setup_tpl->set_var(array(
732                                'FormDomain' => $firstDomain,
733                                'FormUser'   => $GLOBALS['phpgw_domain'][$firstDomain]['config_user'],
734                                'FormPW'     => $GLOBALS['phpgw_domain'][$firstDomain]['config_passwd']
735                        ));
736                        $setup_tpl->set_var('errors',$errors);
737
738                        $setup_tpl->set_var('lang_settings',lang('Settings'));
739                        $setup_tpl->set_var('lang_adddomain',lang('Add a domain'));
740                        $setup_tpl->set_var('lang_serverroot',lang('Server Root'));
741                        $setup_tpl->set_var('lang_includeroot',lang('Include Root (this should be the same as Server Root unless you know what you are doing)'));
742                        $setup_tpl->set_var('lang_adminuser',lang('Admin user for header manager'));
743                        $setup_tpl->set_var('lang_adminpass',lang('Admin password to header manager'));
744                        $setup_tpl->set_var('lang_dbhost',lang('DB Host'));
745                        $setup_tpl->set_var('lang_dbhostdescr',lang('Hostname/IP of database server'));
746                        $setup_tpl->set_var('lang_dbport',lang('DB Port'));
747                        $setup_tpl->set_var('lang_dbportdescr',lang('TCP port number of database server'));
748                        $setup_tpl->set_var('lang_dbname',lang('DB Name'));
749                        $setup_tpl->set_var('lang_dbnamedescr',lang('Name of database'));
750                        $setup_tpl->set_var('lang_dbuser',lang('DB User'));
751                        $setup_tpl->set_var('lang_dbuserdescr',lang('Name of db user eGroupWare uses to connect'));
752                        $setup_tpl->set_var('lang_dbpass',lang('DB Password'));
753                        $setup_tpl->set_var('lang_dbpassdescr',lang('Password of db user'));
754                        $setup_tpl->set_var('lang_dbtype',lang('DB Type'));
755                        $setup_tpl->set_var('lang_whichdb',lang('Which database type do you want to use with eGroupWare?'));
756                        $setup_tpl->set_var('lang_configuser',lang('Configuration User'));
757                        $setup_tpl->set_var('lang_configpass',lang('Configuration Password'));
758                        $setup_tpl->set_var('lang_passforconfig',lang('Password needed for configuration'));
759                        $setup_tpl->set_var('lang_persist',lang('Persistent connections'));
760                        $setup_tpl->set_var('lang_persistdescr',lang('Do you want persistent connections (higher performance, but consumes more resources)'));
761                        $setup_tpl->set_var('lang_sesstype',lang('Sessions Type'));
762                        $setup_tpl->set_var('lang_sesstypedescr',lang('What type of sessions management do you want to use (PHP4 session management may perform better)?'));
763                        $setup_tpl->set_var('lang_enablemcrypt',lang('Enable MCrypt'));
764                        $setup_tpl->set_var('lang_mcrypt_warning',lang('Not all mcrypt algorithms and modes work with eGroupWare. If you experience problems try switching it off.'));
765                        $setup_tpl->set_var('lang_mcryptversion',lang('MCrypt version'));
766                        $setup_tpl->set_var('lang_mcryptversiondescr',lang('Set this to "old" for versions &lt; 2.4, otherwise the exact mcrypt version you use.'));
767                        $setup_tpl->set_var('lang_mcryptiv',lang('MCrypt initialization vector'));
768                        $setup_tpl->set_var('lang_mcryptivdescr',lang('This should be around 30 bytes in length.<br>Note: The default has been randomly generated.'));
769                        $setup_tpl->set_var('lang_domselect',lang('Domain select box on login'));
770                        $setup_tpl->set_var('lang_finaldescr',lang('After retrieving the file, put it into place as the header.inc.php.  Then, click "continue".'));
771                        $setup_tpl->set_var('lang_continue',lang('Continue'));
772                        $setup_tpl->set_var('lang_Yes',lang('Yes'));
773                        $setup_tpl->set_var('lang_No',lang('No'));
774
775
776                        $setup_tpl->pfp('out','manageheader');
777
778                        $GLOBALS['phpgw_setup']->html->show_footer();
779
780                        break; // ending the switch default
781        }
782?>
Note: See TracBrowser for help on using the repository browser.