welcome.mod.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. function welcome_notices_get() {
  8. global $_W;
  9. $order = !empty($_W['setting']['notice_display']) ? $_W['setting']['notice_display'] : 'displayorder';
  10. $article_table = table('article_notice');
  11. $article_table->orderby($order, 'DESC');
  12. $article_table->searchWithIsDisplay();
  13. $article_table->searchWithPage(0, 15);
  14. $notices = $article_table->getall();
  15. if(!empty($notices)) {
  16. foreach ($notices as $key => $notice_val) {
  17. $notices[$key]['url'] = url('article/notice-show/detail', array('id' => $notice_val['id']));
  18. $notices[$key]['createtime'] = date('Y-m-d', $notice_val['createtime']);
  19. $notices[$key]['style'] = iunserializer($notice_val['style']);
  20. $notices[$key]['group'] = empty($notice_val['group']) ? array('vice_founder' => array(), 'normal' => array()) : iunserializer($notice_val['group']);
  21. if (!empty($notice_val['group'])) {
  22. if (($_W['isfounder'] && !empty($notices[$key]['group']['vice_founder']) && !in_array($_W['user']['groupid'], $notices[$key]['group']['vice_founder'])) || (!$_W['isfounder'] && !empty($notices[$key]['group']['normal']) && !in_array($_W['user']['groupid'], $notices[$key]['group']['normal']))) {
  23. unset($notices[$key]);
  24. }
  25. }
  26. }
  27. }
  28. return $notices;
  29. }
  30. function welcome_database_backup_days() {
  31. $cachekey = cache_system_key('back_days');
  32. $cache = cache_load($cachekey);
  33. if (!empty($cache) && !empty($cache['expire']) && $cache['expire'] > TIMESTAMP) {
  34. return $cache['data'];
  35. }
  36. $reductions = system_database_backup();
  37. if (!empty($reductions)) {
  38. $last_backup_time = 0;
  39. foreach ($reductions as $key => $reduction) {
  40. if ($reduction['time'] <= $last_backup_time) {
  41. continue;
  42. }
  43. $last_backup_time = $reduction['time'];
  44. }
  45. $backup_days = floor((time() - $last_backup_time) / (3600 * 24));
  46. } else {
  47. $backup_days = -1;
  48. }
  49. cache_write($cachekey, $backup_days, 12 * 3600);
  50. return $backup_days;
  51. }