人人商城

welcome.mod.php 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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_get_last_modules() {
  8. load()->classs('cloudapi');
  9. $api = new CloudApi();
  10. $last_modules = $api->get('store', 'app_fresh');
  11. return $last_modules;
  12. }
  13. function welcome_get_ads() {
  14. load()->classs('cloudapi');
  15. $result = array();
  16. $api = new CloudApi();
  17. $result = $api->get('store', 'we7_index_a');
  18. return $result;
  19. }
  20. function welcome_notices_get() {
  21. global $_W;
  22. $order = !empty($_W['setting']['notice_display']) ? $_W['setting']['notice_display'] : 'displayorder';
  23. $notices = pdo_getall('article_notice', array('is_display' => 1), array('id', 'title', 'createtime', 'style', 'group'), '', $order . ' DESC', array(1,15));
  24. if(!empty($notices)) {
  25. foreach ($notices as $key => $notice_val) {
  26. $notices[$key]['url'] = url('article/notice-show/detail', array('id' => $notice_val['id']));
  27. $notices[$key]['createtime'] = date('Y-m-d', $notice_val['createtime']);
  28. $notices[$key]['style'] = iunserializer($notice_val['style']);
  29. $notices[$key]['group'] = empty($notice_val['group']) ? array('vice_founder' => array(), 'normal' => array()) : iunserializer($notice_val['group']);
  30. if (!empty($_W['user']['groupid']) && !empty($notice_val['group']) && !in_array($_W['user']['groupid'], $notices[$key]['group']['vice_founder']) && !in_array($_W['user']['groupid'], $notices[$key]['group']['normal'])) {
  31. unset($notices[$key]);
  32. }
  33. }
  34. }
  35. return $notices;
  36. }
  37. function welcome_database_backup_days($time) {
  38. global $_W;
  39. $cachekey = cache_system_key('back_days');
  40. $cache = cache_load($cachekey);
  41. if (!empty($cache)) {
  42. return $cache;
  43. }
  44. $backup_days = 0;
  45. if (is_array($time)) {
  46. $max_backup_time = $time[0];
  47. foreach ($time as $key => $backup_time) {
  48. if ($backup_time <= $max_backup_time) {
  49. continue;
  50. }
  51. $max_backup_time = $backup_time;
  52. }
  53. $backup_days = ceil((time() - $max_backup_time) / (3600 * 24));
  54. }
  55. if (is_numeric($time)) {
  56. $backup_days = ceil((time() - $time) / (3600 * 24));
  57. }
  58. cache_write($cachekey, $backup_days, 24 * 3600);
  59. return $backup_days;
  60. }
  61. function welcome_get_cloud_upgrade() {
  62. load()->model('cloud');
  63. $upgrade_cache = cache_load(cache_system_key('upgrade'));
  64. if (empty($upgrade_cache) || TIMESTAMP - $upgrade_cache['lastupdate'] >= 3600 * 24 || empty($upgrade_cache['data'])) {
  65. $upgrade = cloud_build();
  66. } else {
  67. $upgrade = $upgrade_cache['data'];
  68. }
  69. cache_delete(cache_system_key('cloud_transtoken'));
  70. if (is_error($upgrade) || empty($upgrade['upgrade'])) {
  71. $upgrade = array();
  72. }
  73. if (!empty($upgrade['schemas'])) {
  74. $upgrade['database'] = cloud_build_schemas($schems);
  75. }
  76. if (!empty($upgrade['files'])) {
  77. $file_nums = count($upgrade['files']);
  78. }
  79. if (!empty($upgrade['database'])) {
  80. $database_nums = count($upgrade['database']);
  81. }
  82. if (!empty($upgrade['scripts'])) {
  83. $script_nums = count($upgrade['scripts']);
  84. }
  85. $upgrade['file_nums'] = $file_nums;
  86. $upgrade['database_nums'] = $database_nums;
  87. $upgrade['script_nums'] = $script_nums;
  88. return $upgrade;
  89. }