|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
You may not change or alter any portion of this comment or credits |
|
4
|
|
|
of supporting developers from this source code or any supporting source code |
|
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
6
|
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
|
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Wfdownloads module |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
16
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
|
17
|
|
|
* @package wfdownload |
|
18
|
|
|
* @since 3.23 |
|
19
|
|
|
* @author Xoops Development Team |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
use Xmf\Module\Admin; |
|
23
|
|
|
use Xmf\Request; |
|
24
|
|
|
use Xmf\Yaml; |
|
25
|
|
|
use XoopsModules\Wfdownloads\{ |
|
26
|
|
|
Common\Configurator, |
|
27
|
|
|
Common\DirectoryChecker, |
|
28
|
|
|
Common\TestdataButtons, |
|
29
|
|
|
Helper, |
|
30
|
|
|
Utility |
|
31
|
|
|
}; |
|
32
|
|
|
/** @var Helper $helper */ |
|
33
|
|
|
/** @var Utility $utility */ |
|
34
|
|
|
|
|
35
|
|
|
$currentFile = basename(__FILE__); |
|
36
|
|
|
require_once __DIR__ . '/admin_header.php'; |
|
37
|
|
|
|
|
38
|
|
|
define('INDEX_FILE_PATH', XOOPS_ROOT_PATH . '/uploads/index.html'); |
|
39
|
|
|
define('BLANK_FILE_PATH', XOOPS_ROOT_PATH . '/uploads/blank.png'); |
|
40
|
|
|
|
|
41
|
|
|
// require_once dirname(__DIR__) . '/class/common/directorychecker.php'; |
|
42
|
|
|
// require_once dirname(__DIR__) . '/class/common/filechecker.php'; |
|
43
|
|
|
|
|
44
|
|
|
xoops_cp_header(); |
|
45
|
|
|
$adminObject = Admin::getInstance(); |
|
46
|
|
|
|
|
47
|
|
|
$helper = Helper::getInstance(); |
|
48
|
|
|
|
|
49
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
|
50
|
|
|
$moduleDirNameUpper = mb_strtoupper($moduleDirName); |
|
51
|
|
|
|
|
52
|
|
|
//-------------------------- |
|
53
|
|
|
$categories_count = Utility::categoriesCount(); |
|
54
|
|
|
$votes_count = $helper->getHandler('Rating')->getCount(); |
|
55
|
|
|
$brokenDownloads_count = $helper->getHandler('Report')->getCount(); |
|
56
|
|
|
$modificationRequests_count = $helper->getHandler('Modification')->getCount(); |
|
57
|
|
|
$newReviews_count = $helper->getHandler('Review')->getCount(); |
|
58
|
|
|
$newMirrors_count = $helper->getHandler('Mirror')->getCount(); |
|
59
|
|
|
$newDownloads_count = $helper->getHandler('Download')->getCount(new Criteria('published', 0)); |
|
60
|
|
|
$downloads_count = $helper->getHandler('Download')->getCount(new Criteria('published', 0, '>')); |
|
61
|
|
|
|
|
62
|
|
|
$adminObject->addInfoBox(_AM_WFDOWNLOADS_MINDEX_DOWNSUMMARY); |
|
63
|
|
|
// Categories |
|
64
|
|
|
if ($categories_count > 0) { |
|
65
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel><a href="categories.php">' . _AM_WFDOWNLOADS_SCATEGORY . '</a></infolabel>', $categories_count, 'green')); |
|
66
|
|
|
} else { |
|
67
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_WFDOWNLOADS_SCATEGORY . '</infolabel>', $categories_count, 'green')); |
|
68
|
|
|
} |
|
69
|
|
|
// Downloads |
|
70
|
|
|
if ($downloads_count > 0) { |
|
71
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel><a href="downloads.php">' . _AM_WFDOWNLOADS_SFILES . '</a><b></infolabel>', $downloads_count, 'green')); |
|
72
|
|
|
} else { |
|
73
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_WFDOWNLOADS_SFILES . '</infolabel>', $downloads_count, 'green')); |
|
74
|
|
|
} |
|
75
|
|
|
// New/waiting downloads |
|
76
|
|
|
if ($newDownloads_count > 0) { |
|
77
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel><a href="downloads.php">' . _AM_WFDOWNLOADS_SNEWFILESVAL . '</a></infolabel>', $newDownloads_count, 'green')); |
|
78
|
|
|
} else { |
|
79
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_WFDOWNLOADS_SNEWFILESVAL . '</infolabel>', $newDownloads_count, 'green')); |
|
80
|
|
|
} |
|
81
|
|
|
// Reviews |
|
82
|
|
|
if (false === $helper->getConfig('enable_reviews')) { |
|
83
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_WFDOWNLOADS_SREVIEWS . '</infolabel>', _CO_WFDOWNLOADS_DISABLED, 'red')); |
|
84
|
|
|
} elseif ($newReviews_count > 0) { |
|
85
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel><a href="reviews.php">' . _AM_WFDOWNLOADS_SREVIEWS . '</a></infolabel>', $newReviews_count, 'green')); |
|
86
|
|
|
} else { |
|
87
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_WFDOWNLOADS_SREVIEWS . '</infolabel>', $newReviews_count, 'green')); |
|
88
|
|
|
} |
|
89
|
|
|
// Ratings |
|
90
|
|
|
if (false === $helper->getConfig('enable_ratings')) { |
|
91
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_WFDOWNLOADS_SVOTES . '</infolabel>', _CO_WFDOWNLOADS_DISABLED, 'red')); |
|
92
|
|
|
} elseif ($votes_count > 0) { |
|
93
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel><a href="ratings.php">' . _AM_WFDOWNLOADS_SVOTES . '</a></infolabel>', $votes_count, 'green')); |
|
94
|
|
|
} else { |
|
95
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_WFDOWNLOADS_SVOTES . '</infolabel>', $votes_count, 'green')); |
|
96
|
|
|
} |
|
97
|
|
|
// Modifications |
|
98
|
|
|
if ($modificationRequests_count > 0) { |
|
99
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel><a href="reportsmodifications.php">' . _AM_WFDOWNLOADS_SMODREQUEST . '</a></infolabel>', $modificationRequests_count, 'green')); |
|
100
|
|
|
} else { |
|
101
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_WFDOWNLOADS_SMODREQUEST . '</infolabel>', $modificationRequests_count, 'green')); |
|
102
|
|
|
} |
|
103
|
|
|
// Brokens reports |
|
104
|
|
|
if (false === $helper->getConfig('enable_brokenreports')) { |
|
105
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_WFDOWNLOADS_SBROKENSUBMIT . '</infolabel>', _CO_WFDOWNLOADS_DISABLED, 'red')); |
|
106
|
|
|
} elseif ($brokenDownloads_count > 0) { |
|
107
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel><a href="reportsmodifications.php">' . _AM_WFDOWNLOADS_SBROKENSUBMIT . '</a></infolabel>', $brokenDownloads_count, 'green')); |
|
108
|
|
|
} else { |
|
109
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_WFDOWNLOADS_SBROKENSUBMIT . '</infolabel>', $brokenDownloads_count, 'green')); |
|
110
|
|
|
} |
|
111
|
|
|
// Mirrors |
|
112
|
|
|
if (false === $helper->getConfig('enable_mirrors')) { |
|
113
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_WFDOWNLOADS_SMIRRORS . '</infolabel>', _CO_WFDOWNLOADS_DISABLED, 'red')); |
|
114
|
|
|
} elseif ($newMirrors_count > 0) { |
|
115
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel><a href="mirrors.php">' . _AM_WFDOWNLOADS_SMIRRORS . '</a></infolabel>', $newMirrors_count, 'green')); |
|
116
|
|
|
} else { |
|
117
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_WFDOWNLOADS_SMIRRORS . '</infolabel>', $newMirrors_count, 'green')); |
|
118
|
|
|
} |
|
119
|
|
|
// module max file size |
|
120
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_WFDOWNLOADS_DOWN_MODULE_MAXFILESIZE . '</infolabel>', Utility::bytesToSize1024($helper->getConfig('maxfilesize')), 'green')); |
|
121
|
|
|
// upload file size limit |
|
122
|
|
|
// get max file size (setup and php.ini) |
|
123
|
|
|
$phpiniMaxFileSize = min((int)ini_get('upload_max_filesize'), (int)ini_get('post_max_size'), (int)ini_get('memory_limit')) * 1024 * 1024; // bytes |
|
124
|
|
|
$maxFileSize = Utility::bytesToSize1024(min($helper->getConfig('maxfilesize'), $phpiniMaxFileSize)); |
|
125
|
|
|
$adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_WFDOWNLOADS_UPLOAD_MAXFILESIZE . '</infolabel>', $maxFileSize, 'green')); |
|
126
|
|
|
|
|
127
|
|
|
//------ check directories --------------- |
|
128
|
|
|
|
|
129
|
|
|
$adminObject->addConfigBoxLine(''); |
|
130
|
|
|
$redirectFile = $_SERVER['SCRIPT_NAME']; |
|
131
|
|
|
|
|
132
|
|
|
//check Formulize presence |
|
133
|
|
|
if (!Utility::checkModule('formulize')) { |
|
134
|
|
|
$adminObject->addConfigBoxLine(_AM_WFDOWNLOADS_FORMULIZE_NOT_AVILABLE); |
|
135
|
|
|
} else { |
|
136
|
|
|
$adminObject->addConfigBoxLine(_AM_WFDOWNLOADS_FORMULIZE_AVAILABLE); |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
//check directories |
|
140
|
|
|
$adminObject->addConfigBoxLine(''); |
|
141
|
|
|
//$path = $helper->getConfig('uploaddir') . '/'; |
|
142
|
|
|
$path = $helper->getConfig('uploaddir'); |
|
143
|
|
|
//$path0 = $helper->getModule()->getInfo('uploaddir'); |
|
144
|
|
|
$adminObject->addConfigBoxLine(DirectoryChecker::getDirectoryStatus($path, 0777, $redirectFile)); |
|
145
|
|
|
|
|
146
|
|
|
$path = $helper->getConfig('batchdir') . '/'; |
|
147
|
|
|
$adminObject->addConfigBoxLine(DirectoryChecker::getDirectoryStatus($path, 0777, $redirectFile)); |
|
148
|
|
|
|
|
149
|
|
|
$path = XOOPS_ROOT_PATH . '/' . $helper->getConfig('mainimagedir') . '/'; |
|
150
|
|
|
$adminObject->addConfigBoxLine(DirectoryChecker::getDirectoryStatus($path, 0777, $redirectFile)); |
|
151
|
|
|
//$adminObject->addConfigBoxLine(FileChecker::getFileStatus($path . 'blank.png', BLANK_FILE_PATH, $redirectFile)); |
|
152
|
|
|
|
|
153
|
|
|
$path = XOOPS_ROOT_PATH . '/' . $helper->getConfig('screenshots') . '/'; |
|
154
|
|
|
$adminObject->addConfigBoxLine(DirectoryChecker::getDirectoryStatus($path, 0777, $redirectFile)); |
|
155
|
|
|
//$adminObject->addConfigBoxLine(FileChecker::getFileStatus($path . 'blank.png', BLANK_FILE_PATH, $redirectFile)); |
|
156
|
|
|
$adminObject->addConfigBoxLine(DirectoryChecker::getDirectoryStatus($path . 'thumbs' . '/', 0777, $redirectFile)); |
|
157
|
|
|
//$adminObject->addConfigBoxLine(FileChecker::getFileStatus($path . 'thumbs' . '/' . 'blank.png', BLANK_FILE_PATH, $redirectFile)); |
|
158
|
|
|
|
|
159
|
|
|
$path = XOOPS_ROOT_PATH . '/' . $helper->getConfig('catimage') . '/'; |
|
160
|
|
|
$adminObject->addConfigBoxLine(DirectoryChecker::getDirectoryStatus($path, 0777, $redirectFile)); |
|
161
|
|
|
//$adminObject->addConfigBoxLine(FileChecker::getFileStatus($path . 'blank.png', BLANK_FILE_PATH, $redirectFile)); |
|
162
|
|
|
$adminObject->addConfigBoxLine(DirectoryChecker::getDirectoryStatus($path . 'thumbs' . '/', 0777, $redirectFile)); |
|
163
|
|
|
//$adminObject->addConfigBoxLine(FileChecker::getFileStatus($path . 'thumbs' . '/' . 'blank.png', BLANK_FILE_PATH, $redirectFile)); |
|
164
|
|
|
|
|
165
|
|
|
//--------------------------- |
|
166
|
|
|
$adminObject->addConfigBoxLine(''); |
|
167
|
|
|
|
|
168
|
|
|
$configurator = new Configurator(); |
|
169
|
|
|
|
|
170
|
|
|
$utility = new Utility(); |
|
171
|
|
|
|
|
172
|
|
|
foreach (array_keys($configurator->uploadFolders) as $i) { |
|
173
|
|
|
// $utility::createFolder($configurator->uploadFolders[$i]); |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
|
177
|
|
|
|
|
178
|
|
|
//check for latest release |
|
179
|
|
|
//$newRelease = $utility::checkVerModule($helper); |
|
180
|
|
|
//if (!empty($newRelease)) { |
|
181
|
|
|
// $adminObject->addItemButton($newRelease[0], $newRelease[1], 'download', 'style="color : Red"'); |
|
182
|
|
|
//} |
|
183
|
|
|
|
|
184
|
|
|
//------------- Test Data Buttons ---------------------------- |
|
185
|
|
|
if ($helper->getConfig('displaySampleButton')) { |
|
186
|
|
|
TestdataButtons::loadButtonConfig($adminObject); |
|
187
|
|
|
$adminObject->displayButton('left', '');; |
|
188
|
|
|
} |
|
189
|
|
|
$op = \Xmf\Request::getString('op', 0, 'GET'); |
|
190
|
|
|
switch ($op) { |
|
191
|
|
|
case 'hide_buttons': |
|
192
|
|
|
TestdataButtons::hideButtons(); |
|
193
|
|
|
break; |
|
194
|
|
|
case 'show_buttons': |
|
195
|
|
|
TestdataButtons::showButtons(); |
|
196
|
|
|
break; |
|
197
|
|
|
} |
|
198
|
|
|
//------------- End Test Data Buttons ---------------------------- |
|
199
|
|
|
|
|
200
|
|
|
|
|
201
|
|
|
$adminObject->displayIndex(); |
|
202
|
|
|
echo $utility::getServerStats(); |
|
203
|
|
|
|
|
204
|
|
|
//codeDump(__FILE__); |
|
205
|
|
|
require __DIR__ . '/admin_footer.php'; |
|
206
|
|
|
|