CommonTwoController.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. <?php
  2. namespace app\controller;
  3. require_once app()->getRootPath() . 'vendor/autoload.php';
  4. use app\BaseController;
  5. use Neoxygen\NeoClient\ClientBuilder;
  6. use think\facade\Request;
  7. class CommonTwoController extends BaseController
  8. {
  9. // checkIsExistSession
  10. public function checkIslogin()
  11. {
  12. return Request::session('name') ?? false;
  13. }
  14. /**
  15. * Xy
  16. * Connect Neo4j
  17. * return Object
  18. */
  19. private function connectNeo4j()
  20. {
  21. $client = ClientBuilder::create()
  22. ->addConnection('default', 'http', '124.70.100.133', 7474, true, 'neo4j', 'neo4j-pwd')
  23. ->setAutoFormatResponse(true)
  24. ->setDefaultTimeout(200)
  25. ->build();
  26. return $client;
  27. }
  28. /**
  29. * Zy
  30. * Connect Neo4j
  31. * return Object
  32. */
  33. private function connectNeo4jByzy()
  34. {
  35. $client = ClientBuilder::create()
  36. ->addConnection('default', 'http', '120.46.136.62', 7474, true, 'neo4j', 'neo4j-pwd')
  37. ->setAutoFormatResponse(true)
  38. ->setDefaultTimeout(200)
  39. ->build();
  40. return $client;
  41. }
  42. /**
  43. * Document|Guide
  44. * Connect Neo4j
  45. * return Object
  46. */
  47. private function connectNeo4jByDocgui()
  48. {
  49. $client = ClientBuilder::create()
  50. ->addConnection('default', 'http', '121.36.94.218', 7474, true, 'neo4j', 'neo4j-pwd')
  51. ->setAutoFormatResponse(true)
  52. ->setDefaultTimeout(200)
  53. ->build();
  54. return $client;
  55. }
  56. /**
  57. * 获取neo4j连接
  58. */
  59. public function getNeo4jConnect($tag)
  60. {
  61. if('zy' === $tag) {
  62. $client = $this->connectNeo4jByzy();
  63. } elseif('xy' === $tag) {
  64. $client = $this->connectNeo4j();
  65. } elseif('guide' === $tag){
  66. $client = $this->connectNeo4jByDocgui();
  67. }
  68. return $client;
  69. }
  70. /**
  71. * Select SingleNode
  72. * @param $node string
  73. * @param $label string
  74. * @param $field string
  75. * @param $value string
  76. * return array
  77. */
  78. public function getNodes($tag , $node , $label , $skip , $limit , $field = '' , $value = '' , $fields = [])
  79. {
  80. $client = $this->getNeo4jConnect($tag);
  81. if($field) {
  82. $query = "match (". $node . ":" . $label .")"."where $node . $field =~ '.*".$value.".*' ". " RETURN $node";
  83. $data = $client->sendCypherQuery($query)->getResult();
  84. } else {
  85. $query = "match (". $node . ":" . $label .") RETURN $node skip $skip limit $limit";
  86. $data = $client->sendCypherQuery($query)->getResult();
  87. }
  88. foreach ($data->getNodes() as $key => $node){
  89. $datas[] = ['id' => $node->getId()];
  90. }
  91. $list = array_column($p = $data->getTableFormat() , 'n');
  92. foreach ($list as $k => $value) {
  93. $list[$k]['id'] = $datas[$k]['id'];
  94. }
  95. $query1 = "MATCH (n:".$label.") RETURN count(n) as count";
  96. $count = $client->sendCypherQuery($query1)->getResult()->getTableFormat();
  97. $list = ['list' => $list , 'count' => $count[0]['count']];
  98. return $list;
  99. }
  100. /**
  101. * ID获取节点
  102. */
  103. public function getNodeById($zsk , $id , $tag = '')
  104. {
  105. $client = $this->getNeo4jConnect($zsk);
  106. $query = "MATCH (n) WHERE id(n)=$id RETURN n";
  107. $result = $client->sendCypherQuery($query)->getResult()->getSingleNode();
  108. if($tag) {
  109. return $result->getLabels();
  110. }
  111. $detail = $result->getProperties();
  112. $detail['id'] = $id;
  113. return $detail;
  114. }
  115. /**
  116. * 节点属性修改
  117. */
  118. public function setNode($query , $tag = 'zy')
  119. {
  120. $client = $this->getNeo4jConnect($tag);
  121. $result = $client->sendCypherQuery($query);
  122. return $result;
  123. }
  124. /**
  125. * Create Node
  126. * @param $node string
  127. * @param $label string
  128. * @param $data array
  129. */
  130. public function createNode($node , $label , $data)
  131. {
  132. $client = $this->getNeo4jConnect('guide');
  133. $str = json_encode($data , JSON_UNESCAPED_UNICODE);
  134. $singleData = preg_replace('/"([a-zA-Z]+[a-zA-Z0-9]*)":/' ,'$1:' , $str); // 替换key引号
  135. $query = "CREATE (". $node . ":" . $label . $singleData . ") RETURN $node";
  136. $query = stripslashes($query);
  137. return $client->sendCypherQuery($query);
  138. }
  139. // ----------------------------------------------------------
  140. // 获取文献|指南属性
  141. public function getProperty($query)
  142. {
  143. $client = $this->connectNeo4jByDocgui();
  144. $data = $client->sendCypherQuery($query)->getResult();
  145. return $data->getTableFormat();
  146. }
  147. // 获取文献总条数
  148. public function _getTotalCount($query)
  149. {
  150. $client = $this->connectNeo4jByDocgui();
  151. $result = $client->sendCypherQuery($query)->getResult();
  152. $count = $result->getTableFormat();
  153. return $count[0]['count'] ?? 0;
  154. }
  155. // 获取文献属性id
  156. public function _getId($val , $tag = 'hot')
  157. {
  158. $client = $this->connectNeo4jByDocgui();
  159. $query1 = "match(n:Keyword {name:"."'".$val."'"."}) return n";
  160. $query2 = "match(n:Author {kgid:"."'".$val."'"."}) return n";
  161. $query = $tag == 'hot' ? $query1 : $query2;
  162. return $client->sendCypherQuery($query)->getResult()->getSingleNode()->getId();
  163. }
  164. // 获取标签属性
  165. public function getAboutInfo($query , $tag = '')
  166. {
  167. $client = $tag ? $this->connectNeo4jByzy() : $this->connectNeo4j();
  168. $data = $client->sendCypherQuery($query)->getResult();
  169. return $data->getTableFormat();
  170. }
  171. // 获取总条数
  172. public function getTotalCount($query , $tag = '')
  173. {
  174. $client = $tag ? $this->connectNeo4jByzy() : $this->connectNeo4j();
  175. $result = $client->sendCypherQuery($query)->getResult();
  176. $count = $result->getTableFormat();
  177. return $count[0]['count'] ?? 0;
  178. }
  179. // 获取属性id
  180. public function getId($val , $tag = 'hot')
  181. {
  182. $client = $this->connectNeo4j();
  183. $query1 = "match(n:Keyword {name:"."'".$val."'"."}) return n";
  184. $query2 = "match(n:Author {kgid:"."'".$val."'"."}) return n";
  185. $query = $tag == 'hot' ? $query1 : $query2;
  186. return $client->sendCypherQuery($query)->getResult()->getSingleNode()->getId();
  187. }
  188. public function getXyR($query , $query1 = '', $query2 = '')
  189. {
  190. $client = $this->connectNeo4j();
  191. $result = $client->sendCypherQuery($query)->getResult();
  192. foreach ($result->getRelationships() as $rel)
  193. {
  194. $edges[] = [
  195. 'start' => [
  196. 'identity' => $rel->getStartNode()->getId() ,
  197. 'labels' => $rel->getStartNode()->getLabels(),
  198. 'properties' => $rel->getStartNode()->getProperties(),
  199. ] ,
  200. 'end' => [
  201. 'identity' => $rel->getEndNode()->getId() ,
  202. 'labels' => $rel->getEndNode()->getLabels(),
  203. 'properties' => $rel->getEndNode()->getProperties(),
  204. ],
  205. 'relationship' => [
  206. 'start' => $rel->getStartNode()->getId() ,
  207. 'end' => $rel->getEndNode()->getId() ,
  208. 'type' => $rel->getType(),
  209. 'properties' => $rel->getProperties()
  210. ]
  211. ];
  212. }
  213. if($query1) {
  214. $result1 = $client->sendCypherQuery($query1)->getResult();
  215. foreach ($result1->getRelationships() as $rel1)
  216. {
  217. $edges1[] = [
  218. 'start' => [
  219. 'identity' => $rel1->getStartNode()->getId() ,
  220. 'labels' => $rel1->getStartNode()->getLabels(),
  221. 'properties' => $rel1->getStartNode()->getProperties(),
  222. ] ,
  223. 'end' => [
  224. 'identity' => $rel1->getEndNode()->getId() ,
  225. 'labels' => $rel1->getEndNode()->getLabels(),
  226. 'properties' => $rel1->getEndNode()->getProperties(),
  227. ],
  228. 'relationship' => [
  229. 'start' => $rel1->getStartNode()->getId() ,
  230. 'end' => $rel1->getEndNode()->getId() ,
  231. 'type' => $rel1->getType(),
  232. 'properties' => $rel1->getProperties()
  233. ]
  234. ];
  235. }
  236. }
  237. if($query2) {
  238. $result2 = $client->sendCypherQuery($query2)->getResult();
  239. foreach ($result2->getRelationships() as $rel2)
  240. {
  241. $edges2[] = [
  242. 'start' => [
  243. 'identity' => $rel2->getStartNode()->getId() ,
  244. 'labels' => $rel2->getStartNode()->getLabels(),
  245. 'properties' => $rel2->getStartNode()->getProperties(),
  246. ] ,
  247. 'end' => [
  248. 'identity' => $rel2->getEndNode()->getId() ,
  249. 'labels' => $rel2->getEndNode()->getLabels(),
  250. 'properties' => $rel2->getEndNode()->getProperties(),
  251. ],
  252. 'relationship' => [
  253. 'start' => $rel2->getStartNode()->getId() ,
  254. 'end' => $rel2->getEndNode()->getId() ,
  255. 'type' => $rel2->getType(),
  256. 'properties' => $rel2->getProperties()
  257. ]
  258. ];
  259. }
  260. }
  261. $edges = $edges ?? [];
  262. $edges1 = $edges1 ?? [];
  263. $edges2 = $edges2 ?? [];
  264. return array_merge($edges , $edges1 , $edges2);
  265. }
  266. public function getZyR($query , $query1 , $query2 , $query3)
  267. {
  268. if($query && $query1 && $query2 && $query3) {
  269. $r1 = $this->getRelationship($query);
  270. $r2 = $this->getRelationship($query1);
  271. $r3 = $this->getRelationship($query2);
  272. $r4 = $this->getRelationship($query3);
  273. return array_merge($r1 , $r2 , $r3 , $r4);
  274. } elseif ($query && !$query1 && !$query2 && !$query3) {
  275. $r = $this->getRelationship($query);
  276. return $r;
  277. }
  278. }
  279. public function getSingle($query , $tag = '')
  280. {
  281. $client = $tag ? $this->connectNeo4jByzy() : $this->connectNeo4j();
  282. $result = $client->sendCypherQuery($query)->getResult()->getSingleNode();
  283. $results[] = [
  284. 'start' => [
  285. 'identity' => $result->getId() ,
  286. 'labels' => $result->getLabels(),
  287. 'properties' => $result->getProperties(),
  288. ]
  289. ];
  290. return $results;
  291. }
  292. public function getRelationship($query , $tag = '')
  293. {
  294. $client = $tag ? $this->connectNeo4j() : $this->connectNeo4jByzy();
  295. $result = $client->sendCypherQuery($query)->getResult();
  296. foreach ($result->getRelationships() as $rel)
  297. {
  298. $results[] = [
  299. 'start' => [
  300. 'identity' => $rel->getStartNode()->getId() ,
  301. 'labels' => $rel->getStartNode()->getLabels(),
  302. 'properties' => $rel->getStartNode()->getProperties(),
  303. ] ,
  304. 'end' => [
  305. 'identity' => $rel->getEndNode()->getId() ,
  306. 'labels' => $rel->getEndNode()->getLabels(),
  307. 'properties' => $rel->getEndNode()->getProperties(),
  308. ],
  309. 'relationship' => [
  310. 'start' => $rel->getStartNode()->getId() ,
  311. 'end' => $rel->getEndNode()->getId() ,
  312. 'type' => $rel->getType(),
  313. 'properties' => $rel->getProperties()
  314. ]
  315. ];
  316. }
  317. $results = $results ?? [];
  318. return $results;
  319. }
  320. public function getComplication($query , $tag = '')
  321. {
  322. $client = $tag ? $this->connectNeo4jByzy() : $this->connectNeo4j();
  323. $result = $client->sendCypherQuery($query)->getResult();
  324. foreach ($result->getRelationships() as $rel) {
  325. $results[] = [
  326. 'properties'=> $rel->getEndNode()->getProperty('name')
  327. ];
  328. }
  329. return $results ?? [];
  330. }
  331. public function checkPhone($phone)
  332. {
  333. return preg_match("/^1[3456789]{1}\d{9}$/", $phone) ?? false;
  334. }
  335. public function _json_succ($data = [] , $code = 0 , $msg = 'Success')
  336. {
  337. return json(['code' => $code , 'msg' => $msg , 'data' => $data]);
  338. }
  339. public function _json_error($msg = '' , $code = 1 , $data = null)
  340. {
  341. return json(['code' => $code , 'msg' => $msg , 'data' => $data]);
  342. }
  343. /**
  344. * 格式化text文案
  345. * @param array $data
  346. * @return array
  347. */
  348. public static function beautifyText($data) {
  349. $searchStr = [
  350. ' 1.',' 2.',' 3.',' 4.',
  351. '(1)','(2)','(3)','(4)',
  352. '0级','Ⅰ级','Ⅱ级','Ⅲ级','Ⅳ级',
  353. //'①','②','③','④','⑤','⑥','⑦',
  354. '•',
  355. '一、','二、','三、','四、',
  356. '(一)','(二)','(三)','(四)'
  357. ];
  358. $replaceStr = [
  359. "\r\n1.","\r\n2.","\r\n3.","\r\n4.",
  360. "\r\n\t(1)","\r\n\t(2)","\r\n\t(3)","\r\n\t(4)",
  361. "\r\n\t0级","\r\n\tⅠ级","\r\n\tⅡ级","\r\n\tⅢ级","\r\n\tⅢ级","\r\n\tⅣ级",
  362. "\r\n\t①","\r\n\t②","\r\n\t③","\r\n\t④","\r\n\t⑤","\r\n\t⑥","\r\n\t⑦",
  363. "\r\n\t•",
  364. "\r\n\t\t一、","\r\n\t\t二、","\r\n\t\t三、","\r\n\t\t四、",
  365. "\r\n\t\t\t(一)","\r\n\t\t\t(二)","\r\n\t\t\t(三)","\r\n\t\t\t(四)",
  366. ];
  367. if(is_array($data)) {
  368. foreach ($data as &$item){
  369. $item['text'] = str_replace($searchStr,$replaceStr,$item['text']);
  370. }
  371. return $data;
  372. }
  373. return str_replace($searchStr,$replaceStr,$data);
  374. }
  375. /**加密 解密 时间限制
  376. * @param $string
  377. * @param string $operation
  378. * @param string $key
  379. * @param int $expiry
  380. * @return false|string
  381. */
  382. //print_r(self::encrypteAndDecrypt('123456','E','app',60));
  383. //var_dump(self::encrypteAndDecrypt('4defT76Ez1PcSvG6qCLyKSkjGlIIxkhzplV4JfMpvn_hqb4','D','app'));
  384. public function encrypteAndDecrypt(string $string,string $operation = 'D',string $key = '',int $expiry = 0)
  385. {
  386. // 动态密匙长度,相同的明文会生成不同密文就是依靠动态密匙
  387. $ckey_length = 4;
  388. // 密匙
  389. $key = md5($key ? MD5($key) : MD5('QeEMcyiwg'));
  390. // 密匙a会参与加解密
  391. $keya = md5(substr($key, 0, 16));
  392. // 密匙b会用来做数据完整性验证
  393. $keyb = md5(substr($key, 16, 16));
  394. $string = strtr($string, '-_', '+/=');
  395. // 密匙c��于变化生成的密文
  396. $keyc = $ckey_length ? ($operation == 'D' ? substr($string, 0, $ckey_length) : substr(md5(microtime()), -$ckey_length)) : '';
  397. // 参与运算的密匙
  398. $cryptkey = $keya . md5($keya . $keyc);
  399. $key_length = strlen($cryptkey);
  400. // 明文,前10位用来保存时间戳,解密时验证数据有效性,10到26位用来保存$keyb(密匙b),解密时会通过这个密匙验证数据完整性
  401. // 如果是解码的话,会从第$ckey_length位开始,因为密文前$ckey_length位保存 动态密匙,以保证解密正确
  402. $string = $operation == 'D' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0) . substr(md5($string . $keyb), 0, 16) . $string;
  403. $string_length = strlen($string);
  404. $result = '';
  405. $JinMi = range(0, 255);
  406. $rndkey = array();
  407. // 产生密匙簿
  408. for ($i = 0; $i <= 255; $i++) {
  409. $rndkey[$i] = ord($cryptkey[$i % $key_length]);
  410. }
  411. // 用固定的算法,打乱密匙簿,增加随机性
  412. for ($j = $i = 0; $i < 256; $i++) {
  413. $j = ($j + $JinMi[$i] + $rndkey[$i]) % 256;
  414. $tmp = $JinMi[$i];
  415. $JinMi[$i] = $JinMi[$j];
  416. $JinMi[$j] = $tmp;
  417. }
  418. // 核心加解密部分
  419. for ($a = $j = $i = 0; $i < $string_length; $i++) {
  420. $a = ($a + 1) % 256;
  421. $j = ($j + $JinMi[$a]) % 256;
  422. $tmp = $JinMi[$a];
  423. $JinMi[$a] = $JinMi[$j];
  424. $JinMi[$j] = $tmp;
  425. // 从密匙簿得出密匙进行异或,再转成字符
  426. $result .= chr(ord($string[$i]) ^ ($JinMi[($JinMi[$a] + $JinMi[$j]) % 256]));
  427. }
  428. if ($operation === 'D') {
  429. // 验证数据有效性,请看未加密明文的格式
  430. if ((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26) . $keyb), 0, 16)) {
  431. return substr($result, 26);
  432. } else {
  433. return '';
  434. }
  435. } else {
  436. // 把动态密匙保存在密文里,这也是为什么同样的明文,生产不同密文后能解密的原因
  437. // 因为加密后的密文可能是一些特殊字符,复制过程可能会丢失,所以用base64编码
  438. $result = $keyc . str_replace('=', '', base64_encode($result));
  439. $result = strtr($result, '+/=', '-_');
  440. return $result;
  441. }
  442. }
  443. /**
  444. * 获取字符首字母
  445. */
  446. public function getFirstCharters($str)
  447. {
  448. $str = substr($str , 0 , 3);
  449. $s1 = iconv('UTF-8', 'gb2312//IGNORE', $str);
  450. if(empty($s1)) {
  451. return null;
  452. }
  453. $s2 = iconv('gb2312', 'UTF-8', $s1);
  454. if(empty($s2)) {
  455. return null;
  456. }
  457. $s = $s2 == $str ? $s1 : $str;
  458. $asc = ord($s{0}) * 256 + ord($s{1}) - 65536;
  459. if ($asc >= -20319 && $asc <= -20284)
  460. return 'A';
  461. if ($asc >= -20283 && $asc <= -19776)
  462. return 'B';
  463. if ($asc >= -19775 && $asc <= -19219)
  464. return 'C';
  465. if ($asc >= -19218 && $asc <= -18711)
  466. return 'D';
  467. if ($asc >= -18710 && $asc <= -18527)
  468. return 'E';
  469. if ($asc >= -18526 && $asc <= -18240)
  470. return 'F';
  471. if ($asc >= -18239 && $asc <= -17923)
  472. return 'G';
  473. if ($asc >= -17922 && $asc <= -17418)
  474. return 'H';
  475. if ($asc >= -17417 && $asc <= -16475)
  476. return 'J';
  477. if ($asc >= -16474 && $asc <= -16213)
  478. return 'K';
  479. if ($asc >= -16212 && $asc <= -15641)
  480. return 'L';
  481. if ($asc >= -15640 && $asc <= -15166)
  482. return 'M';
  483. if ($asc >= -15165 && $asc <= -14923)
  484. return 'N';
  485. if ($asc >= -14922 && $asc <= -14915)
  486. return 'O';
  487. if ($asc >= -14914 && $asc <= -14631)
  488. return 'P';
  489. if ($asc >= -14630 && $asc <= -14150)
  490. return 'Q';
  491. if ($asc >= -14149 && $asc <= -14091)
  492. return 'R';
  493. if ($asc >= -14090 && $asc <= -13319)
  494. return 'S';
  495. if ($asc >= -13318 && $asc <= -12839)
  496. return 'T';
  497. if ($asc >= -12838 && $asc <= -12557)
  498. return 'W';
  499. if ($asc >= -12556 && $asc <= -11848)
  500. return 'X';
  501. if ($asc >= -11847 && $asc <= -11056)
  502. return 'Y';
  503. if ($asc >= -11055 && $asc <= -10247)
  504. return 'Z';
  505. return $this->rare_words($asc);
  506. }
  507. public function rare_words($asc='')
  508. {
  509. $rare_arr = array(
  510. -3652=>array('word'=>"窦",'first_char'=>'D'),
  511. -8503=>array('word'=>"奚",'first_char'=>'X'),
  512. -9286=>array('word'=>"酆",'first_char'=>'F'),
  513. -7761=>array('word'=>"岑",'first_char'=>'C'),
  514. -5128=>array('word'=>"滕",'first_char'=>'T'),
  515. -9479=>array('word'=>"邬",'first_char'=>'W'),
  516. -5456=>array('word'=>"臧",'first_char'=>'Z'),
  517. -7223=>array('word'=>"闵",'first_char'=>'M'),
  518. -2877=>array('word'=>"裘",'first_char'=>'Q'),
  519. -6191=>array('word'=>"缪",'first_char'=>'M'),
  520. -5414=>array('word'=>"贲",'first_char'=>'B'),
  521. -4102=>array('word'=>"嵇",'first_char'=>'J'),
  522. -8969=>array('word'=>"荀",'first_char'=>'X'),
  523. -4938=>array('word'=>"於",'first_char'=>'Y'),
  524. -9017=>array('word'=>"芮",'first_char'=>'R'),
  525. -2848=>array('word'=>"羿",'first_char'=>'Y'),
  526. -9477=>array('word'=>"邴",'first_char'=>'B'),
  527. -9485=>array('word'=>"隗",'first_char'=>'K'),
  528. -6731=>array('word'=>"宓",'first_char'=>'M'),
  529. -9299=>array('word'=>"郗",'first_char'=>'X'),
  530. -5905=>array('word'=>"栾",'first_char'=>'L'),
  531. -4393=>array('word'=>"钭",'first_char'=>'T'),
  532. -9300=>array('word'=>"郜",'first_char'=>'G'),
  533. -8706=>array('word'=>"蔺",'first_char'=>'L'),
  534. -3613=>array('word'=>"胥",'first_char'=>'X'),
  535. -8777=>array('word'=>"莘",'first_char'=>'S'),
  536. -6708=>array('word'=>"逄",'first_char'=>'P'),
  537. -9302=>array('word'=>"郦",'first_char'=>'L'),
  538. -5965=>array('word'=>"璩",'first_char'=>'Q'),
  539. -6745=>array('word'=>"濮",'first_char'=>'P'),
  540. -4888=>array('word'=>"扈",'first_char'=>'H'),
  541. -9309=>array('word'=>"郏",'first_char'=>'J'),
  542. -5428=>array('word'=>"晏",'first_char'=>'Y'),
  543. -2849=>array('word'=>"暨",'first_char'=>'J'),
  544. -7206=>array('word'=>"阙",'first_char'=>'Q'),
  545. -4945=>array('word'=>"殳",'first_char'=>'S'),
  546. -9753=>array('word'=>"夔",'first_char'=>'K'),
  547. -10041=>array('word'=>"厍",'first_char'=>'S'),
  548. -5429=>array('word'=>"晁",'first_char'=>'C'),
  549. -2396=>array('word'=>"訾",'first_char'=>'Z'),
  550. -7205=>array('word'=>"阚",'first_char'=>'K'),
  551. -10049=>array('word'=>"乜",'first_char'=>'N'),
  552. -10015=>array('word'=>"蒯",'first_char'=>'K'),
  553. -3133=>array('word'=>"竺",'first_char'=>'Z'),
  554. -6698=>array('word'=>"逯",'first_char'=>'L'),
  555. -9799=>array('word'=>"俟",'first_char'=>'Q'),
  556. -6749=>array('word'=>"澹",'first_char'=>'T'),
  557. -7220=>array('word'=>"闾",'first_char'=>'L'),
  558. -10047=>array('word'=>"亓",'first_char'=>'Q'),
  559. -10005=>array('word'=>"仉",'first_char'=>'Z'),
  560. -3417=>array('word'=>"颛",'first_char'=>'Z'),
  561. -6431=>array('word'=>"驷",'first_char'=>'S'),
  562. -7226=>array('word'=>"闫",'first_char'=>'Y'),
  563. -9293=>array('word'=>"鄢",'first_char'=>'Y'),
  564. -6205=>array('word'=>"缑",'first_char'=>'G'),
  565. -9764=>array('word'=>"佘",'first_char'=>'S'),
  566. -9818=>array('word'=>"佴",'first_char'=>'N'),
  567. -9509=>array('word'=>"谯",'first_char'=>'Q'),
  568. -3122=>array('word'=>"笪",'first_char'=>'D'),
  569. -9823=>array('word'=>"佟",'first_char'=>'T'),
  570. );
  571. if(array_key_exists($asc, $rare_arr) && $rare_arr[$asc]['first_char']){
  572. return $rare_arr[$asc]['first_char'] ;
  573. }else{
  574. return null;
  575. }
  576. }
  577. /**
  578. * Curl request
  579. */
  580. public function curlRequest($url , $method = 'GET' , $post_data = '')
  581. {
  582. $curl = curl_init();
  583. curl_setopt($curl, CURLOPT_URL, $url);
  584. if('POST' === $method) {
  585. curl_setopt($curl, CURLOPT_POST, 1);
  586. curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data); // 设置post方式提交,使用get方式也可开启此项
  587. }
  588. curl_setopt($curl, CURLOPT_HEADER, 0); // 设置http头部信息不输出
  589. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 设置获取的信息以文件流的形式返回,而不是直接输出。
  590. $result = curl_exec($curl);
  591. curl_close($curl);
  592. return $result;
  593. }
  594. /**
  595. * 调试输出
  596. * @param string $message
  597. * @param mixed $data
  598. */
  599. protected function debug($message, $data = null)
  600. {
  601. if (env('APP_DEBUG')) {
  602. trace($message . ': ' . json_encode($data, JSON_UNESCAPED_UNICODE));
  603. }
  604. }
  605. }