Completed
Push — master ( 369c90...324e29 )
by Michael
04:57
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
 * ****************************************************************************
4
 * references - MODULE FOR XOOPS
5
 * Copyright (c) Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
6
 *
7
 * You may not change or alter any portion of this comment or credits
8
 * of supporting developers from this source code or any supporting source code
9
 * which is considered copyrighted (c) material of the original comment or credit authors.
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 *
14
 * @copyright       Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
15
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
16
 * @package         references
17
 * @author          Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
18
 *
19
 * ****************************************************************************
20
 */
21
22
/**
23
 * Flux RSS
24
 */
25
require __DIR__ . '/header.php';
26
require_once XOOPS_ROOT_PATH . '/class/template.php';
27
error_reporting(0);
28
@$xoopsLogger->activated = false;
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
29
30
if (!references_utils::getModuleOption('use_rss')) {
31
    exit(_ERRORS);
32
}
33
34
if (function_exists('mb_http_output')) {
35
    mb_http_output('pass');
36
}
37
$charset = 'utf-8';
38
header('Content-Type:text/xml; charset=' . $charset);
39
40
$tpl = new XoopsTpl();
41
$tpl->xoops_setCaching(2);                                                        // 1 = Cache global, 2 = Cache individuel (par template)
42
$tpl->xoops_setCacheTime(references_utils::getModuleOption('rss_cache_time'));    // Temps de cache en secondes
43
$uid = references_utils::getCurrentUserID();
44
if (!$tpl->is_cached('db:references_rss.tpl', $uid)) {
45
    $categoryTitle = '';
46
    global $xoopsConfig;
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...
47
    $sitename = htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES);
48
    $email    = $xoopsConfig['adminmail'];
49
    $slogan   = htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES);
50
51
    $tpl->assign('charset', $charset);
52
    $tpl->assign('channel_title', xoops_utf8_encode($sitename));
53
    $tpl->assign('channel_link', XOOPS_URL . '/');
54
    $tpl->assign('channel_desc', xoops_utf8_encode($slogan));
55
    $tpl->assign('channel_lastbuild', formatTimestamp(time(), 'rss'));
56
    $tpl->assign('channel_webmaster', xoops_utf8_encode($email));
57
    $tpl->assign('channel_editor', xoops_utf8_encode($email));
58
    $tpl->assign('channel_category', xoops_utf8_encode($categoryTitle));
59
    $tpl->assign('channel_generator', xoops_utf8_encode(references_utils::getModuleName()));
60
    $tpl->assign('channel_language', _LANGCODE);
61
    $tpl->assign('image_url', XOOPS_URL . '/assets/images/logo.gif');
62
    $dimention = getimagesize(XOOPS_ROOT_PATH . '/assets/images/logo.gif');
63 View Code Duplication
    if (empty($dimention[0])) {
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...
64
        $width = 88;
65
    } else {
66
        $width = ($dimention[0] > 144) ? 144 : $dimention[0];
67
    }
68 View Code Duplication
    if (empty($dimention[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
        $height = 31;
70
    } else {
71
        $height = ($dimention[1] > 400) ? 400 : $dimention[1];
72
    }
73
    $tpl->assign('image_width', $width);
74
    $tpl->assign('image_height', $height);
75
    $start = 0;
76
    $limit = references_utils::getModuleOption('nb_perpage');
77
    $items = array();
78
79
    $items = $h_references_articles->getRecentArticles($start, $limit);
80
    foreach ($items as $item) {
81
        $titre       = htmlspecialchars($item->getVar('article_title', 'n'), ENT_QUOTES);
82
        $description = htmlspecialchars($item->getVar('article_text'), ENT_QUOTES);
83
        $link        = REFERENCES_URL;
84
        $tpl->append('items', array(
85
            'title'       => xoops_utf8_encode($titre),
86
            'link'        => $link,
87
            'guid'        => $link,
88
            'pubdate'     => formatTimestamp($item->getVar('article_timestamp'), 'rss'),
89
            'description' => xoops_utf8_encode($description)
90
        ));
91
    }
92
}
93
$tpl->display('db:references_rss.tpl', $uid);
94