Completed
Pull Request — master (#8)
by Michael
02:48
created

include/feeddata.inc.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
 * @param int $limit
4
 * @param int $offset
5
 * @return array
6
 */
7
function mylinks_feednew($limit = 0, $offset = 0)
8
{
9
    global $xoopsDB;
10
11
    $myts      = MyTextSanitizer::getInstance();
12
    $dirname   = basename(dirname(__DIR__));
13
    $moduleURL = XOOPS_URL . "/modules/{$dirname}";
14
15
    $limit  = ((int)$limit > 0) ? (int)$limit : 0;
16
    $offset = ((int)$offset > 0) ? (int)$offset : 0;
17
18
    if (isset($_GET['cid'])) {
19
        $categoryid = ((int)$_GET['cid'] && (int)($_GET['cid'] > 0)) ? (int)$_GET['cid'] : 0;
20
        $sql        = 'SELECT l.lid, l.title as ltitle, l.date, l.cid, l.submitter, l.hits, t.description, c.title as ctitle FROM ' . $xoopsDB->prefix('mylinks_links') . ' l, ' . $xoopsDB->prefix('mylinks_text') . ' t, ' . $xoopsDB->prefix('mylinks_cat')
21
                      . " c WHERE l.cid= {$categoryid} AND t.lid=l.lid AND l.cid=c.cid AND l.status>0 ORDER BY l.date DESC";
22
    } else {
23
        $sql = 'SELECT l.lid, l.title as ltitle, l.date, l.cid, l.submitter, l.hits, t.description, c.title as ctitle FROM ' . $xoopsDB->prefix('mylinks_links') . ' l, ' . $xoopsDB->prefix('mylinks_text') . ' t, ' . $xoopsDB->prefix('mylinks_cat')
24
               . ' c WHERE t.lid=l.lid AND l.cid=c.cid AND l.status>0 ORDER BY l.date DESC';
25
    }
26
27
    $result = $xoopsDB->query($sql, $limit, $offset);
28
29
    $i   = 0;
30
    $ret = array();
31
32 View Code Duplication
    while ($row = $xoopsDB->fetchArray($result)) {
33
        $ret[$i]['link']     = "{$moduleURL}/singlelink.php?lid={$row['lid']}";
34
        $ret[$i]['cat_link'] = "{$moduleURL}/viewcat.php?cid={$row['cid']}";
35
        $ret[$i]['title']    = $row['ltitle'];    // link title
36
        $ret[$i]['time']     = $row['date'];       // date
37
        //        $ret[$i]['description'] = $row['description'];
38
        $ret[$i]['id']          = $row['lid'];          // atom feed
39
        $ret[$i]['description'] = $myts->displayTarea($row['description'], 0);    //no html
40
        $ret[$i]['cat_name']    = $row['ctitle']; // category
41
        $ret[$i]['hits']        = $row['hits'];       // counter
42
        //        $ret[$i]['uid'] = $row['submitter'];   // user name
0 ignored issues
show
Unused Code Comprehensibility introduced by
71% 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...
43
        $i++;
44
    }
45
46
    return $ret;
47
}
48