Beispiel #1
0
 /**
  * 收集当前请求执行过的SQL,写入8.188上的swoole
  * @return [type] [description]
  */
 public static function getSql()
 {
     if (DI::getDefault()->has('profiler')) {
         $sqlArr = array();
         $url = $_SERVER['HTTP_HOST'] . '/?' . $_SERVER['QUERY_STRING'];
         $sqlStaticsUrl = "http://192.168.8.188:9671/";
         //统计SQL的URL
         $profiles = DI::getDefault()->get('profiler')->getProfiles();
         if (empty($profiles)) {
             return '';
         }
         foreach ($profiles as $profile) {
             $sqlArr[] = array('sql' => $profile->getSQLStatement(), 'time' => $profile->getTotalElapsedSeconds() * 1000, 'url' => $url);
         }
         $url = $sqlStaticsUrl . "?type=file&cmd=sqlStatics&param=" . urlencode(json_encode($sqlArr));
         \Xz\Func\ReqHelp::get($url, 2);
         return $sqlArr;
     }
 }
Beispiel #2
0
 /**
  * 匹配字符
  *
  * @access public
  * @param mixed $str
  * @param mixed $count
  * @return void
  * @author 刘建辉
  * @修改日期 2012-11-05 10:57:56
  */
 public function matcher($str)
 {
     $di = \Phalcon\DI::getDefault();
     //检测用户提交一些转换成unicode的违禁词(正常情况下用户提交unicode字符串的可能性很小)
     if (strpos($str, '&#') !== false) {
         //匹配出所有unicode字符串
         preg_match_all('/&#.*;/U', $str, $unMat);
         return empty($unMat[0]) ? true : $unMat[0];
     }
     $this->cleanChars($str);
     $this->matchStr = $this->qj2bj(trim($this->matchStr));
     //转全角为半角
     $this->matchStr = $this->promatcher($this->matchStr);
     //进行繁简转换并过滤空格
     //过滤固定电话,手机号码,qq
     $patArr = array('/1\\d{10}/', '/0\\d{2,3}([\\s-]+)?\\d{7,8}/', '/[1-9]\\d{5,9}/');
     $this->matchStr = preg_replace($patArr, '', $this->matchStr);
     //去除非字母,数字,汉字,标点符号外的其他字符
     $this->matchStr = preg_replace('/[^\\x7f-\\xff0-9a-zA-Z,.:;\'\'""?!《》,。:;‘’“”?!]/', '', $this->matchStr);
     //小写
     $this->matchStr = strtolower($this->matchStr);
     $data = array('text' => $this->matchStr);
     $url = $di['config']->base->api->default . "/gckeyword/confilter/word/";
     $match = \Xz\Func\ReqHelp::post($url, $data);
     $matchArr = array_unique(json_decode($match, true));
     $maArr = array();
     foreach ($matchArr as $key => $val) {
         $request = array('service' => 'Gckeyword\\Services\\Banword', 'method' => 'getByWord', 'args' => array($val));
         $result = $di['remote']->call($request);
         $res = $result['data'];
         //数据库中查不到该词,继续下一条
         if (empty($result['data']) || $result['code'] != 200) {
             continue;
         }
         //中文逗号
         $res['relakeyword'] = str_replace(',', ',', $res['relakeyword']);
         $res['norelakeyword'] = str_replace(',', ',', $res['norelakeyword']);
         //检查是否过滤,检查时候判断该词是否为变形词,为变形词则找其主词所对应的正选和反选,与当前正选反选合并后一起验证
         if ($res['is_filter']) {
             //是变形词则找主词,res['transferword']数据库记录可能为空
             if (!empty($res['transferword']) && $res['kid'] != $res['transferword']) {
                 $request = array('service' => 'Gckeyword\\Services\\Banword', 'method' => 'getByKid', 'args' => array($res['transferword']));
                 $mainRs = $di['remote']->call($request);
                 $mainWordRs = $mainRs['data'];
                 //合并正反选
                 if (!empty($mainWordRs['relakeyword'])) {
                     $res['relakeyword'] = $res['relakeyword'] . ',' . str_replace(',', ',', $mainWordRs['relakeyword']);
                 }
                 if (!empty($mainWordRs['norelakeyword'])) {
                     $res['norelakeyword'] = $res['norelakeyword'] . ',' . str_replace(',', ',', $mainWordRs['norelakeyword']);
                 }
             }
             //先过滤反选
             if (!empty($res['norelakeyword'])) {
                 $tmpArr = array_unique(array_filter(explode(',', $res['norelakeyword'])));
                 foreach ($tmpArr as $k => $v) {
                     if (strpos($this->matchStr, $v) !== false) {
                         continue 2;
                     }
                 }
             }
             //过滤正选
             if (!empty($res['relakeyword'])) {
                 $tmpArr = array_unique(array_filter(explode(',', $res['relakeyword'])));
                 $len = 10;
                 foreach ($tmpArr as $k => $v) {
                     //往前匹配
                     $pat = "/{$v}(?<t>.*){$val}/U";
                     preg_match_all($pat, $this->matchStr, $foreMatch);
                     if (isset($foreMatch['t'])) {
                         foreach ($foreMatch['t'] as $vv) {
                             if (mb_strlen($vv, 'UTF-8') <= $len) {
                                 $maArr[] = $v;
                             }
                         }
                     }
                     //往后匹配
                     $pat = "/{$val}(?<t>.*){$v}/U";
                     preg_match_all($pat, $this->matchStr, $afterMatch);
                     if (isset($afterMatch['t'])) {
                         foreach ($afterMatch['t'] as $vv) {
                             if (mb_strlen($vv, 'UTF-8') <= $len) {
                                 $maArr[] = $v;
                             }
                         }
                     }
                 }
             }
             //当正选为空时候,$maArr 赋值为当前词主词
             empty($res['relakeyword']) && ($maArr = array($val));
             //当前词是否存在正选列表中的违禁词,存在直接返回
             if (!empty($maArr)) {
                 $matchArr = array_unique(array_merge($matchArr, $maArr));
                 $this->matchWord = !empty($matchArr) ? $matchArr : false;
                 return $this->matchWord;
             }
         } else {
             //不过滤的词直接返回
             $this->matchWord = !empty($matchArr) ? $matchArr : false;
             return $this->matchWord;
         }
     }
     //foreach end
     return false;
 }
Beispiel #3
0
 /**
  * 生成企业二维码名片
  * @param array $data  生成名片所需数据
  * @return string 名片地址信息
  */
 public function qrcode($data = array())
 {
     require_once APP_ROOT . '/apps/library/qrcode/phpqrcode.php';
     $qrcodeText = "BEGIN:VCARD\n" . "VERSION:3.0\n" . "URL: " . $data['comurl'] . "\n" . "N:{$data['name']}\n" . "ORG:{$data['comname']}\n" . "TITLE:{$data['position']}\n" . "ADR;TYPE=WORK:;;{$data['address']}\n" . "END:VCARD";
     $filename = md5($data['cid'] . md5('w2d7aa@#$%^') . md5($data['comname']));
     chmod(APP_ROOT . 'apps/gccominfo/tmp/', 0777);
     $QRPath = APP_ROOT . 'apps/gccominfo/tmp/' . $filename . '.png';
     //生成二维码图片
     \QRcode::png($qrcodeText, $QRPath);
     $qrcodeUrl = \Xz\Func\ReqHelp::upYun($QRPath);
     unlink($QRPath);
     return $this->outputData($qrcodeUrl);
 }