table_forum_attachment_unused.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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: table_forum_attachment_unused.php 27449 2012-02-01 05:32:35Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_forum_attachment_unused extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'forum_attachment_unused';
  15. $this->_pk = 'aid';
  16. parent::__construct();
  17. }
  18. public function clear() {
  19. require_once libfile('function/forum');
  20. $delaids = array();
  21. $query = DB::query("SELECT aid, attachment, thumb FROM %t WHERE %i", array($this->_table, DB::field('dateline', TIMESTAMP - 86400)));
  22. while($attach = DB::fetch($query)) {
  23. dunlink($attach);
  24. $delaids[] = $attach['aid'];
  25. }
  26. if($delaids) {
  27. DB::query("DELETE FROM %t WHERE %i", array('forum_attachment', DB::field('aid', $delaids)), false, true);
  28. DB::query("DELETE FROM %t WHERE %i", array($this->_table, DB::field('dateline', TIMESTAMP - 86400)), false, true);
  29. }
  30. }
  31. }
  32. ?>