Completed
Push — master ( 9a673a...c804e0 )
by Michael
04:20 queued 10s
created

sitemap.xml.php (3 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
 * Xoositemap module
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       The XOOPS Project http://sourceforge.net/projects/xoops/
13
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
14
 * @package         Xoositemap
15
 * @since           2.6.0
16
 * @author          Laurent JEN (Aka DuGris)
17
 */
18
19
if (file_exists('mainfile.php')) {
20
    include __DIR__ . '/mainfile.php';
21
} else {
22
    include '../../mainfile.php';
23
}
24
$xoops = Xoops::getInstance();
25
$xoops->disableErrorReporting();
26
27
if (function_exists('mb_http_output')) {
28
    mb_http_output('pass');
29
}
30
header('Content-Type:text/xml; charset=utf-8');
31
32
$dirname = $xoops->isModule() ? $xoops->module->getVar('dirname') : 'system';
33
$tpl     = new XoopsTpl();
34
//$tpl->caching = 2;
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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...
35
//$tpl->cache_lifetime = 3600;
36
//if (!$tpl->is_cached('module:xoositemap/xoositemap_xml.html')) {
37
38
if ($xoops->isModule()) {
39
    $plugin = \Xoops\Module\Plugin::getPlugin($dirname, 'xoositemap');
40
    $res    = $plugin->Xoositemap_xml(true);
41 View Code Duplication
    if (is_array($res)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
42
        $time       = isset($res['time']) ? $res['time'] : time();
43
        $mod_time[] = array('time' => $time);
44
        $modules[]  = array(
45
            'time'    => $time,
46
            'dirname' => $res['dirname'],
47
            'date'    => gmdate('Y-m-d\TH:i:s\Z', $time),);
48
        if (count($res['items']) > 0) {
49
            foreach ($res['items'] as $item) {
50
                $times[] = array('time' => $item['time']);
51
                $items[] = array(
52
                    'time' => $item['time'],
53
                    'date' => gmdate('Y-m-d\TH:i:s\Z', $item['time']),
54
                    'link' => $item['url'],);
55
            }
56
        }
57
    }
58
} else {
59
    $plugins = \Xoops\Module\Plugin::getPlugins('xoositemap');
60
    foreach ($plugins as $plugin) {
61
        $res = $plugin->Xoositemap_xml(true);
62 View Code Duplication
        if (is_array($res)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
63
            $time       = isset($res['time']) ? $res['time'] : time();
64
            $mod_time[] = array('time' => $time);
65
            $modules[]  = array(
66
                'time'    => $time,
67
                'dirname' => $res['dirname'],
68
                'date'    => gmdate('Y-m-d\TH:i:s\Z', $time),);
69
            if (count($res['items']) > 0) {
70
                foreach ($res['items'] as $item) {
71
                    $times[] = array('time' => $item['time']);
72
                    $items[] = array(
73
                        'time' => $item['time'],
74
                        'date' => gmdate('Y-m-d\TH:i:s\Z', $item['time']),
75
                        'link' => $item['url'],);
76
                }
77
            }
78
        }
79
    }
80
}
81
82
array_multisort($times, SORT_DESC, $items);
83
array_multisort($mod_time, SORT_DESC, $modules);
84
$tpl->assign('items', $items);
85
$tpl->assign('modules', $modules);
86
$tpl->assign('modification', gmdate('Y-m-d\TH:i:s\Z'));
87
//}
88
$tpl->display('module:xoositemap/xoositemap_xml.tpl');
89