1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* ExtGallery Admin settings |
5
|
|
|
* Manage admin pages |
6
|
|
|
* |
7
|
|
|
* You may not change or alter any portion of this comment or credits |
8
|
|
|
* of supporting developers from this source code or any supporting source code |
9
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
* |
14
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
15
|
|
|
* @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
16
|
|
|
* @author Zoullou (http://www.zoullou.net) |
17
|
|
|
* @package ExtGallery |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
use Xmf\Request; |
21
|
|
|
|
22
|
|
|
require_once __DIR__ . '/admin_header.php'; |
23
|
|
|
|
24
|
|
|
if (Request::hasVar('step', 'POST')) { |
25
|
|
|
$step = $_POST['step']; |
26
|
|
|
} else { |
27
|
|
|
$step = 'default'; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
require_once __DIR__ . '/moduleUpdateFunction.php'; |
31
|
|
|
|
32
|
|
|
// Change this variable if you use a cloned version of eXtGallery |
33
|
|
|
$localModuleDir = 'extgallery'; |
34
|
|
|
|
35
|
|
|
$moduleName = 'extgallery'; |
36
|
|
|
$downloadServer = _MU_MODULE_DOWNLOAD_SERVER; |
37
|
|
|
|
38
|
|
|
$lastVersionString = getLastModuleVersion(); |
39
|
|
|
$moduleFileName = $moduleName . '-' . $lastVersionString . '.tar.gz'; |
40
|
|
|
$langFileName = $moduleName . '-lang-' . $lastVersionString . '_' . $xoopsConfig['language'] . '.tar.gz'; |
41
|
|
|
|
42
|
|
|
switch ($step) { |
43
|
|
|
case 'download': |
44
|
|
|
|
45
|
|
|
xoops_cp_header(); |
46
|
|
|
|
47
|
|
|
if (isModuleUpToDate()) { |
48
|
|
|
echo _AM_EXTGALLERY_UPDATE_OK; |
49
|
|
|
xoops_cp_footer(); |
50
|
|
|
break; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
if (!$handle = @fopen($downloadServer . $moduleFileName, 'rb')) { |
54
|
|
|
printf(_AM_EXTGALLERY_MD_FILE_DONT_EXIST, $downloadServer, $moduleFileName); |
55
|
|
|
xoops_cp_footer(); |
56
|
|
|
break; |
57
|
|
|
} |
58
|
|
|
$localHandle = @fopen(XOOPS_ROOT_PATH . '/uploads/' . $moduleFileName, 'wb+'); |
59
|
|
|
|
60
|
|
|
// Downlad module archive |
61
|
|
|
if ($handle) { |
|
|
|
|
62
|
|
|
while (!feof($handle)) { |
63
|
|
|
$buffer = fread($handle, 8192); |
64
|
|
|
fwrite($localHandle, $buffer); |
65
|
|
|
} |
66
|
|
|
fclose($localHandle); |
67
|
|
|
fclose($handle); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
// English file are included on module package |
71
|
|
|
if ('english' !== $xoopsConfig['language']) { |
72
|
|
|
if (!$handle = @fopen($downloadServer . $langFileName, 'rb')) { |
73
|
|
|
printf(_AM_EXTGALLERY_LG_FILE_DONT_EXIST, $downloadServer, $langFileName); |
74
|
|
|
} else { |
75
|
|
|
$localHandle = @fopen(XOOPS_ROOT_PATH . '/uploads/' . $langFileName, 'wb+'); |
76
|
|
|
// Download language archive |
77
|
|
|
if ($handle) { |
|
|
|
|
78
|
|
|
while (!feof($handle)) { |
79
|
|
|
$buffer = fread($handle, 8192); |
80
|
|
|
fwrite($localHandle, $buffer); |
81
|
|
|
} |
82
|
|
|
fclose($localHandle); |
83
|
|
|
fclose($handle); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
xoops_confirm(['step' => 'install'], 'upgrade.php', _AM_EXTGALLERY_DOWN_DONE, _AM_EXTGALLERY_INSTALL); |
89
|
|
|
|
90
|
|
|
xoops_cp_footer(); |
91
|
|
|
|
92
|
|
|
break; |
93
|
|
|
case 'install': |
94
|
|
|
|
95
|
|
|
xoops_cp_header(); |
96
|
|
|
|
97
|
|
|
if (!file_exists(XOOPS_ROOT_PATH . '/uploads/' . $moduleFileName)) { |
98
|
|
|
echo _AM_EXTGALLERY_MD_FILE_DONT_EXIST_SHORT; |
99
|
|
|
xoops_cp_footer(); |
100
|
|
|
|
101
|
|
|
break; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
$g_pcltar_lib_dir = XOOPS_ROOT_PATH . '/modules/' . $localModuleDir . '/class'; |
105
|
|
|
require_once \dirname(__DIR__) . '/class/pcltar.lib.php'; |
106
|
|
|
|
107
|
|
|
//TrOn(5); |
108
|
|
|
|
109
|
|
|
// Extract module files |
110
|
|
|
PclTarExtract(XOOPS_ROOT_PATH . '/uploads/' . $moduleFileName, XOOPS_ROOT_PATH . '/modules/' . $localModuleDir . '/', 'modules/' . $moduleName . '/'); |
111
|
|
|
// Delete downloaded module's files |
112
|
|
|
unlink(XOOPS_ROOT_PATH . '/uploads/' . $moduleFileName); |
113
|
|
|
|
114
|
|
|
if (file_exists(XOOPS_ROOT_PATH . '/uploads/' . $langFileName)) { |
115
|
|
|
// Extract language files |
116
|
|
|
PclTarExtract(XOOPS_ROOT_PATH . '/uploads/' . $langFileName, XOOPS_ROOT_PATH . '/modules/' . $localModuleDir . '/', 'modules/' . $moduleName . '/'); |
117
|
|
|
// Delete downloaded module's files |
118
|
|
|
unlink(XOOPS_ROOT_PATH . '/uploads/' . $langFileName); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
// Delete folder created by a small issu in PclTar lib |
122
|
|
|
if (is_dir(XOOPS_ROOT_PATH . '/modules/' . $localModuleDir . '/modules')) { |
123
|
|
|
rmdir(XOOPS_ROOT_PATH . '/modules/' . $localModuleDir . '/modules'); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
// Delete template_c file |
127
|
|
|
if (false !== ($handle = opendir(XOOPS_ROOT_PATH . '/templates_c'))) { |
128
|
|
|
while (false !== ($file = readdir($handle))) { |
129
|
|
|
if ('.' !== $file && '..' !== $file && 'index.html' !== $file) { |
130
|
|
|
unlink(XOOPS_ROOT_PATH . '/templates_c/' . $file); |
131
|
|
|
} |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
closedir($handle); |
135
|
|
|
} |
136
|
|
|
//TrDisplay(); |
137
|
|
|
|
138
|
|
|
xoops_confirm(['dirname' => $localModuleDir, 'op' => 'update_ok', 'fct' => 'modulesadmin'], XOOPS_URL . '/modules/system/admin.php', _AM_EXTGALLERY_INSTALL_DONE, _AM_EXTGALLERY_UPDATE); |
139
|
|
|
|
140
|
|
|
xoops_cp_footer(); |
141
|
|
|
|
142
|
|
|
break; |
143
|
|
|
default: |
144
|
|
|
case 'default': |
145
|
|
|
|
146
|
|
|
redirect_header('index.php', 3, ''); |
147
|
|
|
|
148
|
|
|
break; |
149
|
|
|
} |
150
|
|
|
|