This commit is contained in:
2012-10-31 21:13:20 +08:00
parent aa5ae34544
commit d5f3b47056
14 changed files with 223 additions and 264 deletions

View File

@@ -1,24 +1,13 @@
<?php
/**
* 自动发布插件
* @copyright (c) xiaosong.org All Rights Reserved
*/
!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 = '".addslashes($content)."' WHERE gid='".$row['gid']."'";
$DB->query($sql_do);
$CACHE->updateCache();
doAction('save_log', $row['gid']);
unlink(AUTOPUB_CACHE_DIR.$row['gid'].'.php');
}
}
$isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strstr($_SERVER['HTTP_X_REQUESTED_WITH'], 'XMLHttpRequest')) ? 1 : 0;
if ($isAjax) {
doPub();
exit();
}
emDirect(BLOG_URL);
?>