1.3.4
This commit is contained in:
10
README.md
10
README.md
@@ -1,6 +1,6 @@
|
|||||||
emlog Rss订阅插件
|
emlog Rss订阅插件
|
||||||
====================
|
====================
|
||||||
|
|
||||||
订阅你喜欢的网站的feed,然后显示在博客前台,有可能把访客带到别的站,但是,不影响SEO,因为,前台都是通过ajax请求的。
|
订阅你喜欢的网站的feed,然后显示在博客前台,有可能把访客带到别的站,但是,不影响SEO,因为,前台都是通过ajax请求的。
|
||||||
|
|
||||||
[插件主页](http://xiaosong.org/share/the-official-releas-of-rss-subscribe-plugin)
|
[插件主页](http://xiaosong.org/share/the-official-releas-of-rss-subscribe-plugin)
|
||||||
314
lastRSS.php
314
lastRSS.php
@@ -1,158 +1,158 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
Plugin Name: Rss订阅
|
Plugin Name: Rss订阅
|
||||||
Version: 1.3.4
|
Version: 1.3.4
|
||||||
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: 小松
|
||||||
Author Email: sahala_2007@126.com
|
Author Email: sahala_2007@126.com
|
||||||
Author URL: http://xiaosong.org/
|
Author URL: http://xiaosong.org/
|
||||||
*/
|
*/
|
||||||
!defined('EMLOG_ROOT') && exit('access deined!');
|
!defined('EMLOG_ROOT') && exit('access deined!');
|
||||||
require_once(EMLOG_ROOT.'/content/plugins/lastRSS/lastRSS_config.php');
|
require_once(EMLOG_ROOT.'/content/plugins/lastRSS/lastRSS_config.php');
|
||||||
require_once(EMLOG_ROOT.'/content/plugins/lastRSS/lastRSS_class.php');
|
require_once(EMLOG_ROOT.'/content/plugins/lastRSS/lastRSS_class.php');
|
||||||
$rssparser = new lastRSS;
|
$rssparser = new lastRSS;
|
||||||
$rssparser->cache_dir = EMLOG_ROOT.'/content/cache/';
|
$rssparser->cache_dir = EMLOG_ROOT.'/content/cache/';
|
||||||
$rssparser->cache_time = $lastRSS_cache_time;
|
$rssparser->cache_time = $lastRSS_cache_time;
|
||||||
$rssparser->items_limit = $lastRSS_item_num > 3 ? 3 : $lastRSS_item_num;
|
$rssparser->items_limit = $lastRSS_item_num > 3 ? 3 : $lastRSS_item_num;
|
||||||
$rssparser->CDATA = 'content';
|
$rssparser->CDATA = 'content';
|
||||||
$rssparser->cp = 'UTF-8';
|
$rssparser->cp = 'UTF-8';
|
||||||
$rssparser->channeltags = array ('title');
|
$rssparser->channeltags = array ('title');
|
||||||
$rssparser->itemtags = array ('title','link');
|
$rssparser->itemtags = array ('title','link');
|
||||||
$rssparser->imagetags = array ();
|
$rssparser->imagetags = array ();
|
||||||
$rssparser->textinputtags = array ();
|
$rssparser->textinputtags = array ();
|
||||||
$DB = MySql::getInstance();
|
$DB = MySql::getInstance();
|
||||||
|
|
||||||
function urlShort($url){
|
function urlShort($url){
|
||||||
global $rssparser, $lastRSS_urlshort_domain;
|
global $rssparser, $lastRSS_urlshort_domain;
|
||||||
$api = 'http://json.so/api/short.htm?d='.$lastRSS_urlshort_domain.'&u='.$url;
|
$api = 'http://json.so/api/short.htm?d='.$lastRSS_urlshort_domain.'&u='.$url;
|
||||||
$results = $rssparser->getRemoteFile($api);
|
$results = $rssparser->getRemoteFile($api);
|
||||||
if (empty($results)) {
|
if (empty($results)) {
|
||||||
return $url;
|
return $url;
|
||||||
} else {
|
} else {
|
||||||
$results = json_decode($results, true);
|
$results = json_decode($results, true);
|
||||||
if(isset($results['state']) && $results['state'] == 'success'){
|
if(isset($results['state']) && $results['state'] == 'success'){
|
||||||
return $results['msg'];
|
return $results['msg'];
|
||||||
}
|
}
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function getRssFeeds(){
|
function getRssFeeds(){
|
||||||
global $DB;
|
global $DB;
|
||||||
$sql = "SELECT * FROM ".DB_PREFIX."rssfeeds ORDER BY id ASC";
|
$sql = "SELECT * FROM ".DB_PREFIX."rssfeeds ORDER BY id ASC";
|
||||||
$result = $DB->query($sql);
|
$result = $DB->query($sql);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
function isLogExists($rssid, $hash){
|
function isLogExists($rssid, $hash){
|
||||||
global $DB;
|
global $DB;
|
||||||
$sql = "SELECT id FROM ".DB_PREFIX."rsslogs WHERE rssid = $rssid AND hash = '$hash'";
|
$sql = "SELECT id FROM ".DB_PREFIX."rsslogs WHERE rssid = $rssid AND hash = '$hash'";
|
||||||
$result = $DB->query($sql);
|
$result = $DB->query($sql);
|
||||||
$rows = $DB->num_rows($result);
|
$rows = $DB->num_rows($result);
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
function isFeedExists($url){
|
function isFeedExists($url){
|
||||||
global $DB;
|
global $DB;
|
||||||
$sql = "SELECT id FROM ".DB_PREFIX."rssfeeds WHERE url = '$url'";
|
$sql = "SELECT id FROM ".DB_PREFIX."rssfeeds WHERE url = '$url'";
|
||||||
$result = $DB->query($sql);
|
$result = $DB->query($sql);
|
||||||
$rows = $DB->num_rows($result);
|
$rows = $DB->num_rows($result);
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
function insertLog($rssid, $log ,$hash){
|
function insertLog($rssid, $log ,$hash){
|
||||||
global $DB;
|
global $DB;
|
||||||
if (isLogExists($rssid, $hash) == 0) {
|
if (isLogExists($rssid, $hash) == 0) {
|
||||||
$DB->query("INSERT INTO ".DB_PREFIX."rsslogs (rssid, log, hash) VALUES($rssid, '$log', '$hash')");
|
$DB->query("INSERT INTO ".DB_PREFIX."rsslogs (rssid, log, hash) VALUES($rssid, '$log', '$hash')");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function insertFeed($url, $title){
|
function insertFeed($url, $title){
|
||||||
global $DB;
|
global $DB;
|
||||||
if (isFeedExists($url) == 0) {
|
if (isFeedExists($url) == 0) {
|
||||||
$DB->query("INSERT INTO ".DB_PREFIX."rssfeeds (url, title) VALUES('$url', '$title')");
|
$DB->query("INSERT INTO ".DB_PREFIX."rssfeeds (url, title) VALUES('$url', '$title')");
|
||||||
} elseif (!getTitle($url)) {
|
} elseif (!getTitle($url)) {
|
||||||
emMsg("RSS导入失败,RSS地址{$url}解析失败,请确定RSS地址及XML文件格式正确");
|
emMsg("RSS导入失败,RSS地址{$url}解析失败,请确定RSS地址及XML文件格式正确");
|
||||||
} else {
|
} else {
|
||||||
emMsg("RSS导入失败,数据库中已存在{$url}");
|
emMsg("RSS导入失败,数据库中已存在{$url}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function deleteFeed($id){
|
function deleteFeed($id){
|
||||||
global $DB;
|
global $DB;
|
||||||
$rssurl = $DB->fetch_array($DB->query("SELECT url FROM ".DB_PREFIX."rssfeeds WHERE id = $id"));
|
$rssurl = $DB->fetch_array($DB->query("SELECT url FROM ".DB_PREFIX."rssfeeds WHERE id = $id"));
|
||||||
$rssurl = $rssurl['url'];
|
$rssurl = $rssurl['url'];
|
||||||
$cache_file = EMLOG_ROOT.'/content/cache/rsscache_'.md5($rssurl);
|
$cache_file = EMLOG_ROOT.'/content/cache/rsscache_'.md5($rssurl);
|
||||||
$DB->query("DELETE FROM ".DB_PREFIX."rssfeeds WHERE id = $id");
|
$DB->query("DELETE FROM ".DB_PREFIX."rssfeeds WHERE id = $id");
|
||||||
$DB->query("DELETE FROM ".DB_PREFIX."rsslogs WHERE rssid = $id");
|
$DB->query("DELETE FROM ".DB_PREFIX."rsslogs WHERE rssid = $id");
|
||||||
unlink($cache_file);
|
unlink($cache_file);
|
||||||
}
|
}
|
||||||
function updateFeed($id, $url, $title){
|
function updateFeed($id, $url, $title){
|
||||||
global $DB;
|
global $DB;
|
||||||
$DB->query("UPDATE ".DB_PREFIX."rssfeeds SET url = '$url', title = '$title' WHERE id = $id");
|
$DB->query("UPDATE ".DB_PREFIX."rssfeeds SET url = '$url', title = '$title' WHERE id = $id");
|
||||||
}
|
}
|
||||||
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']);
|
||||||
$checklog = isLogExists($rssid, $hash);
|
$checklog = isLogExists($rssid, $hash);
|
||||||
if ($checklog == 0) {
|
if ($checklog == 0) {
|
||||||
if (trim($data['title']) != '') {
|
if (trim($data['title']) != '') {
|
||||||
$link = $lastRSS_is_urlshort ? urlShort($data['link']) : $data['link'];
|
$link = $lastRSS_is_urlshort ? urlShort($data['link']) : $data['link'];
|
||||||
$target = $lastRSS_is_blank ? ' target="_blank"' : '';
|
$target = $lastRSS_is_blank ? ' target="_blank"' : '';
|
||||||
$log = '<a href="'.$link.'"'.$target.'>'.strip_tags($data['title']).'</a>';
|
$log = '<a href="'.$link.'"'.$target.'>'.strip_tags($data['title']).'</a>';
|
||||||
insertLog($rssid, $log ,$hash);
|
insertLog($rssid, $log ,$hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function displayLog(){
|
function displayLog(){
|
||||||
global $DB, $lastRSS_item_num;
|
global $DB, $lastRSS_item_num;
|
||||||
$sql = "SELECT ".DB_PREFIX."rsslogs.log,".DB_PREFIX."rssfeeds.title FROM ".DB_PREFIX."rsslogs INNER JOIN ".DB_PREFIX."rssfeeds ON ".DB_PREFIX."rsslogs.rssid = ".DB_PREFIX."rssfeeds.id ORDER BY ".DB_PREFIX."rsslogs.id DESC limit $lastRSS_item_num";
|
$sql = "SELECT ".DB_PREFIX."rsslogs.log,".DB_PREFIX."rssfeeds.title FROM ".DB_PREFIX."rsslogs INNER JOIN ".DB_PREFIX."rssfeeds ON ".DB_PREFIX."rsslogs.rssid = ".DB_PREFIX."rssfeeds.id ORDER BY ".DB_PREFIX."rsslogs.id DESC limit $lastRSS_item_num";
|
||||||
$result = $DB->query($sql);
|
$result = $DB->query($sql);
|
||||||
$output = '';
|
$output = '';
|
||||||
while ($row = $DB->fetch_array($result)) {
|
while ($row = $DB->fetch_array($result)) {
|
||||||
$output .= '<li>'.$row['log'].' 来自 《'.$row["title"].'》</li>';
|
$output .= '<li>'.$row['log'].' 来自 《'.$row["title"].'》</li>';
|
||||||
}
|
}
|
||||||
$output = empty($output) ? '<li>暂无Rss文章 ^_^' : $output;
|
$output = empty($output) ? '<li>暂无Rss文章 ^_^' : $output;
|
||||||
$output = '<ul class="rsslogs">'.$output.'</ul>';
|
$output = '<ul class="rsslogs">'.$output.'</ul>';
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
function displayLogIndex(){
|
function displayLogIndex(){
|
||||||
echo '<div id="lastRSS" class="lastRSS_loding"></div>';
|
echo '<div id="lastRSS" class="lastRSS_loding"></div>';
|
||||||
}
|
}
|
||||||
function lastRSS_css(){
|
function lastRSS_css(){
|
||||||
echo '<link rel="stylesheet" href="'.BLOG_URL.'content/plugins/lastRSS/css/lastRSS.css" />'."\n";
|
echo '<link rel="stylesheet" href="'.BLOG_URL.'content/plugins/lastRSS/css/lastRSS.css" />'."\n";
|
||||||
}
|
}
|
||||||
function lastRSS_ajax(){
|
function lastRSS_ajax(){
|
||||||
echo '<script type="text/javascript" src="'.BLOG_URL.'content/plugins/lastRSS/js/jquery-autoscroll.js"></script>'."\n";
|
echo '<script type="text/javascript" src="'.BLOG_URL.'content/plugins/lastRSS/js/jquery-autoscroll.js"></script>'."\n";
|
||||||
echo '<script type="text/javascript">$(function(){$.get("'.BLOG_URL.'index.php?plugin=lastRSS&action=update&r="+Math.random());$("#lastRSS").load("'.BLOG_URL.'index.php?plugin=lastRSS&action=ajaxshow&r="+Math.random(),function(){$(this).removeClass("lastRSS_loding").autoScroll()})})</script>'."\n";
|
echo '<script type="text/javascript">$(function(){$.get("'.BLOG_URL.'index.php?plugin=lastRSS&action=update&r="+Math.random());$("#lastRSS").load("'.BLOG_URL.'index.php?plugin=lastRSS&action=ajaxshow&r="+Math.random(),function(){$(this).removeClass("lastRSS_loding").autoScroll()})})</script>'."\n";
|
||||||
}
|
}
|
||||||
function lastRSS_adminUpdate(){
|
function lastRSS_adminUpdate(){
|
||||||
echo '<script type="text/javascript">$(function(){$.get("'.BLOG_URL.'index.php?plugin=lastRSS&action=update&r="+Math.random());})</script>'."\n";
|
echo '<script type="text/javascript">$(function(){$.get("'.BLOG_URL.'index.php?plugin=lastRSS&action=update&r="+Math.random());})</script>'."\n";
|
||||||
}
|
}
|
||||||
function lastRSS_menu(){
|
function lastRSS_menu(){
|
||||||
echo '<div class="sidebarsubmenu" id="lastRSS"><a href="./plugin.php?plugin=lastRSS">Rss订阅</a></div>';
|
echo '<div class="sidebarsubmenu" id="lastRSS"><a href="./plugin.php?plugin=lastRSS">Rss订阅</a></div>';
|
||||||
}
|
}
|
||||||
function lastRSS_backup(){
|
function lastRSS_backup(){
|
||||||
global $DB, $tables;
|
global $DB, $tables;
|
||||||
$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"');
|
||||||
if($DB->num_rows($is_exist_rssfeeds_query) != 0) array_push($tables, 'rssfeeds');
|
if($DB->num_rows($is_exist_rssfeeds_query) != 0) array_push($tables, 'rssfeeds');
|
||||||
if($DB->num_rows($is_exist_rsslogs_query) != 0) array_push($tables, 'rsslogs');
|
if($DB->num_rows($is_exist_rsslogs_query) != 0) array_push($tables, 'rsslogs');
|
||||||
}
|
}
|
||||||
emLoadJQuery();
|
emLoadJQuery();
|
||||||
addAction('data_prebakup', 'lastRSS_backup');
|
addAction('data_prebakup', 'lastRSS_backup');
|
||||||
addAction('index_head', 'lastRSS_css');
|
addAction('index_head', 'lastRSS_css');
|
||||||
addAction('index_loglist_top', 'displayLogIndex');
|
addAction('index_loglist_top', 'displayLogIndex');
|
||||||
addAction('index_footer', 'lastRSS_ajax');
|
addAction('index_footer', 'lastRSS_ajax');
|
||||||
addAction('adm_head', 'lastRSS_adminUpdate');
|
addAction('adm_head', 'lastRSS_adminUpdate');
|
||||||
addAction('adm_sidebar_ext', 'lastRSS_menu');
|
addAction('adm_sidebar_ext', 'lastRSS_menu');
|
||||||
?>
|
?>
|
||||||
@@ -1,45 +1,45 @@
|
|||||||
<?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”。请联系空间商开启!');
|
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"');
|
||||||
$dbcharset = 'utf8';
|
$dbcharset = 'utf8';
|
||||||
$type = 'MYISAM';
|
$type = 'MYISAM';
|
||||||
$add = $DB->getMysqlVersion() > '4.1' ? "ENGINE=".$type." DEFAULT CHARSET=".$dbcharset.";":"TYPE=".$type.";";
|
$add = $DB->getMysqlVersion() > '4.1' ? "ENGINE=".$type." DEFAULT CHARSET=".$dbcharset.";":"TYPE=".$type.";";
|
||||||
$addone = "INSERT INTO ".DB_PREFIX."rssfeeds (url, title) VALUES('http://xiaosong.org/rss.php', '快乐忆站')";
|
$addone = "INSERT INTO ".DB_PREFIX."rssfeeds (url, title) VALUES('http://xiaosong.org/rss.php', '快乐忆站')";
|
||||||
if($DB->num_rows($is_exist_rssfeeds_query) == 0){
|
if($DB->num_rows($is_exist_rssfeeds_query) == 0){
|
||||||
$sql_rssfeeds = "
|
$sql_rssfeeds = "
|
||||||
CREATE TABLE `".DB_PREFIX."rssfeeds` (
|
CREATE TABLE `".DB_PREFIX."rssfeeds` (
|
||||||
`id` int(10) NOT NULL AUTO_INCREMENT,
|
`id` int(10) NOT NULL AUTO_INCREMENT,
|
||||||
`url` text NOT NULL,
|
`url` text NOT NULL,
|
||||||
`title` varchar(255) NOT NULL,
|
`title` varchar(255) NOT NULL,
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
)".$add;
|
)".$add;
|
||||||
$DB->query($sql_rssfeeds);
|
$DB->query($sql_rssfeeds);
|
||||||
$DB->query($addone);
|
$DB->query($addone);
|
||||||
|
|
||||||
}
|
}
|
||||||
if($DB->num_rows($is_exist_rsslogs_query) == 0){
|
if($DB->num_rows($is_exist_rsslogs_query) == 0){
|
||||||
$sql_rsslogs = "
|
$sql_rsslogs = "
|
||||||
CREATE TABLE `".DB_PREFIX."rsslogs` (
|
CREATE TABLE `".DB_PREFIX."rsslogs` (
|
||||||
`id` int(10) NOT NULL AUTO_INCREMENT,
|
`id` int(10) NOT NULL AUTO_INCREMENT,
|
||||||
`rssid` int(10) NOT NULL,
|
`rssid` int(10) NOT NULL,
|
||||||
`log` text NOT NULL,
|
`log` text NOT NULL,
|
||||||
`hash` varchar(64) NOT NULL,
|
`hash` varchar(64) NOT NULL,
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
)".$add;
|
)".$add;
|
||||||
$DB->query($sql_rsslogs);
|
$DB->query($sql_rsslogs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function callback_rm(){
|
function callback_rm(){
|
||||||
$DB = MySql::getInstance();
|
$DB = MySql::getInstance();
|
||||||
$feeds = getRssFeeds();
|
$feeds = getRssFeeds();
|
||||||
while ($item = $DB->fetch_array($feeds)) {
|
while ($item = $DB->fetch_array($feeds)) {
|
||||||
deleteFeed($item['id']);
|
deleteFeed($item['id']);
|
||||||
}
|
}
|
||||||
$DB->query("DROP TABLE IF EXISTS ".DB_PREFIX."rssfeeds");
|
$DB->query("DROP TABLE IF EXISTS ".DB_PREFIX."rssfeeds");
|
||||||
$DB->query("DROP TABLE IF EXISTS ".DB_PREFIX."rsslogs");
|
$DB->query("DROP TABLE IF EXISTS ".DB_PREFIX."rsslogs");
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,165 +1,165 @@
|
|||||||
<?php
|
<?php
|
||||||
!defined('EMLOG_ROOT') && exit('access deined!');
|
!defined('EMLOG_ROOT') && exit('access deined!');
|
||||||
$DB = MySql::getInstance();
|
$DB = MySql::getInstance();
|
||||||
require_once(EMLOG_ROOT.'/content/plugins/lastRSS/lastRSS_config.php');
|
require_once(EMLOG_ROOT.'/content/plugins/lastRSS/lastRSS_config.php');
|
||||||
function plugin_setting_view(){
|
function plugin_setting_view(){
|
||||||
global $DB, $lastRSS_cache_time, $lastRSS_item_num, $lastRSS_is_urlshort, $lastRSS_is_blank, $lastRSS_urlshort_domain;
|
global $DB, $lastRSS_cache_time, $lastRSS_item_num, $lastRSS_is_urlshort, $lastRSS_is_blank, $lastRSS_urlshort_domain;
|
||||||
?>
|
?>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
#lastRSS_form_config p, #lastRSS_form_input p, #lastRSS_form_modify p {font-size:14px;}
|
#lastRSS_form_config p, #lastRSS_form_input p, #lastRSS_form_modify p {font-size:14px;}
|
||||||
ol {margin:0;padding:0;}
|
ol {margin:0;padding:0;}
|
||||||
.entry {overflow:hidden;zoom:1;list-style: decimal inside none;font-size:14px;padding:8px;background:#DFE1E3;border-top:1px solid #E9EAEB;border-bottom:1px solid #C7CCD1;}
|
.entry {overflow:hidden;zoom:1;list-style: decimal inside none;font-size:14px;padding:8px;background:#DFE1E3;border-top:1px solid #E9EAEB;border-bottom:1px solid #C7CCD1;}
|
||||||
.right {float:right;display:inline;}
|
.right {float:right;display:inline;}
|
||||||
#lastRSS_form_modify {display:none;}
|
#lastRSS_form_modify {display:none;}
|
||||||
</style>
|
</style>
|
||||||
<div class="containertitle"><b>Rss订阅 参数设置</b>
|
<div class="containertitle"><b>Rss订阅 参数设置</b>
|
||||||
<?php if(isset($_GET['setting'])):?><span class="actived">插件设置完成</span><?php endif;?>
|
<?php if(isset($_GET['setting'])):?><span class="actived">插件设置完成</span><?php endif;?>
|
||||||
</div>
|
</div>
|
||||||
<div class="line"></div>
|
<div class="line"></div>
|
||||||
<form action="?plugin=lastRSS&action=setting&do=config" method="post" id="lastRSS_form_config">
|
<form action="?plugin=lastRSS&action=setting&do=config" method="post" id="lastRSS_form_config">
|
||||||
<p>缓存时间:<input type="text" name="lastRSS_cache_time" value="<?php echo $lastRSS_cache_time; ?>" size="20" /> 单位为秒,留空或“0”表示不缓存,推荐设置大于“1200”</p>
|
<p>缓存时间:<input type="text" name="lastRSS_cache_time" value="<?php echo $lastRSS_cache_time; ?>" size="20" /> 单位为秒,留空或“0”表示不缓存,推荐设置大于“1200”</p>
|
||||||
<p>显示条数:<input type="text" name="lastRSS_item_num" value="<?php echo $lastRSS_item_num; ?>" size="20" /> 前台轮播显示的条数,推荐大于“1”</p>
|
<p>显示条数:<input type="text" name="lastRSS_item_num" value="<?php echo $lastRSS_item_num; ?>" size="20" /> 前台轮播显示的条数,推荐大于“1”</p>
|
||||||
<p><input type="checkbox" value="1" name="lastRSS_is_urlshort"<?php if($lastRSS_is_urlshort == 1):?> checked<?php endif;?> /> 使用网址缩短服务来缩短RSS日志的链接(已存入数据库的链接不变),需服务器开启curl,开启会增加程序运行时间</p>
|
<p><input type="checkbox" value="1" name="lastRSS_is_urlshort"<?php if($lastRSS_is_urlshort == 1):?> checked<?php endif;?> /> 使用网址缩短服务来缩短RSS日志的链接(已存入数据库的链接不变),需服务器开启curl,开启会增加程序运行时间</p>
|
||||||
<p><label for="lastRSS_urlshort_domain">短网址服务商:</label>
|
<p><label for="lastRSS_urlshort_domain">短网址服务商:</label>
|
||||||
<select name="lastRSS_urlshort_domain" id="lastRSS_urlshort_domain">
|
<select name="lastRSS_urlshort_domain" id="lastRSS_urlshort_domain">
|
||||||
<option value="t.cn"<?php if($lastRSS_urlshort_domain == 't.cn'):?> selected<?php endif;?>>t.cn</option>
|
<option value="t.cn"<?php if($lastRSS_urlshort_domain == 't.cn'):?> selected<?php endif;?>>t.cn</option>
|
||||||
<option value="bit.ly"<?php if($lastRSS_urlshort_domain == 'bit.ly'):?> selected<?php endif;?>>bit.ly</option>
|
<option value="bit.ly"<?php if($lastRSS_urlshort_domain == 'bit.ly'):?> selected<?php endif;?>>bit.ly</option>
|
||||||
<option value="j.mp"<?php if($lastRSS_urlshort_domain == 'j.mp'):?> selected<?php endif;?>>j.mp</option>
|
<option value="j.mp"<?php if($lastRSS_urlshort_domain == 'j.mp'):?> selected<?php endif;?>>j.mp</option>
|
||||||
<option value="goo.gl"<?php if($lastRSS_urlshort_domain == 'goo.gl'):?> selected<?php endif;?>>goo.gl</option>
|
<option value="goo.gl"<?php if($lastRSS_urlshort_domain == 'goo.gl'):?> selected<?php endif;?>>goo.gl</option>
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
<p><input type="checkbox" value="1" name="lastRSS_is_blank"<?php if($lastRSS_is_blank == 1):?> checked<?php endif;?> /> 新窗口打开前台显示的RSS日志链接 <input type="submit" value="保存参数" class="submit" /></p>
|
<p><input type="checkbox" value="1" name="lastRSS_is_blank"<?php if($lastRSS_is_blank == 1):?> checked<?php endif;?> /> 新窗口打开前台显示的RSS日志链接 <input type="submit" value="保存参数" class="submit" /></p>
|
||||||
</form>
|
</form>
|
||||||
<div class="containertitle"><b>RSS 导入</b></div>
|
<div class="containertitle"><b>RSS 导入</b></div>
|
||||||
<div class="line"></div>
|
<div class="line"></div>
|
||||||
<form action="?plugin=lastRSS&action=setting&do=add" method="post" id="lastRSS_form_input">
|
<form action="?plugin=lastRSS&action=setting&do=add" method="post" id="lastRSS_form_input">
|
||||||
<p>RSS URL: <input type="text" name="url" style="width: 270px;" /> 标题(不填则插件自动获取): <input type="text" name="title" style="width: 200px;" /> <input type="submit" value="添加 RSS" class="submit" /></p>
|
<p>RSS URL: <input type="text" name="url" style="width: 270px;" /> 标题(不填则插件自动获取): <input type="text" name="title" style="width: 200px;" /> <input type="submit" value="添加 RSS" class="submit" /></p>
|
||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
$feeds = getRssFeeds();
|
$feeds = getRssFeeds();
|
||||||
if ($DB->num_rows($feeds) != 0):
|
if ($DB->num_rows($feeds) != 0):
|
||||||
?>
|
?>
|
||||||
<div class="containertitle"><b>管理:(双击单行可对应修改该RSS的URL和标题)</b></div>
|
<div class="containertitle"><b>管理:(双击单行可对应修改该RSS的URL和标题)</b></div>
|
||||||
<div class="line"></div>
|
<div class="line"></div>
|
||||||
<form action="?plugin=lastRSS&action=setting&do=update" method="post" id="lastRSS_form_modify">
|
<form action="?plugin=lastRSS&action=setting&do=update" method="post" id="lastRSS_form_modify">
|
||||||
<p>RSS URL: <input type="text" name="url" id="modify_url" style="width: 270px;" /> 标题: <input type="text" name="title" id="modify_title" style="width: 200px;" /> <input type="hidden" name="id" id="modify_id" /> <input type="submit" value="更新 RSS" class="submit" /> <input type="submit" id="cancel_update" value="取消更新" /></p>
|
<p>RSS URL: <input type="text" name="url" id="modify_url" style="width: 270px;" /> 标题: <input type="text" name="title" id="modify_title" style="width: 200px;" /> <input type="hidden" name="id" id="modify_id" /> <input type="submit" value="更新 RSS" class="submit" /> <input type="submit" id="cancel_update" value="取消更新" /></p>
|
||||||
</form>
|
</form>
|
||||||
<ol>
|
<ol>
|
||||||
<?php
|
<?php
|
||||||
while ($item = $DB->fetch_array($feeds)) {
|
while ($item = $DB->fetch_array($feeds)) {
|
||||||
?>
|
?>
|
||||||
<li class="entry" data-id="<?php echo $item['id']; ?>" data-url="<?php echo $item['url']; ?>" data-title="<?php echo $item['title']; ?>">
|
<li class="entry" data-id="<?php echo $item['id']; ?>" data-url="<?php echo $item['url']; ?>" data-title="<?php echo $item['title']; ?>">
|
||||||
<span class="right"><a href="javascript:;" class="del">删除</a></span>
|
<span class="right"><a href="javascript:;" class="del">删除</a></span>
|
||||||
《<span ><?php echo $item['title']; ?></span>》 URL:<span style="color:#666; font-size: 12px;"><?php echo $item['url']; ?></span>
|
《<span ><?php echo $item['title']; ?></span>》 URL:<span style="color:#666; font-size: 12px;"><?php echo $item['url']; ?></span>
|
||||||
</li>
|
</li>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
?>
|
?>
|
||||||
<div class="containertitle"><b>暂无RSS地址,请导入</b></div>
|
<div class="containertitle"><b>暂无RSS地址,请导入</b></div>
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<?php
|
<?php
|
||||||
function plugin_setting(){
|
function plugin_setting(){
|
||||||
$do = isset($_GET['do']) ? $_GET['do'] : '';
|
$do = isset($_GET['do']) ? $_GET['do'] : '';
|
||||||
if ($do == 'del') {
|
if ($do == 'del') {
|
||||||
$id = intval($_POST['id']);
|
$id = intval($_POST['id']);
|
||||||
if ($id != 0) {
|
if ($id != 0) {
|
||||||
deleteFeed($id);
|
deleteFeed($id);
|
||||||
$msg = array('success' => 'true');
|
$msg = array('success' => 'true');
|
||||||
exit(json_encode($msg));
|
exit(json_encode($msg));
|
||||||
}
|
}
|
||||||
} elseif ($do == 'update') {
|
} elseif ($do == 'update') {
|
||||||
$id = intval($_POST['id']);
|
$id = intval($_POST['id']);
|
||||||
$url = isset($_POST['url']) ? trim($_POST['url']) : '';
|
$url = isset($_POST['url']) ? trim($_POST['url']) : '';
|
||||||
if (!empty($url)) {
|
if (!empty($url)) {
|
||||||
$title = (isset($_POST['title']) && trim($_POST['title']) !='') ? $_POST['title'] : getTitle($url);
|
$title = (isset($_POST['title']) && trim($_POST['title']) !='') ? $_POST['title'] : getTitle($url);
|
||||||
$title = addslashes($title);
|
$title = addslashes($title);
|
||||||
if (!empty($title)) {
|
if (!empty($title)) {
|
||||||
updateFeed($id, $url, $title);
|
updateFeed($id, $url, $title);
|
||||||
header("Location:plugin.php?plugin=lastRSS&setting=true");
|
header("Location:plugin.php?plugin=lastRSS&setting=true");
|
||||||
} else {
|
} else {
|
||||||
emMsg("RSS修改失败,插件无法获取{$url}的标题,请自行添加标题再添加该RSS");
|
emMsg("RSS修改失败,插件无法获取{$url}的标题,请自行添加标题再添加该RSS");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emMsg("RSS修改失败,RSS地址不能为空");
|
emMsg("RSS修改失败,RSS地址不能为空");
|
||||||
}
|
}
|
||||||
} elseif ($do == 'add') {
|
} elseif ($do == 'add') {
|
||||||
$url = isset($_POST['url']) ? trim($_POST['url']) : '';
|
$url = isset($_POST['url']) ? trim($_POST['url']) : '';
|
||||||
if (!empty($url)) {
|
if (!empty($url)) {
|
||||||
$title = (isset($_POST['title']) && trim($_POST['title']) !='') ? $_POST['title'] : getTitle($url);
|
$title = (isset($_POST['title']) && trim($_POST['title']) !='') ? $_POST['title'] : getTitle($url);
|
||||||
$title = addslashes($title);
|
$title = addslashes($title);
|
||||||
if (!empty($title)) {
|
if (!empty($title)) {
|
||||||
insertFeed($url, $title);
|
insertFeed($url, $title);
|
||||||
updateLogs();
|
updateLogs();
|
||||||
header("Location:plugin.php?plugin=lastRSS&setting=true");
|
header("Location:plugin.php?plugin=lastRSS&setting=true");
|
||||||
} else {
|
} else {
|
||||||
emMsg("RSS导入失败,插件无法获取{$url}的标题,请自行添加标题再导入该RSS");
|
emMsg("RSS导入失败,插件无法获取{$url}的标题,请自行添加标题再导入该RSS");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emMsg("RSS导入失败,RSS地址不能为空");
|
emMsg("RSS导入失败,RSS地址不能为空");
|
||||||
}
|
}
|
||||||
} elseif ($do == 'config') {
|
} elseif ($do == 'config') {
|
||||||
$lastRSS_cache_time = isset($_POST['lastRSS_cache_time']) ? intval($_POST['lastRSS_cache_time']) : 0;
|
$lastRSS_cache_time = isset($_POST['lastRSS_cache_time']) ? intval($_POST['lastRSS_cache_time']) : 0;
|
||||||
$lastRSS_item_num = isset($_POST['lastRSS_item_num']) ? intval($_POST['lastRSS_item_num']) : 2;
|
$lastRSS_item_num = isset($_POST['lastRSS_item_num']) ? intval($_POST['lastRSS_item_num']) : 2;
|
||||||
$lastRSS_is_urlshort = isset($_POST['lastRSS_is_urlshort']) ? intval($_POST['lastRSS_is_urlshort']) : 0;
|
$lastRSS_is_urlshort = isset($_POST['lastRSS_is_urlshort']) ? intval($_POST['lastRSS_is_urlshort']) : 0;
|
||||||
$lastRSS_urlshort_domain = isset($_POST['lastRSS_urlshort_domain']) ? trim($_POST['lastRSS_urlshort_domain']) : 't.cn';
|
$lastRSS_urlshort_domain = isset($_POST['lastRSS_urlshort_domain']) ? trim($_POST['lastRSS_urlshort_domain']) : 't.cn';
|
||||||
$lastRSS_is_blank = isset($_POST['lastRSS_is_blank']) ? intval($_POST['lastRSS_is_blank']) : 0;
|
$lastRSS_is_blank = isset($_POST['lastRSS_is_blank']) ? intval($_POST['lastRSS_is_blank']) : 0;
|
||||||
$data = "<?php
|
$data = "<?php
|
||||||
\$lastRSS_cache_time = ".$lastRSS_cache_time.";
|
\$lastRSS_cache_time = ".$lastRSS_cache_time.";
|
||||||
\$lastRSS_item_num = ".$lastRSS_item_num.";
|
\$lastRSS_item_num = ".$lastRSS_item_num.";
|
||||||
\$lastRSS_is_urlshort = ".$lastRSS_is_urlshort.";
|
\$lastRSS_is_urlshort = ".$lastRSS_is_urlshort.";
|
||||||
\$lastRSS_urlshort_domain = '".$lastRSS_urlshort_domain."';
|
\$lastRSS_urlshort_domain = '".$lastRSS_urlshort_domain."';
|
||||||
\$lastRSS_is_blank = ".$lastRSS_is_blank.";
|
\$lastRSS_is_blank = ".$lastRSS_is_blank.";
|
||||||
?>";
|
?>";
|
||||||
$file = EMLOG_ROOT.'/content/plugins/lastRSS/lastRSS_config.php';
|
$file = EMLOG_ROOT.'/content/plugins/lastRSS/lastRSS_config.php';
|
||||||
@ $fp = fopen($file, 'wb') OR emMsg('读取文件失败,如果您使用的是Unix/Linux主机,请修改文件/content/plugins/lastRSS/lastRSS_config.php的权限为777。如果您使用的是Windows主机,请联系管理员,将该文件设为everyone可写');
|
@ $fp = fopen($file, 'wb') OR emMsg('读取文件失败,如果您使用的是Unix/Linux主机,请修改文件/content/plugins/lastRSS/lastRSS_config.php的权限为777。如果您使用的是Windows主机,请联系管理员,将该文件设为everyone可写');
|
||||||
@ $fw = fwrite($fp,$data) OR emMsg('写入文件失败,如果您使用的是Unix/Linux主机,请修改文件/content/plugins/lastRSS/lastRSS_config.php的权限为777。如果您使用的是Windows主机,请联系管理员,将该文件设为everyone可写');
|
@ $fw = fwrite($fp,$data) OR emMsg('写入文件失败,如果您使用的是Unix/Linux主机,请修改文件/content/plugins/lastRSS/lastRSS_config.php的权限为777。如果您使用的是Windows主机,请联系管理员,将该文件设为everyone可写');
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
header("Location:plugin.php?plugin=lastRSS&setting=true");
|
header("Location:plugin.php?plugin=lastRSS&setting=true");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</ol>
|
</ol>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function(){
|
$(function(){
|
||||||
$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $("html") : $("body")) : $("html,body");
|
$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $("html") : $("body")) : $("html,body");
|
||||||
$("#lastRSS").addClass('sidebarsubmenu1');
|
$("#lastRSS").addClass('sidebarsubmenu1');
|
||||||
$(".entry").dblclick(function(){
|
$(".entry").dblclick(function(){
|
||||||
var feedUrl = $(this).data("url"),
|
var feedUrl = $(this).data("url"),
|
||||||
feedId = $(this).data("id"),
|
feedId = $(this).data("id"),
|
||||||
feedTitle = $(this).data("title");
|
feedTitle = $(this).data("title");
|
||||||
$("#modify_url").val(feedUrl);
|
$("#modify_url").val(feedUrl);
|
||||||
$("#modify_title").val(feedTitle);
|
$("#modify_title").val(feedTitle);
|
||||||
$("#modify_id").val(feedId);
|
$("#modify_id").val(feedId);
|
||||||
$("#lastRSS_form_modify").slideDown(400,function(){
|
$("#lastRSS_form_modify").slideDown(400,function(){
|
||||||
$body.animate({
|
$body.animate({
|
||||||
scrollTop: $(this).offset().top - 40
|
scrollTop: $(this).offset().top - 40
|
||||||
}, 500);
|
}, 500);
|
||||||
$("#modify_url").focus();
|
$("#modify_url").focus();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$('.del').click(function(){
|
$('.del').click(function(){
|
||||||
if (confirm('确认删除这个 RSS 数据源?')) {
|
if (confirm('确认删除这个 RSS 数据源?')) {
|
||||||
var _parent = $(this).parents('.entry');
|
var _parent = $(this).parents('.entry');
|
||||||
var _id = _parent.data('id');
|
var _id = _parent.data('id');
|
||||||
$.post('./plugin.php?plugin=lastRSS&action=setting&do=del', {id: _id}, function(e, s){
|
$.post('./plugin.php?plugin=lastRSS&action=setting&do=del', {id: _id}, function(e, s){
|
||||||
if (s === 'success') {
|
if (s === 'success') {
|
||||||
_parent.remove();
|
_parent.remove();
|
||||||
} else {
|
} else {
|
||||||
alert('删除出错!请前往http://xiaosong.org/留言');
|
alert('删除出错!请前往http://xiaosong.org/留言');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$("#cancel_update").click(function(){
|
$("#cancel_update").click(function(){
|
||||||
$("#lastRSS_form_modify").slideUp(200,function(){
|
$("#lastRSS_form_modify").slideUp(200,function(){
|
||||||
$("#modify_url").blur();
|
$("#modify_url").blur();
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user