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

67 lines
2.4KB

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