Passed
Push — master ( 6436ae...468f1f )
by Goffy
29s queued 11s
created

returnBytes()   B

Complexity

Conditions 7
Paths 7

Size

Total Lines 14
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 14
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
    // Blocks styles
171
    ['file' => $moduleDirName . '_block_styledefault.tpl', 'description' => '', 'type' => 'block'],
172
    ['file' => $moduleDirName . '_block_stylesimple.tpl', 'description' => '', 'type' => 'block'],
173
    // User
174
    ['file' => $moduleDirName . '_brokenfile.tpl', 'description' => ''],
175
    ['file' => $moduleDirName . '_download.tpl', 'description' => ''],
176
    ['file' => $moduleDirName . '_index.tpl', 'description' => ''],
177
    ['file' => $moduleDirName . '_modfile.tpl', 'description' => ''],
178
    ['file' => $moduleDirName . '_ratefile.tpl', 'description' => ''],
179
    ['file' => $moduleDirName . '_singlefile.tpl', 'description' => ''],
180
    ['file' => $moduleDirName . '_submit.tpl', 'description' => ''],
181
    ['file' => $moduleDirName . '_viewcat.tpl', 'description' => ''],
182
    ['file' => $moduleDirName . '_liste.tpl', 'description' => ''],
183
    ['file' => $moduleDirName . '_rss.tpl', 'description' => ''],
