|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* **************************************************************************** |
|
4
|
|
|
* - A Project by Developers TEAM For Xoops - ( https://xoops.org ) |
|
5
|
|
|
* **************************************************************************** |
|
6
|
|
|
* XNEWSLETTER - MODULE FOR XOOPS |
|
7
|
|
|
* Copyright (c) 2007 - 2012 |
|
8
|
|
|
* Goffy ( wedega.com ) |
|
9
|
|
|
* |
|
10
|
|
|
* You may not change or alter any portion of this comment or credits |
|
11
|
|
|
* of supporting developers from this source code or any supporting |
|
12
|
|
|
* source code which is considered copyrighted (c) material of the |
|
13
|
|
|
* original comment or credit authors. |
|
14
|
|
|
* |
|
15
|
|
|
* This program is distributed in the hope that it will be useful, |
|
16
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18
|
|
|
* GNU General Public License for more details. |
|
19
|
|
|
* --------------------------------------------------------------------------- |
|
20
|
|
|
* @copyright Goffy ( wedega.com ) |
|
21
|
|
|
* @license GPL 2.0 |
|
22
|
|
|
* @package xnewsletter |
|
23
|
|
|
* @author Goffy ( [email protected] ) |
|
24
|
|
|
* |
|
25
|
|
|
* Version : 1 Mon 2012/11/05 14:31:32 : Exp $ |
|
26
|
|
|
* **************************************************************************** |
|
27
|
|
|
*/ |
|
28
|
|
|
|
|
29
|
|
|
use XoopsModules\Xnewsletter; |
|
30
|
|
|
use XoopsModules\Xnewsletter\Common; |
|
31
|
|
|
|
|
32
|
|
|
defined('XOOPS_ROOT_PATH') || die('XOOPS root path not defined'); |
|
33
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/xnewsletter/include/common.php'; |
|
34
|
|
|
//@require XOOPS_ROOT_PATH . '/modules/xnewsletter/language/' . $xoopsConfig['language'] . '/admin.php'; |
|
35
|
|
|
xoops_loadLanguage('admin', 'xnewsletter'); |
|
36
|
|
|
|
|
37
|
|
|
define('INDEX_FILE_PATH', XOOPS_UPLOAD_PATH . '/index.html'); |
|
38
|
|
|
define('BLANK_FILE_PATH', XOOPS_UPLOAD_PATH . '/blank.gif'); |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param \XoopsModule $module |
|
42
|
|
|
* |
|
43
|
|
|
* @return bool |
|
44
|
|
|
*/ |
|
45
|
|
|
function xoops_module_pre_install_xnewsletter(\XoopsModule $module) |
|
|
|
|
|
|
46
|
|
|
{ |
|
47
|
|
|
// NOP |
|
48
|
|
|
return true; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @param \XoopsModule $module |
|
53
|
|
|
* |
|
54
|
|
|
* @return bool |
|
55
|
|
|
*/ |
|
56
|
|
|
function xoops_module_install_xnewsletter(\XoopsModule $module) |
|
57
|
|
|
{ |
|
58
|
|
|
require_once dirname(__DIR__) . '/preloads/autoloader.php'; |
|
59
|
|
|
|
|
60
|
|
|
// get module config values |
|
61
|
|
|
$hModConfig = xoops_getHandler('config'); |
|
62
|
|
|
$configArray = $hModConfig->getConfigsByCat(0, $module->getVar('mid')); |
|
63
|
|
|
|
|
64
|
|
|
//Creation of folder "uploads" for the module to the site root |
|
65
|
|
|
$path = XOOPS_ROOT_PATH . '/uploads/xnewsletter'; |
|
66
|
|
View Code Duplication |
if (!is_dir($path)) { |
|
67
|
|
|
if (!mkdir($path, 0777, true) && !is_dir($path)) { |
|
68
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $path)); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
chmod($path, 0777); |
|
72
|
|
|
copy(INDEX_FILE_PATH, $path . '/index.html'); |
|
73
|
|
|
|
|
74
|
|
|
//Creation of the file accounts in uploads directory |
|
75
|
|
|
$path = XOOPS_ROOT_PATH . '/uploads/xnewsletter/accounts'; |
|
76
|
|
View Code Duplication |
if (!is_dir($path)) { |
|
77
|
|
|
if (!mkdir($path, 0777, true) && !is_dir($path)) { |
|
78
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $path)); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
chmod($path, 0777); |
|
82
|
|
|
copy(INDEX_FILE_PATH, $path . '/index.html'); |
|
83
|
|
|
|
|
84
|
|
|
//Creation of the file cat in uploads directory |
|
85
|
|
|
$path = XOOPS_ROOT_PATH . '/uploads/xnewsletter/cat'; |
|
86
|
|
View Code Duplication |
if (!is_dir($path)) { |
|
87
|
|
|
if (!mkdir($path, 0777, true) && !is_dir($path)) { |
|
88
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $path)); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
chmod($path, 0777); |
|
92
|
|
|
copy(INDEX_FILE_PATH, $path . '/index.html'); |
|
93
|
|
|
|
|
94
|
|
|
//Creation of the file subscr in uploads directory |
|
95
|
|
|
$path = XOOPS_ROOT_PATH . '/uploads/xnewsletter/subscr'; |
|
96
|
|
View Code Duplication |
if (!is_dir($path)) { |
|
97
|
|
|
if (!mkdir($path, 0777, true) && !is_dir($path)) { |
|
98
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $path)); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
chmod($path, 0777); |
|
102
|
|
|
copy(INDEX_FILE_PATH, $path . '/index.html'); |
|
103
|
|
|
|
|
104
|
|
|
//Creation of the file catsubscr in uploads directory |
|
105
|
|
|
$path = XOOPS_ROOT_PATH . '/uploads/xnewsletter/catsubscr'; |
|
106
|
|
View Code Duplication |
if (!is_dir($path)) { |
|
107
|
|
|
if (!mkdir($path, 0777, true) && !is_dir($path)) { |
|
108
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $path)); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
chmod($path, 0777); |
|
112
|
|
|
copy(INDEX_FILE_PATH, $path . '/index.html'); |
|
113
|
|
|
|
|
114
|
|
|
//Creation of the file letter in uploads directory |
|
115
|
|
|
$path = XOOPS_ROOT_PATH . '/uploads/xnewsletter/letter'; |
|
116
|
|
View Code Duplication |
if (!is_dir($path)) { |
|
117
|
|
|
if (!mkdir($path, 0777, true) && !is_dir($path)) { |
|
118
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $path)); |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
chmod($path, 0777); |
|
122
|
|
|
copy(INDEX_FILE_PATH, $path . '/index.html'); |
|
123
|
|
|
|
|
124
|
|
|
//Creation of the file protocol in uploads directory |
|
125
|
|
|
$path = XOOPS_ROOT_PATH . '/uploads/xnewsletter/protocol'; |
|
126
|
|
View Code Duplication |
if (!is_dir($path)) { |
|
127
|
|
|
if (!mkdir($path, 0777, true) && !is_dir($path)) { |
|
128
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $path)); |
|
129
|
|
|
} |
|
130
|
|
|
} |
|
131
|
|
|
chmod($path, 0777); |
|
132
|
|
|
copy(INDEX_FILE_PATH, $path . '/index.html'); |
|
133
|
|
|
|
|
134
|
|
|
//Creation of the folder letter_attachment in uploads directory for files |
|
135
|
|
|
$path = XOOPS_ROOT_PATH . '/uploads' . $configArray['xn_attachment_path']; |
|
136
|
|
View Code Duplication |
if (!is_dir($path)) { |
|
137
|
|
|
if (!mkdir($path, 0777, true) && !is_dir($path)) { |
|
138
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $path)); |
|
139
|
|
|
} |
|
140
|
|
|
} |
|
141
|
|
|
chmod($path, 0777); |
|
142
|
|
|
copy(INDEX_FILE_PATH, $path . '/index.html'); |
|
143
|
|
|
|
|
144
|
|
|
return true; |
|
145
|
|
|
} |
|
146
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.