Completed
Push — master ( 786b6e...dc199a )
by Michael
01:38
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 dirname(dirname(__DIR__)) . '/mainfile.php';
4
include_once XOOPS_ROOT_PATH . '/class/template.php';
5
error_reporting(0);
6
7
$modulename = basename(__DIR__);
8
include_once XOOPS_ROOT_PATH . "/modules/{$modulename}/include/feedfunc.new.php";
9
10
$param_array = array(
11
    'show'  => 10,
12
    'image' => 1
13
);
14
15
// for debug
16
$cache = 0;
17
18
$new_array = mylinks_get_new($param_array);
19
20
// logo image
21
$logo          = 'images/logo.gif';
22
$template      = XOOPS_ROOT_PATH . "/modules/{$modulename}/templates/mylinks_atom.tpl";
23
$ATOM_DESC_MAX = 1000;
24
25
//not really needed any more since now PHP5 only
26
if (function_exists('mb_http_output')) {
27
    mb_http_output('pass');
28
}
29
30
header('Content-Type:text/xml; charset=utf-8');
31
$tpl = new XoopsTpl();
32
33
if ($cache) {
34
    $tpl->xoops_setCaching(2);
35
    $tpl->xoops_setCacheTime(3600);
36
}
37
38
if (!$tpl->is_cached('file:' . $template) || !$cache) {
39
    if (count($new_array) > 0) {
40
        $link_alt  = XOOPS_URL . '/';
41
        $link_self = XOOPS_URL . "/modules/{$modulename}/atom.php";
42
        // site tag
43
        $site_tag    = 'mylinks';
44
        $site_author = wani_utf8_encode(htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES));
45
        $year        = date('Y');
46
        $copyright   = "Copyright $year, $site_author";
47
        $feed_id     = "tag:$site_tag,$year://1";
48
49
        $updated = wani_iso8601_date(time());
50
        $tpl->assign('xml_lang', _LANGCODE);
51
        $tpl->assign('feed_updated', wani_utf8_encode($updated));
52
        $tpl->assign('feed_generator', XOOPS_VERSION);
53
        $tpl->assign('feed_generator_uri', 'http://www.xoops.org/');
54
        $tpl->assign('feed_link_alt', wani_utf8_encode($link_alt));
55
        $tpl->assign('feed_link_self', wani_utf8_encode($link_self));
56
        $tpl->assign('feed_author_uri', wani_utf8_encode($link_alt));
57
        $tpl->assign('feed_author_name', $site_author);
58
        $tpl->assign('feed_title', wani_utf8_encode(htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)));
59
        $tpl->assign('feed_rights', $copyright);
60
        $tpl->assign('feed_id', $feed_id);
61
62
        foreach ($new_array as $new) {
63
            $updated   = wani_iso8601_date(time());
64
            $published = wani_iso8601_date(time());
65
            $created   = '';
66
            if (isset($new['time'])) {
67
                $created   = wani_iso8601_date($new['time']);
68
                $updated   = wani_iso8601_date($new['time']);
69
                $published = wani_iso8601_date($new['time']);
70
            }
71
72
            $title       = wani_utf8_encode(wani_make_html_title($new['title']));
73
            $link        = $new['link'];
74
            $description = '';
75 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...
76
                $description = $new['description'];
77
                $description = wani_make_html_summary($description, $ATOM_DESC_MAX);
78
                $description = wani_utf8_encode($description);
79
            }
80
            $mid = '';
81
            $aid = '';
82
            if (isset($new['mod_id'])) {
83
                $mid = $new['mod_id'];
84
            }
85
            if (isset($new['id'])) {
86
                $aid = $new['id'];
87
            }
88
89
            $year = date('Y');
90
            if (empty($mid) && empty($aid)) {
91
                $atom_id = "tag:{$site_tag},{$year}://1" . time();
92
            } else {
93
                $atom_id = "tag:{$site_tag},{$year}://1.{$mid}.{$aid}";
94
            }
95
            $tpl->append('entrys', array(
96
                'author_name'  => $site_author,
97
                'updated'      => wani_utf8_encode($updated),
98
                'published'    => wani_utf8_encode($published),
99
                'author_uri'   => '',
100
                'author_email' => '',
101
                'title'        => $title,
102
                'summary'      => $description,
103
                'category'     => '',
104
                'content'      => $description,
105
                'link'         => $link,
106
                'id'           => $atom_id
107
            ));
108
        }
109
    }
110
}
111
112
$tpl->display("file:{$template}");
113
exit();
114