Completed
Push — master ( 234b0e...1578b3 )
by Michael
14s
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
include '../../mainfile.php';
4
include_once XOOPS_ROOT_PATH . '/class/template.php';
5
error_reporting(0);
6
$modulename = basename(__DIR__);
7
include_once XOOPS_ROOT_PATH . "/modules/{$modulename}/include/feedfunc.new.php";
8
9
$param_array = array(
10
  'show'  => 10,
11
  'image' => 1,
12
  );
13
14
// for debug
15
$cache = 0;
16
17
$new_array = mylinks_get_new($param_array);
18
19
// logo image
20
$logo = 'images/logo.gif';
21
$template = XOOPS_ROOT_PATH . "/modules/{$modulename}/templates/mylinks_rss.html";
22
$RSS_DESC_MAX = 1000;
23
24
// rss output
25
if (function_exists('mb_http_output')) {
26
    mb_http_output('pass');
27
}
28
29
header ('Content-Type:text/xml; charset=utf-8');
30
$tpl = new XoopsTpl();
31
32
if ($cache) {
33
    $tpl->xoops_setCaching(2);
34
    $tpl->xoops_setCacheTime(3600);
35
}
36
37
if (!$tpl->is_cached('file:'.$template) || !$cache) {
38
    if (count($new_array) > 0) {
39
        $tpl->assign('channel_title', wani_utf8_encode(htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)));
40
        $tpl->assign('self_link', XOOPS_URL . "/modules/{$modulename}/rss.php");
41
        $tpl->assign('channel_link', XOOPS_URL . '/');
42
        $tpl->assign('channel_desc', wani_utf8_encode(htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES)));
43
        $tpl->assign('channel_lastbuild', wani_utf8_encode(date('r')));
44
        $tpl->assign('channel_webmaster', $xoopsConfig['adminmail'] . '(' . $xoopsConfig['sitename'] . ')');
45
        $tpl->assign('channel_editor', $xoopsConfig['adminmail'] . '(' . $xoopsConfig['sitename'] . ')');
46
        $tpl->assign('channel_category', 'New Contents of Mylinks');
47
        $tpl->assign('channel_generator', XOOPS_VERSION);
48
        $tpl->assign('channel_language', _LANGCODE);
49
        $tpl->assign('image_url', XOOPS_URL."/$logo");
50
        $tpl->assign('channel_pubdate', wani_utf8_encode(date('r')));
51
//        $tpl->assign('channel_copyright', 'wanisys' );
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
52
53
        $dimention = getimagesize(XOOPS_ROOT_PATH . "/{$logo}");
54
55
        $width  = empty($dimention[0]) ? 88 : ($dimention[0] > 144) ? 144 : $dimention[0];
56
        $height = empty($dimention[1]) ? 31 : ($dimention[1] > 400) ? 400 : $dimention[1];
57
58
        $tpl->assign('image_title', wani_utf8_encode(htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)));
59
        $tpl->assign('image_width', $width);
60
        $tpl->assign('image_height', $height);
61
        $tpl->assign('image_link', XOOPS_URL . '/');
62
63
        foreach ($new_array as $new) {
64
            $title = wani_utf8_encode(wani_make_html_title($new['title']));
65
            $link    = $new['link'];
66
            $pubdate = '';
67
            if ( isset($new['time']) ) {
68
                $pubdate = wani_utf8_encode(date('r', $new['time']));
69
            }
70
            $description = '';
71 View Code Duplication
            if (isset($new['description'])) {
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...
72
                $description = $new['description'];
73
                $description = wani_make_html_summary($description, $RSS_DESC_MAX);
74
                $description = wani_utf8_encode($description);
75
            }
76
77
            $tpl->append('items', array('title'       => $title,
78
                                      'link'        => $link,
79
                                      'guid'        => $link,
80
                                      'pubdate'     => $pubdate,
81
                                      'description' => $description));
82
        }
83
    }
84
}
85
86
$tpl->display("file:{$template}");
87
exit();
88