Completed
Push — master ( 3024c9...954431 )
by Michael
04:21
created

admin/upload.php (9 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Module: XoopsTube
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
 *
9
 * PHP version 5
10
 *
11
 * @category        Module
12
 * @package         Xoopstube
13
 * @author          XOOPS Development Team
14
 * @copyright       2001-2016 XOOPS Project (http://xoops.org)
15
 * @license         GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
16
 * @link            http://xoops.org/
17
 * @since           1.0.6
18
 */
19
20
include_once __DIR__ . '/admin_header.php';
21
22
//$op       = (isset($_REQUEST['op']) && !empty($_REQUEST['op'])) ? $_REQUEST['op'] : '';
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
23
//$rootpath = (isset($_GET['rootpath'])) ? (int) $_GET['rootpath'] : 0;
24
25
$op       = XoopsRequest::getCmd('op', XoopsRequest::getCmd('op', '', 'POST'), 'GET');
26
$rootpath = XoopsRequest::getInt('rootpath', 0, 'GET');
27
28
switch (strtolower($op)) {
29
    case 'upload':
30
        if ($_FILES['uploadfile']['name'] !== '') {
31 View Code Duplication
            if (file_exists(XOOPS_ROOT_PATH . '/' . XoopsRequest::getString('uploadpath', '', 'POST') . '/' . $_FILES['uploadfile']['name'])) {
32
                redirect_header('upload.php', 2, _AM_XOOPSTUBE_VIDEO_IMAGEEXIST);
33
            }
34
            $allowed_mimetypes = array(
35
                'image/gif',
36
                'image/jpeg',
37
                'image/pjpeg',
38
                'image/x-png',
39
                'image/png',
40
                'media/flv'
41
            );
42
            XoopstubeUtilities::xtubeUploadFiles($_FILES, XoopsRequest::getString('uploadpath', '', 'POST'), $allowed_mimetypes, 'upload.php', 1, 0);
43
            redirect_header('upload.php', 2, _AM_XOOPSTUBE_VIDEO_IMAGEUPLOAD);
44
        } else {
45
            redirect_header('upload.php', 2, _AM_XOOPSTUBE_VIDEO_NOIMAGEEXIST);
46
        }
47
        break;
48
49 View Code Duplication
    case 'delfile':
50
51
        if (1 == XoopsRequest::getInt('confirm', '', 'POST')) { // isset($_POST['confirm']) && $_POST['confirm'] == 1) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
69% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
52
            $filetodelete = XOOPS_ROOT_PATH . '/' . XoopsRequest::getString('uploadpath', '', 'POST') . '/' . XoopsRequest::getString('videofile', '', 'POST');
53
            if (file_exists($filetodelete)) {
54
                chmod($filetodelete, 0666);
55
                if (@unlink($filetodelete)) {
56
                    redirect_header('upload.php', 1, _AM_XOOPSTUBE_VIDEO_FILEDELETED);
57
                } else {
58
                    redirect_header('upload.php', 1, _AM_XOOPSTUBE_VIDEO_FILEERRORDELETE);
59
                }
60
            }
61
        } else {
62
            //            if (empty($_POST['videofile'])) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
79% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
63
            if (!XoopsRequest::getString('videofile', '', 'POST')) {
64
                redirect_header('upload.php', 1, _AM_XOOPSTUBE_VIDEO_NOFILEERROR);
65
            }
66
            xoops_cp_header();
67
            xoops_confirm(array(
68
                              'op'         => 'delfile',
69
                              'uploadpath' => XoopsRequest::getString('uploadpath', '', 'POST'),
70
                              'videofile'  => XoopsRequest::getString('videofile', '', 'POST'),
71
                              'confirm'    => 1
72
                          ), 'upload.php', _AM_XOOPSTUBE_VIDEO_DELETEFILE . '<br><br>' . XoopsRequest::getString('videofile', '', 'POST'), _AM_XOOPSTUBE_BDELETE);
73
        }
74
        break;
75
76
    case 'default':
77
    default:
78
        $displayimage = '';
79
        xoops_cp_header();
80
        $aboutAdmin = new ModuleAdmin();
81
        echo $aboutAdmin->addNavigation(basename(__FILE__));
82
83
        $dirarray  = array(
84
            1 => $GLOBALS['xoopsModuleConfig']['catimage'],
85
            2 => $GLOBALS['xoopsModuleConfig']['mainimagedir'],
86
            3 => $GLOBALS['xoopsModuleConfig']['videoimgdir']
87
        );
88
        $namearray = array(
89
            1 => _AM_XOOPSTUBE_VIDEO_CATIMAGE,
90
            2 => _AM_XOOPSTUBE_VIDEO_MAINIMAGEDIR,
91
            3 => _AM_XOOPSTUBE_VIDEO_CATVIDEOIMG
92
        );
93
        $listarray = array(
94
            1 => _AM_XOOPSTUBE_VIDEO_FCATIMAGE,
95
            2 => _AM_XOOPSTUBE_VIDEO_FMAINIMAGEDIR,
96
            3 => _AM_XOOPSTUBE_VIDEO_FCATVIDEOIMG
97
        );
98
99
        //    $dirarray  = array(
100
        //        1 => $GLOBALS['xoopsModuleConfig']['catimage'],
0 ignored issues
show
Unused Code Comprehensibility introduced by
77% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
101
        //        2 => $GLOBALS['xoopsModuleConfig']['mainimagedir']
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
102
        //    );
103
        //    $namearray = array(
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
104
        //        1 => _AM_XOOPSTUBE_VIDEO_CATIMAGE,
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
105
        //        2 => _AM_XOOPSTUBE_VIDEO_MAINIMAGEDIR
106
        //    );
107
        //    $listarray = array(
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
108
        //        1 => _AM_XOOPSTUBE_VIDEO_FCATIMAGE,
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
109
        //        2 => _AM_XOOPSTUBE_VIDEO_FMAINIMAGEDIR
110
        //    );
111
112
        //xtubeRenderAdminMenu( _AM_XOOPSTUBE_MUPLOADS );
113
        XoopstubeUtilities::xtubeGetServerStatistics();
114 View Code Duplication
        if ($rootpath > 0) {
115
            echo '<div><b>' . _AM_XOOPSTUBE_VIDEO_FUPLOADPATH . '</b> ' . XOOPS_ROOT_PATH . '/' . $dirarray[$rootpath] . '</div>';
116
            echo '<div><b>' . _AM_XOOPSTUBE_VIDEO_FUPLOADURL . '</b> ' . XOOPS_URL . '/' . $dirarray[$rootpath] . '</div><br>';
117
        }
118
        $pathlist = isset($listarray[$rootpath]) ? $namearray[$rootpath] : '';
119
        $namelist = isset($listarray[$rootpath]) ? $namearray[$rootpath] : '';
120
121
        $iform = new XoopsThemeForm(_AM_XOOPSTUBE_VIDEO_FUPLOADIMAGETO . $pathlist, 'op', xoops_getenv('PHP_SELF'));
122
        $iform->setExtra('enctype="multipart/form-data"');
123
        ob_start();
124
        $iform->addElement(new XoopsFormHidden('dir', $rootpath));
125
        XoopstubeUtilities::xtubeGetDirSelectOption($namelist, $dirarray, $namearray);
126
        $iform->addElement(new XoopsFormLabel(_AM_XOOPSTUBE_VIDEO_FOLDERSELECTION, ob_get_contents()));
127
        ob_end_clean();
128
129
        if ($rootpath > 0) {
130
            $graph_array      = &XoopstubeLists:: getListTypeAsArray(XOOPS_ROOT_PATH . '/' . $dirarray[$rootpath], $type = 'images');
131
            $indexImageSelect = new XoopsFormSelect('', 'videofile', '');
132
            $indexImageSelect->addOptionArray($graph_array);
133
            $indexImageSelect->setExtra("onchange='showImgSelected(\"image\", \"videofile\", \"" . $dirarray[$rootpath] . "\", \"\", \"" . XOOPS_URL . "\")'");
134
            $indeximage_tray = new XoopsFormElementTray(_AM_XOOPSTUBE_VIDEO_FSHOWSELECTEDIMAGE, '&nbsp;');
135
            $indeximage_tray->addElement($indexImageSelect);
136 View Code Duplication
            if (!empty($imgurl)) {
137
                $indeximage_tray->addElement(new XoopsFormLabel('', '<br><br><img src="' . XOOPS_URL . '/' . $dirarray[$rootpath] . '/' . $videofile . '" name="image" id="image" alt"" />'));
138
            } else {
139
                $indeximage_tray->addElement(new XoopsFormLabel('', '<br><br><img src="' . XOOPS_URL . '/uploads/blank.gif" name="image" id="image" alt="" />'));
140
            }
141
            $iform->addElement($indeximage_tray);
142
143
            $iform->addElement(new XoopsFormFile(_AM_XOOPSTUBE_VIDEO_FUPLOADIMAGE, 'uploadfile', 0));
144
            $iform->addElement(new XoopsFormHidden('uploadpath', $dirarray[$rootpath]));
145
            $iform->addElement(new XoopsFormHidden('rootnumber', $rootpath));
146
147
            $dup_tray = new XoopsFormElementTray('', '');
148
            $dup_tray->addElement(new XoopsFormHidden('op', 'upload'));
149
            $butt_dup = new XoopsFormButton('', '', _AM_XOOPSTUBE_BUPLOAD, 'submit');
150
            $butt_dup->setExtra('onclick="this.form.elements.op.value=\'upload\'"');
151
            $dup_tray->addElement($butt_dup);
152
153
            $butt_dupct = new XoopsFormButton('', '', _AM_XOOPSTUBE_BDELETEIMAGE, 'submit');
154
            $butt_dupct->setExtra('onclick="this.form.elements.op.value=\'delfile\'"');
155
            $dup_tray->addElement($butt_dupct);
156
            $iform->addElement($dup_tray);
157
        }
158
        $iform->display();
159
}
160
include_once __DIR__ . '/admin_footer.php';
161