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

48 lines
1.5KB

  1. <?php
  2. /**
  3. * 获取网站搜索的热门关键字
  4. *
  5. * @version $Id: hotwords.lib.php 1 9:29 2010年7月6日Z tianya $
  6. * @package DedeCMS.Taglib
  7. * @copyright Copyright (c) 2007 - 2020, DesDev, Inc.
  8. * @license http://help.dedecms.com/usersguide/license.html
  9. * @link http://www.dedecms.com
  10. */
  11. /*>>dede>>
  12. <name>热门关键词</name>
  13. <type>全局标记</type>
  14. <for>V55,V56,V57</for>
  15. <description>获取网站搜索的热门关键字</description>
  16. <demo>
  17. {dede:hotwords /}
  18. </demo>
  19. <attributes>
  20. <iterm>num:关键词数目</iterm>
  21. <iterm>subday:天数</iterm>
  22. <iterm>maxlength:关键词最大长度</iterm>
  23. </attributes>
  24. >>dede>>*/
  25. function lib_hotwords(&$ctag,&$refObj)
  26. {
  27. global $cfg_phpurl,$dsql;
  28. $attlist="num|6,subday|365,maxlength|16";
  29. FillAttsDefault($ctag->CAttribute->Items,$attlist);
  30. extract($ctag->CAttribute->Items, EXTR_SKIP);
  31. $nowtime = time();
  32. if(empty($subday)) $subday = 365;
  33. if(empty($num)) $num = 6;
  34. if(empty($maxlength)) $maxlength = 20;
  35. $maxlength = $maxlength+1;
  36. $mintime = $nowtime - ($subday * 24 * 3600);
  37. $dsql->SetQuery("SELECT keyword FROM `#@__search_keywords` WHERE lasttime>$mintime AND length(keyword)<$maxlength ORDER BY count DESC LIMIT 0,$num");
  38. $dsql->Execute('hw');
  39. $hotword = '';
  40. while($row=$dsql->GetArray('hw')){
  41. $hotword .= " <a href='".$cfg_phpurl."/search.php?keyword=".urlencode($row['keyword'])."'>".$row['keyword']."</a> ";
  42. }
  43. return $hotword;
  44. }