Project

General

Profile

« Previous | Next » 

Revision 925

Added by doc almost 16 years ago

Added option to perform pre-installation checks to test requirements of Add-Ons

View differences:

install.php
29 29
	exit(0);
30 30
}
31 31

  
32
// do not display notices and warnings during installation
33
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
34

  
32 35
// Setup admin object
33 36
require('../../config.php');
34 37
require_once(WB_PATH.'/framework/class.admin.php');
......
65 68
	$admin->print_error($MESSAGE['GENERIC']['CANNOT_UPLOAD']);
66 69
}
67 70

  
71
// Check if uploaded file is a valid language file (no binary file etc.)
72
$content = file_get_contents($temp_file);
73
if (strpos($content, '<?php') === false) $admin->print_error($MESSAGE['GENERIC']['INVALID_LANGUAGE_FILE']);
74

  
68 75
// Remove any vars with name "language_code"
69 76
unset($language_code);
70 77

  
78
// Include precheck files for versionCompare routine
79
require(WB_PATH . '/framework/addon.precheck.inc.php');
80

  
71 81
// Read the temp file and look for a language code
72 82
require($temp_file);
73 83
$new_language_version=$language_version;
......
77 87
	if(file_exists($temp_file)) { unlink($temp_file); } // Remove temp file
78 88
	// Restore to correct language
79 89
	require(WB_PATH.'/languages/'.LANGUAGE.'.php');
80
	$admin->print_error($MESSAGE['GENERIC']['INVALID']);
90
	$admin->print_error($MESSAGE['GENERIC']['INVALID_LANGUAGE_FILE']);
81 91
}
82 92

  
83 93
// Set destination for language file
84 94
$language_file = WB_PATH.'/languages/'.$language_code.'.php';
95
$action="install";
85 96

  
86 97
// Move to new location
87 98
if (file_exists($language_file)) {
88 99
	require($language_file);
89
	if ($language_version>$new_language_version) {
100
	if (versionCompare($language_version, $new_language_version, '>=')) {
101
		// Restore to correct language
102
		require(WB_PATH . '/languages/' . LANGUAGE . '.php');
90 103
		$admin->print_error($MESSAGE['GENERIC']['ALREADY_INSTALLED']);
91 104
	}
105
	$action="upgrade";
92 106
	unlink($language_file);
93 107
}
94 108

  
......
104 118
require(WB_PATH.'/languages/'.LANGUAGE.'.php');
105 119

  
106 120
// Print success message
107
$admin->print_success($MESSAGE['GENERIC']['INSTALLED']);
121
if ($action=="install") {
122
	$admin->print_success($MESSAGE['GENERIC']['INSTALLED']);
123
} else {
124
	$admin->print_success($MESSAGE['GENERIC']['UPGRADED']);
125
}
108 126

  
109 127
// Print admin footer
110 128
$admin->print_footer();

Also available in: Unified diff