sitemap.inc.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. if(!defined('IN_DISCUZ')) {
  3. exit('Access Denied');
  4. }
  5. require_once(DISCUZ_ROOT.'source/plugin/milu_seotool/config.inc.php');
  6. sload('F:sitemap,F:copyright');
  7. $args = array('default_ac' => 'sitemap_set');
  8. $sitemap_set = tool_common_get('sitemap');
  9. $sitemap_set['sitemap_type'] = dunserialize($sitemap_set['sitemap_type']);
  10. if(!function_exists('gzopen')) unset($sitemap_set['sitemap_type'][array_search('gz', $sitemap_set['sitemap_type'])]);
  11. $sitemap_set['max_article_num'] = $sitemap_set['max_article_num'] ? $sitemap_set['max_article_num'] : 500;
  12. $sitemap_set['max_threads_num'] = $sitemap_set['max_threads_num'] ? $sitemap_set['max_threads_num'] : 500;
  13. seo_tpl($args);
  14. function sitemap_set(){
  15. global $_G,$pluin_info,$sitemap_set;
  16. if($_POST['editsubmit']){
  17. $set = $_POST['set'];
  18. $set['sitemap_type'] = st_serialize($_POST['sitemap_type']);
  19. $update_info = update_sitemap($set);
  20. save_syscache('milu_seotool_sitemap', $update_info);
  21. //计划任务要重新设定
  22. tool_common_set('milu_seotool_cron', array('sitemap_maker' => 0));
  23. tool_common_set('sitemap', $set);
  24. cpmsg(stlang('op_success'), PLUGIN_GO."sitemap", 'succeed');
  25. }else{
  26. $info = $sitemap_set;
  27. $show .= seoOutput::show_title(stlang('base_set'));
  28. if(VIP){
  29. $show .= seoOutput::show_tr(
  30. array(
  31. 'name' => stlang('auto_update_sitemap'),
  32. 'desc' => '',
  33. 'arr' => array(
  34. 'name' => 'is_auto',
  35. 'info' => $info,
  36. 'int_val' => 2,
  37. 'lang_type' => 2,
  38. ),
  39. )
  40. ,'radio');
  41. $show .= seoOutput::show_tr(
  42. array(
  43. 'name' => stlang('sitemap_update_tiimes'),
  44. 'desc' => stlang('sitemap_update_tiimes_notice'),
  45. 'arr' => array(
  46. 'name' => 'auto_time',
  47. 'int_val' => 1,
  48. 'info' => $info,
  49. ),
  50. )
  51. ,'input');
  52. }
  53. $show .= seoOutput::show_tr(
  54. array(
  55. 'name' => stlang('sitemap_article_max_count'),
  56. 'desc' => stlang('sitemap_article_max_notice'),
  57. 'arr' => array(
  58. 'name' => 'max_article_num',
  59. 'int_val' => 500,
  60. 'info' => $info,
  61. ),
  62. )
  63. ,'input');
  64. $show .= seoOutput::show_tr(
  65. array(
  66. 'name' => stlang('sitemap_bbs_max_count'),
  67. 'desc' => stlang('sitemap_article_max_notice'),
  68. 'arr' => array(
  69. 'name' => 'max_threads_num',
  70. 'int_val' => 500,
  71. 'info' => $info,
  72. ),
  73. )
  74. ,'input');
  75. $create_file_type = seoOutput::show_tr(
  76. array(
  77. 'name' => stlang('sitemap_file_type'),
  78. 'desc' => stlang('sitemap_file_type_notice'),
  79. 'arr' => array(
  80. 'name' => 'sitemap_type',
  81. 'info' => $info,
  82. 'option_arr' => array('xml' => 'xml', 'txt' => 'txt', 'gz' => 'gz', 'html' => 'html'),
  83. ),
  84. )
  85. ,'checkbox');
  86. $create_file_type = !function_exists('gzopen') ? str_replace(array('id="sitemap_type2"', '<label for="sitemap_type2">gz</label>'), array(' id="sitemap_type2" disabled="disabled"', '<label for="sitemap_type2">gz('.stlang('server_no_zhichi').')</label>'), $create_file_type) : $create_file_type;
  87. $show .= $create_file_type;
  88. $show .= seoOutput::show_title(stlang('sitemap_status'));
  89. loadcache('milu_seotool_sitemap');
  90. $sitemap_update_data = $_G['cache']['milu_seotool_sitemap'];
  91. $info['updateline'] = $sitemap_update_data['updateline'];
  92. $info['sitemap_url_count'] = $sitemap_update_data['sitemap_url_count'];
  93. $info['updateline'] = $info['updateline'] ? dgmdate($info['updateline']) : stlang('no_have');
  94. foreach($info['sitemap_type'] as $k => $v){
  95. $path = $v == 'gz' ? 'sitemap.xml.gz' : 'sitemap.'.$v;
  96. $sitemap['show'] .= ' &nbsp;<a href="'.$_G['siteurl'].$path.'" target="_blank">'.stlang('view_type_sitemap', array('c' => $v)).'</a>';
  97. }
  98. $sitemap['show'] = seoOutput::add_tr(array(''), $sitemap['show']);
  99. $sitemap['status'] = seoOutput::add_tr(array(''), stlang('in_url_count').":$info[sitemap_url_count] ".stlang('modify_dateline').":$info[updateline]");
  100. if($info['sitemap_type']){
  101. $show .= $sitemap['status'].$sitemap['show'];
  102. }else{
  103. $show .= seoOutput::add_tr(array(''), stlang('no_create'));
  104. }
  105. $show .= seoOutput::add_tr(array(''), stlang('sitemap_create_notice').' <a href="'.$_G['siteurl'].'robots.txt" target="_blank">'.stlang('view').'</a>');
  106. $info['show'] = $show;
  107. $info['submit_name'] = stlang('submit_update_sitemap');
  108. $info['tpl'] = 'common_set';
  109. return $info;
  110. }
  111. }
  112. //执行计划任务
  113. function milu_seotool_cron(){
  114. global $_G;
  115. sload('C:cron');
  116. $cron_info = tool_common_get('milu_seotool_cron');
  117. print_r($cron_info);
  118. //收录查询
  119. if((int)$cron_info['included_check'] <= TIMESTAMP) {
  120. milu_seotool_cron::included_check();
  121. }
  122. //ping查询
  123. if((int)$cron_info['ping_check'] <= TIMESTAMP) {
  124. milu_seotool_cron::ping_check();
  125. }
  126. //排名查询
  127. if((int)$cron_info['keyword_rank_check'] <= TIMESTAMP) {
  128. if(VIP) milu_seotool_cron::keyword_rank_check();
  129. }
  130. //网站地图更新
  131. if((int)$cron_info['sitemap_maker'] <= TIMESTAMP) {
  132. if(VIP) milu_seotool_cron::sitemap_maker();
  133. }
  134. }
  135. ?>