cron_magic_daily.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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_magic_daily.php 24589 2011-09-27 07:45:55Z monkey $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if(!empty($_G['setting']['magicstatus'])) {
  12. $magicarray = array();
  13. foreach(C::t('common_magic')->fetch_all_data(1) as $magic) {
  14. if($magic['supplytype'] && $magic['supplynum']) {
  15. $magicarray[$magic['magicid']]['supplytype'] = $magic['supplytype'];
  16. $magicarray[$magic['magicid']]['supplynum'] = $magic['supplynum'];
  17. }
  18. }
  19. list($daynow, $weekdaynow) = explode('-', dgmdate(TIMESTAMP, 'd-w', $_G['setting']['timeoffset']));
  20. foreach($magicarray as $id => $magic) {
  21. $autosupply = 0;
  22. if($magic['supplytype'] == 1) {
  23. $autosupply = 1;
  24. } elseif($magic['supplytype'] == 2 && $weekdaynow == 1) {
  25. $autosupply = 1;
  26. } elseif($magic['supplytype'] == 3 && $daynow == 1) {
  27. $autosupply = 1;
  28. }
  29. if(!empty($autosupply)) {
  30. C::t('common_magic')->update($id, array('num' => $magic['supplynum']));
  31. }
  32. }
  33. }
  34. ?>