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

70 lines
2.5KB

  1. <?php
  2. if (!defined('DEDEINC')) {
  3. exit("Request Error!");
  4. }
  5. /**
  6. * 友情链接
  7. *
  8. * @version $Id: flink.lib.php 1 9:29 2010年7月6日Z tianya $
  9. * @package DedeCMS.Taglib
  10. * @copyright Copyright (c) 2020, DedeBIZ.COM
  11. * @license https://www.dedebiz.com/license
  12. * @link https://www.dedebiz.com
  13. */
  14. helper('cache');
  15. function lib_flink(&$ctag, &$refObj)
  16. {
  17. global $dsql, $cfg_soft_lang;
  18. $attlist = "type|textall,row|24,titlelen|24,linktype|1,typeid|0";
  19. FillAttsDefault($ctag->CAttribute->Items, $attlist);
  20. extract($ctag->CAttribute->Items, EXTR_SKIP);
  21. $totalrow = $row;
  22. $revalue = '';
  23. if (isset($GLOBALS['envs']['flinkid'])) {
  24. $typeid = $GLOBALS['envs']['flinkid'];
  25. }
  26. $wsql = " where ischeck >= '$linktype' ";
  27. if ($typeid == 0) {
  28. $wsql .= '';
  29. } else {
  30. $wsql .= "And typeid = '$typeid'";
  31. }
  32. if ($type == 'image') {
  33. $wsql .= " And logo<>'' ";
  34. } else if ($type == 'text') {
  35. $wsql .= " And logo='' ";
  36. }
  37. $equery = "SELECT * FROM `#@__flink` $wsql order by sortrank asc limit 0,$totalrow";
  38. if (trim($ctag->GetInnerText()) == '') $innertext = "[field:link /] ";
  39. else $innertext = $ctag->GetInnerText();
  40. $dsql->SetQuery($equery);
  41. $dsql->Execute();
  42. while ($dbrow = $dsql->GetObject()) {
  43. if ($type == 'text' || $type == 'textall') {
  44. $link = "<a href='" . $dbrow->url . "' target='_blank'>" . cn_substr($dbrow->webname, $titlelen) . "</a> ";
  45. } else if ($type == 'image') {
  46. $link = "<a href='" . $dbrow->url . "' target='_blank'><img src='" . $dbrow->logo . "' width='88' height='31' border='0'></a> ";
  47. } else {
  48. if ($dbrow->logo == '') {
  49. $link = "<a href='" . $dbrow->url . "' target='_blank'>" . cn_substr($dbrow->webname, $titlelen) . "</a> ";
  50. } else {
  51. $link = "<a href='" . $dbrow->url . "' target='_blank'><img src='" . $dbrow->logo . "' width='88' height='31' border='0'></a> ";
  52. }
  53. }
  54. $rbtext = preg_replace("/\[field:url([\/\s]{0,})\]/isU", $dbrow->url, $innertext);
  55. $rbtext = preg_replace("/\[field:webname([\/\s]{0,})\]/isU", $dbrow->webname, $rbtext);
  56. $rbtext = preg_replace("/\[field:logo([\/\s]{0,})\]/isU", $dbrow->logo, $rbtext);
  57. $rbtext = preg_replace("/\[field:link([\/\s]{0,})\]/isU", $link, $rbtext);
  58. $revalue .= $rbtext;
  59. }
  60. return $revalue;
  61. }