1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* ExtGallery Admin settings |
4
|
|
|
* Manage admin pages |
5
|
|
|
* |
6
|
|
|
* You may not change or alter any portion of this comment or credits |
7
|
|
|
* of supporting developers from this source code or any supporting source code |
8
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
9
|
|
|
* This program is distributed in the hope that it will be useful, |
10
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
12
|
|
|
* |
13
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
14
|
|
|
* @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
15
|
|
|
* @author Zoullou (http://www.zoullou.net) |
16
|
|
|
* @package ExtGallery |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
use Xmf\Module\Admin; |
20
|
|
|
use XoopsModules\Extgallery; |
21
|
|
|
|
22
|
|
|
require_once __DIR__ . '/admin_header.php'; |
23
|
|
|
|
24
|
|
|
require_once __DIR__ . '/function.php'; |
25
|
|
|
require_once __DIR__ . '/moduleUpdateFunction.php'; |
26
|
|
|
|
27
|
|
|
$catHandler = Extgallery\Helper::getInstance()->getHandler('PublicCategory'); |
28
|
|
|
$photoHandler = Extgallery\Helper::getInstance()->getHandler('PublicPhoto'); |
29
|
|
|
|
30
|
|
|
xoops_cp_header(); |
31
|
|
|
|
32
|
|
|
// DNPROSSI - In PHP 5.3.0 "JPG Support" was renamed to "JPEG Support". |
33
|
|
|
// This leads to the following error: "Undefined index: JPG Support in |
34
|
|
|
// Fixed with version compare |
35
|
|
|
if (PHP_VERSION_ID < 50300) { |
36
|
|
|
$jpegsupport = 'JPG Support'; |
37
|
|
|
} else { |
38
|
|
|
$jpegsupport = 'JPEG Support'; |
39
|
|
|
} |
40
|
|
|
$code = 'function gd_info() { |
41
|
|
|
$array = Array( |
42
|
|
|
"GD Version" => "", |
43
|
|
|
"FreeType Support" => 0, |
44
|
|
|
"FreeType Support" => 0, |
45
|
|
|
"FreeType Linkage" => "", |
46
|
|
|
"T1Lib Support" => 0, |
47
|
|
|
"GIF Read Support" => 0, |
48
|
|
|
"GIF Create Support" => 0, |
49
|
|
|
"' . $jpegsupport . '" => 0, |
50
|
|
|
"PNG Support" => 0, |
51
|
|
|
"WBMP Support" => 0, |
52
|
|
|
"XBM Support" => 0 |
53
|
|
|
); |
54
|
|
|
$gif_support = 0; |
55
|
|
|
|
56
|
|
|
ob_start(); |
57
|
|
|
eval("phpinfo();"); |
58
|
|
|
$info = ob_get_contents(); |
59
|
|
|
ob_end_clean(); |
60
|
|
|
|
61
|
|
|
foreach (explode("\n", $info) as $line) { |
62
|
|
|
if(strpos($line, "GD Version")!==false) |
63
|
|
|
$array["GD Version"] = trim(str_replace("GD Version", "", strip_tags($line))); |
64
|
|
|
if(strpos($line, "FreeType Support")!==false) |
65
|
|
|
$array["FreeType Support"] = trim(str_replace("FreeType Support", "", strip_tags($line))); |
66
|
|
|
if(strpos($line, "FreeType Linkage")!==false) |
67
|
|
|
$array["FreeType Linkage"] = trim(str_replace("FreeType Linkage", "", strip_tags($line))); |
68
|
|
|
if(strpos($line, "T1Lib Support")!==false) |
69
|
|
|
$array["T1Lib Support"] = trim(str_replace("T1Lib Support", "", strip_tags($line))); |
70
|
|
|
if(strpos($line, "GIF Read Support")!==false) |
71
|
|
|
$array["GIF Read Support"] = trim(str_replace("GIF Read Support", "", strip_tags($line))); |
72
|
|
|
if(strpos($line, "GIF Create Support")!==false) |
73
|
|
|
$array["GIF Create Support"] = trim(str_replace("GIF Create Support", "", strip_tags($line))); |
74
|
|
|
if(strpos($line, "GIF Support")!==false) |
75
|
|
|
$gif_support = trim(str_replace("GIF Support", "", strip_tags($line))); |
76
|
|
|
if(strpos($line, "' . $jpegsupport . '")!==false) |
77
|
|
|
$array["' . $jpegsupport . '"] = trim(str_replace("J' . $jpegsupport . '", "", strip_tags($line))); |
78
|
|
|
if(strpos($line, "PNG Support")!==false) |
79
|
|
|
$array["PNG Support"] = trim(str_replace("PNG Support", "", strip_tags($line))); |
80
|
|
|
if(strpos($line, "WBMP Support")!==false) |
81
|
|
|
$array["WBMP Support"] = trim(str_replace("WBMP Support", "", strip_tags($line))); |
82
|
|
|
if(strpos($line, "XBM Support")!==false) |
83
|
|
|
$array["XBM Support"] = trim(str_replace("XBM Support", "", strip_tags($line))); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
if ($gif_support==="enabled") { |
87
|
|
|
$array["GIF Read Support"] = 1; |
88
|
|
|
$array["GIF Create Support"] = 1; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
if ($array["FreeType Support"]==="enabled") { |
92
|
|
|
$array["FreeType Support"] = 1; } |
93
|
|
|
|
94
|
|
|
if($array["T1Lib Support"]==="enabled") |
95
|
|
|
$array["T1Lib Support"] = 1; |
96
|
|
|
|
97
|
|
|
if ($array["GIF Read Support"]==="enabled") { |
98
|
|
|
$array["GIF Read Support"] = 1; } |
99
|
|
|
|
100
|
|
|
if($array["GIF Create Support"]==="enabled") |
101
|
|
|
$array["GIF Create Support"] = 1; |
102
|
|
|
|
103
|
|
|
if($array["' . $jpegsupport . '"]==="enabled") |
104
|
|
|
$array["' . $jpegsupport . '"] = 1; |
105
|
|
|
|
106
|
|
|
if($array["PNG Support"]==="enabled") |
107
|
|
|
$array["PNG Support"] = 1; |
108
|
|
|
|
109
|
|
|
if($array["WBMP Support"]==="enabled") |
110
|
|
|
$array["WBMP Support"] = 1; |
111
|
|
|
|
112
|
|
|
if($array["XBM Support"]==="enabled") |
113
|
|
|
$array["XBM Support"] = 1; |
114
|
|
|
|
115
|
|
|
return $array; |
116
|
|
|
}'; |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @param $dir |
120
|
|
|
* |
121
|
|
|
* @return mixed |
122
|
|
|
*/ |
123
|
|
|
function dskspace($dir) |
124
|
|
|
{ |
125
|
|
|
$s = stat($dir); |
126
|
|
|
$space = $s[7]; |
127
|
|
|
if (is_dir($dir)) { |
128
|
|
|
$dh = opendir($dir); |
129
|
|
|
while (false !== ($file = readdir($dh))) { |
130
|
|
|
if ('.' !== $file && '..' !== $file) { |
131
|
|
|
$space += dskspace($dir . '/' . $file); |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
closedir($dh); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
return $space; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @return array |
142
|
|
|
*/ |
143
|
|
|
function imageMagickSupportType() |
144
|
|
|
{ |
145
|
|
|
/** @var Extgallery\Helper $helper */ |
146
|
|
|
$helper = Extgallery\Helper::getInstance(); |
147
|
|
|
|
148
|
|
|
$cmd = $helper->getConfig('graphic_lib_path') . 'convert -list format'; |
149
|
|
|
exec($cmd, $data); |
150
|
|
|
|
151
|
|
|
$ret = [ |
152
|
|
|
'GIF Support' => '<span style="color:#FF0000;"><b>KO</b></span>', |
153
|
|
|
'JPG Support' => '<span style="color:#FF0000;"><b>KO</b></span>', |
154
|
|
|
'PNG Support' => '<span style="color:#FF0000;"><b>KO</b></span>', |
155
|
|
|
]; |
156
|
|
|
|
157
|
|
|
foreach ($data as $line) { |
158
|
|
|
preg_match("`GIF\* GIF.*([rw]{2})`", $line, $matches); |
159
|
|
|
if (isset($matches[1]) && 'rw' === $matches[1]) { |
160
|
|
|
$ret['GIF Support'] = '<span style="color:#33CC33;"><b>OK</b></span>'; |
161
|
|
|
} |
162
|
|
|
preg_match("`JPG\* JPEG.*([rw]{2})`", $line, $matches); |
163
|
|
|
if (isset($matches[1]) && 'rw' === $matches[1]) { |
164
|
|
|
$ret['JPG Support'] = '<span style="color:#33CC33;"><b>OK</b></span>'; |
165
|
|
|
} |
166
|
|
|
preg_match("`PNG\* PNG.*([rw]{2})`", $line, $matches); |
167
|
|
|
if (isset($matches[1]) && 'rw' === $matches[1]) { |
168
|
|
|
$ret['PNG Support'] = '<span style="color:#33CC33;"><b>OK</b></span>'; |
169
|
|
|
} |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
return $ret; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* @param $path |
177
|
|
|
* |
178
|
|
|
* @return bool |
179
|
|
|
*/ |
180
|
|
|
function is__writable($path) |
181
|
|
|
{ |
182
|
|
|
//will work in despite of Windows ACLs bug |
183
|
|
|
//NOTE: use a trailing slash for folders!!! |
184
|
|
|
//see http://bugs.php.net/bug.php?id=27609 |
185
|
|
|
//see http://bugs.php.net/bug.php?id=30931 |
186
|
|
|
|
187
|
|
|
if ('/' === $path[mb_strlen($path) - 1]) { |
188
|
|
|
// recursively return a temporary file path |
189
|
|
|
return is__writable($path . uniqid(mt_rand(), true) . '.tmp'); |
190
|
|
|
} elseif (is_dir($path)) { |
191
|
|
|
return is__writable($path . '/' . uniqid(mt_rand(), true) . '.tmp'); |
192
|
|
|
} |
193
|
|
|
// check tmp file for read/write capabilities |
194
|
|
|
$rm = file_exists($path); |
195
|
|
|
$f = @fopen($path, 'ab'); |
196
|
|
|
if (false === $f) { |
197
|
|
|
return false; |
198
|
|
|
} |
199
|
|
|
fclose($f); |
200
|
|
|
if (!$rm) { |
201
|
|
|
unlink($path); |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
return true; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
// dossier dans uploads |
208
|
|
|
$folder = [ |
209
|
|
|
XOOPS_ROOT_PATH . '/uploads/extgallery', |
210
|
|
|
XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo', |
211
|
|
|
XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/original', |
212
|
|
|
XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/large', |
213
|
|
|
XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/medium', |
214
|
|
|
XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/thumb', |
215
|
|
|
]; |
216
|
|
|
|
217
|
|
|
$adminObject = Admin::getInstance(); |
218
|
|
|
|
219
|
|
|
$adminObject->addInfoBox(_AM_EXTGALLERY_SERVER_CONF); |
220
|
|
|
if ('gd' === $helper->getConfig('graphic_lib')) { |
221
|
|
|
$gd = gd_info(); |
222
|
|
|
// GD graphic lib |
223
|
|
|
$test1 = ('' == $gd['GD Version']) ? '<span style="color:#FF0000;"><b>KO</b></span>' : $gd['GD Version']; |
224
|
|
|
($gd['GIF Read Support'] |
225
|
|
|
&& $gd['GIF Create Support']) ? $test2 = '<span style="color:#33CC33;"><b>OK</b></span>' : $test2 = '<span style="color:#FF0000;"><b>KO</b></span>'; |
226
|
|
|
$gd['' . $jpegsupport . ''] ? $test3 = '<span style="color:#33CC33;"><b>OK</b></span>' : $test3 = '<span style="color:#FF0000;"><b>KO</b></span>'; |
227
|
|
|
$gd['PNG Support'] ? $test4 = '<span style="color:#33CC33;"><b>OK</b></span>' : $test4 = '<span style="color:#FF0000;"><b>KO</b></span>'; |
228
|
|
|
|
229
|
|
|
$adminObject->addInfoBoxLine(sprintf(_AM_EXTGALLERY_GRAPH_GD_LIB_VERSION . ' ' . $test1), ''); |
230
|
|
|
$adminObject->addInfoBoxLine(sprintf(_AM_EXTGALLERY_GIF_SUPPORT . ' ' . $test2), ''); |
231
|
|
|
$adminObject->addInfoBoxLine(sprintf(_AM_EXTGALLERY_JPEG_SUPPORT . ' ' . $test3), ''); |
232
|
|
|
$adminObject->addInfoBoxLine(sprintf(_AM_EXTGALLERY_PNG_SUPPORT . ' ' . $test4), ''); |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
if ('imagick' === $helper->getConfig('graphic_lib')) { |
236
|
|
|
// ImageMagick graphic lib |
237
|
|
|
$cmd = $helper->getConfig('graphic_lib_path') . 'convert -version'; |
238
|
|
|
exec($cmd, $data, $error); |
239
|
|
|
$test = $data[0] ?? '<span style="color:#FF0000;"><b>KO</b></span>'; |
240
|
|
|
$imSupport = imageMagickSupportType(); |
241
|
|
|
$adminObject->addInfoBoxLine(sprintf(_AM_EXTGALLERY_GRAPH_IM_LIB_VERSION . ' ' . $test), ''); |
242
|
|
|
$adminObject->addInfoBoxLine(sprintf(_AM_EXTGALLERY_GIF_SUPPORT . ' ' . $imSupport['GIF Support']), ''); |
243
|
|
|
$adminObject->addInfoBoxLine(sprintf(_AM_EXTGALLERY_JPEG_SUPPORT . ' ' . $imSupport['JPG Support']), ''); |
244
|
|
|
$adminObject->addInfoBoxLine(sprintf(_AM_EXTGALLERY_PNG_SUPPORT . ' ' . $imSupport['PNG Support']), ''); |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
$adminObject->addInfoBoxLine(sprintf(_AM_EXTGALLERY_UPLOAD_MAX_FILESIZE . get_cfg_var('upload_max_filesize')), ''); |
|
|
|
|
248
|
|
|
$adminObject->addInfoBoxLine(sprintf(_AM_EXTGALLERY_POST_MAX_SIZE . get_cfg_var('post_max_size')), ''); |
|
|
|
|
249
|
|
|
|
250
|
|
|
foreach (array_keys($folder) as $i) { |
251
|
|
|
$adminObject->addConfigBoxLine($folder[$i], 'folder'); |
252
|
|
|
$adminObject->addConfigBoxLine([$folder[$i], '777'], 'chmod'); |
253
|
|
|
} |
254
|
|
|
/** @var \XoopsTpl $xoopsTpl */ |
255
|
|
|
$xoopsTpl->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); |
256
|
|
|
$xoopsTpl->assign('index', $adminObject->displayIndex()); |
257
|
|
|
|
258
|
|
|
// Call template file |
259
|
|
|
$xoopsTpl->display(XOOPS_ROOT_PATH . '/modules/extgallery/templates/admin/extgallery_admin_index.tpl'); |
260
|
|
|
|
261
|
|
|
xoops_cp_footer(); |
262
|
|
|
|