|
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\Request; |
|
20
|
|
|
use XoopsModules\Extgallery; |
|
21
|
|
|
|
|
22
|
|
|
require_once __DIR__ . '/admin_header.php'; |
|
23
|
|
|
if (Request::hasVar('step', 'POST')) { |
|
24
|
|
|
$step = $_POST['step']; |
|
25
|
|
|
} else { |
|
26
|
|
|
$step = 'default'; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
// Change this variable if you use a cloned version of eXtGallery |
|
30
|
|
|
$localModuleDir = 'extgallery'; |
|
31
|
|
|
|
|
32
|
|
|
$downloadServer = 'http://downloads.sourceforge.net/xoops/'; |
|
33
|
|
|
//$downloadServer = 'http://localhost/divers/extgallery/'; |
|
34
|
|
|
$extensionFileName = 'extgallery-extension-hook.tar.gz'; |
|
35
|
|
|
|
|
36
|
|
|
switch ($step) { |
|
37
|
|
|
case 'download': |
|
38
|
|
|
|
|
39
|
|
|
xoops_cp_header(); |
|
40
|
|
|
|
|
41
|
|
|
if (!$handle = @fopen($downloadServer . $extensionFileName, 'rb')) { |
|
42
|
|
|
printf(_AM_EXTGALLERY_EXT_FILE_DONT_EXIST, $downloadServer, $extensionFileName); |
|
43
|
|
|
xoops_cp_footer(); |
|
44
|
|
|
break; |
|
45
|
|
|
} |
|
46
|
|
|
$localHandle = @fopen(XOOPS_ROOT_PATH . '/uploads/' . $extensionFileName, 'wb+'); |
|
47
|
|
|
|
|
48
|
|
|
// Downlad module archive |
|
49
|
|
|
if ($handle) { |
|
|
|
|
|
|
50
|
|
|
while (!feof($handle)) { |
|
51
|
|
|
$buffer = fread($handle, 8192); |
|
52
|
|
|
fwrite($localHandle, $buffer); |
|
53
|
|
|
} |
|
54
|
|
|
fclose($localHandle); |
|
55
|
|
|
fclose($handle); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
xoops_confirm(['step' => 'install'], 'install-extension.php', _AM_EXTGALLERY_DOWN_DONE, _AM_EXTGALLERY_INSTALL); |
|
59
|
|
|
|
|
60
|
|
|
xoops_cp_footer(); |
|
61
|
|
|
|
|
62
|
|
|
break; |
|
63
|
|
|
case 'install': |
|
64
|
|
|
|
|
65
|
|
|
if (!file_exists(XOOPS_ROOT_PATH . '/uploads/' . $extensionFileName)) { |
|
66
|
|
|
xoops_cp_header(); |
|
67
|
|
|
echo _AM_EXTGALLERY_EXT_FILE_DONT_EXIST_SHORT; |
|
68
|
|
|
xoops_cp_footer(); |
|
69
|
|
|
|
|
70
|
|
|
break; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
$g_pcltar_lib_dir = XOOPS_ROOT_PATH . '/modules/' . $localModuleDir . '/class'; |
|
74
|
|
|
require_once \dirname(__DIR__) . '/class/pcltar.lib.php'; |
|
75
|
|
|
|
|
76
|
|
|
// Extract extension files |
|
77
|
|
|
PclTarExtract(XOOPS_ROOT_PATH . '/uploads/' . $extensionFileName, XOOPS_ROOT_PATH . '/class/textsanitizer/', 'class/textsanitizer/'); |
|
78
|
|
|
// Delete downloaded extension's files |
|
79
|
|
|
unlink(XOOPS_ROOT_PATH . '/uploads/' . $extensionFileName); |
|
80
|
|
|
|
|
81
|
|
|
// Delete folder created by a small issu in PclTar lib |
|
82
|
|
|
if (is_dir(XOOPS_ROOT_PATH . '/class/textsanitizer/class')) { |
|
83
|
|
|
rmdir(XOOPS_ROOT_PATH . '/class/textsanitizer/class'); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
// Activate extension |
|
87
|
|
|
$conf = require XOOPS_ROOT_PATH . '/class/textsanitizer/config.php'; |
|
88
|
|
|
$conf['extensions']['gallery'] = 1; |
|
89
|
|
|
file_put_contents(XOOPS_ROOT_PATH . '/class/textsanitizer/config.custom.php', "<?php\rreturn \$config = " . var_export($conf, true) . "\r?>", LOCK_EX); |
|
90
|
|
|
|
|
91
|
|
|
redirect_header('extension.php', 3, _AM_EXTGALLERY_EXTENSION_INSTALLED); |
|
92
|
|
|
|
|
93
|
|
|
break; |
|
94
|
|
|
default: |
|
95
|
|
|
case 'default': |
|
96
|
|
|
|
|
97
|
|
|
redirect_header('extension.php', 3, ''); |
|
98
|
|
|
|
|
99
|
|
|
break; |
|
100
|
|
|
} |
|
101
|
|
|
|