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