source: trunk/phpgwapi/setup/manageheader.php @ 7655

Revision 7655, 27.3 KB checked in by douglasz, 11 years ago (diff)

Ticket #3236 - Melhorias de performance no codigo do Expresso.

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