-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
setup.php
238 lines (199 loc) · 6.42 KB
/
setup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?php
/**
* @version $Id: setup.php 239 2009-05-26 06:56:30Z andrew.eddie $
* @package Joomla.Installation
* @copyright Copyright (C) 2005 - 2009 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
*/
defined('_JEXEC') or die;
jimport('joomla.application.component.model');
/**
* Setup model for the Joomla Core Installer.
*
* @package Joomla.Installation
* @since 1.6
*/
class JInstallationModelSetup extends JModel
{
function getOptions()
{
// Get the current setup options from the session.
$session = & JFactory::getSession();
$options = $session->get('setup.options', array());
return $options;
}
function storeOptions($options)
{
// Get the current setup options from the session.
$session = & JFactory::getSession();
$old = $session->get('setup.options', array());
// Merge the new setup options into the current ones and store in the session.
$options = array_merge($old, (array)$options);
$session->set('setup.options', $options);
// If the setup language is set in the options, set it separately in the session.
if (!empty($options['lang'])) {
$session->set('setup.language', $options['lang']);
}
return $options;
}
function getDboptions()
{
// Initialize variables.
$options = array();
// Create an array of known database connect functions.
$map = array(
'MySQL' => 'mysql_connect',
'MySQLi' => 'mysqli_connect',
//'MSSQL' => 'mssql_connect'
);
// Iterate over the options, building an array.
$found = false;
foreach ($map as $k => $v)
{
// Only list available options.
if (!function_exists($v)) {
continue;
}
// Create the option object.
$option = new stdClass;
$option->text = $k;
$option->value = strtolower($k);
// Select the first available.
if (!$found) {
$option->selected = ' selected="selected"';
$found = true;
}
$options[] = $option;
}
return $options;
}
/**
* Generate a panel of language choices for the user to select their language
*
* @return boolean True if successful
* @access public
* @since 1.5
*/
function getLanguages()
{
// Initialize variables.
$app = & JFactory::getApplication();
// Get existing values from the session.
//$vars = & $this->getVars();
// Detect the native language.
jimport('joomla.language.helper');
$native = JLanguageHelper::detectLanguage();
// Get a forced language if it exists.
$forced = $app->getLocalise();
if (!empty($forced['lang']))
{
$native = $forced['lang'];
}
// Get the list of available languages.
$list = JLanguageHelper::createLanguageList($native);
if (!$list || JError::isError($list)) {
$list = array();
}
return $list;
}
function getPhpOptions()
{
// Initialize variables.
$options = array();
// Check the PHP Version.
$option = new stdClass;
$option->label = JText::_('PHP version').' >= 5.2.0';
$option->state = (phpversion() >= '5.2.0');
$option->notice = null;
$options[] = $option;
// Check for zlib support.
$option = new stdClass;
$option->label = JText::_('zlib compression support');
$option->state = extension_loaded('zlib');
$option->notice = null;
$options[] = $option;
// Check for XML support.
$option = new stdClass;
$option->label = JText::_('XML support');
$option->state = extension_loaded('xml');
$option->notice = null;
$options[] = $option;
// Check for MySQL support.
$option = new stdClass;
$option->label = JText::_('MySQL support');
$option->state = (function_exists('mysql_connect') || function_exists('mysqli_connect'));
$option->notice = null;
$options[] = $option;
// Check for mbstring options.
if (extension_loaded('mbstring'))
{
// Check for default MB language.
$option = new stdClass;
$option->label = JText::_('MB language is default');
$option->state = (strtolower(ini_get('mbstring.language')) == 'neutral');
$option->notice = ($option->state) ? null : JText::_('NOTICEMBLANGNOTDEFAULT');
$options[] = $option;
// Check for MB function overload.
$option = new stdClass;
$option->label = JText::_('MB string overload off');
$option->state = (ini_get('mbstring.func_overload') == 0);
$option->notice = ($option->state) ? null : JText::_('NOTICEMBSTRINGOVERLOAD');
$options[] = $option;
}
// Check for configuration file writeable.
$option = new stdClass;
$option->label = 'configuration.php '.JText::_('writable');
$option->state = ((@ file_exists('../configuration.php') && @ is_writable('../configuration.php')) || is_writable('../'));
$option->notice = ($option->state) ? null : JText::_('NOTICEYOUCANSTILLINSTALL');
$options[] = $option;
return $options;
}
function getPhpSettings()
{
// Initialize variables
$settings = array();
// Check for safe mode.
$setting = new stdClass;
$setting->label = JText::_('Safe Mode');
$setting->state = (ini_get('safe_mode') == '1' ? true : false);
$setting->recommended = false;
$settings[] = $setting;
// Check for display errors.
$setting = new stdClass;
$setting->label = JText::_('Display Errors');
$setting->state = (ini_get('display_errors') == '1' ? true : false);
$setting->recommended = false;
$settings[] = $setting;
// Check for file uploads.
$setting = new stdClass;
$setting->label = JText::_('File Uploads');
$setting->state = (ini_get('file_uploads') == '1' ? true : false);
$setting->recommended = true;
$settings[] = $setting;
// Check for magic quotes.
$setting = new stdClass;
$setting->label = JText::_('Magic Quotes Runtime');
$setting->state = (ini_get('magic_quotes_runtime') == '1' ? true : false);
$setting->recommended = false;
$settings[] = $setting;
// Check for register globals.
$setting = new stdClass;
$setting->label = JText::_('Register Globals');
$setting->state = (ini_get('register_globals') == '1' ? true : false);
$setting->recommended = false;
$settings[] = $setting;
// Check for output buffering.
$setting = new stdClass;
$setting->label = JText::_('Output Buffering');
$setting->state = (ini_get('output_buffering') == '1' ? true : false);
$setting->recommended = false;
$settings[] = $setting;
// Check for session auto-start.
$setting = new stdClass;
$setting->label = JText::_('Session auto start');
$setting->state = (ini_get('session.auto_start') == '1' ? true : false);
$setting->recommended = false;
$settings[] = $setting;
return $settings;
}
}