suggest.php.in 728 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * suggest.php
  4. * @project_name@ 提取搜索建议(输出JSON)
  5. *
  6. * 该文件由 xunsearch PHP-SDK 工具自动生成,请根据实际需求进行修改
  7. * 创建时间:@date_time@
  8. */
  9. // 加载 XS 入口文件
  10. require_once '@xs_lib_root@/XS.php';
  11. // Prefix Query is: term (by jQuery-ui)
  12. $q = isset($_GET['term']) ? trim($_GET['term']) : '';
  13. $q = get_magic_quotes_gpc() ? stripslashes($q) : $q;
  14. $terms = array();
  15. if (!empty($q) && strpos($q, ':') === false)
  16. {
  17. try
  18. {
  19. $xs = new XS('@project@');
  20. $terms = $xs->search->setCharset('UTF-8')->getExpandedQuery($q);
  21. }
  22. catch (XSException $e)
  23. {
  24. }
  25. }
  26. // output json
  27. header("Content-Type: application/json; charset=utf-8");
  28. echo json_encode($terms);
  29. exit(0);