1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Module: WF-Links |
4
|
|
|
* Version: v1.0.3 |
5
|
|
|
* Release Date: 21 June 2005 |
6
|
|
|
* Developer: John N |
7
|
|
|
* Team: WF-Projects |
8
|
|
|
* Licence: GNU |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
use Xmf\Request; |
12
|
|
|
use XoopsModules\Wflinks; |
13
|
|
|
|
14
|
|
|
require_once __DIR__ . '/admin_header.php'; |
15
|
|
|
|
16
|
|
|
/** @var Wflinks\Helper $helper */ |
17
|
|
|
$helper = Wflinks\Helper::getInstance(); |
18
|
|
|
|
19
|
|
|
$op = (isset($_REQUEST['op']) && !empty($_REQUEST['op'])) ? $_REQUEST['op'] : ''; |
20
|
|
|
$rootpath = Request::getInt('rootpath', 0, 'GET'); |
21
|
|
|
|
22
|
|
|
switch (mb_strtolower($op)) { |
23
|
|
|
case 'upload': |
24
|
|
|
if ('' !== $_FILES['uploadfile']['name']) { |
25
|
|
|
if (file_exists(XOOPS_ROOT_PATH . '/' . $_POST['uploadpath'] . '/' . $_FILES['uploadfile']['name'])) { |
26
|
|
|
redirect_header('upload.php', 2, _AM_WFL_LINK_IMAGEEXIST); |
27
|
|
|
} |
28
|
|
|
$allowed_mimetypes = ['image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png']; |
29
|
|
|
Wflinks\Utility::uploadFiles($_FILES, $_POST['uploadpath'], $allowed_mimetypes, 'upload.php', 1, 0); |
|
|
|
|
30
|
|
|
redirect_header('upload.php', 2, _AM_WFL_LINK_IMAGEUPLOAD); |
31
|
|
|
} else { |
32
|
|
|
redirect_header('upload.php', 2, _AM_WFL_LINK_NOIMAGEEXIST); |
33
|
|
|
} |
34
|
|
|
break; |
35
|
|
|
case 'delfile': |
36
|
|
|
|
37
|
|
|
if (Request::hasVar('confirm', 'POST') && 1 == $_POST['confirm']) { |
38
|
|
|
$filetodelete = XOOPS_ROOT_PATH . '/' . $_POST['uploadpath'] . '/' . $_POST['linkfile']; |
39
|
|
|
if (file_exists($filetodelete)) { |
40
|
|
|
chmod($filetodelete, 0666); |
41
|
|
|
if (@unlink($filetodelete)) { |
42
|
|
|
redirect_header('upload.php', 1, _AM_WFL_LINK_FILEDELETED); |
43
|
|
|
} else { |
44
|
|
|
redirect_header('upload.php', 1, _AM_WFL_LINK_FILEERRORDELETE); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
exit(); |
48
|
|
|
} |
49
|
|
|
if (empty($_POST['linkfile'])) { |
50
|
|
|
redirect_header('upload.php', 1, _AM_WFL_LINK_NOFILEERROR); |
51
|
|
|
} |
52
|
|
|
xoops_cp_header(); |
53
|
|
|
xoops_confirm( |
54
|
|
|
[ |
55
|
|
|
'op' => 'delfile', |
56
|
|
|
'uploadpath' => $_POST['uploadpath'], |
57
|
|
|
'linkfile' => $_POST['linkfile'], |
58
|
|
|
'confirm' => 1, |
59
|
|
|
], |
60
|
|
|
'upload.php', |
61
|
|
|
_AM_WFL_LINK_DELETEFILE . '<br><br>' . $_POST['linkfile'], |
62
|
|
|
_AM_WFL_BDELETE |
63
|
|
|
); |
64
|
|
|
|
65
|
|
|
break; |
66
|
|
|
case 'default': |
67
|
|
|
default: |
68
|
|
|
$displayimage = ''; |
69
|
|
|
xoops_cp_header(); |
70
|
|
|
|
71
|
|
|
$dirarray = [ |
72
|
|
|
1 => $helper->getConfig('catimage'), |
73
|
|
|
2 => $helper->getConfig('screenshots'), |
74
|
|
|
3 => $helper->getConfig('mainimagedir'), |
75
|
|
|
]; |
76
|
|
|
$namearray = [1 => _AM_WFL_LINK_CATIMAGE, 2 => _AM_WFL_LINK_SCREENSHOTS, 3 => _AM_WFL_LINK_MAINIMAGEDIR]; |
77
|
|
|
$listarray = [ |
78
|
|
|
1 => _AM_WFL_LINK_FCATIMAGE, |
79
|
|
|
2 => _AM_WFL_LINK_FSCREENSHOTS, |
80
|
|
|
3 => _AM_WFL_LINK_FMAINIMAGEDIR, |
81
|
|
|
]; |
82
|
|
|
|
83
|
|
|
Wflinks\Utility::getServerStats(); |
84
|
|
|
if ($rootpath > 0) { |
85
|
|
|
echo '<div><b>' . _AM_WFL_LINK_FUPLOADPATH . '</b> ' . XOOPS_ROOT_PATH . '/' . $dirarray[$rootpath] . "</div>\n"; |
86
|
|
|
echo '<div><b>' . _AM_WFL_LINK_FUPLOADURL . '</b> ' . XOOPS_URL . '/' . $dirarray[$rootpath] . "</div><br>\n"; |
87
|
|
|
} |
88
|
|
|
$pathlist = isset($listarray[$rootpath]) ? $namearray[$rootpath] : ''; |
89
|
|
|
$namelist = isset($listarray[$rootpath]) ? $namearray[$rootpath] : ''; |
90
|
|
|
|
91
|
|
|
$iform = new \XoopsThemeForm(_AM_WFL_LINK_FUPLOADIMAGETO . $pathlist, 'op', xoops_getenv('SCRIPT_NAME'), 'post', true); |
92
|
|
|
$iform->setExtra('enctype="multipart/form-data"'); |
93
|
|
|
ob_start(); |
94
|
|
|
$iform->addElement(new \XoopsFormHidden('dir', $rootpath)); |
95
|
|
|
Wflinks\Utility::getDirSelectOption($namelist, $dirarray, $namearray); |
96
|
|
|
$iform->addElement(new \XoopsFormLabel(_AM_WFL_LINK_FOLDERSELECTION, ob_get_clean())); |
97
|
|
|
|
98
|
|
|
if ($rootpath > 0) { |
99
|
|
|
$graph_array = Wflinks\Lists::getListTypeAsArray(XOOPS_ROOT_PATH . '/' . $dirarray[$rootpath], $type = 'images'); |
100
|
|
|
$indeximage_select = new \XoopsFormSelect('', 'linkfile', ''); |
101
|
|
|
$indeximage_select->addOptionArray($graph_array); |
102
|
|
|
$indeximage_select->setExtra("onchange='showImgSelected(\"image\", \"linkfile\", \"" . $dirarray[$rootpath] . '", "", "' . XOOPS_URL . "\")'"); |
103
|
|
|
$indeximage_tray = new \XoopsFormElementTray(_AM_WFL_LINK_FSHOWSELECTEDIMAGE, ' '); |
104
|
|
|
$indeximage_tray->addElement($indeximage_select); |
105
|
|
|
if (!empty($imgurl)) { |
106
|
|
|
$indeximage_tray->addElement(new \XoopsFormLabel('', "<br><br><img src='" . XOOPS_URL . '/' . $dirarray[$rootpath] . '/' . $linkfile . "' name='image' id='image' alt=''>")); |
107
|
|
|
} else { |
108
|
|
|
$indeximage_tray->addElement(new \XoopsFormLabel('', "<br><br><img src='" . XOOPS_URL . "/uploads/blank.gif' name='image' id='image' alt=''>")); |
109
|
|
|
} |
110
|
|
|
$iform->addElement($indeximage_tray); |
111
|
|
|
$iform->addElement(new \XoopsFormFile(_AM_WFL_LINK_FUPLOADIMAGE, 'uploadfile', 0)); |
112
|
|
|
$iform->addElement(new \XoopsFormHidden('uploadpath', $dirarray[$rootpath])); |
113
|
|
|
$iform->addElement(new \XoopsFormHidden('rootnumber', $rootpath)); |
114
|
|
|
|
115
|
|
|
$dup_tray = new \XoopsFormElementTray('', ''); |
116
|
|
|
$dup_tray->addElement(new \XoopsFormHidden('op', 'upload')); |
117
|
|
|
$butt_dup = new \XoopsFormButton('', '', _AM_WFL_BUPLOAD, 'submit'); |
118
|
|
|
$butt_dup->setExtra('onclick="this.form.elements.op.value=\'upload\'"'); |
119
|
|
|
$dup_tray->addElement($butt_dup); |
120
|
|
|
|
121
|
|
|
$butt_dupct = new \XoopsFormButton('', '', _AM_WFL_BDELETEIMAGE, 'submit'); |
122
|
|
|
$butt_dupct->setExtra('onclick="this.form.elements.op.value=\'delfile\'"'); |
123
|
|
|
$dup_tray->addElement($butt_dupct); |
124
|
|
|
$iform->addElement($dup_tray); |
125
|
|
|
} |
126
|
|
|
$iform->display(); |
127
|
|
|
} |
128
|
|
|
require_once __DIR__ . '/admin_footer.php'; |
129
|
|
|
|