welcome.mod.php 3.0 KB

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