source: trunk/setup/inc/functions.inc.php @ 2

Revision 2, 4.7 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2  /**************************************************************************\
3  * eGroupWare - Setup                                                       *
4  * http://www.egroupware.org                                                *
5  * --------------------------------------------                             *
6  * This file written by Joseph Engo<jengo@phpgroupware.org>                 *
7  *  and Dan Kuykendall<seek3r@phpgroupware.org>                             *
8  *  and Mark Peters<skeeter@phpgroupware.org>                               *
9  *  and Miles Lott<milosch@groupwhere.org>                                  *
10  * --------------------------------------------                             *
11  *  This program is free software; you can redistribute it and/or modify it *
12  *  under the terms of the GNU General Public License as published by the   *
13  *  Free Software Foundation; either version 2 of the License, or (at your  *
14  *  option) any later version.                                              *
15  \**************************************************************************/
16
17
18        /* ######## Start security check ########## */
19        $d1 = strtolower(substr(@$GLOBALS['phpgw_info']['server']['api_inc'],0,3));
20        $d2 = strtolower(substr(@$GLOBALS['phpgw_info']['server']['server_root'],0,3));
21        $d3 = strtolower(substr(@$GLOBALS['phpgw_info']['server']['app_inc'],0,3));
22        if($d1 == 'htt' || $d1 == 'ftp' || $d2 == 'htt' || $d2 == 'ftp' || $d3 == 'htt' || $d3 == 'ftp')
23        {
24                echo 'Failed attempt to break in via an old Security Hole!<br>';
25                exit;
26        }
27        unset($d1);unset($d2);unset($d3);
28        /* ######## End security check ########## */
29
30        error_reporting(error_reporting() & ~E_NOTICE);
31
32        if(file_exists('../header.inc.php'))
33        {
34                include('../header.inc.php');
35        }
36
37        if (!function_exists('version_compare'))//version_compare() is only available in PHP4.1+
38        {
39                echo 'eGroupWare now requires PHP 4.1 or greater.<br>';
40                echo 'Please contact your System Administrator';
41                exit;
42        }
43
44        /*  If we included the header.inc.php, but it is somehow broken, cover ourselves... */
45        if(!defined('PHPGW_SERVER_ROOT') && !defined('PHPGW_INCLUDE_ROOT'))
46        {
47                define('PHPGW_SERVER_ROOT','..');
48                define('PHPGW_INCLUDE_ROOT','..');
49        }
50
51        include(PHPGW_INCLUDE_ROOT . '/phpgwapi/inc/common_functions.inc.php');
52
53        define('SEP',filesystem_separator());
54
55        /*!
56         @function lang
57         @abstract function to handle multilanguage support
58        */
59        function lang($key,$m1='',$m2='',$m3='',$m4='',$m5='',$m6='',$m7='',$m8='',$m9='',$m10='')
60        {
61                if(is_array($m1))
62                {
63                        $vars = $m1;
64                }
65                else
66                {
67                        $vars = array($m1,$m2,$m3,$m4,$m5,$m6,$m7,$m8,$m9,$m10);
68                }
69                $value = $GLOBALS['phpgw_setup']->translation->translate("$key", $vars );
70                return $value;
71        }
72
73        /*!
74        @function get_langs
75        @abstract       returns array of languages we support, with enabled set
76                                to True if the lang file exists
77        */
78        function get_langs()
79        {
80                $f = fopen('./lang/languages','rb');
81                while($line = fgets($f,200))
82                {
83                        list($x,$y) = split("\t",$line);
84                        $languages[$x]['lang']  = trim($x);
85                        $languages[$x]['descr'] = trim($y);
86                        $languages[$x]['available'] = False;
87                }
88                fclose($f);
89
90                $d = dir('./lang');
91                while($file=$d->read())
92                {
93                        if(preg_match('/^phpgw_([-a-z]+).lang$/i',$file,$matches))
94                        {
95                                $languages[$matches[1]]['available'] = True;
96                        }
97                }
98                $d->close();
99
100                //print_r($languages);
101                return $languages;
102        }
103
104        function lang_select($onChange=False,$ConfigLang='')
105        {
106                if (!$ConfigLang)
107                {
108                        $ConfigLang = get_var('ConfigLang',Array('POST','COOKIE'));
109                }
110                $select = '<select name="ConfigLang"'.($onChange ? ' onChange="this.form.submit();"' : '').'>' . "\n";
111                $languages = get_langs();
112                usort($languages,create_function('$a,$b','return strcmp(@$a[\'descr\'],@$b[\'descr\']);'));
113                foreach($languages as $data)
114                {
115                        if($data['available'] && !empty($data['lang']))
116                        {
117                                $selected = '';
118                                $short = substr($data['lang'],0,2);
119                                if ($short == $ConfigLang || empty($ConfigLang) && $short == substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2))
120                                {
121                                        $selected = ' selected';
122                                }
123                                $select .= '<option value="' . $data['lang'] . '"' . $selected . '>' . $data['descr'] . '</option>' . "\n";
124                        }
125                }
126                $select .= '</select>' . "\n";
127
128                return $select;
129        }
130
131        if(file_exists(PHPGW_SERVER_ROOT.'/phpgwapi/setup/setup.inc.php'))
132        {
133                include(PHPGW_SERVER_ROOT.'/phpgwapi/setup/setup.inc.php'); /* To set the current core version */
134                /* This will change to just use setup_info */
135                $GLOBALS['phpgw_info']['server']['versions']['current_header'] = $setup_info['phpgwapi']['versions']['current_header'];
136        }
137        else
138        {
139                $GLOBALS['phpgw_info']['server']['versions']['phpgwapi'] = 'Undetected';
140        }
141
142        $GLOBALS['phpgw_info']['server']['app_images'] = 'templates/default/images';
143
144        $GLOBALS['phpgw_setup'] = CreateObject('phpgwapi.setup',True,True);
145?>
Note: See TracBrowser for help on using the repository browser.