国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

133 linhas
4.9KB

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