|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* XoopsTube - a multicategory video management module |
|
4
|
|
|
* |
|
5
|
|
|
* Based upon WF-Links |
|
6
|
|
|
* |
|
7
|
|
|
* File: admin/vupload.php |
|
8
|
|
|
* |
|
9
|
|
|
* @copyright https://xoops.org/ XOOPS Project |
|
10
|
|
|
* @copyright XOOPS_copyrights.txt |
|
11
|
|
|
* @copyright http://www.impresscms.org/ The ImpressCMS Project |
|
12
|
|
|
* @license GNU General Public License (GPL) |
|
13
|
|
|
* a copy of the GNU license is enclosed. |
|
14
|
|
|
* ---------------------------------------------------------------------------------------------------------- |
|
15
|
|
|
* @package WF-Links |
|
16
|
|
|
* @since 1.03 |
|
17
|
|
|
* @author John N |
|
18
|
|
|
* ---------------------------------------------------------------------------------------------------------- |
|
19
|
|
|
* XoopsTube |
|
20
|
|
|
* @since 1.00 |
|
21
|
|
|
* @author McDonald |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
use Xmf\Module\Admin; |
|
25
|
|
|
use Xmf\Request; |
|
26
|
|
|
use XoopsModules\Xoopstube\{ |
|
27
|
|
|
Lists, |
|
28
|
|
|
Utility |
|
29
|
|
|
}; |
|
30
|
|
|
|
|
31
|
|
|
require_once __DIR__ . '/admin_header.php'; |
|
32
|
|
|
|
|
33
|
|
|
//$op = (isset($_REQUEST['op']) && !empty($_REQUEST['op'])) ? $_REQUEST['op'] : ''; |
|
34
|
|
|
//$rootpath = (isset($_GET['rootpath'])) ? (int) $_GET['rootpath'] : 0; |
|
35
|
|
|
|
|
36
|
|
|
$op = Request::getCmd('op', Request::getCmd('op', '', 'POST'), 'GET'); |
|
37
|
|
|
$rootpath = Request::getInt('rootpath', 0, 'GET'); |
|
38
|
|
|
|
|
39
|
|
|
switch (mb_strtolower($op)) { |
|
40
|
|
|
case 'vupload': |
|
41
|
|
|
if ('' !== $_FILES['uploadfile']['name']) { |
|
42
|
|
|
if (file_exists(XOOPS_ROOT_PATH . '/' . Request::getString('uploadpath', '', 'POST') . '/' . $_FILES['uploadfile']['name'])) { |
|
43
|
|
|
redirect_header('vupload.php', 2, _AM_XOOPSTUBE_VUPLOAD_VIDEOEXIST); |
|
44
|
|
|
} |
|
45
|
|
|
$allowed_mimetypes = 'media/aac, media/flv, media/mp3, media/mp4'; |
|
46
|
|
|
Utility::uploadFiles($_FILES, Request::getString('uploadpath', '', 'POST'), $allowed_mimetypes, 'vupload.php', 1, 0); |
|
47
|
|
|
redirect_header('vupload.php', 2, _AM_XOOPSTUBE_VUPLOAD_VIDEOUPLOAD); |
|
48
|
|
|
} else { |
|
49
|
|
|
redirect_header('vupload.php', 2, _AM_XOOPSTUBE_VUPLOAD_NOVIDEOEXIST); |
|
50
|
|
|
} |
|
51
|
|
|
break; |
|
52
|
|
|
case 'delfile': |
|
53
|
|
|
if (1 == Request::getInt('confirm', '', 'POST')) { //isset($_POST['confirm']) && $_POST['confirm'] == 1) { |
|
|
|
|
|
|
54
|
|
|
$filetodelete = XOOPS_ROOT_PATH . '/' . Request::getString('uploadpath', '', 'POST') . '/' . Request::getString('videofile', '', 'POST'); |
|
55
|
|
|
if (file_exists($filetodelete)) { |
|
56
|
|
|
chmod($filetodelete, 0666); |
|
57
|
|
|
if (@unlink($filetodelete)) { |
|
58
|
|
|
redirect_header('vupload.php', 1, _AM_XOOPSTUBE_VUPLOAD_FILEDELETED); |
|
59
|
|
|
} else { |
|
60
|
|
|
redirect_header('vupload.php', 1, _AM_XOOPSTUBE_VUPLOAD_FILEERRORDELETE); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
} else { |
|
64
|
|
|
// if (empty($_POST['videofile'])) { |
|
65
|
|
|
if (!Request::hasVar('videofile', 'POST')) { |
|
66
|
|
|
redirect_header('vupload.php', 1, _AM_XOOPSTUBE_VUPLOAD_NOFILEERROR); |
|
67
|
|
|
} |
|
68
|
|
|
xoops_cp_header(); |
|
69
|
|
|
xoops_confirm( |
|
70
|
|
|
[ |
|
71
|
|
|
'op' => 'delfile', |
|
72
|
|
|
'uploadpath' => Request::getString('uploadpath', '', 'POST'), |
|
73
|
|
|
'videofile' => Request::getString('videofile', '', 'POST'), |
|
74
|
|
|
'confirm' => 1, |
|
75
|
|
|
], |
|
76
|
|
|
'vupload.php', |
|
77
|
|
|
_AM_XOOPSTUBE_VUPLOAD_DELETEFILE . '<br><br>' . Request::getString('videofile', '', 'POST'), |
|
78
|
|
|
_AM_XOOPSTUBE_BDELETE |
|
79
|
|
|
); |
|
80
|
|
|
} |
|
81
|
|
|
break; |
|
82
|
|
|
case 'default': |
|
83
|
|
|
default: |
|
84
|
|
|
$displayimage = ''; |
|
85
|
|
|
xoops_cp_header(); |
|
86
|
|
|
$adminObject = Admin::getInstance(); |
|
87
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
|
88
|
|
|
|
|
89
|
|
|
$dirarray = [1 => $GLOBALS['xoopsModuleConfig']['videodir']]; |
|
90
|
|
|
$namearray = [1 => _AM_XOOPSTUBE_VUPLOAD_CATVIDEO]; |
|
91
|
|
|
$listarray = [1 => _AM_XOOPSTUBE_VUPLOAD_FCATVIDEO]; |
|
92
|
|
|
|
|
93
|
|
|
//renderAdminMenu( _AM_XOOPSTUBE_VUPLOADS ); |
|
94
|
|
|
|
|
95
|
|
|
if ($rootpath > 0) { |
|
96
|
|
|
echo '<div><b> ' . _AM_XOOPSTUBE_VUPLOAD_FUPLOADPATH . '</b> ' . XOOPS_ROOT_PATH . '/' . $dirarray[$rootpath] . '</div>'; |
|
97
|
|
|
echo '<div><b> ' . _AM_XOOPSTUBE_VUPLOAD_FUPLOADURL . '</b> ' . XOOPS_URL . '/' . $dirarray[$rootpath] . '</div><br>'; |
|
98
|
|
|
} |
|
99
|
|
|
$pathlist = isset($listarray[$rootpath]) ? $namearray[$rootpath] : ''; |
|
100
|
|
|
$namelist = isset($listarray[$rootpath]) ? $namearray[$rootpath] : ''; |
|
101
|
|
|
|
|
102
|
|
|
$iform = new \XoopsThemeForm(_AM_XOOPSTUBE_VUPLOAD_FUPLOADVIDEOTO . $pathlist, 'op', xoops_getenv('SCRIPT_NAME'), 'post', true); |
|
103
|
|
|
$iform->setExtra('enctype="multipart/form-data"'); |
|
104
|
|
|
ob_start(); |
|
105
|
|
|
$iform->addElement(new \XoopsFormHidden('dir', $rootpath)); |
|
106
|
|
|
Utility::getDirSelectOption($namelist, $dirarray, $namearray); |
|
107
|
|
|
$iform->addElement(new \XoopsFormLabel(_AM_XOOPSTUBE_VUPLOAD_FOLDERSELECTION, ob_get_clean())); |
|
108
|
|
|
|
|
109
|
|
|
if ($rootpath > 0) { |
|
110
|
|
|
$file_array = Lists:: getListTypeAsArray(XOOPS_ROOT_PATH . '/' . $dirarray[$rootpath], $type = 'media'); |
|
111
|
|
|
$indexfile_select = new \XoopsFormSelect('', 'videofile', ''); |
|
112
|
|
|
$indexfile_select->addOptionArray($file_array); |
|
113
|
|
|
$indexfile_select->setExtra("onchange='showImgSelected(\"media\", \"videofile\", \"" . $dirarray[$rootpath] . '", "", "' . XOOPS_URL . "\")'"); |
|
114
|
|
|
$indexfile_tray = new \XoopsFormElementTray(_AM_XOOPSTUBE_VUPLOAD_FSHOWSELECTEDFILE, ' '); |
|
115
|
|
|
$indexfile_tray->addElement($indexfile_select); |
|
116
|
|
|
if (!empty($imgurl)) { |
|
117
|
|
|
$indexfile_tray->addElement(new \XoopsFormLabel('', '<br><br><img src="' . XOOPS_URL . '/' . $dirarray[$rootpath] . '/' . $videofile . '" name="image" id="image" alt="">')); |
|
118
|
|
|
} else { |
|
119
|
|
|
$indexfile_tray->addElement(new \XoopsFormLabel('', '<br><br><img src="' . XOOPS_URL . '/uploads/blank.gif" name="image" id="image" alt="">')); |
|
120
|
|
|
} |
|
121
|
|
|
$iform->addElement($indexfile_tray); |
|
122
|
|
|
|
|
123
|
|
|
$file_tray = new \XoopsFormFile(_AM_XOOPSTUBE_VUPLOAD_FUPLOADVIDEO, 'uploadfile', 0); |
|
124
|
|
|
$file_tray->setDescription('<span style="font-size: small;">' . _AM_XOOPSTUBE_VUPLOAD_FSHOWSELECTEDFILEDSC . '</span>'); |
|
125
|
|
|
$iform->addElement($file_tray); |
|
126
|
|
|
$iform->addElement(new \XoopsFormHidden('uploadpath', $dirarray[$rootpath])); |
|
127
|
|
|
$iform->addElement(new \XoopsFormHidden('rootnumber', $rootpath)); |
|
128
|
|
|
|
|
129
|
|
|
$dup_tray = new \XoopsFormElementTray('', ''); |
|
130
|
|
|
$dup_tray->addElement(new \XoopsFormHidden('op', 'vupload')); |
|
131
|
|
|
$butt_dup = new \XoopsFormButton('', '', _AM_XOOPSTUBE_BUPLOAD, 'submit'); |
|
132
|
|
|
$butt_dup->setExtra('onclick="this.form.elements.op.value=\'vupload\'"'); |
|
133
|
|
|
$dup_tray->addElement($butt_dup); |
|
134
|
|
|
|
|
135
|
|
|
$butt_dupct = new \XoopsFormButton('', '', _AM_XOOPSTUBE_BDELETEVIDEO, 'submit'); |
|
136
|
|
|
$butt_dupct->setExtra('onclick="this.form.elements.op.value=\'delfile\'"'); |
|
137
|
|
|
$dup_tray->addElement($butt_dupct); |
|
138
|
|
|
$iform->addElement($dup_tray); |
|
139
|
|
|
} |
|
140
|
|
|
$iform->display(); |
|
141
|
|
|
} |
|
142
|
|
|
require_once __DIR__ . '/admin_footer.php'; |
|
143
|
|
|
|