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

34 lines
1.2KB

  1. <?php
  2. if (!defined('DEDEINC')) exit('dedebiz');
  3. /**
  4. * 获取网站搜索的热门关键字
  5. *
  6. * @version $Id: hotwords.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. function lib_hotwords(&$ctag, &$refObj)
  13. {
  14. global $cfg_phpurl, $dsql;
  15. $attlist = "num|6,subday|365,maxlength|16";
  16. FillAttsDefault($ctag->CAttribute->Items, $attlist);
  17. extract($ctag->CAttribute->Items, EXTR_SKIP);
  18. $nowtime = time();
  19. if (empty($subday)) $subday = 365;
  20. if (empty($num)) $num = 6;
  21. if (empty($maxlength)) $maxlength = 20;
  22. $maxlength = $maxlength + 1;
  23. $mintime = $nowtime - ($subday * 24 * 3600);
  24. $dsql->SetQuery("SELECT keyword FROM `#@__search_keywords` WHERE lasttime>$mintime AND length(keyword)<$maxlength ORDER BY count DESC LIMIT 0,$num");
  25. $dsql->Execute('hw');
  26. $hotword = '';
  27. while ($row = $dsql->GetArray('hw')) {
  28. $hotword .= " <a href='".$cfg_phpurl."/search.php?keyword=".urlencode($row['keyword'])."'>".$row['keyword']."</a> ";
  29. }
  30. return $hotword;
  31. }