Completed
Push — master ( c39b68...a1acf8 )
by Michael
03:03
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
 * TDMDownload
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright   Gregory Mage (Aka Mage)
13
 * @license     GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
14
 * @author      Gregory Mage (Aka Mage)
15
 */
16
17
include_once 'header.php';
18
include_once XOOPS_ROOT_PATH.'/class/template.php';
19
$items_count = $xoopsModuleConfig['perpagerss'];
20
$cid = isset($_GET['cid']) ? intval($_GET['cid']) : 0;
21
if (function_exists('mb_http_output')) {
22
    mb_http_output('pass');
23
}
24
//header ('Content-Type:text/xml; charset=UTF-8');
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...
25
$xoopsModuleConfig["utf8"] = false;
26
27
$tpl = new XoopsTpl();
28
$tpl->caching=2; //1 = Cache global, 2 = Cache individuel (par template)
29
$tpl->xoops_setCacheTime($xoopsModuleConfig['timecacherss']*60); // Temps de cache en secondes
30
$categories = TDMDownloads_MygetItemIds('tdmdownloads_view', 'TDMDownloads');
31
$criteria = new CriteriaCompo();
32
$criteria->add(new Criteria('status', 0, '!='));
33
$criteria->add(new Criteria('cid', '(' . implode(',', $categories) . ')','IN'));
34
if ($cid != 0) {
35
    $criteria->add(new Criteria('cid', $cid));
36
    $cat = $downloadscat_Handler->get($cid);
37
    $title = $xoopsConfig['sitename'] . ' - ' . $xoopsModule->getVar('name') . ' - ' . $cat->getVar('cat_title');
38
} else {
39
    $title = $xoopsConfig['sitename'] . ' - ' . $xoopsModule->getVar('name');
40
}
41
$criteria->setLimit($xoopsModuleConfig['perpagerss']);
42
$criteria->setSort('date');
43
$criteria->setOrder('DESC');
44
$downloads_arr = $downloads_Handler->getall($criteria);
45
46
if (!$tpl->is_cached('db:tdmdownloads_rss.html', $cid)) {
47
    $tpl->assign('channel_title', htmlspecialchars($title, ENT_QUOTES));
48
    $tpl->assign('channel_link', XOOPS_URL.'/');
49
    $tpl->assign('channel_desc', htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES));
50
    $tpl->assign('channel_lastbuild', formatTimestamp(time(), 'rss'));
51
    $tpl->assign('channel_webmaster', $xoopsConfig['adminmail']);
52
    $tpl->assign('channel_editor', $xoopsConfig['adminmail']);
53
    $tpl->assign('channel_category', 'Event');
54
    $tpl->assign('channel_generator', 'XOOPS - ' . htmlspecialchars($xoopsModule->getVar('name'), ENT_QUOTES));
55
    $tpl->assign('channel_language', _LANGCODE);
56
    if (_LANGCODE == 'fr') {
57
        $tpl->assign('docs', 'http://www.scriptol.fr/rss/RSS-2.0.html');
58
    } else {
59
        $tpl->assign('docs', 'http://cyber.law.harvard.edu/rss/rss.html');
60
    }
61
    $tpl->assign('image_url', XOOPS_URL . $xoopsModuleConfig['logorss']);
62
    $dimention = getimagesize(XOOPS_ROOT_PATH . $xoopsModuleConfig['logorss']);
63 View Code Duplication
    if (empty($dimention[0])) {
64
        $width = 88;
65
    } else {
66
        $width = ($dimention[0] > 144) ? 144 : $dimention[0];
67
    }
68 View Code Duplication
    if (empty($dimention[1])) {
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
    foreach (array_keys($downloads_arr) as $i) {
76
        $description = $downloads_arr[$i]->getVar('description');
77
        //permet d'afficher uniquement la description courte
78 View Code Duplication
        if (strpos($description,'[pagebreak]')==false) {
79
            $description_short = $description;
80
        } else {
81
            $description_short = substr($description,0,strpos($description,'[pagebreak]'));
82
        }
83
        $tpl->append('items', array('title' => htmlspecialchars($downloads_arr[$i]->getVar('title'), ENT_QUOTES),
84
                                    'link' => XOOPS_URL . '/modules/TDMDownloads/singlefile.php?cid=' . $downloads_arr[$i]->getVar('cid') . '&amp;lid=' . $downloads_arr[$i]->getVar('lid'),
85
                                    'guid' => XOOPS_URL . '/modules/TDMDownloads/singlefile.php?cid=' . $downloads_arr[$i]->getVar('cid') . '&amp;lid=' . $downloads_arr[$i]->getVar('lid'),
86
                                    'pubdate' => formatTimestamp($downloads_arr[$i]->getVar('date'), 'rss'),
87
                                    'description' => htmlspecialchars($description_short, ENT_QUOTES)));
88
    }
89
}
90
header("Content-Type:text/xml; charset=" . _CHARSET);
91
$tpl->display('db:tdmdownloads_rss.html', $cid);
92