Completed
Push — master ( faf584...6fba47 )
by Michael
02:56
created

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: Lexikon - glossary module
5
 * Version: v 1.00
6
 * Release Date: 18 Dec 2011
7
 * Author: Yerres
8
 * Licence: GNU
9
 */
10
11
global $xoopsModule, $xoopsUser;
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...
12
13
include __DIR__ . '/../../mainfile.php';
14
$GLOBALS['xoopsLogger']->activated = false;
15
if (function_exists('mb_http_output')) {
16
    mb_http_output('pass');
17
}
18
//error_reporting(E_ALL |E_ERROR | E_WARNING | E_PARSE);
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% 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...
19
header('Content-Type:text/xml; charset=utf-8');
20
include_once $GLOBALS['xoops']->path('class/template.php');
21
$tpl                 = new XoopsTpl();
22
$tpl->caching        = 0;
23
$tpl->cache_lifetime = 3600;
24
25
$db           = XoopsDatabaseFactory::getDatabaseConnection();
26
$myts         = MyTextSanitizer::getInstance();
27
$category_rss = isset($_GET['categoryID']) ? $_GET['categoryID'] : 0;
28
//permissions
29
$gpermHandler = xoops_getHandler('groupperm');
30
$groups        = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
31
/** @var XoopsModuleHandler $moduleHandler */
32
$moduleHandler = xoops_getHandler('module');
33
$module        = $moduleHandler->getByDirname('lexikon');
34
$module_id     = $module->getVar('mid');
35
$allowed_cats  = $gpermHandler->getItemIds('lexikon_view', $groups, $module_id);
36
$catids        = implode(',', $allowed_cats);
37
$catperms      = " AND categoryID IN ($catids) ";
38
39
if ($category_rss <= 0) {
40
    $result = $db->query('SELECT * FROM ' . $db->prefix('lxentries') . '  WHERE offline=0 ' . $catperms . "  ORDER BY 'datesub' DESC LIMIT 0,50");
41
} else {
42
    $result = $db->query('SELECT * FROM ' . $db->prefix('lxentries') . " WHERE categoryID='$category_rss'  " . $catperms . '  ORDER BY `datesub` DESC LIMIT 0,50');
43
    $info   = $db->fetchArray($db->query('SELECT * FROM ' . $db->prefix('lxcategories') . " WHERE categoryID='$category_rss'"));
44
}
45
if (!$tpl->is_cached('db:lexikon_rss.tpl')) {
46
    xoops_load('XoopsLocal');
47
    if ($category_rss > 0) {
48
        $tpl->assign('channel_title', htmlspecialchars($xoopsConfig['sitename'] . ' - ' . sprintf(_MD_LEXIKON_INCATS, $info['name']), ENT_QUOTES, 'utf-8'));
49
        $tpl->assign('channel_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/category.php?categoryID=' . $category_rss);
50
        $tpl->assign('channel_desc', sprintf(_MD_LEXIKON_INCATS_DESC, $info['name'], $xoopsConfig['sitename']));
51
        $tpl->assign('channel_lastbuild', formatTimestamp(time(), 'rss'));
52
        $tpl->assign('channel_generator', 'XOOPS Lexikon');
53
        $tpl->assign('channel_category', 'Categories');
54
        $tpl->assign('channel_editor', $xoopsConfig['adminmail']);
55
        $tpl->assign('channel_webmaster', $xoopsConfig['adminmail']);
56
        $tpl->assign('channel_language', _LANGCODE);
57
        $tpl->assign('image_url', XOOPS_URL . '/images/logo.gif');
58
        $dimention = getimagesize(XOOPS_ROOT_PATH . '/images/logo.gif');
59 View Code Duplication
        if (empty($dimention[0])) {
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...
60
            $width = 128;
61
        } else {
62
            $width = ($dimention[0] > 128) ? 128 : $dimention[0];
63
        }
64 View Code Duplication
        if (empty($dimention[1])) {
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...
65
            $height = 128;
66
        } else {
67
            $height = ($dimention[1] > 128) ? 128 : $dimention[1];
68
        }
69
        $tpl->assign('image_width', $width);
70
        $tpl->assign('image_height', $height);
71
    } else {
72
        $tpl->assign('channel_title', htmlspecialchars($xoopsConfig['sitename'] . ' - ' . sprintf(_MD_LEXIKON_INCATS, $xoopsModule->getVar('dirname')), ENT_QUOTES, 'utf-8'));
73
        $tpl->assign('channel_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname'));
74
        $tpl->assign('channel_desc', sprintf(_MD_LEXIKON_LASTDESC, $xoopsConfig['sitename']));
75
        $tpl->assign('channel_lastbuild', formatTimestamp(time(), 'rss'));
76
        $tpl->assign('channel_generator', 'XOOPS Lexikon');
77
        $tpl->assign('channel_category', 'Entries');
78
        $tpl->assign('channel_editor', $xoopsConfig['adminmail']);
79
        $tpl->assign('channel_webmaster', $xoopsConfig['adminmail']);
80
        $tpl->assign('channel_language', _LANGCODE);
81
        $tpl->assign('image_url', XOOPS_URL . '/images/logo.gif');
82
        $dimention = getimagesize(XOOPS_ROOT_PATH . '/images/logo.gif');
83 View Code Duplication
        if (empty($dimention[0])) {
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...
84
            $width = 128;
85
        } else {
86
            $width = ($dimention[0] > 128) ? 128 : $dimention[0];
87
        }
88 View Code Duplication
        if (empty($dimention[1])) {
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...
89
            $height = 128;
90
        } else {
91
            $height = ($dimention[1] > 128) ? 128 : $dimention[1];
92
        }
93
        $tpl->assign('image_width', $width);
94
        $tpl->assign('image_height', $height);
95
    }
96
    while ($row = $db->fetchArray($result)) {
97
        $tpl->append('items', array(
98
            'title'       => htmlspecialchars($row['term'], ENT_QUOTES, 'utf-8'),
99
            'link'        => XOOPS_URL . '/modules/lexikon/entry.php?entryID=' . $row['entryID'],
100
            'guid'        => XOOPS_URL . '/modules/lexikon/entry.php?entryID=' . $row['entryID'],
101
            'pubdate'     => formatTimestamp($row['datesub'], 'rss'),
102
            'description' => htmlspecialchars($myts->displayTarea($row['definition'], 1, 1, 1), ENT_QUOTES)
103
        ));
104
    }
105
}
106
$tpl->display('db:lexikon_rss.tpl');
107