Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Mapbuild.php 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?php
  2. /**
  3. * 易优CMS
  4. * ============================================================================
  5. * 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
  6. * 网站地址: http://www.eyoucms.com
  7. * ----------------------------------------------------------------------------
  8. * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
  9. * ============================================================================
  10. * Author: 小虎哥 <1105415366@qq.com>
  11. * Date: 2018-4-3
  12. */
  13. namespace app\api\controller;
  14. use \think\Db;
  15. use Overtrue\Pinyin\Pinyin;
  16. use app\api\logic\Sqldata;
  17. class Mapbuild extends Base
  18. {
  19. /*
  20. * 初始化操作
  21. */
  22. public function _initialize() {
  23. parent::_initialize();
  24. session('user'); // 哪里用到 session_id() , 哪个文件就加上这行代码
  25. }
  26. /*
  27. * 地图url分组
  28. * https://www.zc10000.com/api/mapbuild/catIndex
  29. */
  30. public function catIndex()
  31. {
  32. $data = [
  33. '主页',
  34. '申报资讯列表页',
  35. '申报资讯详情页',
  36. '评审政策列表页',
  37. '评审政策详情页',
  38. '评审政策 区域 列表页',
  39. '评审政策 区域 列表页 分页',
  40. '评审政策 区域 详情页',
  41. '业绩材料列表页',
  42. '业绩材料详情页',
  43. '标签页列表页',
  44. '标签页列表页分页'
  45. ];
  46. foreach ($data as $key => $row){
  47. $insert['gid'] = $key;
  48. $insert['name'] = $row;
  49. $one = Db::name('all_name')->where('gid','=',$key)->find();
  50. if(!empty($one)){
  51. Db::name('all_name')->where('gid','=',$key)->update($insert);
  52. }else{
  53. Db::name('all_name')->insert($insert);
  54. }
  55. }
  56. /*
  57. * 查询sql
  58. *
  59. */
  60. $sql = "select a.group_id,(SELECT b.name FROM ey_all_name b WHERE b.gid = a.group_id) AS group_name,a.url, date_format(a.update_time,'%Y-%m-%d %H:%i:%s') AS 更新时间, CASE
  61. WHEN a.is_del = 0 THEN ''
  62. ELSE '文档已删除'
  63. END AS 是否删除,CASE
  64. WHEN a.is_null = 0 THEN ''
  65. ELSE '列表数据为空'
  66. END AS 列表是否为空,CASE
  67. WHEN a.is_arcrank = 0 THEN ''
  68. ELSE '文档审核中'
  69. END AS 文档是否审核,CASE
  70. WHEN a.is_status = 0 THEN ''
  71. ELSE '屏蔽中'
  72. END AS 正常或者屏蔽 from ey_all_url a order by a.group_id asc";
  73. }
  74. /*
  75. * 生成百度地图
  76. * https://www.zc10000.com/api/mapbuild/index100?type=xml
  77. * https://www.zc10000.com/api/mapbuild/index100?type=txt
  78. * https://www.zc10000.com/api/mapbuild/index100?type=html
  79. *
  80. */
  81. public function index100(){
  82. $Sqldata = new Sqldata();
  83. //$aid = $Sqldata->index();
  84. //var_dump($aid);die;
  85. /*
  86. * 可对比系统的xml生成
  87. * 地图文档开头输出
  88. */
  89. $type = request()->get('type','xml');
  90. $data = '';
  91. switch ($type) {
  92. case 'xml':
  93. header('Content-type: text/xml');
  94. $data = new \XMLWriter();
  95. $data->openMemory();
  96. $data->startDocument('1.0', 'UTF-8');
  97. $data->startElement('urlset');
  98. $data->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
  99. $data->writeAttribute('xmlns:mobile', 'http://www.google.com/schemas/sitemap-mobile/1.0');
  100. break;
  101. case 'txt':
  102. $data = '';
  103. break;
  104. case 'html':
  105. //var_dump("444");
  106. $data = $Sqldata->gethtml();
  107. break;
  108. default:
  109. // 如果没有匹配的值
  110. }
  111. /*
  112. * 方法1 获取主页
  113. */
  114. $data = $Sqldata->add_1($type,$data);
  115. /*
  116. * 方法2 生成其他数据
  117. * 根据具体场景生成 组id
  118. */
  119. //申报资讯列表页
  120. $list = $Sqldata->get_url_list('zx',1231,12);
  121. $data = $Sqldata->add_2($type,$data,$list,1,0,'hourly','0.9',0);
  122. //申报资讯详情页
  123. $list = $Sqldata->get_url_detail('zx',1231,2);
  124. $data = $Sqldata->add_2($type,$data,$list,2,0,'hourly','0.8',0);
  125. //评审政策列表页
  126. $list = $Sqldata->get_url_list('zc',1232,12);
  127. $data = $Sqldata->add_2($type,$data,$list,3,0,'hourly','0.9',0);
  128. //评审政策详情页
  129. $list = $Sqldata->get_url_detail('zc/',1232,2);
  130. $data = $Sqldata->add_2($type,$data,$list,4,0,'hourly','0.8',0);
  131. //评审政策 区域 列表页
  132. $list = $Sqldata->get_cat_area_list('zc',1232,12);
  133. $data = $Sqldata->add_2($type,$data,$list,5,1,'hourly','0.9',1);
  134. //评审政策 区域 列表页 分页
  135. $list = $Sqldata->get_cat_area_list_page('zc',1232,12);
  136. $data = $Sqldata->add_2($type,$data,$list,6,0,'hourly','0.9',0);
  137. //评审政策 区域 详情页
  138. $list = $Sqldata->get_url_area_detail('zc',1232,2);
  139. $data = $Sqldata->add_2($type,$data,$list,7,0,'hourly','0.8',0);
  140. //业绩材料列表页
  141. $list = $Sqldata->get_url_list('cl',1233,12);
  142. $data = $Sqldata->add_2($type,$data,$list,8,0,'hourly','0.9',0);
  143. //业绩材料详情页
  144. $list = $Sqldata->get_url_detail('cl/',1233,2);
  145. $data = $Sqldata->add_2($type,$data,$list,9,0,'hourly','0.8',0);
  146. //标签页列表页 不需要标签页主页和分页
  147. $list = $Sqldata->get_tag_list();
  148. $data = $Sqldata->add_2($type,$data,$list,10,0,'hourly','0.9',0);
  149. //标签页列表页 分页
  150. $list = $Sqldata->get_tag_list_page('tag',12);
  151. $data = $Sqldata->add_2($type,$data,$list,11,0,'hourly','0.9',0);
  152. //地图文档结尾输出
  153. switch ($type) {
  154. case 'xml':
  155. // ... 添加其他页面的URL
  156. $data->endElement();
  157. $data->endDocument();
  158. //var_dump($xmlWriter->outputMemory(true));
  159. file_put_contents('./sitemap.xml', $data->outputMemory(true));
  160. break;
  161. case 'txt':
  162. file_put_contents('./sitemap.txt',$data);
  163. break;
  164. case 'html':
  165. $data .= $Sqldata->gethtmlend();
  166. //./sitemaps/sitemap.html
  167. file_put_contents('./sitemap.html',$data);
  168. break;
  169. default:
  170. // 如果没有匹配的值
  171. }
  172. return json([]);
  173. }
  174. /*
  175. * 以下都是获取链接的方法
  176. * 有共性 有差异
  177. */
  178. }