184
];
185
186
// ------------------- Help files ------------------- //
187
$modversion['helpsection'] = [
188
    ['name' => _MI_TDMDOWNLOADS_OVERVIEW, 'link' => 'page=help'],
189
    ['name' => _MI_TDMDOWNLOADS_DISCLAIMER, 'link' => 'page=disclaimer'],
190
    ['name' => _MI_TDMDOWNLOADS_LICENSE, 'link' => 'page=license'],
191
    ['name' => _MI_TDMDOWNLOADS_SUPPORT, 'link' => 'page=support'],
192
];
193
194
// Préférences
195
$modversion['config'][] = [
196
    'name' => 'break',
197
    'title' => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_GENERAL',
198
    'description' => '',
199
    'formtype' => 'line_break',
200
    'valuetype' => 'textbox',
201
    'default' => 'head',
202
];
203
204
$modversion['config'][] = [
205
    'name' => 'popular',
206
    'title' => '_MI_TDMDOWNLOADS_POPULAR',
207
    'description' => '',
208
    'formtype' => 'textbox',
209
    'valuetype' => 'int',
210
    'default' => 100,
211
];
212
213
$modversion['config'][] = [
214
    'name' => 'autosummary',
215
    'title' => '_MI_TDMDOWNLOADS_AUTO_SUMMARY',
216
    'description' => '',
217
    'formtype' => 'yesno',
218
    'valuetype' => 'int',
219
    'default' => 0,
220
];
221
222
$modversion['config'][] = [
223
    'name' => 'showupdated',
224
    'title' => '_MI_TDMDOWNLOADS_SHOW_UPDATED',
225
    'description' => '',
226
    'formtype' => 'yesno',
227
    'valuetype' => 'int',
228
    'default' => 1,
229
];
230
231
$modversion['config'][] = [
232
    'name' => 'useshots',
233
    'title' => '_MI_TDMDOWNLOADS_USESHOTS',
234
    'description' => '',
235
    'formtype' => 'yesno',
236
    'valuetype' => 'int',
237
    'default' => 1,
238
];
239
240
$modversion['config'][] = [
241
    'name' => 'shotwidth',
242
    'title' => '_MI_TDMDOWNLOADS_SHOTWIDTH',
243
    'description' => '',
244
    'formtype' => 'textbox',
245
    'valuetype' => 'int',
246
    'default' => 90,
247
];
248
249
$modversion['config'][] = [
250
    'name' => 'img_float',
251
    'title' => '_MI_TDMDOWNLOADS_IMGFLOAT',
252
    'description' => '',
253
    'formtype' => 'select',
254
    'valuetype' => 'text',
255
    'default' => 'left',
256
    'options' => [_MI_TDMDOWNLOADS_IMGFLOAT_LEFT => 'left', _MI_TDMDOWNLOADS_IMGFLOAT_RIGHT => 'Aaright'],
257
];
258
259
$modversion['config'][] = [
260
    'name' => 'platform',
261
    'title' => '_MI_TDMDOWNLOADS_PLATEFORM',
262
    'description' => '_MI_TDMDOWNLOADS_PLATEFORM_DSC',
263
    'formtype' => 'textarea',
264
    'valuetype' => 'text',
265
    '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',
266
];
267
268
$modversion['config'][] = [
269
    'name' => 'usetellafriend',
270
    'title' => '_MI_TDMDOWNLOADS_USETELLAFRIEND',
271
    'description' => '_MI_TDMDOWNLOADS_USETELLAFRIENDDSC',
272
    'formtype' => 'yesno',
273
    'valuetype' => 'int',
274
    'default' => 0,
275
];
276
277
$modversion['config'][] = [
278
    'name' => 'usetag',
279
    'title' => '_MI_TDMDOWNLOADS_USETAG',
280
    'description' => '_MI_TDMDOWNLOADS_USETAGDSC',
281
    'formtype' => 'yesno',
282
    'valuetype' => 'int',
283
    'default' => 0,
284
];
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
include_once 'include/xoops_version.inc.php';
537
$iniPostMaxSize = tdmdownloadsReturnBytes(ini_get('post_max_size'));
538
$iniUploadMaxFileSize = tdmdownloadsReturnBytes(ini_get('upload_max_filesize'));
539
$maxSize = min($iniPostMaxSize, $iniUploadMaxFileSize);
540
if ($maxSize > 10000 * 1048576) {
541
    $increment = 500;
542
}
543
if ($maxSize <= 10000 * 1048576){
544
    $increment = 200;
545
}
546
if ($maxSize <= 5000 * 1048576){
547
    $increment = 100;
548
}
549
if ($maxSize <= 2500 * 1048576){
550
    $increment = 50;
551
}
552
if ($maxSize <= 1000 * 1048576){
553
    $increment = 20;
554
}
555
if ($maxSize <= 500 * 1048576){
556
    $increment = 10;
557
}
558
if ($maxSize <= 100 * 1048576){
559
    $increment = 2;
560
}
561
if ($maxSize <= 50 * 1048576){
562
    $increment = 1;
563
}
564
if ($maxSize <= 25 * 1048576){
565
    $increment = 0.5;
566
}
567
$optionMaxsize = [];
568
$i = $increment;
569
while ($i* 1048576 <= $maxSize) {
570
    $optionMaxsize[$i . ' ' . _MI_TDMDOWNLOADS_MAXUPLOAD_SIZE_MB] = $i * 1048576;
571
    $i += $increment;
572
}
573
$modversion['config'][] = [
574
    'name' => 'maxuploadsize',
575
    'title' => '_MI_TDMDOWNLOADS_MAXUPLOAD_SIZE',
576
    'description' => '_MI_TDMDOWNLOADS_MAXUPLOAD_SIZE_DESC',
577
    'formtype' => 'select',
578
    'valuetype' => 'int',
579
    'default' => 1048576,
580
    'options' => $optionMaxsize,
581
];
582
583
$modversion['config'][] = [
584
    'name' => 'mimetype',
585
    'title' => '_MI_TDMDOWNLOADS_MIMETYPE',
586
    'description' => '_MI_TDMDOWNLOADS_MIMETYPE_DSC',
587
    'formtype' => 'select_multi',
588
    'valuetype' => 'array',
589
    'default' => [
590
        'image/gif', 'image/jpeg', 'image/png',
591
        'application/zip', 'application/rar', 'application/pdf', 'application/x-gtar', 'application/x-tar',
592
        'application/msword', 'application/vnd.ms-excel', 'application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.spreadsheet',
593
        'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
594
    ],
595
    'options' => include $GLOBALS['xoops']->path('include/mimetypes.inc.php'),
596
];
597
598
$modversion['config'][] = [
599
    'name' => 'check_host',
600
    'title' => '_MI_TDMDOWNLOADS_CHECKHOST',
601
    'description' => '',
602
    'formtype' => 'yesno',
603
    'valuetype' => 'int',
604
    'default' => 0,
605
];
606
607
$xoopsUrl = parse_url(XOOPS_URL);
608
$modversion['config'][] = [
609
    'name' => 'referers',
610
    'title' => '_MI_TDMDOWNLOADS_REFERERS',
611
    'description' => '',
612
    'formtype' => 'textarea',
613
    'valuetype' => 'array',
614
    'default' => [$xoopsUrl['host']],
615
];
616
617
$modversion['config'][] = [
618
    'name' => 'downlimit',
619
    'title' => '_MI_TDMDOWNLOADS_DOWNLIMIT',
620
    'description' => '_MI_TDMDOWNLOADS_DOWNLIMITDSC',
621
    'formtype' => 'yesno',
622
    'valuetype' => 'int',
623
    'default' => 0,
624
];
625
626
$modversion['config'][] = [
627
    'name' => 'limitglobal',
628
    'title' => '_MI_TDMDOWNLOADS_LIMITGLOBAL',
629
    'description' => '_MI_TDMDOWNLOADS_LIMITGLOBALDSC',
630
    'formtype' => 'textbox',
631
    'valuetype' => 'int',
632
    'default' => 10,
633
];
634
635
$modversion['config'][] = [
636
    'name' => 'limitlid',
637
    'title' => '_MI_TDMDOWNLOADS_LIMITLID',
638
    'description' => '_MI_TDMDOWNLOADS_LIMITLIDDSC',
639
    'formtype' => 'textbox',
640
    'valuetype' => 'int',
641
    'default' => 2,
642
];
643
644
$modversion['config'][] = [
645
    'name' => 'break',
646
    'title' => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_PAYPAL',
647
    'description' => '',
648
    'formtype' => 'line_break',
649
    'valuetype' => 'textbox',
650
    'default' => 'head',
651
];
652
653
$modversion['config'][] = [
654
    'name' => 'use_paypal',
655
    'title' => '_MI_TDMDOWNLOADS_USEPAYPAL',
656
    'description' => '',
657
    'formtype' => 'yesno',
658
    'valuetype' => 'int',
659
    'default' => 0,
660
];
661
662
$modversion['config'][] = [
663
    'name' => 'currency_paypal',
664
    'title' => '_MI_TDMDOWNLOADS_CURRENCYPAYPAL',
665
    'description' => '',
666
    'formtype' => 'select',
667
    'valuetype' => 'text',
668
    'default' => 'EUR',
669
    'options' => [
670
        'AUD' => 'AUD',
671
        'BRL' => 'BRL',
672
        'CAD' => 'CAD',
673
        'CHF' => 'CHF',
674
        'CZK' => 'CZK',
675
        'DKK' => 'DKK',
676
        'EUR' => 'EUR',
677
        'GBP' => 'GBP',
678
        'HKD' => 'HKD',
679
        'HUF' => 'HUF',
680
        'ILS' => 'ILS',
681
        'JPY' => 'JPY',
682
        'MXN' => 'MXN',
683
        'NOK' => 'NOK',
684
        'NZD' => 'NZD',
685
        'PHP' => 'PHP',
686
        'PLN' => 'PLN',
687
        'SEK' => 'SEK',
688
        'SGD' => 'SGD',
689
        'THB' => 'THB',
690
        'TWD' => 'TWD',
691
        'USD' => 'USD',
692
    ],
693
];
694
695
$modversion['config'][] = [
696
    'name' => 'image_paypal',
697
    'title' => '_MI_TDMDOWNLOADS_IMAGEPAYPAL',
698
    'description' => '_MI_TDMDOWNLOADS_IMAGEPAYPALDSC',
699
    'formtype' => 'textbox',
700
    'valuetype' => 'text',
701
    'default' => 'https://www.paypal.com/fr_FR/FR/i/btn/btn_donateCC_LG.gif',
702
];
703
704
$modversion['config'][] = [
705
    'name' => 'break',
706
    'title' => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_RSS',
707
    'description' => '',
708
    'formtype' => 'line_break',
709
    'valuetype' => 'textbox',
710
    'default' => 'head',
711
];
712
713
$modversion['config'][] = [
714
    'name' => 'perpagerss',
715
    'title' => '_MI_TDMDOWNLOADS_PERPAGERSS',
716
    'description' => '_MI_TDMDOWNLOADS_PERPAGERSSDSC',
717
    'formtype' => 'textbox',
718
    'valuetype' => 'int',
719
    'default' => 10,
720
];
721
722
$modversion['config'][] = [
723
    'name' => 'timecacherss',
724
    'title' => '_MI_TDMDOWNLOADS_TIMECACHERSS',
725
    'description' => '_MI_TDMDOWNLOADS_TIMECACHERSSDSC',
726
    'formtype' => 'textbox',
727
    'valuetype' => 'int',
728
    'default' => 60,
729
];
730
731
$modversion['config'][] = [
732
    'name' => 'logorss',
733
    'title' => '_MI_TDMDOWNLOADS_LOGORSS',
734
    'description' => '',
735
    'formtype' => 'textbox',
736
    'valuetype' => 'text',
737
    'default' => '/modules/tdmdownloads/assets/images/mydl_slogo.png',
738
];
739
740
$modversion['config'][] = [
741
    'name' => 'break',
742
    'title' => '_MI_TDMDOWNLOADS_CONFCAT_OTHERS',
743
    'description' => '',
744
    'formtype' => 'line_break',
745
    'valuetype' => 'textbox',
746
    'default' => 'head',
747
];
748
749
/**
750
 * Make Sample button visible?
751
 */
