增加对空间支持的判断,获取feed方法更强大
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
Plugin Name: Rss订阅
|
Plugin Name: Rss订阅
|
||||||
Version: 1.3.2
|
Version: 1.3.3
|
||||||
Plugin URL: http://xiaosong.org/tech/the-official-releas-of-rss-subscribe-plugin
|
Plugin URL: http://xiaosong.org/tech/the-official-releas-of-rss-subscribe-plugin
|
||||||
Description: 订阅朋友的博客feed,显示在自己博客~
|
Description: 订阅朋友的博客feed,显示在自己博客~
|
||||||
Author: 小松
|
Author: 小松
|
||||||
@@ -93,15 +93,15 @@ function updateFeed($id, $url, $title){
|
|||||||
}
|
}
|
||||||
function getTitle($rss_url){
|
function getTitle($rss_url){
|
||||||
global $rssparser;
|
global $rssparser;
|
||||||
$rss = $rssparser->get($rss_url);
|
$rss = $rssparser->Get($rss_url);
|
||||||
return $rss['title'];
|
return $rss['title'];
|
||||||
}
|
}
|
||||||
function updateLogs(){
|
function updateLogs(){
|
||||||
global $rssparser, $DB, $lastRSS_is_urlshort, $lastRSS_is_blank;
|
global $rssparser, $DB, $lastRSS_is_urlshort, $lastRSS_is_blank;
|
||||||
$feeds = getRssFeeds();
|
$feeds = getRssFeeds();
|
||||||
while ($item = $DB->fetch_array($feeds)) {
|
while ($item = $DB->fetch_array($feeds)) {
|
||||||
$rss = $rssparser->get($item['url']);
|
$rss = $rssparser->Get($item['url']);
|
||||||
if(!empty($rss['items']))
|
if(!empty($rss['items'])) {
|
||||||
foreach ($rss['items'] as $key => $data) {
|
foreach ($rss['items'] as $key => $data) {
|
||||||
$rssid = $item['id'];
|
$rssid = $item['id'];
|
||||||
$hash = md5($data['title']);
|
$hash = md5($data['title']);
|
||||||
@@ -117,6 +117,7 @@ function updateLogs(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
function displayLog(){
|
function displayLog(){
|
||||||
global $DB, $lastRSS_item_num;
|
global $DB, $lastRSS_item_num;
|
||||||
$sql = "SELECT rssid,log FROM ".DB_PREFIX."rsslogs ORDER BY id DESC limit $lastRSS_item_num";
|
$sql = "SELECT rssid,log FROM ".DB_PREFIX."rsslogs ORDER BY id DESC limit $lastRSS_item_num";
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
function callback_init(){
|
function callback_init(){
|
||||||
|
if (!get_cfg_var("allow_url_fopen") && !extension_loaded('curl') && !function_exists('file_get_contents')) emMsg('该插件需要开启“allow_url_fopen”或“curl”或“file_get_contents”。请联系空间商开启!');
|
||||||
$DB = MySql::getInstance();
|
$DB = MySql::getInstance();
|
||||||
$is_exist_rssfeeds_query = $DB->query('show tables like "'.DB_PREFIX.'rssfeeds"');
|
$is_exist_rssfeeds_query = $DB->query('show tables like "'.DB_PREFIX.'rssfeeds"');
|
||||||
$is_exist_rsslogs_query = $DB->query('show tables like "'.DB_PREFIX.'rsslogs"');
|
$is_exist_rsslogs_query = $DB->query('show tables like "'.DB_PREFIX.'rsslogs"');
|
||||||
|
|||||||
@@ -126,18 +126,44 @@ class lastRSS {
|
|||||||
return strtr ($string, $trans_tbl);
|
return strtr ($string, $trans_tbl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Get remote file or open url
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
function getRemoteFile ($url){
|
||||||
|
$results = '';
|
||||||
|
$context = stream_context_create(array(
|
||||||
|
'http' => array(
|
||||||
|
'timeout' => 3
|
||||||
|
)
|
||||||
|
));
|
||||||
|
if (get_cfg_var('allow_url_fopen')) {
|
||||||
|
$f = fopen($url, 'r');
|
||||||
|
while (!feof($f)) {
|
||||||
|
$results .= fgets($f, 4096);
|
||||||
|
}
|
||||||
|
fclose($f);
|
||||||
|
} else if (extension_loaded('curl')) {
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
||||||
|
curl_setopt($ch, CURLOPT_USERAGENT, 'PHP Curl/emlog Rss订阅插件');
|
||||||
|
$results = curl_exec($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
} else {
|
||||||
|
$results = file_get_contents($url, 0, $context);
|
||||||
|
}
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Parse() is private method used by Get() to load and parse RSS file.
|
// Parse() is private method used by Get() to load and parse RSS file.
|
||||||
// Don't use Parse() in your scripts - use Get($rss_file) instead.
|
// Don't use Parse() in your scripts - use Get($rss_file) instead.
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
function Parse ($rss_url) {
|
function Parse ($rss_url) {
|
||||||
// Open and load RSS file
|
// Open and load RSS file
|
||||||
if ($f = @fopen($rss_url, 'r')) {
|
$rss_content = $this->getRemoteFile($rss_url);
|
||||||
$rss_content = '';
|
if (!empty($rss_content)) {
|
||||||
while (!feof($f)) {
|
|
||||||
$rss_content .= fgets($f, 4096);
|
|
||||||
}
|
|
||||||
fclose($f);
|
|
||||||
|
|
||||||
// Parse document encoding
|
// Parse document encoding
|
||||||
$result['encoding'] = $this->my_preg_match("'encoding=[\'\"](.*?)[\'\"]'si", $rss_content);
|
$result['encoding'] = $this->my_preg_match("'encoding=[\'\"](.*?)[\'\"]'si", $rss_content);
|
||||||
|
|||||||
@@ -61,34 +61,8 @@ function plugin_setting_view(){
|
|||||||
endif;
|
endif;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</ol>
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(function(){
|
|
||||||
$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $("html") : $("body")) : $("html,body");
|
|
||||||
$("#lastRSS").addClass('sidebarsubmenu1');
|
|
||||||
$(".entry").dblclick(function(){
|
|
||||||
var feedUrl = $(this).children("#data-url").attr("data"),
|
|
||||||
feedId = $(this).children("#data-id").attr("data"),
|
|
||||||
feedTitle = $(this).children("#data-title").attr("data");
|
|
||||||
$("#modify_url").val(feedUrl);
|
|
||||||
$("#modify_title").val(feedTitle);
|
|
||||||
$("#modify_id").val(feedId);
|
|
||||||
$("#lastRSS_form_modify").slideDown(400,function(){
|
|
||||||
$body.animate({
|
|
||||||
scrollTop: $(this).offset().top - 40
|
|
||||||
}, 500);
|
|
||||||
$("#modify_url").focus();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
$("#cancel_update").click(function(){
|
|
||||||
$("#lastRSS_form_modify").slideUp(200,function(){
|
|
||||||
$("#modify_url").blur();
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
})
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
<?php
|
<?php
|
||||||
|
function plugin_setting(){
|
||||||
$do = isset($_GET['do']) ? addslashes($_GET['do']) : '';
|
$do = isset($_GET['do']) ? addslashes($_GET['do']) : '';
|
||||||
if ($do == 'del') {
|
if ($do == 'del') {
|
||||||
$id = intval($_GET['id']);
|
$id = intval($_GET['id']);
|
||||||
@@ -145,4 +119,32 @@ if ($do == 'del') {
|
|||||||
fclose($fp);
|
fclose($fp);
|
||||||
header("Location:plugin.php?plugin=lastRSS&setting=true");
|
header("Location:plugin.php?plugin=lastRSS&setting=true");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
</ol>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function(){
|
||||||
|
$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $("html") : $("body")) : $("html,body");
|
||||||
|
$("#lastRSS").addClass('sidebarsubmenu1');
|
||||||
|
$(".entry").dblclick(function(){
|
||||||
|
var feedUrl = $(this).children("#data-url").attr("data"),
|
||||||
|
feedId = $(this).children("#data-id").attr("data"),
|
||||||
|
feedTitle = $(this).children("#data-title").attr("data");
|
||||||
|
$("#modify_url").val(feedUrl);
|
||||||
|
$("#modify_title").val(feedTitle);
|
||||||
|
$("#modify_id").val(feedId);
|
||||||
|
$("#lastRSS_form_modify").slideDown(400,function(){
|
||||||
|
$body.animate({
|
||||||
|
scrollTop: $(this).offset().top - 40
|
||||||
|
}, 500);
|
||||||
|
$("#modify_url").focus();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$("#cancel_update").click(function(){
|
||||||
|
$("#lastRSS_form_modify").slideUp(200,function(){
|
||||||
|
$("#modify_url").blur();
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user