Passed
Push — feature/branch_ggoffy ( ea155b )
by Goffy
03:28 queued 44s
created

returnBytes()   B

Complexity

Conditions 7
Paths 7

Size

Total Lines 13
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 7
eloc 12
c 1
b 0
f 1
nc 7
nop 1
dl 0
loc 13
rs 8.8333
1
<?php
2
/**
3
 * TDMDownload
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright   Gregory Mage (Aka Mage)
13
 * @license     GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
14
 * @author      Gregory Mage (Aka Mage)
15
 */
16
defined('XOOPS_ROOT_PATH') || die('Restricted access');
17
18
require_once __DIR__ . '/preloads/autoloader.php';
19
20
$moduleDirName = basename(__DIR__);
21
xoops_load('xoopseditorhandler');
22
$editorHandler = \XoopsEditorHandler::getInstance();
23
$xoopsUrl      = parse_url(XOOPS_URL);
24
25
$modversion = [
26
    'name'                => _MI_TDMDOWNLOADS_NAME,
27
    'version'             => '2.0',
28
    'module_status'       => 'Beta 1',
29
    'release_date'        => '2019/01/12',
30
    'description'         => _MI_TDMDOWNLOADS_DESC,
31
    'credits'             => 'G. Mage, Mamba, Goffy',
32
    'author'              => 'G. Mage',
33
    'nickname'            => 'Mage',
34
    'module_website_url'  => 'www.xoops.org',
35
    'module_website_name' => 'Support site',
36
    'help'                => 'page=help',
37
    'license'             => 'GNU GPL 2.0 or later',
38
    'license_url'         => 'www.gnu.org/licenses/gpl-2.0.html',
39
    'official'            => 0,
40
    // ------------------- Folders & Files -------------------
41
    'dirname'             => $moduleDirName,
42
    'image'               => 'assets/images/logoModule.png',
43
    'modicons16'          => 'assets/images/icons/16',
44
    'modicons32'          => 'assets/images/icons/32',
45
    'release_file'        => XOOPS_URL . '/modules/' . $moduleDirName . '/docs/changelog.txt',
46
    'onInstall'           => 'include/oninstall.php',
47
    'onUpdate'            => 'include/onupdate.php',
48
    // ------------------- Min Requirements -------------------
49
    'min_php'             => '7.0',
50
    'min_xoops'           => '2.5.9',
51
    'min_admin'           => '1.1',
52
    'min_db'              => ['mysql' => '5.0.7', 'mysqli' => '5.0.7'],
53
    // ------------------- Admin Menu -------------------
54
    'hasAdmin'            => 1,
55
    'system_menu'         => 1,
56
    'adminindex'          => 'admin/index.php',
57
    'adminmenu'           => 'admin/menu.php',
58
    // ------------------- Mysql -------------------
59
    'sqlfile'             => ['mysql' => 'sql/mysql.sql'],
60
61
    // ------------------- Tables -------------------
62
    'tables'              => [
63
        $moduleDirName . '_broken',
64
        $moduleDirName . '_cat',
65
        $moduleDirName . '_downloads',
66
        $moduleDirName . '_mod',
67
        $moduleDirName . '_votedata',
68
        $moduleDirName . '_field',
69
        $moduleDirName . '_fielddata',
70
        $moduleDirName . '_modfielddata',
71
        $moduleDirName . '_downlimit',
72
    ],
73
74
    // ------------------- Menu -------------------
75
    'hasMain'             => 1,
76
    'sub'                 => [
77
        [
78
            'name' => _MI_TDMDOWNLOADS_SMNAME1,
79
            'url'  => 'submit.php',
80
        ],
81
        [
82
            'name' => _MI_TDMDOWNLOADS_SMNAME2,
83
            'url'  => 'search.php',
84
        ],
85
    ],
86
    // ------------------- Search -------------------
87
88
    'hasSearch' => 1,
89
    'search'    => [
90
        'file' => 'include/search.inc.php',
91
        'func' => 'tdmdownloads_search',
92
    ],
93
];
94
95
// Pour les blocs
96
97
$modversion['blocks'][] = [
98
    'file'        => 'tdmdownloads_top.php',
99
    'name'        => _MI_TDMDOWNLOADS_BNAME1,
100
    'description' => _MI_TDMDOWNLOADS_BNAMEDSC1,
101
    'show_func'   => 'b_tdmdownloads_top_show',
102
    'edit_func'   => 'b_tdmdownloads_top_edit',
103
    'options'     => 'date|10|19|1|1|1|left|90|400|0',
104
    'template'    => $moduleDirName . '_block_new.tpl',
105
];
106
107
$modversion['blocks'][] = [
108
    'file'        => 'tdmdownloads_top.php',
109
    'name'        => _MI_TDMDOWNLOADS_BNAME2,
110
    'description' => _MI_TDMDOWNLOADS_BNAMEDSC2,
111
    'show_func'   => 'b_tdmdownloads_top_show',
112
    'edit_func'   => 'b_tdmdownloads_top_edit',
113
    'options'     => 'hits|10|19|1|1|1|left|90|400|0',
114
    'template'    => $moduleDirName . '_block_top.tpl',
115
];
116
117
$modversion['blocks'][] = [
118
    'file'        => 'tdmdownloads_top.php',
119
    'name'        => _MI_TDMDOWNLOADS_BNAME3,
120
    'description' => _MI_TDMDOWNLOADS_BNAMEDSC3,
121
    'show_func'   => 'b_tdmdownloads_top_show',
122
    'edit_func'   => 'b_tdmdownloads_top_edit',
123
    'options'     => 'rating|10|19|1|1|1|left|90|400|0',
124
    'template'    => $moduleDirName . '_block_rating.tpl',
125
];
126
127
$modversion['blocks'][] = [
128
    'file'        => 'tdmdownloads_top.php',
129
    'name'        => _MI_TDMDOWNLOADS_BNAME4,
130
    'description' => _MI_TDMDOWNLOADS_BNAMEDSC4,
131
    'show_func'   => 'b_tdmdownloads_top_show',
132
    'edit_func'   => 'b_tdmdownloads_top_edit',
133
    'options'     => 'random|10|19|1|1|1|left|90|400|0',
134
    'template'    => $moduleDirName . '_block_random.tpl',
135
];
136
137
$modversion['blocks'][] = [
138
    'file'        => 'tdmdownloads_search.php',
139
    'name'        => _MI_TDMDOWNLOADS_BNAME5,
140
    'description' => _MI_TDMDOWNLOADS_BNAMEDSC5,
141
    'show_func'   => 'b_tdmdownloads_search_show',
142
    'edit_func'   => '',
143
    'options'     => '',
144
    'template'    => $moduleDirName . '_block_search.tpl',
145
];
146
147
// Commentaires
148
$modversion['hasComments']                     = 1;
149
$modversion['comments']['itemName']            = 'lid';
150
$modversion['comments']['pageName']            = 'singlefile.php';
151
$modversion['comments']['extraParams']         = ['cid'];
152
$modversion['comments']['callbackFile']        = 'include/comment_functions.php';
153
$modversion['comments']['callback']['approve'] = 'tdmdownloads_com_approve';
154
$modversion['comments']['callback']['update']  = 'tdmdownloads_com_update';
155
156
// Templates
157
$modversion['templates'] = [
158
    // Admin
159
    ['file' => $moduleDirName . '_admin_about.tpl', 'description' => '', 'type' => 'admin'],
160
    ['file' => $moduleDirName . '_admin_header.tpl', 'description' => '', 'type' => 'admin'],
161
    ['file' => $moduleDirName . '_admin_index.tpl', 'description' => '', 'type' => 'admin'],
162
    ['file' => $moduleDirName . '_admin_footer.tpl', 'description' => '', 'type' => 'admin'],
163
    ['file' => $moduleDirName . '_admin_category.tpl', 'description' => '', 'type' => 'admin'],
164
    ['file' => $moduleDirName . '_admin_downloads.tpl', 'description' => '', 'type' => 'admin'],
165
    ['file' => $moduleDirName . '_admin_broken.tpl', 'description' => '', 'type' => 'admin'],
166
    ['file' => $moduleDirName . '_admin_modified.tpl', 'description' => '', 'type' => 'admin'],
167
    ['file' => $moduleDirName . '_admin_field.tpl', 'description' => '', 'type' => 'admin'],
168
    ['file' => $moduleDirName . '_admin_import.tpl', 'description' => '', 'type' => 'admin'],
169
    ['file' => $moduleDirName . '_admin_permissions.tpl', 'description' => '', 'type' => 'admin'],
170
    // User
171
    ['file' => $moduleDirName . '_brokenfile.tpl', 'description' => ''],
172
    ['file' => $moduleDirName . '_download.tpl', 'description' => ''],
173
    ['file' => $moduleDirName . '_index.tpl', 'description' => ''],
174
    ['file' => $moduleDirName . '_modfile.tpl', 'description' => ''],
175
    ['file' => $moduleDirName . '_ratefile.tpl', 'description' => ''],
176
    ['file' => $moduleDirName . '_singlefile.tpl', 'description' => ''],
177
    ['file' => $moduleDirName . '_submit.tpl', 'description' => ''],
178
    ['file' => $moduleDirName . '_viewcat.tpl', 'description' => ''],
179
    ['file' => $moduleDirName . '_liste.tpl', 'description' => ''],
180
    ['file' => $moduleDirName . '_rss.tpl', 'description' => ''],
181
];
182
183
// ------------------- Help files ------------------- //
184
$modversion['helpsection'] = [
185
    ['name' => _MI_TDMDOWNLOADS_OVERVIEW, 'link' => 'page=help'],
186
    ['name' => _MI_TDMDOWNLOADS_DISCLAIMER, 'link' => 'page=disclaimer'],
187
    ['name' => _MI_TDMDOWNLOADS_LICENSE, 'link' => 'page=license'],
188
    ['name' => _MI_TDMDOWNLOADS_SUPPORT, 'link' => 'page=support'],
189
];
190
191
// Préférences
192
$modversion['config'][] = [
193
    'name'        => 'break',
194
    'title'       => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_GENERAL',
195
    'description' => '',
196
    'formtype'    => 'line_break',
197
    'valuetype'   => 'textbox',
198
    'default'     => 'head',
199
];
200
201
$modversion['config'][] = [
202
    'name'        => 'popular',
203
    'title'       => '_MI_TDMDOWNLOADS_POPULAR',
204
    'description' => '',
205
    'formtype'    => 'textbox',
206
    'valuetype'   => 'int',
207
    'default'     => 100,
208
];
209
210
$modversion['config'][] = [
211
    'name'        => 'autosummary',
212
    'title'       => '_MI_TDMDOWNLOADS_AUTO_SUMMARY',
213
    'description' => '',
214
    'formtype'    => 'yesno',
215
    'valuetype'   => 'int',
216
    'default'     => 0,
217
];
218
219
$modversion['config'][] = [
220
    'name'        => 'showupdated',
221
    'title'       => '_MI_TDMDOWNLOADS_SHOW_UPDATED',
222
    'description' => '',
223
    'formtype'    => 'yesno',
224
    'valuetype'   => 'int',
225
    'default'     => 1,
226
];
227
228
$modversion['config'][] = [
229
    'name'        => 'useshots',
230
    'title'       => '_MI_TDMDOWNLOADS_USESHOTS',
231
    'description' => '',
232
    'formtype'    => 'yesno',
233
    'valuetype'   => 'int',
234
    'default'     => 1,
235
];
236
237
$modversion['config'][] = [
238
    'name'        => 'shotwidth',
239
    'title'       => '_MI_TDMDOWNLOADS_SHOTWIDTH',
240
    'description' => '',
241
    'formtype'    => 'textbox',
242
    'valuetype'   => 'int',
243
    'default'     => 90,
244
];
245
246
$modversion['config'][] = [
247
    'name'        => 'img_float',
248
    'title'       => '_MI_TDMDOWNLOADS_IMGFLOAT',
249
    'description' => '',
250
    'formtype'    => 'select',
251
    'valuetype'   => 'text',
252
    'default'     => 'left',
253
    'options'     => [_MI_TDMDOWNLOADS_IMGFLOAT_LEFT => 'left', _MI_TDMDOWNLOADS_IMGFLOAT_RIGHT => 'Aaright'],
254
];
255
256
$modversion['config'][] = [
257
    'name'        => 'platform',
258
    'title'       => '_MI_TDMDOWNLOADS_PLATEFORM',
259
    'description' => '_MI_TDMDOWNLOADS_PLATEFORM_DSC',
260
    'formtype'    => 'textarea',
261
    'valuetype'   => 'text',
262
    'default'     => 'None|XOOPS 2.0.x|XOOPS 2.2.x|XOOPS 2.3.x|XOOPS 2.4.x|XOOPS 2.5.x|XOOPS 2.6.x|Other',
263
];
264
265
$modversion['config'][] = [
266
    'name'        => 'usetellafriend',
267
    'title'       => '_MI_TDMDOWNLOADS_USETELLAFRIEND',
268
    'description' => '_MI_TDMDOWNLOADS_USETELLAFRIENDDSC',
269
    'formtype'    => 'yesno',
270
    'valuetype'   => 'int',
271
    'default'     => 0,
272
];
273
274
$modversion['config'][] = [
275
    'name'        => 'usetag',
276
    'title'       => '_MI_TDMDOWNLOADS_USETAG',
277
    'description' => '_MI_TDMDOWNLOADS_USETAGDSC',
278
    'formtype'    => 'yesno',
279
    'valuetype'   => 'int',
280
    'default'     => 0,
281
];
282
283
//xoops_load('xoopseditorhandler');
284
//$editorHandler = \XoopsEditorHandler::getInstance();
285
286
$modversion['config'][] = [
287
    'name'        => 'editor',
288
    'title'       => '_MI_TDMDOWNLOADS_FORM_OPTIONS',
289
    'description' => '',
290
    'formtype'    => 'select',
291
    'valuetype'   => 'text',
292
    'default'     => 'dhtmltextarea',
293
    'options'     => array_flip($editorHandler->getList()),
294
];
295
296
$modversion['config'][] = [
297
    'name'        => 'break',
298
    'title'       => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_USER',
299
    'description' => '',
300
    'formtype'    => 'line_break',
301
    'valuetype'   => 'textbox',
302
    'default'     => 'head',
303
];
304
305
$modversion['config'][] = [
306
    'name'        => 'perpage',
307
    'title'       => '_MI_TDMDOWNLOADS_PERPAGE',
308
    'description' => '',
309
    'formtype'    => 'textbox',
310
    'valuetype'   => 'int',
311
    'default'     => 10,
312
];
313
314
$modversion['config'][] = [
315
    'name'        => 'nb_dowcol',
316
    'title'       => '_MI_TDMDOWNLOADS_NBDOWCOL',
317
    'description' => '',
318
    'formtype'    => 'select',
319
    'valuetype'   => 'int',
320
    'default'     => 1,
321
    'options'     => ['1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5],
322
];
323
324
$modversion['config'][] = [
325
    'name'        => 'newdownloads',
326
    'title'       => '_MI_TDMDOWNLOADS_NEWDLS',
327
    'description' => '',
328
    'formtype'    => 'textbox',
329
    'valuetype'   => 'int',
330
    'default'     => 10,
331
];
332
333
$modversion['config'][] = [
334
    'name'        => 'toporder',
335
    'title'       => '_MI_TDMDOWNLOADS_TOPORDER',
336
    'description' => '',
337
    'formtype'    => 'select',
338
    'valuetype'   => 'int',
339
    'default'     => 1,
340
    'options'     => [
341
        '_MI_TDMDOWNLOADS_TOPORDER1' => 1,
342
        '_MI_TDMDOWNLOADS_TOPORDER2' => 2,
343
        '_MI_TDMDOWNLOADS_TOPORDER3' => 3,
344
        '_MI_TDMDOWNLOADS_TOPORDER4' => 4,
345
        '_MI_TDMDOWNLOADS_TOPORDER5' => 5,
346
        '_MI_TDMDOWNLOADS_TOPORDER6' => 6,
347
        '_MI_TDMDOWNLOADS_TOPORDER7' => 7,
348
        '_MI_TDMDOWNLOADS_TOPORDER8' => 8,
349
    ],
350
];
351
352
$modversion['config'][] = [
353
    'name'        => 'perpageliste',
354
    'title'       => '_MI_TDMDOWNLOADS_PERPAGELISTE',
355
    'description' => '',
356
    'formtype'    => 'textbox',
357
    'valuetype'   => 'int',
358
    'default'     => 15,
359
];
360
361
$modversion['config'][] = [
362
    'name'        => 'searchorder',
363
    'title'       => '_MI_TDMDOWNLOADS_SEARCHORDER',
364
    'description' => '',
365
    'formtype'    => 'select',
366
    'valuetype'   => 'int',
367
    'default'     => 8,
368
    'options'     => [
369
        '_MI_TDMDOWNLOADS_TOPORDER1' => 1,
370
        '_MI_TDMDOWNLOADS_TOPORDER2' => 2,
371
        '_MI_TDMDOWNLOADS_TOPORDER3' => 3,
372
        '_MI_TDMDOWNLOADS_TOPORDER4' => 4,
373
        '_MI_TDMDOWNLOADS_TOPORDER5' => 5,
374
        '_MI_TDMDOWNLOADS_TOPORDER6' => 6,
375
        '_MI_TDMDOWNLOADS_TOPORDER7' => 7,
376
        '_MI_TDMDOWNLOADS_TOPORDER8' => 8,
377
    ],
378
];
379
380
$modversion['config'][] = [
381
    'name'        => 'nbsouscat',
382
    'title'       => '_MI_TDMDOWNLOADS_SUBCATPARENT',
383
    'description' => '',
384
    'formtype'    => 'textbox',
385
    'valuetype'   => 'int',
386
    'default'     => 5,
387
];
388
389
$modversion['config'][] = [
390
    'name'        => 'nb_catcol',
391
    'title'       => '_MI_TDMDOWNLOADS_NBCATCOL',
392
    'description' => '',
393
    'formtype'    => 'select',
394
    'valuetype'   => 'int',
395
    'default'     => 3,
396
    'options'     => ['1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5],
397
];
398
399
$modversion['config'][] = [
400
    'name'        => 'bldate',
401
    'title'       => '_MI_TDMDOWNLOADS_BLDATE',
402
    'description' => '',
403
    'formtype'    => 'yesno',
404
    'valuetype'   => 'int',
405
    'default'     => 1,
406
];
407
408
$modversion['config'][] = [
409
    'name'        => 'blpop',
410
    'title'       => '_MI_TDMDOWNLOADS_BLPOP',
411
    'description' => '',
412
    'formtype'    => 'yesno',
413
    'valuetype'   => 'int',
414
    'default'     => 1,
415
];
416
417
$modversion['config'][] = [
418
    'name'        => 'blrating',
419
    'title'       => '_MI_TDMDOWNLOADS_BLRATING',
420
    'description' => '',
421
    'formtype'    => 'yesno',
422
    'valuetype'   => 'int',
423
    'default'     => 1,
424
];
425
426
$modversion['config'][] = [
427
    'name'        => 'nbbl',
428
    'title'       => '_MI_TDMDOWNLOADS_NBBL',
429
    'description' => '',
430
    'formtype'    => 'textbox',
431
    'valuetype'   => 'int',
432
    'default'     => 5,
433
];
434
435
$modversion['config'][] = [
436
    'name'        => 'longbl',
437
    'title'       => '_MI_TDMDOWNLOADS_LONGBL',
438
    'description' => '',
439
    'formtype'    => 'textbox',
440
    'valuetype'   => 'int',
441
    'default'     => 20,
442
];
443
444
$modversion['config'][] = [
445
    'name'        => 'show_bookmark',
446
    'title'       => '_MI_TDMDOWNLOADS_BOOKMARK',
447
    'description' => '_MI_TDMDOWNLOADS_BOOKMARK_DSC',
448
    'formtype'    => 'yesno',
449
    'valuetype'   => 'int',
450
    'default'     => 1,
451
];
452
453
$modversion['config'][] = [
454
    'name'        => 'show_social',
455
    'title'       => '_MI_TDMDOWNLOADS_SOCIAL',
456
    'description' => '_MI_TDMDOWNLOADS_SOCIAL_DSC',
457
    'formtype'    => 'yesno',
458
    'valuetype'   => 'int',
459
    'default'     => 1,
460
];
461
462
$modversion['config'][] = [
463
    'name'        => 'download_float',
464
    'title'       => '_MI_TDMDOWNLOADS_DOWNLOADFLOAT',
465
    'description' => '_MI_TDMDOWNLOADS_DOWNLOADFLOAT_DSC',
466
    'formtype'    => 'select',
467
    'valuetype'   => 'text',
468
    'default'     => 'ltr',
469
    'options'     => [_MI_TDMDOWNLOADS_DOWNLOADFLOAT_LTR => 'ltr', _MI_TDMDOWNLOADS_DOWNLOADFLOAT_RTL => 'rtl'],
470
];
471
472
$modversion['config'][] = [
473
    'name'        => 'show_latest_files',
474
    'title'       => '_MI_TDMDOWNLOADS_SHOW_LATEST_FILES',
475
    'description' => '_MI_TDMDOWNLOADS_SHOW_LATEST_FILES_DSC',
476
    'formtype'    => 'yesno',
477
    'valuetype'   => 'int',
478
    'default'     => 1,
479
];
480
481
$modversion['config'][] = [
482
    'name'        => 'break',
483
    'title'       => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_ADMIN',
484
    'description' => '',
485
    'formtype'    => 'line_break',
486
    'valuetype'   => 'textbox',
487
    'default'     => 'head',
488
];
489
490
$modversion['config'][] = [
491
    'name'        => 'perpageadmin',
492
    'title'       => '_MI_TDMDOWNLOADS_PERPAGEADMIN',
493
    'description' => '',
494
    'formtype'    => 'textbox',
495
    'valuetype'   => 'int',
496
    'default'     => 15,
497
];
498
499
$modversion['config'][] = [
500
    'name'        => 'break',
501
    'title'       => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_DOWNLOADS',
502
    'description' => '',
503
    'formtype'    => 'line_break',
504
    'valuetype'   => 'textbox',
505
    'default'     => 'head',
506
];
507
508
$modversion['config'][] = [
509
    'name'        => 'permission_download',
510
    'title'       => '_MI_TDMDOWNLOADS_PERMISSIONDOWNLOAD',
511
    'description' => '',
512
    'formtype'    => 'select',
513
    'valuetype'   => 'int',
514
    'default'     => 1,
515
    'options'     => ['_MI_TDMDOWNLOADS_PERMISSIONDOWNLOAD1' => 1, '_MI_TDMDOWNLOADS_PERMISSIONDOWNLOAD2' => 2],
516
];
517
518
$modversion['config'][] = [
519
    'name'        => 'newnamedownload',
520
    'title'       => '_MI_TDMDOWNLOADS_DOWNLOAD_NAME',
521
    'description' => '_MI_TDMDOWNLOADS_DOWNLOAD_NAMEDSC',
522
    'formtype'    => 'yesno',
523
    'valuetype'   => 'int',
524
    'default'     => 1,
525
];
526
527
$modversion['config'][] = [
528
    'name'        => 'prefixdownloads',
529
    'title'       => '_MI_TDMDOWNLOADS_DOWNLOAD_PREFIX',
530
    'description' => '_MI_TDMDOWNLOADS_DOWNLOAD_PREFIXDSC',
531
    'formtype'    => 'textbox',
532
    'valuetype'   => 'text',
533
    'default'     => 'downloads_',
534
];
535
536
$iniPostMaxSize = returnBytes(ini_get('post_max_size'));
537
$iniUploadMaxFileSize = returnBytes(ini_get('upload_max_filesize'));
538
$optionMaxsize = [];
539
for ($i = 1; ; $i++) {
540
    if ( min($iniPostMaxSize, $iniUploadMaxFileSize) < $i*1048576 ) break;
541
    $optionMaxsize[$i." MB"] = $i*1048576;
542
}
543
$modversion['config'][] = [
544
    'name'        => 'maxuploadsize',
545
    'title'       => '_MI_TDMDOWNLOADS_MAXUPLOAD_SIZE',
546
    'description' => '',
547
    'formtype'    => 'select',
548
    'valuetype'   => 'int',
549
    'default'     => 1048576,
550
    'options'     => $optionMaxsize
551
];
552
553
$modversion['config'][] = [
554
    'name'        => 'mimetype',
555
    'title'       => '_MI_TDMDOWNLOADS_MIMETYPE',
556
    'description' => '_MI_TDMDOWNLOADS_MIMETYPE_DSC',
557
    'formtype'    => 'select_multi',
558
    'valuetype'   => 'array',
559
    'default'     => array('image/gif', 'image/jpeg', 'image/png', 
560
                            'application/zip', 'application/rar', 'application/pdf', 'application/x-gtar', 'application/x-tar', 
561
                            'application/msword', 'application/vnd.ms-excel', 'application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.spreadsheet', 
562
                            'application/vnd.openxmlformats-officedocument.wordprocessingml.document','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'),
563
	'options'     => include $GLOBALS['xoops']->path('include/mimetypes.inc.php')
564
];
565
566
$modversion['config'][] = [
567
    'name'        => 'check_host',
568
    'title'       => '_MI_TDMDOWNLOADS_CHECKHOST',
569
    'description' => '',
570
    'formtype'    => 'yesno',
571
    'valuetype'   => 'int',
572
    'default'     => 0,
573
];
574
575
$xoopsUrl               = parse_url(XOOPS_URL);
576
$modversion['config'][] = [
577
    'name'        => 'referers',
578
    'title'       => '_MI_TDMDOWNLOADS_REFERERS',
579
    'description' => '',
580
    'formtype'    => 'textarea',
581
    'valuetype'   => 'array',
582
    'default'     => [$xoopsUrl['host']],
583
];
584
585
$modversion['config'][] = [
586
    'name'        => 'downlimit',
587
    'title'       => '_MI_TDMDOWNLOADS_DOWNLIMIT',
588
    'description' => '_MI_TDMDOWNLOADS_DOWNLIMITDSC',
589
    'formtype'    => 'yesno',
590
    'valuetype'   => 'int',
591
    'default'     => 0,
592
];
593
594
$modversion['config'][] = [
595
    'name'        => 'limitglobal',
596
    'title'       => '_MI_TDMDOWNLOADS_LIMITGLOBAL',
597
    'description' => '_MI_TDMDOWNLOADS_LIMITGLOBALDSC',
598
    'formtype'    => 'textbox',
599
    'valuetype'   => 'int',
600
    'default'     => 10,
601
];
602
603
$modversion['config'][] = [
604
    'name'        => 'limitlid',
605
    'title'       => '_MI_TDMDOWNLOADS_LIMITLID',
606
    'description' => '_MI_TDMDOWNLOADS_LIMITLIDDSC',
607
    'formtype'    => 'textbox',
608
    'valuetype'   => 'int',
609
    'default'     => 2,
610
];
611
612
$modversion['config'][] = [
613
    'name'        => 'break',
614
    'title'       => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_PAYPAL',
615
    'description' => '',
616
    'formtype'    => 'line_break',
617
    'valuetype'   => 'textbox',
618
    'default'     => 'head',
619
];
620
621
$modversion['config'][] = [
622
    'name'        => 'use_paypal',
623
    'title'       => '_MI_TDMDOWNLOADS_USEPAYPAL',
624
    'description' => '',
625
    'formtype'    => 'yesno',
626
    'valuetype'   => 'int',
627
    'default'     => 0,
628
];
629
630
$modversion['config'][] = [
631
    'name'        => 'currency_paypal',
632
    'title'       => '_MI_TDMDOWNLOADS_CURRENCYPAYPAL',
633
    'description' => '',
634
    'formtype'    => 'select',
635
    'valuetype'   => 'text',
636
    'default'     => 'EUR',
637
    'options'     => [
638
        'AUD' => 'AUD',
639
        'BRL' => 'BRL',
640
        'CAD' => 'CAD',
641
        'CHF' => 'CHF',
642
        'CZK' => 'CZK',
643
        'DKK' => 'DKK',
644
        'EUR' => 'EUR',
645
        'GBP' => 'GBP',
646
        'HKD' => 'HKD',
647
        'HUF' => 'HUF',
648
        'ILS' => 'ILS',
649
        'JPY' => 'JPY',
650
        'MXN' => 'MXN',
651
        'NOK' => 'NOK',
652
        'NZD' => 'NZD',
653
        'PHP' => 'PHP',
654
        'PLN' => 'PLN',
655
        'SEK' => 'SEK',
656
        'SGD' => 'SGD',
657
        'THB' => 'THB',
658
        'TWD' => 'TWD',
659
        'USD' => 'USD',
660
    ],
661
];
662
663
$modversion['config'][] = [
664
    'name'        => 'image_paypal',
665
    'title'       => '_MI_TDMDOWNLOADS_IMAGEPAYPAL',
666
    'description' => '_MI_TDMDOWNLOADS_IMAGEPAYPALDSC',
667
    'formtype'    => 'textbox',
668
    'valuetype'   => 'text',
669
    'default'     => 'https://www.paypal.com/fr_FR/FR/i/btn/btn_donateCC_LG.gif',
670
];
671
672
$modversion['config'][] = [
673
    'name'        => 'break',
674
    'title'       => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_RSS',
675
    'description' => '',
676
    'formtype'    => 'line_break',
677
    'valuetype'   => 'textbox',
678
    'default'     => 'head',
679
];
680
681
$modversion['config'][] = [
682
    'name'        => 'perpagerss',
683
    'title'       => '_MI_TDMDOWNLOADS_PERPAGERSS',
684
    'description' => '_MI_TDMDOWNLOADS_PERPAGERSSDSC',
685
    'formtype'    => 'textbox',
686
    'valuetype'   => 'int',
687
    'default'     => 10,
688
];
689
690
$modversion['config'][] = [
691
    'name'        => 'timecacherss',
692
    'title'       => '_MI_TDMDOWNLOADS_TIMECACHERSS',
693
    'description' => '_MI_TDMDOWNLOADS_TIMECACHERSSDSC',
694
    'formtype'    => 'textbox',
695
    'valuetype'   => 'int',
696
    'default'     => 60,
697
];
698
699
$modversion['config'][] = [
700
    'name'        => 'logorss',
701
    'title'       => '_MI_TDMDOWNLOADS_LOGORSS',
702
    'description' => '',
703
    'formtype'    => 'textbox',
704
    'valuetype'   => 'text',
705
    'default'     => '/modules/tdmdownloads/assets/images/mydl_slogo.png',
706
];
707
708
$modversion['config'][] = [
709
    'name'        => 'break',
710
    'title'       => '_MI_TDMDOWNLOADS_CONFCAT_OTHERS',
711
    'description' => '',
712
    'formtype'    => 'line_break',
713
    'valuetype'   => 'textbox',
714
    'default'     => 'head',
715
];
716
717
/**
718
 * Make Sample button visible?
719
 */
720
$modversion['config'][] = [
721
    'name'        => 'displaySampleButton',
722
    'title'       => '_MI_TDMDOWNLOADS_SHOW_SAMPLE_BUTTON',
723
    'description' => '_MI_TDMDOWNLOADS_SHOW_SAMPLE_BUTTON_DESC',
724
    'formtype'    => 'yesno',
725
    'valuetype'   => 'int',
726
    'default'     => 1,
727
];
728
729
/**
730
 * Show Developer Tools?
731
 */
732
$modversion['config'][] = [
733
    'name'        => 'displayDeveloperTools',
734
    'title'       => '_MI_TDMDOWNLOADS_SHOW_DEV_TOOLS',
735
    'description' => '_MI_TDMDOWNLOADS_SHOW_DEV_TOOLS_DESC',
736
    'formtype'    => 'yesno',
737
    'valuetype'   => 'int',
738
    'default'     => 0,
739
];
740
741
// ------------------- Notifications -------------------
742
$modversion['config'][] = [
743
    'name'        => 'break',
744
    'title'       => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_COMNOTI',
745
    'description' => '',
746
    'formtype'    => 'line_break',
747
    'valuetype'   => 'textbox',
748
    'default'     => 'head',
749
];
750
$modversion['hasNotification']             = 1;
751
$modversion['notification']['lookup_file'] = 'include/notification.inc.php';
752
$modversion['notification']['lookup_func'] = 'tdmdownloads_notify_iteminfo';
753
754
$modversion['notification']['category'][] = [
755
    'name'           => 'global',
756
    'title'          => _MI_TDMDOWNLOADS_GLOBAL_NOTIFY,
757
    'description'    => _MI_TDMDOWNLOADS_GLOBAL_NOTIFYDSC,
758
    'subscribe_from' => ['index.php', 'viewcat.php', 'singlefile.php'],
759
];
760
761
$modversion['notification']['category'][] = [
762
    'name'           => 'category',
763
    'title'          => _MI_TDMDOWNLOADS_CATEGORY_NOTIFY,
764
    'description'    => _MI_TDMDOWNLOADS_CATEGORY_NOTIFYDSC,
765
    'subscribe_from' => ['viewcat.php', 'singlefile.php'],
766
    'item_name'      => 'cid',
767
    'allow_bookmark' => 1,
768
];
769
770
$modversion['notification']['category'][] = [
771
    'name'           => 'file',
772
    'title'          => _MI_TDMDOWNLOADS_FILE_NOTIFY,
773
    'description'    => _MI_TDMDOWNLOADS_FILE_NOTIFYDSC,
774
    'subscribe_from' => 'singlefile.php',
775
    'item_name'      => 'lid',
776
    'allow_bookmark' => 1,
777
];
778
779
$modversion['notification']['event'][] = [
780
    'name'          => 'new_category',
781
    'category'      => 'global',
782
    'title'         => _MI_TDMDOWNLOADS_GLOBAL_NEWCATEGORY_NOTIFY,
783
    'caption'       => _MI_TDMDOWNLOADS_GLOBAL_NEWCATEGORY_NOTIFYCAP,
784
    'description'   => _MI_TDMDOWNLOADS_GLOBAL_NEWCATEGORY_NOTIFYDSC,
785
    'mail_template' => 'global_newcategory_notify',
786
    'mail_subject'  => _MI_TDMDOWNLOADS_GLOBAL_NEWCATEGORY_NOTIFYSBJ,
787
];
788
789
$modversion['notification']['event'][] = [
790
    'name'          => 'file_modify',
791
    'category'      => 'global',
792
    'admin_only'    => 1,
793
    'title'         => _MI_TDMDOWNLOADS_GLOBAL_FILEMODIFY_NOTIFY,
794
    'caption'       => _MI_TDMDOWNLOADS_GLOBAL_FILEMODIFY_NOTIFYCAP,
795
    'description'   => _MI_TDMDOWNLOADS_GLOBAL_FILEMODIFY_NOTIFYDSC,
796
    'mail_template' => 'global_filemodify_notify',
797
    'mail_subject'  => _MI_TDMDOWNLOADS_GLOBAL_FILEMODIFY_NOTIFYSBJ,
798
];
799
800
$modversion['notification']['event'][] = [
801
    'name'          => 'file_submit',
802
    'category'      => 'global',
803
    'admin_only'    => 1,
804
    'title'         => _MI_TDMDOWNLOADS_GLOBAL_FILESUBMIT_NOTIFY,
805
    'caption'       => _MI_TDMDOWNLOADS_GLOBAL_FILESUBMIT_NOTIFYCAP,
806
    'description'   => _MI_TDMDOWNLOADS_GLOBAL_FILESUBMIT_NOTIFYDSC,
807
    'mail_template' => 'global_filesubmit_notify',
808
    'mail_subject'  => _MI_TDMDOWNLOADS_GLOBAL_FILESUBMIT_NOTIFYSBJ,
809
];
810
811
$modversion['notification']['event'][] = [
812
    'name'          => 'file_broken',
813
    'category'      => 'global',
814
    'admin_only'    => 1,
815
    'title'         => _MI_TDMDOWNLOADS_GLOBAL_FILEBROKEN_NOTIFY,
816
    'caption'       => _MI_TDMDOWNLOADS_GLOBAL_FILEBROKEN_NOTIFYCAP,
817
    'description'   => _MI_TDMDOWNLOADS_GLOBAL_FILEBROKEN_NOTIFYDSC,
818
    'mail_template' => 'global_filebroken_notify',
819
    'mail_subject'  => _MI_TDMDOWNLOADS_GLOBAL_FILEBROKEN_NOTIFYSBJ,
820
];
821
822
$modversion['notification']['event'][] = [
823
    'name'          => 'new_file',
824
    'category'      => 'global',
825
    'title'         => _MI_TDMDOWNLOADS_GLOBAL_NEWFILE_NOTIFY,
826
    'caption'       => _MI_TDMDOWNLOADS_GLOBAL_NEWFILE_NOTIFYCAP,
827
    'description'   => _MI_TDMDOWNLOADS_GLOBAL_NEWFILE_NOTIFYDSC,
828
    'mail_template' => 'global_newfile_notify',
829
    'mail_subject'  => _MI_TDMDOWNLOADS_GLOBAL_NEWFILE_NOTIFYSBJ,
830
];
831
832
$modversion['notification']['event'][] = [
833
    'name'          => 'file_submit',
834
    'category'      => 'category',
835
    'admin_only'    => 1,
836
    'title'         => _MI_TDMDOWNLOADS_CATEGORY_FILESUBMIT_NOTIFY,
837
    'caption'       => _MI_TDMDOWNLOADS_CATEGORY_FILESUBMIT_NOTIFYCAP,
838
    'description'   => _MI_TDMDOWNLOADS_CATEGORY_FILESUBMIT_NOTIFYDSC,
839
    'mail_template' => 'category_filesubmit_notify',
840
    'mail_subject'  => _MI_TDMDOWNLOADS_CATEGORY_FILESUBMIT_NOTIFYSBJ,
841
];
842
843
$modversion['notification']['event'][] = [
844
    'name'          => 'new_file',
845
    'category'      => 'category',
846
    'title'         => _MI_TDMDOWNLOADS_CATEGORY_NEWFILE_NOTIFY,
847
    'caption'       => _MI_TDMDOWNLOADS_CATEGORY_NEWFILE_NOTIFYCAP,
848
    'description'   => _MI_TDMDOWNLOADS_CATEGORY_NEWFILE_NOTIFYDSC,
849
    'mail_template' => 'category_newfile_notify',
850
    'mail_subject'  => _MI_TDMDOWNLOADS_CATEGORY_NEWFILE_NOTIFYSBJ,
851
];
852
853
$modversion['notification']['event'][] = [
854
    'name'          => 'approve',
855
    'category'      => 'file',
856
    'invisible'     => 1,
857
    'title'         => _MI_TDMDOWNLOADS_FILE_APPROVE_NOTIFY,
858
    'caption'       => _MI_TDMDOWNLOADS_FILE_APPROVE_NOTIFYCAP,
859
    'description'   => _MI_TDMDOWNLOADS_FILE_APPROVE_NOTIFYDSC,
860
    'mail_template' => 'file_approve_notify',
861
    'mail_subject'  => _MI_TDMDOWNLOADS_FILE_APPROVE_NOTIFYSBJ,
862
];
863
864
function returnBytes($val) {
865
    switch (substr($val, -1)) {
866
        case 'K':
867
        case 'k':
868
            return (int)$val * 1024;
869
        case 'M':
870
        case 'm':
871
            return (int)$val * 1048576;
872
        case 'G':
873
        case 'g':
874
            return (int)$val * 1073741824;
875
        default:
876
            return $val;
877
    }
878
}
879