国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
3.4KB

  1. <?php
  2. /**
  3. * 百度新闻
  4. *
  5. * @version $Id: baidunews.php 1 14:31 2010年7月12日Z tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__)."/config.php");
  12. $filename = str_replace("..", "", $filename);
  13. $filename = str_replace("{cmspath}", $cfg_cmspath, $filename);
  14. if (empty($do)) {
  15. include DEDEADMIN.'/templets/baidunews.htm';
  16. } else {
  17. $baidunews = "<?xml version=\"1.0\" encoding=\"".$cfg_soft_lang."\" ?>\n";
  18. $baidunews .= "<document>\n";
  19. $baidunews .= "<webSite>$cfg_webname </webSite>\n";
  20. $baidunews .= "<webMaster>$cfg_adminemail </webMaster>\n";
  21. $baidunews .= "<updatePeri>$cfg_updateperi </updatePeri>\n";
  22. $limit = $cfg_baidunews_limit;
  23. if ($limit > 100 || $limit < 1) {
  24. $limit = 100;
  25. }
  26. $query = "SELECT maintable.*, addtable.body, arctype.typename
  27. FROM `#@__archives` maintable
  28. LEFT JOIN `#@__addonarticle` addtable ON addtable.aid=maintable.id
  29. LEFT JOIN `#@__arctype` arctype ON arctype.ID=maintable.typeid
  30. WHERE maintable.channel=1 and maintable.arcrank!=-1 ORDER BY maintable.pubdate DESC LIMIT $limit
  31. ";
  32. $dsql->SetQuery($query);
  33. $dsql->Execute();
  34. while ($row = $dsql->GetArray()) {
  35. $title = dede_htmlspecialchars($row['title']);
  36. $row1 = GetOneArchive($row['id']);
  37. if (strpos($row1['arcurl'], 'http://') === false) {
  38. $link = ($cfg_basehost == '' ? 'http://'.$_SERVER["HTTP_HOST"].$cfg_cmspath : $cfg_basehost).$row1['arcurl'];
  39. } else {
  40. $link = $row1['arcurl'];
  41. }
  42. $link = dede_htmlspecialchars($link);
  43. $description = dede_htmlspecialchars(strip_tags($row['description']));
  44. $text = dede_htmlspecialchars(strip_tags($row['body']));
  45. $image = $row['litpic'] == '' ? '' : $row['litpic'];
  46. if ($image != '' && strpos($image, 'http://') === false) {
  47. $image = ($cfg_basehost == '' ? 'http://'.$_SERVER["HTTP_HOST"].$cfg_cmspath : $cfg_basehost).$image;
  48. }
  49. //$headlineimg = '';
  50. $keywords = dede_htmlspecialchars($row['keywords']);
  51. $category = dede_htmlspecialchars($row['typename']);
  52. $author = dede_htmlspecialchars($row['writer']);
  53. $source = dede_htmlspecialchars($row['source']);
  54. $pubdate = dede_htmlspecialchars(gmdate('Y-m-d H:i', $row['pubdate'] + $cfg_cli_time * 3600));
  55. $baidunews .= "<item>\n";
  56. $baidunews .= "<title>$title </title>\n";
  57. $baidunews .= "<link>$link </link>\n";
  58. $baidunews .= "<description>$description </description>\n";
  59. $baidunews .= "<text>$text </text>\n";
  60. $baidunews .= "<image>$image </image>\n";
  61. //$baidunews .= "<headlineimages/>\n";
  62. $baidunews .= "<keywords>$keywords </keywords>\n";
  63. $baidunews .= "<category>$category </category>\n";
  64. $baidunews .= "<author>$author </author>\n";
  65. $baidunews .= "<source>$source </source>\n";
  66. $baidunews .= "<pubDate>$pubdate </pubDate>\n";
  67. $baidunews .= "</item>\n";
  68. }
  69. $baidunews .= "</document>\n";
  70. $fname = str_replace("//","/",DEDEROOT.$filename) ;
  71. $fp = fopen($fname, 'w');
  72. fwrite($fp, $baidunews);
  73. fclose($fp);
  74. showmsg("<a href='{$filename}' target=\"_blank\">{$filename}生成成功</a>", 'javascript:;');
  75. }