752
$modversion['config'][] = [
753
    'name' => 'displaySampleButton',
754
    'title' => '_MI_TDMDOWNLOADS_SHOW_SAMPLE_BUTTON',
755
    'description' => '_MI_TDMDOWNLOADS_SHOW_SAMPLE_BUTTON_DESC',
756
    'formtype' => 'yesno',
757
    'valuetype' => 'int',
758
    'default' => 1,
759
];
760
761
/**
762
 * Show Developer Tools?
763
 */
764
$modversion['config'][] = [
765
    'name' => 'displayDeveloperTools',
766
    'title' => '_MI_TDMDOWNLOADS_SHOW_DEV_TOOLS',
767
    'description' => '_MI_TDMDOWNLOADS_SHOW_DEV_TOOLS_DESC',
768
    'formtype' => 'yesno',
769
    'valuetype' => 'int',
770
    'default' => 0,
771
];
772
773
// ------------------- Notifications -------------------
774
$modversion['config'][] = [
775
    'name' => 'break',
776
    'title' => '_MI_TDMDOWNLOADS_PREFERENCE_BREAK_COMNOTI',
777
    'description' => '',
778
    'formtype' => 'line_break',
779
    'valuetype' => 'textbox',
780
    'default' => 'head',
781
];
782
$modversion['hasNotification'] = 1;
783
$modversion['notification']['lookup_file'] = 'include/notification.inc.php';
784
$modversion['notification']['lookup_func'] = 'tdmdownloads_notify_iteminfo';
785
786
$modversion['notification']['category'][] = [
787
    'name' => 'global',
788
    'title' => _MI_TDMDOWNLOADS_GLOBAL_NOTIFY,
789
    'description' => _MI_TDMDOWNLOADS_GLOBAL_NOTIFYDSC,
790
    'subscribe_from' => ['index.php', 'viewcat.php', 'singlefile.php'],
791
];
792
793
$modversion['notification']['category'][] = [
794
    'name' => 'category',
795
    'title' => _MI_TDMDOWNLOADS_CATEGORY_NOTIFY,
796
    'description' => _MI_TDMDOWNLOADS_CATEGORY_NOTIFYDSC,
797
    'subscribe_from' => ['viewcat.php', 'singlefile.php'],
798
    'item_name' => 'cid',
799
    'allow_bookmark' => 1,
800
];
801
802
$modversion['notification']['category'][] = [
803
    'name' => 'file',
804
    'title' => _MI_TDMDOWNLOADS_FILE_NOTIFY,
805
    'description' => _MI_TDMDOWNLOADS_FILE_NOTIFYDSC,
806
    'subscribe_from' => 'singlefile.php',
807
    'item_name' => 'lid',
808
    'allow_bookmark' => 1,
809
];
810
811
$modversion['notification']['event'][] = [
812
    'name' => 'new_category',
813
    'category' => 'global',
814
    'title' => _MI_TDMDOWNLOADS_GLOBAL_NEWCATEGORY_NOTIFY,
815
    'caption' => _MI_TDMDOWNLOADS_GLOBAL_NEWCATEGORY_NOTIFYCAP,
816
    'description' => _MI_TDMDOWNLOADS_GLOBAL_NEWCATEGORY_NOTIFYDSC,
817
    'mail_template' => 'global_newcategory_notify',
818
    'mail_subject' => _MI_TDMDOWNLOADS_GLOBAL_NEWCATEGORY_NOTIFYSBJ,
819
];
820
821
$modversion['notification']['event'][] = [
822
    'name' => 'file_modify',
823
    'category' => 'global',
824
    'admin_only' => 1,
825
    'title' => _MI_TDMDOWNLOADS_GLOBAL_FILEMODIFY_NOTIFY,
826
    'caption' => _MI_TDMDOWNLOADS_GLOBAL_FILEMODIFY_NOTIFYCAP,
827
    'description' => _MI_TDMDOWNLOADS_GLOBAL_FILEMODIFY_NOTIFYDSC,
828
    'mail_template' => 'global_filemodify_notify',
829
    'mail_subject' => _MI_TDMDOWNLOADS_GLOBAL_FILEMODIFY_NOTIFYSBJ,
830
];
831
832
$modversion['notification']['event'][] = [
833
    'name' => 'file_submit',
834
    'category' => 'global',
835
    'admin_only' => 1,
836
    'title' => _MI_TDMDOWNLOADS_GLOBAL_FILESUBMIT_NOTIFY,
837
    'caption' => _MI_TDMDOWNLOADS_GLOBAL_FILESUBMIT_NOTIFYCAP,
838
    'description' => _MI_TDMDOWNLOADS_GLOBAL_FILESUBMIT_NOTIFYDSC,
839
    'mail_template' => 'global_filesubmit_notify',
840
    'mail_subject' => _MI_TDMDOWNLOADS_GLOBAL_FILESUBMIT_NOTIFYSBJ,
841
];
842
843
$modversion['notification']['event'][] = [
844
    'name' => 'file_broken',
845
    'category' => 'global',
846
    'admin_only' => 1,
847
    'title' => _MI_TDMDOWNLOADS_GLOBAL_FILEBROKEN_NOTIFY,
848
    'caption' => _MI_TDMDOWNLOADS_GLOBAL_FILEBROKEN_NOTIFYCAP,
849
    'description' => _MI_TDMDOWNLOADS_GLOBAL_FILEBROKEN_NOTIFYDSC,
850
    'mail_template' => 'global_filebroken_notify',
851
    'mail_subject' => _MI_TDMDOWNLOADS_GLOBAL_FILEBROKEN_NOTIFYSBJ,
852
];
853
854
$modversion['notification']['event'][] = [
855
    'name' => 'new_file',
856
    'category' => 'global',
857
    'title' => _MI_TDMDOWNLOADS_GLOBAL_NEWFILE_NOTIFY,
858
    'caption' => _MI_TDMDOWNLOADS_GLOBAL_NEWFILE_NOTIFYCAP,
859
    'description' => _MI_TDMDOWNLOADS_GLOBAL_NEWFILE_NOTIFYDSC,
860
    'mail_template' => 'global_newfile_notify',
861
    'mail_subject' => _MI_TDMDOWNLOADS_GLOBAL_NEWFILE_NOTIFYSBJ,
862
];
863
864
$modversion['notification']['event'][] = [
865
    'name' => 'file_submit',
866
    'category' => 'category',
867
    'admin_only' => 1,
868
    'title' => _MI_TDMDOWNLOADS_CATEGORY_FILESUBMIT_NOTIFY,
869
    'caption' => _MI_TDMDOWNLOADS_CATEGORY_FILESUBMIT_NOTIFYCAP,
870
    'description' => _MI_TDMDOWNLOADS_CATEGORY_FILESUBMIT_NOTIFYDSC,
871
    'mail_template' => 'category_filesubmit_notify',
872
    'mail_subject' => _MI_TDMDOWNLOADS_CATEGORY_FILESUBMIT_NOTIFYSBJ,
873
];
874
875
$modversion['notification']['event'][] = [
876
    'name' => 'new_file',
877
    'category' => 'category',
878
    'title' => _MI_TDMDOWNLOADS_CATEGORY_NEWFILE_NOTIFY,
879
    'caption' => _MI_TDMDOWNLOADS_CATEGORY_NEWFILE_NOTIFYCAP,
880
    'description' => _MI_TDMDOWNLOADS_CATEGORY_NEWFILE_NOTIFYDSC,
881
    'mail_template' => 'category_newfile_notify',
882
    'mail_subject' => _MI_TDMDOWNLOADS_CATEGORY_NEWFILE_NOTIFYSBJ,
883
];
884
885
$modversion['notification']['event'][] = [
886
    'name' => 'approve',
887
    'category' => 'file',
888
    'invisible' => 1,
889
    'title' => _MI_TDMDOWNLOADS_FILE_APPROVE_NOTIFY,
890
    'caption' => _MI_TDMDOWNLOADS_FILE_APPROVE_NOTIFYCAP,
891
    'description' => _MI_TDMDOWNLOADS_FILE_APPROVE_NOTIFYDSC,
892
    'mail_template' => 'file_approve_notify',
893
    'mail_subject' => _MI_TDMDOWNLOADS_FILE_APPROVE_NOTIFYSBJ,
894
];
895