This repository has been archived by the owner on Jul 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.inc.php
executable file
·101 lines (91 loc) · 2.17 KB
/
install.inc.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
<?php
/**
* decaf_upload_precompressor
*
* @author DECAF
* @version $Id$
*/
$mypage = 'decaf_upload_precompressor';
$base_path = $REX['INCLUDE_PATH'] .'/addons/'.$mypage;
if ($REX['REDAXO'])
{
if ($REX['LANG'] == 'default')
{
$be_lang = 'de_de_utf8';
}
else {
$be_lang = $REX['LANG'];
}
$I18N->appendFile($REX['INCLUDE_PATH'].'/addons/'.$mypage.'/lang/');
}
$error = false;
$err_msg = array();
// check for REX version < 4.3
if ( ($REX['VERSION'] < 4) || ($REX['VERSION'] == 4 && $REX['SUBVERSION'] < 3) )
{
$err_msg[] = $I18N->msg('dcf_precomp_rex_version');
$error = true;
}
else {
// check if /config is writable
if (!is_writable($base_path.'/config/'))
{
$error = true;
$err_msg[] = $I18N->msg('dcf_precomp_config_dir_locked');
}
$available_memory = getMemoryLimitInMb();
if ($available_memory < 64 && $available_memory != -1)
{
$err_msg[] = $I18N->msg('dcf_precomp_insufficient_memory');
$error = true;
}
}
if (!$error)
{
// check if config.ini exists
$file = $base_path.'/config/config.ini.php';
if (!file_exists($file))
{
$cfg = parse_ini_file($base_path.'/config/_config.ini.php');
$tpl = rex_get_file_contents($base_path.'/config/_config.ini.php');
// set defaults
$search[] = '@@max_pixel@@';
$replace[] = '1200';
$search[] = '@@jpg_quality@@';
$replace[] = '90';
$config_str = str_replace($search, $replace, $tpl);
file_put_contents($base_path.'/config/config.ini.php', $config_str);
}
}
if (!$error)
{
$REX['ADDON']['install'][$mypage] = true;
}
else
{
$REX['ADDON']['installmsg']['decaf_upload_precompressor'] = implode('<br />', $err_msg);
}
function getMemoryLimitInMb()
{
$ml = @ini_get('memory_limit');
if ($ml == 0) return -1;
$unit = substr($ml,strlen($ml)-1, 1);
switch ($unit) {
case 'G' :
case 'g' :
$memory = (substr($ml,0, strlen($ml)-1) * 1024);
break;
case 'M' :
case 'm' :
$memory = substr($ml,0, strlen($ml)-1);
break;
case 'K' :
case 'k' :
$memory = round((substr($ml,0, strlen($ml)-1) / 1024), 0);
break;
default:
$memory = round(($ml / 1024 / 1024), 0);
}
return $memory;
}
?>