cron_publish_halfhourly.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: cron_publish_halfhourly.php 31463 2012-08-30 08:59:17Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. require_once libfile('function/forum');
  12. require_once libfile('function/post');
  13. loadcache('cronpublish');
  14. $dataChanged = false;
  15. $cron_publish_ids = array();
  16. $cron_publish_ids = unserialize(getglobal('cache/cronpublish'));
  17. if (count($cron_publish_ids) > 0) {
  18. $threadall = C::t('forum_thread')->fetch_all_by_tid($cron_publish_ids);
  19. foreach ($cron_publish_ids as $tid) {
  20. if(!$threadall[$tid]) {
  21. unset($cron_publish_ids[$tid]);
  22. $dataChanged = true;
  23. }
  24. }
  25. foreach ($threadall as $stid=>$sdata) {
  26. if ($sdata['dateline'] <= getglobal('timestamp')) {
  27. threadpubsave($stid, true);
  28. unset($cron_publish_ids[$stid]);
  29. $dataChanged = true;
  30. }
  31. }
  32. if ($dataChanged === true) {
  33. $newcronpublish = serialize($cron_publish_ids);
  34. savecache('cronpublish', $newcronpublish);
  35. }
  36. }
  37. ?>