Пример #1
0
 /**
  * sphinx搜索实现
  *
  * @Author   tianyunzi
  * @DateTime 2015-09-23T14:26:57+0800
  * @param    [type]                   $keyword [description]
  * @return   [type]                            [description]
  */
 public function sphinxHelp($keyword, $page = 1, $limit = 20)
 {
     $stringObj = new StringHelper();
     $keyword = $stringObj->formatKeyword($keyword);
     $splitKeyword = $this->splitKeyword($keyword);
     $sphinxConfig = $this->di['config']['helpsphinx'];
     $conn = new Connection();
     $conn->setParams(array('host' => $sphinxConfig->host, 'port' => $sphinxConfig->port));
     if (count($splitKeyword) > 1) {
     } else {
         $sql = "select id from m_article where match('(@articletitle " . $splitKeyword[0] . "),(@content " . $splitKeyword[0] . ")') order by id desc limit " . $limit;
     }
     $query = SphinxQL::create($conn)->query($sql)->enqueue(Helper::create($conn)->showMeta());
     $result = array('data' => array(), 'total_found' => 0, 'time' => 0);
     try {
         $sphinxRs = $query->executeBatch();
         if (is_array($sphinxRs) && count($sphinxRs) > 0) {
             $sphinxData = $sphinxRs[0];
             $variableData = $sphinxRs[1];
         }
         if (isset($sphinxData) && is_array($sphinxData)) {
             foreach ($sphinxData as $value) {
                 $result['data'][] = $value['id'];
             }
         }
         if (isset($variableData) && is_array($variableData)) {
             foreach ($variableData as $value) {
                 if ($value['Variable_name'] == 'total_found') {
                     $result['total_found'] = $value['Value'];
                 }
                 if ($value['Variable_name'] == 'time') {
                     $result['time'] = $value['Value'];
                 }
             }
         }
     } catch (Exception $e) {
     }
     $result['data'] = implode(",", array_filter($result['data']));
     return $result;
 }
Пример #2
0
 /**
  * 功能描述 企业详情链接生成  供其它项目使用
  * @author 吕小虎
  * @datetime ${DATE} ${TIME}
  * @version
  * @param $pid int 省份id
  * @param $cid int 企业详情id
  * @return
  */
 public static function comLink($cid, $pid = 0, $type = 1)
 {
     if ($cid <= 0) {
         return '';
     }
     $di = \Phalcon\DI::getDefault();
     if ($type == 2) {
         //移动站域名
         $domain = $di['config']->mobile->gc_company;
     } else {
         $domain = $di['config']->base->company;
     }
     //查缓存 获取省份ID
     $comObj = new CacheCombus();
     $resArr = $comObj->getOne($cid);
     $pid = isset($resArr['province']) ? $resArr['province'] : 0;
     return $domain . "/p-{$pid}/{$cid}_" . \Xz\Func\StringHelper::getCombusAuth($cid) . '/';
 }
Пример #3
0
 /**
  * @param $string
  * @param $close 是否进行过滤闭合处理,用于转义和转换html实体
  * @description 过滤编辑器字符串信息
  * @param $isFilterLink 是否过滤外链
  * @return mixed|string
  */
 public function onlineEditerFilter($string, $close = false, $isFilterLink = true)
 {
     $string = \Xz\Func\StringHelper::xssClean($string);
     //防止XSS
     //$isFilterLink && $string = \Xz\Func\StringHelper::delLink($string); //过滤链接
     $string = \Xz\Func\StringHelper::websiteFilter($string);
     //过滤链接
     $string = \Xz\Func\StringHelper::htmlFixSafe($string);
     //清理未闭合的标签
     $string = \Xz\Func\StringHelper::editerFilter($string);
     //过滤在线编辑器
     $close && ($string = \Xz\Func\StringHelper::endFilter($string));
     //用于转义和转换html实体
     return $string;
 }