Completed
Push — master ( 954431...eec6a1 )
by Michael
12s
created

newlist.php (1 issue)

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
/**
4
 * Module: XoopsTube
5
 *
6
 * You may not change or alter any portion of this comment or credits
7
 * of supporting developers from this source code or any supporting source code
8
 * which is considered copyrighted (c) material of the original comment or credit authors.
9
 *
10
 * PHP version 5
11
 *
12
 * @category        Module
13
 * @package         Xoopstube
14
 * @author          XOOPS Development Team
15
 * @copyright       2001-2016 XOOPS Project (http://xoops.org)
16
 * @license         GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
17
 * @since           1.0.6
18
 * @link            http://xoops.org/
19
 */
20
21
include __DIR__ . '/header.php';
22
23
$xoopsOption['template_main'] = 'xoopstube_newlistindex.tpl';
24
include XOOPS_ROOT_PATH . '/header.php';
25
$xoTheme->addStylesheet('modules/'.$moduleDirName.'/assets/css/xtubestyle.css');
26
27
global $xoopsModule;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
28
29
$catarray['imageheader'] = XoopstubeUtilities::xtubeRenderImageHeader();
30
$xoopsTpl->assign('catarray', $catarray);
31
32
if (!isset($_GET['newvideoshowdays'])){
33
    redirect_header('newlist.php?newvideoshowdays=7',1,'');
34
}
35
36
if (XoopsRequest::getInt('newvideoshowdays', '', 'GET')) {
37
    $newvideoshowdays = XoopsRequest::getInt('newvideoshowdays', 7, 'GET');
38
    if ($newvideoshowdays !== 7) {
39
        if ($newvideoshowdays !== 14) {
40
            if ($newvideoshowdays !== 30) {
41
                redirect_header('newlist.php?newvideoshowdays=7', 5,
42
                                _MD_XOOPSTUBE_STOPIT . '<br><img src="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/images/icon/security.png" />');
43
            }
44
        }
45
    }
46
    $time_cur       = time();
47
    $duration       = ($time_cur - (86400 * 30));
48
    $duration_week  = ($time_cur - (86400 * 7));
49
    $allmonthvideos = 0;
50
    $allweekvideos  = 0;
51
    $result         =
52
        $GLOBALS['xoopsDB']->query('SELECT lid, cid, published, updated FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE (published >= ' . $duration . ' AND published <= '
53
                                   . $time_cur . ') OR updated >= ' . $duration . ' AND (expired = 0 OR expired > ' . $time_cur . ') AND offline = 0');
54
55
    while (false !== ($myrow = $GLOBALS['xoopsDB']->fetcharray($result))) {
56
        $published = ($myrow['updated'] > 0) ? $myrow['updated'] : $myrow['published'];
57
        ++$allmonthvideos;
58
        if ($published > $duration_week) {
59
            ++$allweekvideos;
60
        }
61
    }
62
    $xoopsTpl->assign('allweekvideos', $allweekvideos);
63
    $xoopsTpl->assign('allmonthvideos', $allmonthvideos);
64
65
    // List Last VARIABLE Days of videos
66
    //  $newvideoshowdays = xtubeCleanRequestVars($_REQUEST, 'newvideoshowdays', 7 );
67
    $newvideoshowdays = (int)XoopsRequest::getInt('newvideoshowdays', 7, 'GET');
68
    $xoopsTpl->assign('newvideoshowdays', $newvideoshowdays);
69
    
70
    $dailyvideos = array();
71
    for ($i = 0; $i < $newvideoshowdays; ++$i) {
72
        $key                                 = $newvideoshowdays - $i - 1;
73
        $time                                = $time_cur - (86400 * $key);
74
        $dailyvideos[$key]['newvideodayRaw'] = $time;
75
        $dailyvideos[$key]['newvideoView']   = XoopstubeUtilities::xtubeGetTimestamp(formatTimestamp($time, $GLOBALS['xoopsModuleConfig']['dateformat']));
76
        
77
         $dailyvideos[$key]['totalvideos']  = 0;
78
        
79
    }
80
}
81
82
$duration = ($time_cur - (86400 * ($newvideoshowdays - 1)));
83
$result   =
84
    $GLOBALS['xoopsDB']->query('SELECT lid, cid, published, updated FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE (published > ' . $duration . ' AND published <= ' . $time_cur
85
                               . ') OR (updated >= ' . $duration . ' AND updated <= ' . $time_cur . ') AND (expired = 0 OR expired > ' . $time_cur . ') AND offline = 0');
86
while (false !== ($myrow = $GLOBALS['xoopsDB']->fetcharray($result))) {
87
    $published = ($myrow['updated'] > 0) ? date($GLOBALS['xoopsModuleConfig']['dateformat'], $myrow['updated']) : date($GLOBALS['xoopsModuleConfig']['dateformat'], $myrow['published']);
88
    $d         = date('j', $published);
89
    $m         = date('m', $published);
90
    $y         = date('Y', $published);
91
    $key       = (int)($time_cur - mktime(0, 0, 0, $m, $d, $y) / 86400);
92
    $dailyvideos[$key]['totalvideos']++;
93
}
94
ksort($dailyvideos);
95
reset($dailyvideos);
96
$xoopsTpl->assign('dailyvideos', $dailyvideos);
97
unset($dailyvideos);
98
99
$mytree = new XoopstubeTree($GLOBALS['xoopsDB']->prefix('xoopstube_cat'), 'cid', 'pid');
100
$sql    = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos');
101
$sql .= 'WHERE (published > 0 AND published <= ' . $time_cur . ')
102
         OR (updated > 0 AND updated <= ' . $time_cur . ')
103
         AND (expired = 0 OR expired > ' . $time_cur . ')
104
         AND offline = 0
105
         ORDER BY ' . $GLOBALS['xoopsModuleConfig']['linkxorder'];
106
$result = $GLOBALS['xoopsDB']->query($sql, 10, 0);
107
while (false !== ($video_arr = $GLOBALS['xoopsDB']->fetchArray($result))) {
108
    include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/videoloadinfo.php';
109
}
110
111
$xoopsTpl->assign('back', '<a href="javascript:history.go(-1)"><img src="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/images/icon/back.png" /></a>');
112
$xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname'));
113
include XOOPS_ROOT_PATH . '/footer.php';
114