国内流行的内容管理系统(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.

115 lines
4.6KB

  1. <?php
  2. if (!defined('DEDEINC')) exit ('dedebiz');
  3. /**
  4. * 软件标签
  5. *
  6. * @version $id:softlinks.lib.php 9:33 2010年7月8日 tianya $
  7. * @package DedeBIZ.Taglib
  8. * @copyright Copyright (c) 2022 DedeBIZ.COM
  9. * @license GNU GPL v2 (https://www.dedebiz.com/license)
  10. * @link https://www.dedebiz.com
  11. */
  12. function ch_softlinks($fvalue, &$ctag, &$refObj, $fname = '', $downloadpage = false)
  13. {
  14. global $dsql;
  15. $row = $dsql->GetOne("SELECT * FROM `#@__softconfig`");
  16. $phppath = $GLOBALS['cfg_phpurl'];
  17. $downlinks = '';
  18. if ($row['downtype'] != '0' && !$downloadpage) {
  19. $tempStr = GetSysTemplets("channel_downlinkpage.htm");
  20. $links = $phppath."/download.php?open=0&aid=".$refObj->ArcID."&cid=".$refObj->ChannelID;
  21. $downlinks = str_replace("~link~", $links, $tempStr);
  22. return $downlinks;
  23. } else {
  24. return ch_softlinks_all($fvalue, $ctag, $refObj, $row);
  25. }
  26. }
  27. //读取所有链接地址
  28. function ch_softlinks_all($fvalue, &$ctag, &$refObj, &$row)
  29. {
  30. global $cfg_phpurl,$cfg_multi_site,$cfg_mainsite;
  31. $phppath = $cfg_phpurl;
  32. $islinktype = false;
  33. if (!empty($link_type)) $islinktype = true;
  34. $dtp = new DedeTagParse();
  35. $dtp->LoadSource($fvalue);
  36. if (!is_array($dtp->CTags)) {
  37. $dtp->Clear();
  38. return "无链接信息";
  39. }
  40. //去除链接信息
  41. if (!empty($row['sites'])) {
  42. $sertype_arr = array();
  43. $row['sites'] = preg_replace("#[\r\n]{1,}#", "\n", $row['sites']);
  44. $sites = explode("\n", trim($row['sites']));
  45. foreach ($sites as $site) {
  46. if (trim($site) == '') continue;
  47. @list($link, $serverName, $serverType) = explode('|', $site);
  48. $sertype_arr[trim($serverName)] = trim($serverType);
  49. }
  50. }
  51. $tempStr = GetSysTemplets('channel_downlinks.htm');
  52. $downlinks = '';
  53. foreach ($dtp->CTags as $ctag) {
  54. if ($ctag->GetName() == 'link') {
  55. $link = trim($ctag->GetInnerText());
  56. $serverName = trim($ctag->GetAtt('text'));
  57. $islocal = trim($ctag->GetAtt('islocal'));
  58. if (isset($sertype_arr[$serverName]) && $islinktype) continue;
  59. //分析本地链接
  60. if (!isset($firstLink) && $islocal == 1) $firstLink = $link;
  61. if ($islocal == 1 && $row['islocal'] != 1) continue;
  62. //支持http、迅雷下载、ftp、flashget
  63. if (!preg_match("#^(http|https):\/\/|^thunder:\/\/|^ftp:\/\/|^flashget:\/\/#i", $link) && $cfg_multi_site == 'Y') {
  64. $link = $cfg_mainsite.$link;
  65. }
  66. $downloads = getDownloads($link);
  67. $uhash = substr(md5($link), 0, 24);
  68. if ($row['gotojump'] == 1) {
  69. $link = $phppath."/download.php?open=2&id={$refObj->ArcID}&uhash={$uhash}";
  70. }
  71. $temp = str_replace("~link~", $link, $tempStr);
  72. $temp = str_replace("~server~", $serverName, $temp);
  73. $temp = str_replace("~downloads~", $downloads, $temp);
  74. $downlinks .= $temp;
  75. }
  76. }
  77. $dtp->Clear();
  78. //获取镜像功能的地址,必须设置为:根据本地地址和服务器列表自动生成
  79. $linkCount = 1;
  80. if ($row['ismoresite'] == 1 && $row['moresitedo'] == 1 && trim($row['sites']) != '' && isset($firstLink)) {
  81. $firstLink = preg_replace("#http:\/\/([^\/]*)\/#i", '/', $firstLink);
  82. foreach ($sites as $site) {
  83. if (trim($site) == '') continue;
  84. list($link, $serverName, $serverType) = explode('|', $site);
  85. if (!empty($link_type) && $link_type != trim($serverType)) continue;
  86. $link = trim(preg_replace("#\/$#", "", $link)).$firstLink;
  87. $downloads = getDownloads($link);
  88. $uhash = substr(md5($link), 0, 24);
  89. if ($row['gotojump'] == 1) {
  90. $link = $phppath."/download.php?open=2&id={$refObj->ArcID}&uhash={$uhash}";
  91. }
  92. $temp = str_replace("~link~", $link, $tempStr);
  93. $temp = str_replace("~server~", $serverName, $temp);
  94. $temp = str_replace("~downloads~", $downloads, $temp);
  95. $downlinks .= $temp;
  96. }
  97. }
  98. return $downlinks;
  99. }
  100. function getDownloads($url)
  101. {
  102. global $dsql;
  103. $hash = md5($url);
  104. $query = "SELECT downloads FROM `#@__downloads` WHERE hash='$hash' ";
  105. $row = $dsql->GetOne($query);
  106. if (is_array($row)) {
  107. $downloads = $row['downloads'];
  108. } else {
  109. $downloads = 0;
  110. }
  111. return $downloads;
  112. }
  113. ?>