|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Xmf\Request; |
|
4
|
|
|
|
|
5
|
|
|
$step = 'default'; |
|
6
|
|
|
if (Request::hasVar('step', 'POST')) { |
|
7
|
|
|
$step = $_POST['step']; |
|
8
|
|
|
} |
|
9
|
|
|
|
|
10
|
|
|
require_once __DIR__ . '/admin_header.php'; |
|
11
|
|
|
require_once __DIR__ . '/function.php'; |
|
12
|
|
|
|
|
13
|
|
|
global $xoopsConfig; |
|
14
|
|
|
|
|
15
|
|
|
// Change this variable if you use a cloned version of eXtGallery |
|
16
|
|
|
$localModuleDir = 'extcal'; |
|
17
|
|
|
|
|
18
|
|
|
$moduleName = 'extcal'; |
|
19
|
|
|
$versionFile = 'http://www.zoullou.net/extcal.version'; |
|
20
|
|
|
$downloadServer = 'http://downloads.sourceforge.net/zoullou/'; |
|
21
|
|
|
|
|
22
|
|
|
$lastVersion = @file_get_contents($versionFile); |
|
23
|
|
|
$lastVersionString = mb_substr($lastVersion, 0, 1) . '.' . mb_substr($lastVersion, 1, 1) . '.' . mb_substr($lastVersion, 2, 1); |
|
|
|
|
|
|
24
|
|
|
$moduleFileName = $moduleName . '-' . $lastVersionString . '.tar.gz'; |
|
25
|
|
|
$langFileName = $moduleName . '-lang-' . $lastVersionString . '_' . $xoopsConfig['language'] . '.tar.gz'; |
|
26
|
|
|
|
|
27
|
|
|
switch ($step) { |
|
28
|
|
|
case 'download': |
|
29
|
|
|
xoops_cp_header(); |
|
30
|
|
|
adminMenu(); |
|
|
|
|
|
|
31
|
|
|
if ($GLOBALS['xoopsModule']->getVar('version') >= $lastVersion) { |
|
32
|
|
|
echo _AM_EXTCAL_UPDATE_OK; |
|
33
|
|
|
xoops_cp_footer(); |
|
34
|
|
|
break; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
if (!$handle = @fopen($downloadServer . $moduleFileName, 'r')) { |
|
38
|
|
|
printf(_AM_EXTCAL_MD_FILE_DONT_EXIST, $downloadServer, $moduleFileName); |
|
39
|
|
|
xoops_cp_footer(); |
|
40
|
|
|
break; |
|
41
|
|
|
} |
|
42
|
|
|
$localHandle = @fopen(XOOPS_ROOT_PATH . '/uploads/' . $moduleFileName, 'w+'); |
|
43
|
|
|
|
|
44
|
|
|
// Downlad module archive |
|
45
|
|
|
if ($handle) { |
|
46
|
|
|
while (!feof($handle)) { |
|
47
|
|
|
$buffer = fread($handle, 8192); |
|
48
|
|
|
fwrite($localHandle, $buffer); |
|
49
|
|
|
} |
|
50
|
|
|
fclose($localHandle); |
|
51
|
|
|
fclose($handle); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
// English file are included on module package |
|
55
|
|
|
if ('english' !== $xoopsConfig['language']) { |
|
56
|
|
|
if (!$handle = @fopen($downloadServer . $langFileName, 'r')) { |
|
57
|
|
|
printf(_AM_EXTCAL_LG_FILE_DONT_EXIST, $downloadServer, $langFileName); |
|
58
|
|
|
} else { |
|
59
|
|
|
$localHandle = @fopen(XOOPS_ROOT_PATH . '/uploads/' . $langFileName, 'w+'); |
|
60
|
|
|
// Download language 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
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
xoops_confirm(['step' => 'install'], 'upgrade.php', _AM_EXTCAL_DOWN_DONE, _AM_EXTCAL_INSTALL); |
|
73
|
|
|
|
|
74
|
|
|
xoops_cp_footer(); |
|
75
|
|
|
|
|
76
|
|
|
break; |
|
77
|
|
|
case 'install': |
|
78
|
|
|
xoops_cp_header(); |
|
79
|
|
|
adminMenu(); |
|
80
|
|
|
|
|
81
|
|
|
if (!file_exists(XOOPS_ROOT_PATH . '/uploads/' . $moduleFileName)) { |
|
82
|
|
|
echo _AM_EXTCAL_MD_FILE_DONT_EXIST_SHORT; |
|
83
|
|
|
xoops_cp_footer(); |
|
84
|
|
|
|
|
85
|
|
|
break; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
$gPcltarLibDir = XOOPS_ROOT_PATH . '/modules/' . $localModuleDir . '/class'; |
|
89
|
|
|
require_once dirname(__DIR__) . '/class/pcltar.lib.php'; |
|
90
|
|
|
|
|
91
|
|
|
//TrOn(5); |
|
92
|
|
|
|
|
93
|
|
|
// Extract module files |
|
94
|
|
|
PclTarExtract(XOOPS_ROOT_PATH . '/uploads/' . $moduleFileName, XOOPS_ROOT_PATH . '/modules/' . $localModuleDir . '/', 'modules/' . $moduleName . '/'); |
|
95
|
|
|
// Delete downloaded module's files |
|
96
|
|
|
unlink(XOOPS_ROOT_PATH . '/uploads/' . $moduleFileName); |
|
97
|
|
|
|
|
98
|
|
|
if (file_exists(XOOPS_ROOT_PATH . '/uploads/' . $langFileName)) { |
|
99
|
|
|
// Extract language files |
|
100
|
|
|
PclTarExtract(XOOPS_ROOT_PATH . '/uploads/' . $langFileName, XOOPS_ROOT_PATH . '/modules/' . $localModuleDir . '/', 'modules/' . $moduleName . '/'); |
|
101
|
|
|
// Delete downloaded module's files |
|
102
|
|
|
unlink(XOOPS_ROOT_PATH . '/uploads/' . $langFileName); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
// Delete template_c file |
|
106
|
|
|
$handle = opendir(XOOPS_ROOT_PATH . '/templates_c'); |
|
107
|
|
|
if ($handle) { |
|
108
|
|
|
while (false !== ($file = readdir($handle))) { |
|
109
|
|
|
if ('.' !== $file && '..' !== $file && 'index.html' !== $file) { |
|
110
|
|
|
unlink(XOOPS_ROOT_PATH . '/templates_c/' . $file); |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
closedir($handle); |
|
115
|
|
|
} |
|
116
|
|
|
//TrDisplay(); |
|
117
|
|
|
|
|
118
|
|
|
xoops_confirm(['dirname' => $localModuleDir, 'op' => 'update_ok', 'fct' => 'modulesadmin'], XOOPS_URL . '/modules/system/admin.php', _AM_EXTCAL_INSTALL_DONE, _AM_EXTCAL_UPDATE); |
|
119
|
|
|
|
|
120
|
|
|
xoops_cp_footer(); |
|
121
|
|
|
|
|
122
|
|
|
break; |
|
123
|
|
|
default: |
|
124
|
|
|
case 'default': |
|
125
|
|
|
redirect_header('index.php', 3, ''); |
|
126
|
|
|
|
|
127
|
|
|
break; |
|
128
|
|
|
} |
|
129
|
|
|
|