1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category admin
|
5
|
* @package languages
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright 2004-2009, Ryan Djurovich
|
8
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
9
|
* @link http://www.websitebaker2.org/
|
10
|
* @license http://www.gnu.org/licenses/gpl.html
|
11
|
* @platform WebsiteBaker 2.8.x
|
12
|
* @requirements PHP 5.2.2 and higher
|
13
|
* @version $Id: install.php 1467 2011-07-02 00:06:53Z Luisehahne $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/languages/install.php $
|
15
|
* @lastmodified $Date: 2011-07-02 02:06:53 +0200 (Sat, 02 Jul 2011) $
|
16
|
* @description
|
17
|
*
|
18
|
*/
|
19
|
|
20
|
// do not display notices and warnings during installation
|
21
|
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
|
22
|
|
23
|
// Setup admin object
|
24
|
require('../../config.php');
|
25
|
require_once(WB_PATH.'/framework/class.admin.php');
|
26
|
$admin = new admin('Addons', 'languages_install', false);
|
27
|
if( !$admin->checkFTAN() )
|
28
|
{
|
29
|
$admin->print_header();
|
30
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
|
31
|
}
|
32
|
// After check print the header
|
33
|
$admin->print_header();
|
34
|
|
35
|
// Check if user uploaded a file
|
36
|
if(!isset($_FILES['userfile'])) {
|
37
|
header("Location: index.php");
|
38
|
exit(0);
|
39
|
}
|
40
|
|
41
|
// Include the WB functions file
|
42
|
require_once(WB_PATH.'/framework/functions.php');
|
43
|
|
44
|
// Create temp string
|
45
|
$temp_string = '';
|
46
|
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
|
47
|
srand((double)microtime()*1000000);
|
48
|
$i = 0;
|
49
|
while ($i <= 7) {
|
50
|
$num = rand() % 33;
|
51
|
$tmp = substr($salt, $num, 1);
|
52
|
$temp_string = $temp_string . $tmp;
|
53
|
$i++;
|
54
|
}
|
55
|
|
56
|
// Set temp vars
|
57
|
$temp_dir = WB_PATH.'/temp/';
|
58
|
$temp_file = $temp_dir . 'language'.$temp_string;
|
59
|
|
60
|
// Check if language dir is writable
|
61
|
if(!is_writable(WB_PATH.'/languages/')) {
|
62
|
if(file_exists($temp_file)) { unlink($temp_file); } // Remove temp file
|
63
|
$admin->print_error($MESSAGE['GENERIC']['BAD_PERMISSIONS']);
|
64
|
}
|
65
|
|
66
|
// Try to upload the file to the temp dir
|
67
|
if(!move_uploaded_file($_FILES['userfile']['tmp_name'], $temp_file)) {
|
68
|
if(file_exists($temp_file)) { unlink($temp_file); } // Remove temp file
|
69
|
$admin->print_error($MESSAGE['GENERIC']['CANNOT_UPLOAD']);
|
70
|
}
|
71
|
|
72
|
// Check if uploaded file is a valid language file (no binary file etc.)
|
73
|
$content = file_get_contents($temp_file);
|
74
|
if (strpos($content, '<?php') === false) $admin->print_error($MESSAGE['GENERIC']['INVALID_LANGUAGE_FILE']);
|
75
|
|
76
|
// Remove any vars with name "language_code"
|
77
|
unset($language_code);
|
78
|
|
79
|
// Include precheck files for versionCompare routine
|
80
|
require(WB_PATH . '/framework/addon.precheck.inc.php');
|
81
|
|
82
|
// Read the temp file and look for a language code
|
83
|
require($temp_file);
|
84
|
$new_language_version=$language_version;
|
85
|
|
86
|
// Check if the file is valid
|
87
|
if(!isset($language_code)) {
|
88
|
if(file_exists($temp_file)) { unlink($temp_file); } // Remove temp file
|
89
|
// Restore to correct language
|
90
|
require(WB_PATH.'/languages/'.LANGUAGE.'.php');
|
91
|
$admin->print_error($MESSAGE['GENERIC']['INVALID_LANGUAGE_FILE']);
|
92
|
}
|
93
|
|
94
|
// Set destination for language file
|
95
|
$language_file = WB_PATH.'/languages/'.$language_code.'.php';
|
96
|
$action="install";
|
97
|
|
98
|
// Move to new location
|
99
|
if (file_exists($language_file)) {
|
100
|
require($language_file);
|
101
|
if (versionCompare($language_version, $new_language_version, '>=')) {
|
102
|
// Restore to correct language
|
103
|
require(WB_PATH . '/languages/' . LANGUAGE . '.php');
|
104
|
$admin->print_error($MESSAGE['GENERIC']['ALREADY_INSTALLED']);
|
105
|
}
|
106
|
$action="upgrade";
|
107
|
unlink($language_file);
|
108
|
}
|
109
|
|
110
|
rename($temp_file, $language_file);
|
111
|
|
112
|
// Chmod the file
|
113
|
change_mode($language_file, 'file');
|
114
|
|
115
|
// Load language info into DB
|
116
|
load_language($language_file);
|
117
|
|
118
|
// Restore to correct language
|
119
|
require(WB_PATH.'/languages/'.LANGUAGE.'.php');
|
120
|
|
121
|
// Print success message
|
122
|
if ($action=="install") {
|
123
|
$admin->print_success($MESSAGE['GENERIC']['INSTALLED']);
|
124
|
} else {
|
125
|
$admin->print_success($MESSAGE['GENERIC']['UPGRADED']);
|
126
|
}
|
127
|
|
128
|
// Print admin footer
|
129
|
$admin->print_footer();
|
130
|
|
131
|
?>
|