Version Description
Download this release
Release Info
Developer | Bueltge |
Plugin | RSSImport |
Version | 4.1 |
Comparing to | |
See all releases |
Version 4.1
- rssimport.php +111 -0
rssimport.php
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
Plugin Name: WP-RSSImport
|
5 |
+
Plugin URI: http://bueltge.de/wp-rss-import-plugin/55/
|
6 |
+
Description: List a RSS-Feed in your WP-Blog, only headlines or with description.
|
7 |
+
Author: Frank Bueltge
|
8 |
+
Version: 4.1
|
9 |
+
License: GPL
|
10 |
+
Author URI: http://bueltge.de
|
11 |
+
*/
|
12 |
+
|
13 |
+
/*
|
14 |
+
------------------------------------------------------
|
15 |
+
ACKNOWLEDGEMENTS
|
16 |
+
------------------------------------------------------
|
17 |
+
Original and Idea: Dave Wolf, http://www.davewolf.net
|
18 |
+
Thx to Thomas Fischer, http://www.securityfocus.de and Gunnar Tillmann http://www.gunnart.de for a better code
|
19 |
+
|
20 |
+
USAGE: Use following code with a PHP-Plugin for WordPress:
|
21 |
+
Example: <?php RSSImport(10, "http://bueltge.de/feed/", true, false); ?>
|
22 |
+
------------------------------------------------------
|
23 |
+
*/
|
24 |
+
|
25 |
+
// For function fetch_rss
|
26 |
+
if(file_exists(ABSPATH . WPINC . '/rss-functions.php')) {
|
27 |
+
@require_once (ABSPATH . WPINC . '/rss-functions.php');
|
28 |
+
// It's Wordpress 1.5.2 or 2.x. since it has been loaded successfully
|
29 |
+
} elseif (file_exists(ABSPATH . WPINC . '/rss.php')) {
|
30 |
+
@require_once (ABSPATH . WPINC . '/rss.php');
|
31 |
+
// In Wordpress 2.1, a new file name is being used
|
32 |
+
} else {
|
33 |
+
die (__('Error in file: ' . __FILE__ . ' on line: ' . __LINE__ . '.<br />The Wordpress file "rss-functions.php" or "rss.php" could not be included.'));
|
34 |
+
}
|
35 |
+
|
36 |
+
// cache and error report
|
37 |
+
//define('MAGPIE_CACHE_ON', false); // Cache off
|
38 |
+
define('MAGPIE_CACHE_AGE', '60*60'); // in sec, one hour
|
39 |
+
//error_reporting(E_ERROR);
|
40 |
+
|
41 |
+
function RSSImport($display=0, $feedurl, $displaydescriptions=false, $truncatetitle=true) {
|
42 |
+
|
43 |
+
// read in file for search charset
|
44 |
+
ini_set('default_socket_timeout', 120);
|
45 |
+
$a = file_get_contents($feedurl);
|
46 |
+
// for better performance, if the server accepts the method
|
47 |
+
//$a = file_get_contents($feedurl,FALSE,NULL,0,50);
|
48 |
+
|
49 |
+
$rss = fetch_rss($feedurl);
|
50 |
+
|
51 |
+
if ($rss && !$rss->ERROR) {
|
52 |
+
// the follow print_r list all items in array
|
53 |
+
// print_r($rss);
|
54 |
+
echo wptexturize('<ul>');
|
55 |
+
foreach ($rss->items as $item) {
|
56 |
+
if ($display == 0) {
|
57 |
+
break;
|
58 |
+
}
|
59 |
+
|
60 |
+
$title = $item['title'];
|
61 |
+
$href = $item['link'];
|
62 |
+
// view date
|
63 |
+
$pubDate = $item['pubdate'];
|
64 |
+
// cut date
|
65 |
+
$pubDate = substr($pubDate, 0, 25);
|
66 |
+
|
67 |
+
// Edit here:
|
68 |
+
// For import with pure text
|
69 |
+
$desc = $item['description'];
|
70 |
+
// For import with HTML
|
71 |
+
//$desc = $item['content']['encoded'];
|
72 |
+
|
73 |
+
if (eregi('encoding="ISO-8859-', $a)) {
|
74 |
+
isodec($title);
|
75 |
+
isodec($desc);
|
76 |
+
} else {
|
77 |
+
utf8dec($title);
|
78 |
+
utf8dec($desc);
|
79 |
+
}
|
80 |
+
$umlaute = array('„','“','–',' \"','–','—','‘','’','“','”','„','•','…' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�' ,'�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�',utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),utf8_encode('�'),chr(128),chr(129),chr(130),chr(131),chr(132),chr(133),chr(134),chr(135),chr(136),chr(137),chr(138),chr(139),chr(140),chr(141),chr(142),chr(143),chr(144),chr(145),chr(146),chr(147),chr(148),chr(149),chr(150),chr(151),chr(152),chr(153),chr(154),chr(155),chr(156),chr(157),chr(158),chr(159),chr(160),chr(161),chr(162),chr(163),chr(164),chr(165),chr(166),chr(167),chr(168),chr(169),chr(170),chr(171),chr(172),chr(173),chr(174),chr(175),chr(176),chr(177),chr(178),chr(179),chr(180),chr(181),chr(182),chr(183),chr(184),chr(185),chr(186),chr(187),chr(188),chr(189),chr(190),chr(191),chr(192),chr(193),chr(194),chr(195),chr(196),chr(197),chr(198),chr(199),chr(200),chr(201),chr(202),chr(203),chr(204),chr(205),chr(206),chr(207),chr(208),chr(209),chr(210),chr(211),chr(212),chr(213),chr(214),chr(215),chr(216),chr(217),chr(218),chr(219),chr(220),chr(221),chr(222),chr(223),chr(224),chr(225),chr(226),chr(227),chr(228),chr(229),chr(230),chr(231),chr(232),chr(233),chr(234),chr(235),chr(236),chr(237),chr(238),chr(239),chr(240),chr(241),chr(242),chr(243),chr(244),chr(245),chr(246),chr(247),chr(248),chr(249),chr(250),chr(251),chr(252),chr(253),chr(254),chr(255),chr(256));
|
81 |
+
$htmlcode = array('„','“','–',' "','–','—','‘','’','“','”','„','•' ,'…','€','‚','ƒ','„','…','†','‡','ˆ','‰','Š','‹','Œ','Ž','‘','’','“','”','•','–','—','˜','™','š','›','œ','ž','Ÿ','¡','¢','£','¤','¥','¦','§','¨','©','ª','«','¬','®','¯','°','±','²','³','´','µ','¶','·','¸','&supl;','º','»','¼','½','¾','¿','À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ','€','‚','ƒ','„','…','†','‡','ˆ','‰','Š','‹','Œ','Ž','‘','’','“','”','•','–','—','˜','™','š','›','œ','ž','Ÿ','¡','¢','£','¤','¥','¦','§','¨','©','ª','«','¬','®','¯','°','±','²','³','´','µ','¶','·','¸','&supl;','º','»','¼','½','¾','¿','À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ','€','','‚','ƒ','„','…','†','‡','ˆ','‰','Š','‹','Œ','','Ž','','','‘','’','“','”','•','–','—','˜','™','š','›','œ','','ž','Ÿ',' ','¡','¡','¡','¡','¥','¦','§','¨','©','ª','«','¬','�­','®','¯','°','±','²','³','´','µ','¶','·','¸','&supl;','º','»','¼','½','¾','¿','À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ');
|
82 |
+
$title = str_replace($umlaute, $htmlcode, $title);
|
83 |
+
$desc = str_replace($umlaute, $htmlcode, $desc);
|
84 |
+
|
85 |
+
if ($truncatetitle && (strlen($title)>30)) {
|
86 |
+
$title = substr($title, 0, 30) . " ... ";
|
87 |
+
}
|
88 |
+
echo wptexturize('<li>');
|
89 |
+
echo wptexturize('<a href="' . $href . '" title="'. ereg_replace("[^A-Za-z0-9 ]", "", $item['title']) . '">' . $title . '</a> <small>' . $pubDate . '</small>');
|
90 |
+
if ($displaydescriptions && $desc <> "") {
|
91 |
+
echo wptexturize('<br />' . "\n" . $desc . "\n");
|
92 |
+
}
|
93 |
+
$display--;
|
94 |
+
echo wptexturize('</li>');
|
95 |
+
}
|
96 |
+
echo wptexturize('</ul>');
|
97 |
+
} else {
|
98 |
+
echo '<p>' . __('Error: Feed has a error or is not valid') . $rss->ERROR . '</p>';
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
function utf8dec($s_String) {
|
103 |
+
$s_String = html_entity_decode(htmlentities($s_String." ", ENT_COMPAT, 'UTF-8'));
|
104 |
+
return substr($s_String, 0, strlen($s_String)-1);
|
105 |
+
}
|
106 |
+
|
107 |
+
function isodec($s_String) {
|
108 |
+
$s_String = html_entity_decode(htmlentities($s_String." ", ENT_COMPAT, 'ISO-8859-1'));
|
109 |
+
return substr($s_String, 0, strlen($s_String)-1);
|
110 |
+
}
|
111 |
+
?>
|