1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- use Hashids\Hashids;
- use support\facade\Logger;
-
- function quickSort($array)
- {
- if(!isset($array[1]))
- return $array;
- $mid = $array[0];
- $leftArray = array();
- $rightArray = array();
- foreach($array as $v)
- {
- if($v > $mid)
- $rightArray[] = $v;
- if($v < $mid)
- $leftArray[] = $v;
- }
- $leftArray = quickSort($leftArray);
- $leftArray[] = $mid;
- $rightArray = quickSort($rightArray);
- return array_merge($leftArray,$rightArray);
- }
- function getHashids(){
- global $hashids;
- if($hashids instanceof Hashids ){
- return $hashids;
- }
- $hashids = new Hashids('D6M97LIvpp4qWuz3nKzqi6yYN4GAA61b',32);
- return $hashids;
-
- }
- function getProp($param, $key, $default = '')
- {
- $result = $default;
- if (is_object($param) && isset($param->$key)) {
- $result = $param->$key;
- }
- if (is_array($param) && isset($param[$key])) {
- $result = $param[$key];
- }
- return $result;
- }
- function get_client_ip()
- {
- $ip = '0.0.0.0';
- if ($request = request()) {
- $header = $request->header();
- if(isset($header['remoteip'])){
- $ip = $header['remoteip'];
- }else{
- $rip = $request->getRealIp();
- $riparr = explode(',',$rip);
- $ip = $riparr['0'];
- }
- }
- return $ip;
- }
- function get_client_ua()
- {
- $request = request();
- $header = $request->header();
- return $header['user-agent'];
- }
|