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

31 lines
1.1KB

  1. <?php
  2. /**
  3. * 热门搜索词标签
  4. *
  5. * @version $id:hotwords.lib.php 9:29 2010年7月6日 tianya $
  6. * @package DedeBIZ.Taglib
  7. * @copyright Copyright (c) 2022 DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. function lib_hotwords(&$ctag, &$refObj)
  12. {
  13. global $cfg_phpurl, $dsql;
  14. $attlist = "num|6,subday|365,maxlength|16";
  15. FillAttsDefault($ctag->CAttribute->Items, $attlist);
  16. extract($ctag->CAttribute->Items, EXTR_SKIP);
  17. $nowtime = time();
  18. if (empty($subday)) $subday = 365;
  19. if (empty($num)) $num = 6;
  20. if (empty($maxlength)) $maxlength = 20;
  21. $maxlength = $maxlength + 1;
  22. $mintime = $nowtime - ($subday * 24 * 3600);
  23. $dsql->SetQuery("SELECT keyword FROM `#@__search_keywords` WHERE lasttime>$mintime AND length(keyword)<$maxlength ORDER BY count DESC LIMIT 0,$num");
  24. $dsql->Execute('hw');
  25. $hotword = '';
  26. while ($row = $dsql->GetArray('hw')) {
  27. $hotword .= " <a href='".$cfg_phpurl."/search.php?keyword=".urlencode($row['keyword'])."'>".$row['keyword']."</a> ";
  28. }
  29. return $hotword;
  30. }
  31. ?>