diff --git a/autopub.php b/autopub.php index b4b0611..62ca7bd 100644 --- a/autopub.php +++ b/autopub.php @@ -1,60 +1,62 @@ $(function(){$.get("'.BLOG_URL.'?plugin=autopub");})'."\n"; + echo ''."\n"; +} +function autopubAjaxAdmin(){ + echo ''."\n"; } function autopubPhp(){ - echo ''."\n"; + echo ''."\n"; } function doPub(){ - $DB = MySql::getInstance(); - $CACHE = Cache::getInstance(); - $autopub = unserialize(Option::get('autopub')); - $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)){ - $key = 'post-'.$row['gid']; - if (isset($autopub[$key])) { - $pub_time = $autopub[$key]; - if (time() >= $pub_time) { - $autopubCopyRight = ''; - $condition = strpos($row['content'], $autopubCopyRight) === false ? ",content = '".addslashes($row['content'].$autopubCopyRight)."'" : ""; - $sql_do = "UPDATE ".DB_PREFIX."blog SET hide = 'n',date = '".$pub_time."'".$condition." WHERE gid='".$row['gid']."'"; - $DB->query($sql_do); - doAction('save_log', $row['gid']); - unset($autopub[$key]); - } + $DB = MySql::getInstance(); + $CACHE = Cache::getInstance(); + $autopub = unserialize(Option::get('autopub')); + $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)){ + $key = 'post-'.$row['gid']; + if (isset($autopub[$key])) { + $pub_time = $autopub[$key]; + if (time() >= $pub_time) { + $autopubCopyRight = ''; + $condition = strpos($row['content'], $autopubCopyRight) === false ? ",content = '".addslashes($row['content'].$autopubCopyRight)."'" : ""; + $sql_do = "UPDATE ".DB_PREFIX."blog SET hide = 'n',date = '".$pub_time."'".$condition." WHERE gid='".$row['gid']."'"; + $DB->query($sql_do); + doAction('save_log', $row['gid']); + unset($autopub[$key]); + } + } } - } - Option::updateOption('autopub', serialize($autopub)); - $CACHE->updateCache(); + Option::updateOption('autopub', serialize($autopub)); + $CACHE->updateCache(); } $autopubArray = unserialize(Option::get('autopub')); if (count($autopubArray) > 1) { - if (isset($autopubArray['trigger']) && $autopubArray['trigger'] == 'ajax') { - emLoadJQuery(); - addAction('index_footer', 'autopubAjax'); - addAction('adm_footer', 'autopubAjax'); - } else if (isset($autopubArray['trigger']) && $autopubArray['trigger'] == 'php') { - addAction('adm_footer', 'autopubPhp'); - } + if (isset($autopubArray['trigger']) && $autopubArray['trigger'] == 'ajax') { + emLoadJQuery(); + addAction('index_footer', 'autopubAjax'); + addAction('adm_footer', 'autopubAjaxAdmin'); + } else if (isset($autopubArray['trigger']) && $autopubArray['trigger'] == 'php') { + addAction('adm_footer', 'autopubPhp'); + } } function autopub_menu() { - echo '
自动发布
'; + echo '
自动发布
'; } -addAction('adm_sidebar_ext', 'autopub_menu'); -?> \ No newline at end of file +addAction('adm_sidebar_ext', 'autopub_menu'); \ No newline at end of file diff --git a/autopub_show.php b/autopub_ajax.php similarity index 76% rename from autopub_show.php rename to autopub_ajax.php index a159ab6..fdd9707 100644 --- a/autopub_show.php +++ b/autopub_ajax.php @@ -3,11 +3,12 @@ * 自动发布插件 * @copyright (c) xiaosong.org All Rights Reserved */ -!defined('EMLOG_ROOT') && exit('access deined!'); +@set_time_limit(0); +require_once('../../../init.php'); + $isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strstr($_SERVER['HTTP_X_REQUESTED_WITH'], 'XMLHttpRequest')) ? 1 : 0; if ($isAjax) { doPub(); exit(); } -emDirect(BLOG_URL); -?> \ No newline at end of file +emDirect(BLOG_URL); \ No newline at end of file diff --git a/autopub_callback.php b/autopub_callback.php index a868c00..65ef8db 100644 --- a/autopub_callback.php +++ b/autopub_callback.php @@ -28,6 +28,4 @@ function callback_init(){ Option::updateOption('autopub', serialize($autopub)); $CACHE = Cache::getInstance(); $CACHE->updateCache('options'); -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/autopub_cron.php b/autopub_cron.php index ce702d2..677872a 100644 --- a/autopub_cron.php +++ b/autopub_cron.php @@ -5,17 +5,13 @@ */ ignore_user_abort(true); set_time_limit(0); +require_once('../../../init.php'); -if (!defined('EMLOG_ROOT')) { - require_once('../../../init.php'); -} do { - clearstatcache(); - $run = EMLOG_ROOT.'/content/plugins/autopub/autopub_cron_pid.php'; - if(!file_exists($run)) die('do nothing'); - doPub(); - sleep(30); -} while (true); - -?> \ No newline at end of file + clearstatcache(); + $run = EMLOG_ROOT.'/content/plugins/autopub/autopub_cron_pid.php'; + if(!file_exists($run)) die('do nothing'); + doPub(); + sleep(30); +} while (true); \ No newline at end of file