suggest.php.in 725 B

12345678910111213141516171819202122232425262728
  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. try {
  17. $xs = new XS('@project@');
  18. $terms = $xs->search->setCharset('UTF-8')->getExpandedQuery($q);
  19. } catch (XSException $e) {
  20. }
  21. }
  22. // output json
  23. header("Content-Type: application/json; charset=utf-8");
  24. echo json_encode($terms);
  25. exit(0);