管理员后台也可触发发布日志的动作

This commit is contained in:
2012-10-18 14:47:13 +08:00
parent 34feee0ea4
commit 375a141cf6
2 changed files with 25 additions and 23 deletions

View File

@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: 自动发布
Version: 1.9.1
Version: 1.9.2
Plugin URL: http://xiaosong.org/share/auto-pub-plugin-update
Description: 自动发布文章,修正时区问题,增加相关挂载点,自动删除缓存文件。
Author: 小松
@@ -23,7 +23,7 @@ function dir_is_empty($dir){
}
function autopub(){
echo '<script type="text/javascript">$(function(){$.get("'.DYNAMIC_BLOGURL.'?plugin=autopub");})</script>'."\n";
echo '<script type="text/javascript">$(function(){$.get("'.BLOG_URL.'?plugin=autopub");})</script>'."\n";
}
if (!dir_is_empty(AUTOPUB_CACHE_DIR)) {

View File

@@ -1,22 +1,24 @@
<?php
!defined('EMLOG_ROOT') && exit('access deined!');
define('AUTOPUB_CACHE_DIR', EMLOG_ROOT.'/content/plugins/autopub/cache/');
set_time_limit(0);
$DB = MySql::getInstance();
$CACHE = Cache::getInstance();
$sql = "SELECT gid FROM ".DB_PREFIX."blog where hide ='y' order by date DESC";
$result = $DB->query($sql);
while($row = $DB->fetch_array($result)){
if(file_exists(AUTOPUB_CACHE_DIR.$row['gid'].'.php')){
include_once(AUTOPUB_CACHE_DIR.$row['gid'].'.php');
$pub_time = emStrtotime($year.'-'.$month.'-'.$day.' '.$hour.':'.$minute.':'.$second);
if(time() > $pub_time){
$sql_do = "UPDATE ".DB_PREFIX."blog SET hide = 'n',date = '".$pub_time."' WHERE gid='".$row['gid']."'";
$DB->query($sql_do);
$CACHE->updateCache();
doAction('save_log', $row['gid']);
unlink(AUTOPUB_CACHE_DIR.$row['gid'].'.php');
}
}
}
<?php
!defined('EMLOG_ROOT') && exit('access deined!');
!defined('AUTOPUB_CACHE_DIR') && define('AUTOPUB_CACHE_DIR', EMLOG_ROOT.'/content/plugins/autopub/cache/');
set_time_limit(0);
$DB = MySql::getInstance();
$CACHE = Cache::getInstance();
$sql = "SELECT gid, content FROM ".DB_PREFIX."blog where hide ='y' order by date DESC";
$result = $DB->query($sql);
while($row = $DB->fetch_array($result)){
if(file_exists(AUTOPUB_CACHE_DIR.$row['gid'].'.php')){
include_once(AUTOPUB_CACHE_DIR.$row['gid'].'.php');
$pub_time = emStrtotime($year.'-'.$month.'-'.$day.' '.$hour.':'.$minute.':'.$second);
$autopubCopyRight = '<p style="text-align:right;font-size:12px;">(此文通过<a href="http://xiaosong.org/share/auto-pub-plugin-update">emlog自动发布插件</a>发布)</p>';
$content = $row['content'].$autopubCopyRight;
if(time() > $pub_time){
$sql_do = "UPDATE ".DB_PREFIX."blog SET hide = 'n',date = '".$pub_time."',content = '".$content."' WHERE gid='".$row['gid']."'";
$DB->query($sql_do);
$CACHE->updateCache();
doAction('save_log', $row['gid']);
unlink(AUTOPUB_CACHE_DIR.$row['gid'].'.php');
}
}
}
?>