Project

General

Profile

« Previous | Next » 

Revision 1100

Added by aldus over 15 years ago

VersionCompare inside addon.precheck.inc.php use a new function to avoid conflicts within wrong results comparing versionnumbers/-strings.
Also remove PHP-Code inside "calender-system.css" (line 36) .

View differences:

trunk/wb/include/jscalendar/calendar-system.css
33 33
}
34 34

  
35 35
.calendar .nav {
36
  background: ButtonFace url(<?php echo WB_URL ?>/include/jscalendar/menuarrow.gif) no-repeat 100% 100%;
36
  background: #DDDDDD url(menuarrow.gif) no-repeat 100% 100%;
37 37
}
38 38

  
39 39
.calendar thead .title { /* This holds the current "month, year" */
trunk/wb/framework/addon.precheck.inc.php
1
<?php
2
/**
3
 * $Id:$
4
 * Website Baker Add-On precheck functions
5
 *
6
 * This file contains the functions of the pretest performed upfront
7
 * of the Add-On installation process. The functions allows developers
8
 * to specify requirements for their Add-On.
9
 *
10
 * LICENSE: GNU Lesser General Public License 3.0
11
 * 
12
 * @author		Christian Sommer
13
 * @copyright	(c) 2009
14
 * @license		http://www.gnu.org/copyleft/lesser.html
15
 * @version		0.2.3
16
 * @platform	Website Baker 2.7
17
 *
18
 * Website Baker Project <http://www.websitebaker.org/>
19
 * Copyright (C) 2004-2009, Ryan Djurovich
20
 *
21
 * Website Baker is free software; you can redistribute it and/or modify
22
 * it under the terms of the GNU General Public License as published by
23
 * the Free Software Foundation; either version 2 of the License, or
24
 * (at your option) any later version.
25
 *
26
 * Website Baker is distributed in the hope that it will be useful,
27
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
 * GNU General Public License for more details.
30
 *
31
 * You should have received a copy of the GNU General Public License
32
 * along with Website Baker; if not, write to the Free Software
33
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
34
*/
35

  
36
// prevent this file from being accessed directly
37
if (!defined('WB_PATH')) die(header('Location: ../index.php'));
38

  
39
function getVersion($version, $strip_suffix = true)
40
{
41
	/**
42
	 * This funtion creates a version string following the major.minor.revision convention
43
	 * The minor and revision part of the version may not exceed 999 (three digits)
44
	 * An optional suffix part can be added after revision (requires $strip_suffix = false)
45
	 *
46
	 * EXAMPLES: input --> output
47
	 *	5 --> 5.000000; 5.0 --> 5.000000; 5.0.0 --> 5.000000
48
	 * 	5.2 --> 5.002000; 5.20 --> 5.002000; 5.2.0 --> 5.002000
49
	 * 	5.21 --> 5.002001; 5.2.1 --> 5.002001;
50
	 * 	5.27.1 --> 5.027001; 5.2.71 --> 5.002071;
51
	 * 	5.27.1 rc1 --> 5.027001_RC1 ($strip_suffix:= false)
52
	 */
53
	// replace comma by decimal point
54
	$version = str_replace(',', '.', $version);
55

  
56
	// convert version into major.minor.revision numbering system
57
	@list($major, $minor, $revision) = explode('.', $version, 3);
58

  
59
	// convert versioning style 5.21 into 5.2.1
60
	if ($revision == '' && strlen(intval($minor)) == 2) {
61
		$revision = substr($minor, -1);
62
		$minor = substr($minor, 0, 1);
63
	}
64
	
65
	// extract possible non numerical suffix from revision part (e.g. Alpha, Beta, RC1)
66
	$suffix = strtoupper(trim(substr($revision, strlen(intval($revision)))));
67

  
68
	// return standard version number (minor and revision numbers may not exceed 999)
69
	return (int) $major . '.' . sprintf('%03d', (int) $minor) . sprintf('%03d', (int) $revision) . 
70
		(($strip_suffix == false && $suffix != '') ? '_' . $suffix : '');
71
}
72

  
73
function versionCompare($version1, $version2, $operator = '>=')
74
{
75
	/**
76
	 * This funtion performs a comparison of two provided version strings
77
	 * The versions are first converted into a string following the major.minor.revision 
78
	 * convention and performs a version_compare afterwards.
79
	 */
80
	return version_compare(getVersion($version1), getVersion($version2), $operator);
81
}
82

  
83
function sortPreCheckArray($precheck_array)
84
{
85
	/**
86
	 * This funtion sorts the precheck array to a common format
87
	 */
88
	// define desired precheck order
89
	$key_order = array('WB_VERSION', 'WB_ADDONS', 'PHP_VERSION', 'PHP_EXTENSIONS', 'PHP_SETTINGS', 'CUSTOM_CHECKS');
90

  
91
	$temp_array = array();
92
	foreach($key_order as $key) {
93
		if (!isset($precheck_array[$key])) continue;
94
		$temp_array[$key] = $precheck_array[$key];
95
	}
96
	return $temp_array;
97
}
98

  
99
function preCheckAddon($temp_addon_file)
100
{
101
	/**
102
	 * This funtion performs pretest upfront of the Add-On installation process.
103
	 * The requirements can be specified via the array $PRECHECK which needs to
104
	 * be defined in the optional Add-on file precheck.php.
105
	 */
106
	global $database, $admin, $TEXT, $HEADING, $MESSAGE;
107
	
108
	// path to the temporary Add-on folder
109
	$temp_path = WB_PATH . '/temp/unzip';
110
	
111
	// check if file precheck.php exists for the Add-On uploaded via WB installation routine
112
	if (!file_exists($temp_path . '/precheck.php')) return;
113
	
114
	// unset any previous declared PRECHECK array
115
	unset($PRECHECK);
116

  
117
	// include Add-On precheck.php file
118
	include($temp_path . '/precheck.php');
119
	
120
	// check if there are any Add-On requirements to check for
121
	if (!(isset($PRECHECK) && count($PRECHECK) > 0)) return;
122
	
123
	// sort precheck array
124
	$PRECHECK = sortPreCheckArray($PRECHECK);
125
	
126
	$failed_checks = 0;
127
	$msg = array();
128
	// check if specified addon requirements are fullfilled
129
	foreach ($PRECHECK as $key => $value) {
130
		switch ($key) {
131
			case 'WB_VERSION':
132
				if (isset($value['VERSION'])) {
133
					// obtain operator for string comparison if exist
134
					$operator = (isset($value['OPERATOR']) &&  trim($value['OPERATOR']) != '') ? $value['OPERATOR'] : '>=';
135
				
136
					// compare versions and extract actual status
137
					$status = versionCompare(WB_VERSION, $value['VERSION'], $operator);
138
					$msg[] = array(
139
						'check'		=> 'WB-' . $TEXT['VERSION'] .': ',
140
						'required'	=> htmlentities($operator) . $value['VERSION'],
141
						'actual'	=> WB_VERSION,
142
						'status'	=> $status
143
					);
144

  
145
					// increase counter if required
146
					if (!$status) $failed_checks++;
147
				}
148
				break;
149

  
150
			case 'WB_ADDONS':
151
				if (is_array($PRECHECK['WB_ADDONS'])) {
152
					foreach($PRECHECK['WB_ADDONS'] as $addon => $values) {
153
						if (is_array($values)) {
154
							// extract module version and operator
155
							$version = (isset($values['VERSION']) &&  trim($values['VERSION']) != '') ? $values['VERSION'] : '';
156
							$operator = (isset($values['OPERATOR']) &&  trim($values['OPERATOR']) != '') ? $values['OPERATOR'] : '>=';
157
						} else {
158
							// no version and operator specified (only check if addon exists)
159
							$addon = strip_tags($values);
160
							$version = ''; $operator = '';
161
						}
162
					
163
						// check if addon is listed in WB database
164
						$table = TABLE_PREFIX . 'addons';
165
						$sql = "SELECT * FROM `$table` WHERE `directory` = '" . addslashes($addon) . "'";
166
						$results = $database->query($sql);
167
					
168
						$status = false; $addon_status = $TEXT['NOT_INSTALLED'];
169
						if ($results && $row = $results->fetchRow()) {
170
							$status = true; 
171
							$addon_status = $TEXT['INSTALLED'];
172
						
173
							// compare version if required
174
							if ($version != '') {
175
								$status = versionCompare($row['version'], $version, $operator);
176
								$addon_status = $row['version'];
177
							}
178
						}
179
					
180
						// provide addon status
181
						$msg[] = array(
182
							'check'		=> '&nbsp; ' . $TEXT['ADDON'] . ': ' . htmlentities($addon),
183
							'required'	=> ($version != '') ? $operator . '&nbsp;' . $version : $TEXT['INSTALLED'],
184
							'actual'	=> $addon_status,
185
							'status'	=> $status
186
						);
187
						
188
						// increase counter if required
189
						if (!$status) $failed_checks++;
190
					}
191
				}
192
				break;
193

  
194
			case 'PHP_VERSION':
195
				if (isset($value['VERSION'])) {
196
					// obtain operator for string comparison if exist
197
					$operator = (isset($value['OPERATOR']) &&  trim($value['OPERATOR']) != '') ? $value['OPERATOR'] : '>=';
198
				
199
					// compare versions and extract actual status
200
					$status = versionCompare(PHP_VERSION, $value['VERSION'], $operator);
201
					$msg[] = array(
202
						'check'		=> 'PHP-' . $TEXT['VERSION'] .': ',
203
						'required'	=> htmlentities($operator) . '&nbsp;' . $value['VERSION'],
204
						'actual'	=> PHP_VERSION,
205
						'status'	=> $status
206
					);
207

  
208
					// increase counter if required
209
					if (!$status) $failed_checks++;
210

  
211
				}
212
				break;
213

  
214
			case 'PHP_EXTENSIONS':
215
				if (is_array($PRECHECK['PHP_EXTENSIONS'])) {
216
					foreach($PRECHECK['PHP_EXTENSIONS'] as $extension) {
217
						$status = extension_loaded(strtolower($extension));
218
						$msg[] = array(
219
							'check'		=> '&nbsp; ' . $TEXT['EXTENSION'] . ': ' . htmlentities($extension),
220
							'required'	=> $TEXT['INSTALLED'],
221
							'actual'	=> ($status) ? $TEXT['INSTALLED'] : $TEXT['NOT_INSTALLED'],
222
							'status'	=> $status
223
						);
224

  
225
						// increase counter if required
226
						if (!$status) $failed_checks++;
227
					}
228
				}
229
				break;
230

  
231
			case 'PHP_SETTINGS':
232
				if (is_array($PRECHECK['PHP_SETTINGS'])) {
233
					foreach($PRECHECK['PHP_SETTINGS'] as $setting => $value) {
234
						$actual_setting = ($temp = ini_get($setting)) ? $temp : 0;
235
						$status = ($actual_setting == $value);
236
					
237
						$msg[] = array(
238
							'check'		=> '&nbsp; '. ($setting),
239
							'required'	=> $value,
240
							'actual'	=> $actual_setting,
241
							'status'	=> $status
242
						);
243

  
244
						// increase counter if required
245
						if (!$status) $failed_checks++;
246
					}
247
				}
248
				break;
249

  
250
			case 'CUSTOM_CHECKS':
251
				if (is_array($PRECHECK['CUSTOM_CHECKS'])) {
252
					foreach($PRECHECK['CUSTOM_CHECKS'] as $key => $values) {
253
						$msg[] = array(
254
							'check'		=> $key,
255
							'required'	=> $values['REQUIRED'],
256
							'actual'	=> $values['ACTUAL'],
257
							'status'	=> $values['STATUS']
258
						);
259
					}
260

  
261
					// increase counter if required
262
					if (!$status) $failed_checks++;
263
				}
264
				break;
265
		}
266
	}
267

  
268
	// leave if all requirements are fullfilled
269
	if ($failed_checks == 0) return;
270
	
271
	// output summary table with requirements not fullfilled
272
	echo <<< EOT
273
	<h2>{$HEADING['ADDON_PRECHECK_FAILED']}</h2>
274
	<p>{$MESSAGE['ADDON']['PRECHECK_FAILED']}</p> 
275

  
276
	<table width="700px" cellpadding="4" border="0" style="margin: 0.5em; border-collapse: collapse; border: 1px solid silver;">
277
	<tr>
278
		<th>{$TEXT['REQUIREMENT']}:</th>
279
		<th>{$TEXT['REQUIRED']}:</th>
280
		<th>{$TEXT['CURRENT']}:</th>
281
	</tr>
282
EOT;
283

  
284
	foreach($msg as $check) {
285
		echo '<tr>';
286
		$style = $check['status'] ? 'color: #46882B;' : 'color: #C00;';
287
		foreach($check as $key => $value) {
288
			if ($key == 'status') continue;
289
			
290
			echo '<td style="' . $style . '">' . $value . '</td>';
291
		}
292
		echo '</tr>';
293
	}
294
	echo '</table>';
295

  
296
	// delete the temp unzip directory
297
	rm_full_dir($temp_path);	
298

  
299
	// delete the temporary zip file of the Add-on
300
	if(file_exists($temp_addon_file)) { unlink($temp_addon_file); }	
301
	
302
	// output status message and die
303
	$admin->print_error('');
304
}
305

  
1
<?php
2
/**
3
 * $Id$
4
 * Website Baker Add-On precheck functions
5
 *
6
 * This file contains the functions of the pretest performed upfront
7
 * of the Add-On installation process. The functions allows developers
8
 * to specify requirements for their Add-On.
9
 *
10
 * LICENSE: GNU Lesser General Public License 3.0
11
 * 
12
 * @author		Christian Sommer
13
 * @copyright	(c) 2009
14
 * @license		http://www.gnu.org/copyleft/lesser.html
15
 * @version		0.2.3
16
 * @platform	Website Baker 2.7
17
 *
18
 * Website Baker Project <http://www.websitebaker.org/>
19
 * Copyright (C) 2004-2009, Ryan Djurovich
20
 *
21
 * Website Baker is free software; you can redistribute it and/or modify
22
 * it under the terms of the GNU General Public License as published by
23
 * the Free Software Foundation; either version 2 of the License, or
24
 * (at your option) any later version.
25
 *
26
 * Website Baker is distributed in the hope that it will be useful,
27
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
 * GNU General Public License for more details.
30
 *
31
 * You should have received a copy of the GNU General Public License
32
 * along with Website Baker; if not, write to the Free Software
33
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
34
*/
35

  
36
// prevent this file from being accessed directly
37
if (!defined('WB_PATH')) die(header('Location: ../index.php'));
38

  
39
function getVersion($version, $strip_suffix = true)
40
{
41
	/**
42
	 * This funtion creates a version string following the major.minor.revision convention
43
	 * The minor and revision part of the version may not exceed 999 (three digits)
44
	 * An optional suffix part can be added after revision (requires $strip_suffix = false)
45
	 *
46
	 * EXAMPLES: input --> output
47
	 *	5 --> 5.000000; 5.0 --> 5.000000; 5.0.0 --> 5.000000
48
	 * 	5.2 --> 5.002000; 5.20 --> 5.002000; 5.2.0 --> 5.002000
49
	 * 	5.21 --> 5.002001; 5.2.1 --> 5.002001;
50
	 * 	5.27.1 --> 5.027001; 5.2.71 --> 5.002071;
51
	 * 	5.27.1 rc1 --> 5.027001_RC1 ($strip_suffix:= false)
52
	 */
53
	// replace comma by decimal point
54
	$version = str_replace(',', '.', $version);
55

  
56
	// convert version into major.minor.revision numbering system
57
	list($major, $minor, $revision) = explode('.', $version, 3);
58

  
59
	// convert versioning style 5.21 into 5.2.1
60
	if ($revision == '' && strlen(intval($minor)) == 2) {
61
		$revision = substr($minor, -1);
62
		$minor = substr($minor, 0, 1);
63
	}
64
	
65
	// extract possible non numerical suffix from revision part (e.g. Alpha, Beta, RC1)
66
	$suffix = strtoupper(trim(substr($revision, strlen(intval($revision)))));
67

  
68
	// return standard version number (minor and revision numbers may not exceed 999)
69
	return (int) $major . '.' . sprintf('%03d', (int) $minor) . sprintf('%03d', (int) $revision) . 
70
		(($strip_suffix == false && $suffix != '') ? '_' . $suffix : '');
71
}
72

  
73
/**
74
 *	As "version_compare" it self seems only got trouble 
75
 *	within words like "Alpha", "Beta" a.s.o. this function
76
 *	only modify the version-string in the way that these words are replaced by values/numbers.
77
 *
78
 *	E.g:	"1.2.3 Beta2" => "1.2.322"
79
 *			"0.1.1 ALPHA" => "0.1.11"
80
 *
81
 *	Notice:	Please keep in mind, that this will not correct the way "version_control" 
82
 *			handel "1 < 1.0 < 1.0.0 < 1.0.0.0" and will not correct missformed version-strings
83
 *			below 2.7, e.g. "1.002 released candidate 2.3"
84
 *			
85
 *	@since	2.8.0 RC2
86
 *
87
 *	@param	string	A versionstring
88
 *	@return	string	The modificated versionstring
89
 *
90
 */
91
function getVersion2 ($version="") {
92
	
93
	$states = array (
94
		'1' => "alpha",
95
		'2' => "beta",
96
		'4' => "rc",
97
		'8' => "final"	
98
	);
99

  
100
	$version = strtolower($version);
101
	
102
	foreach($states as $value=>$keys) $version = str_replace($keys, $value, $version);
103

  
104
	$version = str_replace(" ", "", $version);
105

  
106
	return $version;
107
}
108

  
109
function versionCompare($version1, $version2, $operator = '>=')
110
{
111
	/**
112
	 * This funtion performs a comparison of two provided version strings
113
	 * The versions are first converted into a string following the major.minor.revision 
114
	 * convention and performs a version_compare afterwards.
115
	 */
116
	// return version_compare(getVersion($version1), getVersion($version2), $operator);
117
	return version_compare(getVersion2($version1), getVersion2($version2), $operator);
118
}
119

  
120
function sortPreCheckArray($precheck_array)
121
{
122
	/**
123
	 * This funtion sorts the precheck array to a common format
124
	 */
125
	// define desired precheck order
126
	$key_order = array('WB_VERSION', 'WB_ADDONS', 'PHP_VERSION', 'PHP_EXTENSIONS', 'PHP_SETTINGS', 'CUSTOM_CHECKS');
127

  
128
	$temp_array = array();
129
	foreach($key_order as $key) {
130
		if (!isset($precheck_array[$key])) continue;
131
		$temp_array[$key] = $precheck_array[$key];
132
	}
133
	return $temp_array;
134
}
135

  
136
function preCheckAddon($temp_addon_file)
137
{
138
	/**
139
	 * This funtion performs pretest upfront of the Add-On installation process.
140
	 * The requirements can be specified via the array $PRECHECK which needs to
141
	 * be defined in the optional Add-on file precheck.php.
142
	 */
143
	global $database, $admin, $TEXT, $HEADING, $MESSAGE;
144
	
145
	// path to the temporary Add-on folder
146
	$temp_path = WB_PATH . '/temp/unzip';
147
	
148
	// check if file precheck.php exists for the Add-On uploaded via WB installation routine
149
	if (!file_exists($temp_path . '/precheck.php')) return;
150
	
151
	// unset any previous declared PRECHECK array
152
	unset($PRECHECK);
153

  
154
	// include Add-On precheck.php file
155
	include($temp_path . '/precheck.php');
156
	
157
	// check if there are any Add-On requirements to check for
158
	if (!(isset($PRECHECK) && count($PRECHECK) > 0)) return;
159
	
160
	// sort precheck array
161
	$PRECHECK = sortPreCheckArray($PRECHECK);
162
	
163
	$failed_checks = 0;
164
	$msg = array();
165
	// check if specified addon requirements are fullfilled
166
	foreach ($PRECHECK as $key => $value) {
167
		switch ($key) {
168
			case 'WB_VERSION':
169
				if (isset($value['VERSION'])) {
170
					// obtain operator for string comparison if exist
171
					$operator = (isset($value['OPERATOR']) &&  trim($value['OPERATOR']) != '') ? $value['OPERATOR'] : '>=';
172
				
173
					// compare versions and extract actual status
174
					$status = versionCompare(WB_VERSION, $value['VERSION'], $operator);
175
					$msg[] = array(
176
						'check'		=> 'WB-' . $TEXT['VERSION'] .': ',
177
						'required'	=> htmlentities($operator) . $value['VERSION'],
178
						'actual'	=> WB_VERSION,
179
						'status'	=> $status
180
					);
181

  
182
					// increase counter if required
183
					if (!$status) $failed_checks++;
184
				}
185
				break;
186

  
187
			case 'WB_ADDONS':
188
				if (is_array($PRECHECK['WB_ADDONS'])) {
189
					foreach($PRECHECK['WB_ADDONS'] as $addon => $values) {
190
						if (is_array($values)) {
191
							// extract module version and operator
192
							$version = (isset($values['VERSION']) &&  trim($values['VERSION']) != '') ? $values['VERSION'] : '';
193
							$operator = (isset($values['OPERATOR']) &&  trim($values['OPERATOR']) != '') ? $values['OPERATOR'] : '>=';
194
						} else {
195
							// no version and operator specified (only check if addon exists)
196
							$addon = strip_tags($values);
197
							$version = ''; $operator = '';
198
						}
199
					
200
						// check if addon is listed in WB database
201
						$table = TABLE_PREFIX . 'addons';
202
						$sql = "SELECT * FROM `$table` WHERE `directory` = '" . addslashes($addon) . "'";
203
						$results = $database->query($sql);
204
					
205
						$status = false; $addon_status = $TEXT['NOT_INSTALLED'];
206
						if ($results && $row = $results->fetchRow()) {
207
							$status = true; 
208
							$addon_status = $TEXT['INSTALLED'];
209
						
210
							// compare version if required
211
							if ($version != '') {
212
								$status = versionCompare($row['version'], $version, $operator);
213
								$addon_status = $row['version'];
214
							}
215
						}
216
					
217
						// provide addon status
218
						$msg[] = array(
219
							'check'		=> '&nbsp; ' . $TEXT['ADDON'] . ': ' . htmlentities($addon),
220
							'required'	=> ($version != '') ? $operator . '&nbsp;' . $version : $TEXT['INSTALLED'],
221
							'actual'	=> $addon_status,
222
							'status'	=> $status
223
						);
224
						
225
						// increase counter if required
226
						if (!$status) $failed_checks++;
227
					}
228
				}
229
				break;
230

  
231
			case 'PHP_VERSION':
232
				if (isset($value['VERSION'])) {
233
					// obtain operator for string comparison if exist
234
					$operator = (isset($value['OPERATOR']) &&  trim($value['OPERATOR']) != '') ? $value['OPERATOR'] : '>=';
235
				
236
					// compare versions and extract actual status
237
					$status = versionCompare(PHP_VERSION, $value['VERSION'], $operator);
238
					$msg[] = array(
239
						'check'		=> 'PHP-' . $TEXT['VERSION'] .': ',
240
						'required'	=> htmlentities($operator) . '&nbsp;' . $value['VERSION'],
241
						'actual'	=> PHP_VERSION,
242
						'status'	=> $status
243
					);
244

  
245
					// increase counter if required
246
					if (!$status) $failed_checks++;
247

  
248
				}
249
				break;
250

  
251
			case 'PHP_EXTENSIONS':
252
				if (is_array($PRECHECK['PHP_EXTENSIONS'])) {
253
					foreach($PRECHECK['PHP_EXTENSIONS'] as $extension) {
254
						$status = extension_loaded(strtolower($extension));
255
						$msg[] = array(
256
							'check'		=> '&nbsp; ' . $TEXT['EXTENSION'] . ': ' . htmlentities($extension),
257
							'required'	=> $TEXT['INSTALLED'],
258
							'actual'	=> ($status) ? $TEXT['INSTALLED'] : $TEXT['NOT_INSTALLED'],
259
							'status'	=> $status
260
						);
261

  
262
						// increase counter if required
263
						if (!$status) $failed_checks++;
264
					}
265
				}
266
				break;
267

  
268
			case 'PHP_SETTINGS':
269
				if (is_array($PRECHECK['PHP_SETTINGS'])) {
270
					foreach($PRECHECK['PHP_SETTINGS'] as $setting => $value) {
271
						$actual_setting = ($temp = ini_get($setting)) ? $temp : 0;
272
						$status = ($actual_setting == $value);
273
					
274
						$msg[] = array(
275
							'check'		=> '&nbsp; '. ($setting),
276
							'required'	=> $value,
277
							'actual'	=> $actual_setting,
278
							'status'	=> $status
279
						);
280

  
281
						// increase counter if required
282
						if (!$status) $failed_checks++;
283
					}
284
				}
285
				break;
286

  
287
			case 'CUSTOM_CHECKS':
288
				if (is_array($PRECHECK['CUSTOM_CHECKS'])) {
289
					foreach($PRECHECK['CUSTOM_CHECKS'] as $key => $values) {
290
						$msg[] = array(
291
							'check'		=> $key,
292
							'required'	=> $values['REQUIRED'],
293
							'actual'	=> $values['ACTUAL'],
294
							'status'	=> $values['STATUS']
295
						);
296
					}
297

  
298
					// increase counter if required
299
					if (!$status) $failed_checks++;
300
				}
301
				break;
302
		}
303
	}
304

  
305
	// leave if all requirements are fullfilled
306
	if ($failed_checks == 0) return;
307
	
308
	// output summary table with requirements not fullfilled
309
	echo <<< EOT
310
	<h2>{$HEADING['ADDON_PRECHECK_FAILED']}</h2>
311
	<p>{$MESSAGE['ADDON']['PRECHECK_FAILED']}</p> 
312

  
313
	<table width="700px" cellpadding="4" border="0" style="margin: 0.5em; border-collapse: collapse; border: 1px solid silver;">
314
	<tr>
315
		<th>{$TEXT['REQUIREMENT']}:</th>
316
		<th>{$TEXT['REQUIRED']}:</th>
317
		<th>{$TEXT['CURRENT']}:</th>
318
	</tr>
319
EOT;
320

  
321
	foreach($msg as $check) {
322
		echo '<tr>';
323
		$style = $check['status'] ? 'color: #46882B;' : 'color: #C00;';
324
		foreach($check as $key => $value) {
325
			if ($key == 'status') continue;
326
			
327
			echo '<td style="' . $style . '">' . $value . '</td>';
328
		}
329
		echo '</tr>';
330
	}
331
	echo '</table>';
332

  
333
	// delete the temp unzip directory
334
	rm_full_dir($temp_path);	
335

  
336
	// delete the temporary zip file of the Add-on
337
	if(file_exists($temp_addon_file)) { unlink($temp_addon_file); }	
338
	
339
	// output status message and die
340
	$admin->print_error('');
341
}
342

  
306 343
?>

Also available in: Unified diff