formatString()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 8
c 1
b 0
f 0
nc 8
nop 1
dl 0
loc 13
rs 10
1
<?
0 ignored issues
show
Security Best Practice introduced by
It is not recommended to use PHP's short opening tag <?, better use <?php, or <?= in case of outputting.

Short opening tags are disabled in PHP?s default configuration. In such a case, all content of this file is output verbatim to the browser without being parsed, or executed.

As a precaution to avoid these problems better use the long opening tag <?php.

Loading history...
2
// ----------------------------------------------------------------------------
3
// markItUp! Universal MarkUp Engine, JQuery plugin
4
// Add-on Rss Feed grabber
5
// Dual licensed under the MIT and GPL licenses.
6
// ----------------------------------------------------------------------------
7
// Copyright (C) 2008 Jay Salvat
8
// http://markitup.jaysalvat.com/
9
// ----------------------------------------------------------------------------
10
11
include 'config.php';
12
13
function formatString($string)
14
{
15
    $string = trim($string);
16
    if (STRIP_TAGS) {
17
        $string = strip_tags($string);
18
    }
19
    if (STRIP_NL) {
20
        $string = ereg_replace("\n", '', $string);
21
    }
22
    if (STRIP_SPACES) {
23
        $string = ereg_replace(' {2,}', ' ', $string);
24
    }
25
    return $string;
26
}
27
28
if (isset($_REQUEST['url'])) {
29
    $rssFeed = $_REQUEST['url'];
30
}
31
if (isset($_REQUEST['limit']) && '' !== $_REQUEST['limit']) {
32
    $topStories = $_REQUEST['limit'];
33
}
34
35
$xml = @simplexml_load_file($rssFeed);
36
37
if (!$xml) {
38
    echo 'MIU:ERROR';
39
    exit;
40
}
41
42
$x = 0;
43
foreach ($xml->channel->item as $item) {
44
    printf(
45
        $template,
46
        formatString($item->title),
47
        formatString($item->pubDate),
48
        formatString($item->description),
49
        formatString($item->link)
50
    );
51
    $x++;
52
    if ($x >= $topStories) {
53
        break;
54
    }
55
}
56
57