Passed
Push — master ( 3a2152...658ebb )
by Goffy
04:30 queued 12s
created

syndication.php (7 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
 *
4
 * Module: Lexikon - glossary module
5
 * Version: v 1.00
6
 * Release Date: 18 Dec 2011
7
 * Author: Yerres
8
 * Licence: GNU
9
 */
10
if (function_exists('mb_http_output')) {
11
    mb_http_output('pass');
12
}
13
include __DIR__ . '/../../mainfile.php';
14
include_once XOOPS_ROOT_PATH . '/header.php';
15
include_once XOOPS_ROOT_PATH . '/class/template.php';
16
$tpl = new XoopsTpl();
17
$tpl->xoops_setCaching(0);
18
19
global $xoopsUser, $xoopsDB, $xoopsConfig, $xoopsModuleConfig;
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...
20
$myts = MyTextSanitizer:: getInstance();
21
22
//if ( !is_object( $xoopsUser ) && $xoopsModuleConfig['contentsyndication'] == 0 ) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% 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
if ($xoopsModuleConfig['contentsyndication'] == 0) {
24
    echo ' ' . _NOPERM . ' ';
25
    exit();
26
}
27
//permissions
28
$groups       = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
29
$gpermHandler = xoops_getHandler('groupperm');
30
$module_id    = $xoopsModule->getVar('mid');
31
32
$tpl->assign('multicats', (int)$xoopsModuleConfig['multicats']);
33
34
// To display the syndicated definition
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% 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
//list($numrows) = $xoopsDB -> fetchRow($xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB -> prefix("lxentries")." WHERE offline = '0' AND submit = '0' AND request = '0'"));
36
$resultX = $xoopsDB->query('
37
    SELECT a.entryID, a.categoryID, a.term, a.offline, b.*
38
    FROM ' . $xoopsDB->prefix('lxentries') . ' a, ' . $xoopsDB->prefix('group_permission') . " b
39
    WHERE a.categoryID = b.gperm_itemid AND b.gperm_modid = $module_id AND b.gperm_name = \"lexikon_view\" AND b.gperm_groupid = $groups[0]  AND offline = '0' AND submit = '0' ");
40
$numrows = $xoopsDB->getRowsNum($resultX);
41
42 View Code Duplication
if ($numrows > 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...
43
    --$numrows;
44
    mt_srand((double)microtime() * 1000000);
45
    $entrynumber = mt_rand(0, $numrows);
46
} else {
47
    $entrynumber = 0;
48
}
49
//$resultZ = $xoopsDB -> query ( " SELECT entryID, categoryID, term, definition FROM ".$xoopsDB->prefix("lxentries")." WHERE offline = '0' AND submit = '0' AND request = '0' LIMIT $entrynumber, 1");
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% 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...
50
$resultZ = $xoopsDB->query('SELECT a.entryID, a.categoryID, a.term, a.definition, a.offline, b.* FROM '
51
                           . $xoopsDB->prefix('lxentries')
52
                           . ' a, '
53
                           . $xoopsDB->prefix('group_permission')
54
                           . " b WHERE a.categoryID = b.gperm_itemid AND b.gperm_modid = $module_id AND b.gperm_name = \"lexikon_view\" AND b.gperm_groupid = $groups[0]  AND a.datesub < "
55
                           . time()
56
                           . " AND a.offline = '0' AND a.submit = '0' LIMIT $entrynumber, 1");
57
58
$zerotest = $xoopsDB->getRowsNum($resultZ);
59
if ($zerotest != 0) {
60
    while ($myrow = $xoopsDB->fetchArray($resultZ)) {
61
        $syndication         = array();
62
        $syndication['id']   = $myrow['entryID'];
63
        $syndication['term'] = ucfirst($myrow['term']);
64 View Code Duplication
        if (!XOOPS_USE_MULTIBYTES) {
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
            $syndication['definition'] = $myts->displayTarea(xoops_substr($myrow['definition'], 0, $xoopsModuleConfig['rndlength'] - 3), 1, 1, 1, 1, 1);
66
            // note: if the definitions are too long try : $xoopsModuleConfig['rndlength'] -20 ) and decrease font-size:x-small below ...
67
        }
68 View Code Duplication
        if ($xoopsModuleConfig['multicats'] == 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...
69
            $syndication['catID'] = $myrow['categoryID'];
70
            $resultY              = $xoopsDB->query('SELECT categoryID, name FROM ' . $xoopsDB->prefix('lxcategories') . ' WHERE categoryID = ' . $myrow['categoryID'] . ' ');
71
            list($categoryID, $name) = $xoopsDB->fetchRow($resultY);
72
            $syndication['categoryname'] = $myts->displayTarea($name);
73
        }
74
    }
75
    $tpl->assign('syndication', $syndication);
76
}
77
$tpl->assign('lang_modulename', $xoopsModule->name());
78
$tpl->assign('lang_moduledirname', $xoopsModule->getVar('dirname'));
79
$tpl->assign('lang_sitename', $xoopsConfig['sitename']);
80
81
$tpl->display('db:lx_syndication.tpl');
82