简单编号.
例如：2653 9689 3739 0570.
@return string
8435
public static function simpleCode(): string
    {
        return join('', array_map(function ($item) {
            return substr($item + 1, -1);
        }, str_split(str_replace('.', '', array_sum(
            explode(' ', microtime())
        )) . mt_rand(10, 99))));
    }
327654
protected function getSelectString(): string
    {
        $statement = '';
        $fieldSelect    = $this->builder->getSelect();
        $aggregate = $this->builder->getAggregate();
        if (empty($fieldSelect) && empty($aggregate)) {
            return $statement;
        }

        $select = $this->getAggregateStatement($fieldSelect, $aggregate);

        // 字段组拼
        foreach ($select as $column => $alias) {
            // Filter db keyword
            if (array_key_exists($column, $fieldSelect) && trim($column) != '*' && strpos($column, '.') === false) {
                // 判断是否为函数调用
                if (strpos($column, '(') || strpos($column, ')')) {
                    $column = sprintf('%s', $column);
                } else {
                    $column = sprintf('`%s`', $column);
                }
            }

            $statement .= $column;
            if ($alias !== null) {
                $statement .= sprintf(' AS `%s`', $alias);
            }
            $statement .= ', ';
        }

        //select组拼
        $statement = substr($statement, 0, -2);
        if (!empty($statement)) {
            $statement = 'SELECT ' . $statement;
        }

        return $statement;
    }
249287
public function parseUrl()
    {
        if (self::PATH_FORMAT === $this->urlFormat) {
            $pathInfo = $this->removeUrlSuffix(Request::httpRequest()->getPathInfo(), $this->urlSuffix);
        } elseif (isset($_GET[$this->routeVar])) {
            $pathInfo = $this->removeUrlSuffix($_GET[$this->routeVar], $this->urlSuffix);
        } elseif (isset($_POST[$this->routeVar])) {
            $pathInfo = $_POST[$this->routeVar];
        } else {
            $pathInfo = '';
        }
        foreach ($this->_rules as $i => $rule) {
            $_pathinfo = $rule->parsePathInfo($this, $pathInfo);
            if (false !== $_pathinfo) {
                return $_pathinfo;
            }
        }
        if ($this->throwNotMatchRule) {
            // 不匹配规则时抛出异常
            throw new Exception(str_cover('"{pathInfo}"找不到对应的URL解析规则，不能确定路由', [
                '{pathInfo}' => $pathInfo,
            ]), 100900101);
        } else {
            // 没有匹配的规则，直接返回pathinfo本身
            return $pathInfo;
        }
    }
65687
public static function referer()
    {
        //$protocol = ($_SERVER['SERVER_PORT'] == '443') ? 'https://' : 'http://';
        $protocol = $_SERVER['REQUEST_SCHEME'] . '://';
        
        if ( isset($_SERVER['HTTP_REFERER']) ) {
            // 来路
            $direct = $_SERVER['HTTP_REFERER'];
        } else if ( isset($_SERVER['HTTP_X_FORWARDED_SERVER']) ) {
            // 代理地址
            $direct = $protocol . $_SERVER['HTTP_X_FORWARDED_SERVER'];
        } else {
            // 默认
            $direct = $protocol . $_SERVER['SERVER_NAME'];
        }

        return $direct;
    }
126363
public function getAccessToken()
    {
        if (!empty($this->access_token)) {
            return $this->access_token;
        }
        $cache = $this->config->get('appid') . '_access_token';
        $this->access_token = Tools::getCache($cache);
        if (!empty($this->access_token)) {
            return $this->access_token;
        }
        // 处理开放平台授权公众号获取AccessToken
        if (!empty($this->GetAccessTokenCallback) && is_callable($this->GetAccessTokenCallback)) {
            $this->access_token = call_user_func_array($this->GetAccessTokenCallback, [$this->config->get('appid'), $this]);
            if (!empty($this->access_token)) {
                Tools::setCache($cache, $this->access_token, 7000);
            }
            return $this->access_token;
        }
        list($appid, $secret) = [$this->config->get('appid'), $this->config->get('appsecret')];
        $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}";
        $result = Tools::json2arr(Tools::get($url));
        if (!empty($result['access_token'])) {
            Tools::setCache($cache, $result['access_token'], 7000);
        }
        return $this->access_token = $result['access_token'];
    }
968184
private function getAuthCode()
    {
        $err_no = [
            '1'   => '成功',
            '-11' => '錯誤的廠商 ID',
            '-12' => '廠商 ID 與當初申請之 IP 不符',
            '-13' => '此服務代碼目前無法使用',
            '-14' => '此服務代碼已超過使用期限',
            '-15' => '金額不符',
            '-16' => '金額不符',
            '-17' => '商家交易序號重複',
            '-19' => '系統發生問題',
        ];


        // 获取授权码
        $this->endpoint_auth .= '?' . http_build_query($this->parameter);
        $response = file_get_contents($this->endpoint_auth);
        $response = $this->xml2array($response);
        if ($response['ReturnMsgNo'] != 1) {
            $msg = $err_no[$response['ReturnMsgNo']];
            throw new \Exception($msg);
        }


        // 跳转URL
        if ($this->config['sandbox']) {
            $this->endpoint_login = $this->sandbox_endpoint_login;
        }

        $this->redirect = $this->endpoint_login . '?AuthCode=' . $this->auth_code;
        $this->transactionReference = $response['ReturnTradeSeq'];  // 交易ID For MyCard
        $this->auth_code = $response['ReturnAuthCode'];             // 交易授权码
    }
568664
private function index()
    {
        $indexfile = $this->dirname . '/webroot/' . $this->inname;
        @mkdir($this->dirname . '/webroot/');

        if (file_exists($indexfile)) {
            return false;
        }
        $code = 'PD9waHAKcmVxdWlyZSAnLi4vdmVuZG9yL2F1dG9sb2FkLnBocCc7CiR2aXRleCA9IFx2aXRleFxWaXRleDo6Z2V0SW5zdGFuY2UoKTsKCmNvbnN0IFdFQlJPT1QgPSBfX0RJUl9fOwovL+mFjee9rui3r+eUseaWh+S7tuWcsOWdgAovL+mFjee9ruaooeadv+i3r+W+hAovL+mFjee9ruWIm+W7uueahOW6lOeUqGFwcO+8jOaKiuivpeebruW9leWinuWKoOWIsOiHquWKqOWKoOi9veeahOWQjeWNleS4rQokdml0ZXgtPmluaXQoJ3thcHB9JywgZGlybmFtZShfX0RJUl9fKSk7Cgokdml0ZXgtPnVzaW5nKG5ldyBcdml0ZXhcbWlkZGxld2FyZVxTZXNzaW9uKCkpOwoKJHZpdGV4LT5hbGwoJy8nLCBmdW5jdGlvbiAoKSB7CiAgICBlY2hvICc8aDE+V2VsY29tZSBWaXRleCEhPC9oMT4nOwp9KTsKCiR2aXRleC0+Z3JvdXAoJy93ZWxjb21lJywgJ0luZGV4Jyk7CiR2aXRleC0+Z2V0KCcvdXNlcicsJ1VzZXInKTsgLy/osIPnlKhDb250cm9sbGVy5LitVXNlcuexu+eahGdldOaWueazlQoKJHZpdGV4LT5ydW4oKTs=';
        $code = base64_decode($code);
        //创建新文件
        file_put_contents($indexfile, str_replace('{app}', $this->appname, $code));

        return true;
    }
1289621
public function getRevCardDel(){
        if (isset($this->_receive['CardId']))     //卡券 ID
            $array['CardId'] = $this->_receive['CardId'];
        if (isset($this->_receive['UserCardCode']) && !empty($this->_receive['UserCardCode'])) //code 序列号。自定义 code 及非自定义 code的卡券被领取后都支持事件推送。
            $array['UserCardCode'] = $this->_receive['UserCardCode'];
        if (isset($array) && count($array) > 0) {
            return $array;
        } else {
            return false;
        }
    }
131181
protected function getUpdateString(): string
    {
        $statement = '';
        if (!$this->builder->getUpdate()) {
            return $statement;
        }

        $statement .= $this->getUpdate();

        // join条件
        $statement .= ' ' . $this->getJoinString();
        $statement = rtrim($statement);
        if (!empty($statement)) {
            $statement = sprintf('UPDATE `%s`', $statement);
        }

        return $statement;
    }
169486
public function create(): string
    {
        switch ($this->operation) {
            case 'exist':
                // 判断是否存在满足条件的记录
                return $this->createExist();
            case 'query':
            case 'repair':
            case 'optimize':
            case 'call':
                // 直接SQL查询
                return $this->createQuery();
            case 'execute':
                // 直接SQL操作
                return $this->createExecute();
            case 'insert':
                // 插入
            case 'replace':
                // 存在则替换,否则插入
            case 'insertIgnore':
                // 存在则忽略,否则插入
                return $this->createAdd();
            case 'inserts':
                //多行插入
                return $this->createInserts();
            case 'update':
                // 修改
                return $this->createUpdate();
            case 'delete':
                // 删除
                return $this->createDelete();
            case 'deleteAll':
                // 删除全部
                return $this->createDeleteAll();
            case 'select':
                // 查询
            case 'selectHandle':
                // 查询并返回句柄
                return $this->createSelect();
            case 'crease':
                // 增减
                return $this->createCrease();
        }
        trigger_error('无法识别或不支持的SQL命令:' . $this->operation, E_USER_ERROR);
        return '';
    }
1011235
private function randomFileName()
        {
            if ($this->randomNameType == 1)        // 生成时间格式文件名
            {
                date_default_timezone_set('PRC');  //设置时区
                
                $date     = date($this->randomLength);
                $fileName = $date . "_" . mt_rand(10000, 99999);
            }
            elseif ($this->randomNameType == 2)    // 生成随机字符文件名
            {
                $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
                $max   = strlen($chars) - 1;
                mt_srand((double)microtime() * 1000000);
                
                for($i = 0; $i < $this->randomLength; $i++)
                {
                    $fileName .= $chars[mt_rand(0, $max)];
                }
            }
            else
            {
                $fileName = '';
            }

            return $fileName;
        }
757909
public function showTrace()
    {
        $_trace =   array();
        $included_files = get_included_files();

        // 系统默认显示信息
        if (!empty($this->request->server['SCRIPT_NAME']))
        {
            $_trace['请求脚本'] = $this->request->server['SCRIPT_NAME'];
        }

        $_trace['请求方法'] = $this->swoole->env['mvc']['controller'].'/'.$this->swoole->env['mvc']['view'];
        $_trace['USER_AGENT'] = $this->request->server['HTTP_USER_AGENT'];
        $_trace['HTTP版本'] = $this->request->server['SERVER_PROTOCOL'];
        $_trace['请求时间'] = date('Y-m-d H:i:s', $this->request->server['REQUEST_TIME']);

        if (isset($_SESSION))
        {
            $_trace['SESSION_ID'] = session_id();
        }
        if ($this->swoole->db instanceof \Swoole\Database)
        {
            $_trace['读取数据库'] = $this->swoole->db->read_times . '次';
            $_trace['写入数据库'] = $this->swoole->db->write_times . '次';
        }
        $_trace['加载文件数目'] = count($included_files);
        $_trace['PHP执行占用'] = $this->showTime();
        $_trace = array_merge($this->traceInfo, $_trace);

        // 调用Trace页面模板
        $html = <<<HTMLS
<style type="text/css">
#swoole_trace_content  {
font-family:		Consolas, Courier New, Courier, monospace;
font-size:			14px;
background-color:	#fff;
margin:				40px;
color:				#000;
border:				#999 1px solid;
padding:			20px 20px 12px 20px;
}
</style>
	<div>
		<fieldset style="margin:5px;">
		<div style="overflow:auto;text-align:left;">
HTMLS;
        $html .= "<a href='".Tool::url_merge('_show_request', '1')."'>显示请求参数</a> |
        <a href='".Tool::url_merge('_show_session', '1')."'>显示会话信息</a> |
        <a href='".Tool::url_merge('_show_files', '1')."'>显示加载的PHP文件</a>
        <hr/>";
        foreach ($_trace as $key => $info)
        {
            $html .= $key . ' : ' . $info . BL;
        }
        if (!empty($this->request->get['_show_files']))
        {
            //输出包含的文件
            $html .= '加载的文件：' . BL."<pre style='color: #666'>";
            foreach ($included_files as $file)
            {
                $html .= $file . "\n";
            }
            $html .= "</pre>";
        }
        $html .= "</div></fieldset>";
        $html .= "</div>";

        if (!empty($this->request->get['_show_request']))
        {
            $output = '<fieldset style="margin:5px;"><div style="overflow:auto;text-align:left;">';
            $request = $this->swoole->request;
            $output .= "<h2>HEADER:</h2>".Tool::dump($request->header);
            $output .= "<h2>SERVER:</h2>".Tool::dump($request->server);
            if (!empty($request->files))
            {
                $output .= "<h2>FILE:</h2>".Tool::dump($request->files);
            }
            if (!empty($request->cookie))
            {
                $output .= "<h2>COOKIES:</h2>".Tool::dump($request->cookie);
            }
            if (!empty($request->get))
            {
                $output .= "<h2>GET:</h2>".Tool::dump($this->swoole->request->get);
            }
            if (!empty($request->post))
            {
                $output .= "<h2>POST:</h2>".Tool::dump($request->post);
            }

            $html .= $output."</div></fieldset>";
        }

        if (!empty($this->request->get['_show_session']))
        {
            $output = '<fieldset style="margin:5px;"><div style="overflow:auto;text-align:left;">';
            $this->session->start();
            $output .= "<h2>SESSION:</h2>" . Tool::dump($this->request->session);
            $html .= $output."</div></fieldset>";
        }

        return $html;
    }
638092
public function getReferenceCode()
    {
        if (!isset($this->referenceCode)) {
            $this->referenceCode = date('YmdHis', $_SERVER['REQUEST_TIME']) . substr(md5(rand()), 0, 6);
        }
        return $this->referenceCode;
    }
877979
public function toSixFigureString()
	{
		$hundredkmE = floor($this->easting / 100000);
		$hundredkmN = floor($this->northing / 100000);

		if ($hundredkmN < 5) {
			$firstLetter = ($hundredkmE < 5) ? 'S' : 'T';
		} else if ($hundredkmN < 10) {
			$firstLetter = ($hundredkmE < 5) ? 'N' : 'O';
		} else {
			$firstLetter = 'H';
		}

		$index = 65 + ((4 - ($hundredkmN % 5)) * 5) + ($hundredkmE % 5);
		$ti = $index;
		if ($index >= 73) {
			$index++;
		}

		$secondLetter = chr($index);

		$e = round(($this->easting - (100000 * $hundredkmE)) / 100);
		$n = round(($this->northing - (100000 * $hundredkmN)) / 100);

		return sprintf('%s%s%03d%03d', $firstLetter, $secondLetter, $e, $n);
	}
1124288
public function getRawMt940()
    {
        $seg = $this->findSegment(static::SEG_ACCOUNT_INFORMATION);
        if (is_string($seg)) {
            if (preg_match('/@(\d+)@(.+)/ms', $seg, $m)) {
                return $m[2];
            }
        }

        return '';
    }
1266437
protected function getOss()
    {
        if (!$this->upload) {
            $this->upload = new OssClient(
                $this->config['accessKeyId'],
                $this->config['accessKeySecret'],
                $this->config['endpoint'],
                $this->config['isCName'],
                $this->config['securityToken']
            );

            //设置请求超时时间
            $this->upload->setTimeout($this->config['timeout']);

            //设置连接超时时间
            $this->upload->setConnectTimeout($this->config['connectTimeout']);
        }

        return $this->upload;
    }
757796
public function getSteamID64() {
		if (PHP_INT_SIZE == 4) {
			$ret = new Math_BigInteger();
			$ret = $ret->add((new Math_BigInteger($this->universe))->bitwise_leftShift(56));
			$ret = $ret->add((new Math_BigInteger($this->type))->bitwise_leftShift(52));
			$ret = $ret->add((new Math_BigInteger($this->instance))->bitwise_leftShift(32));
			$ret = $ret->add(new Math_BigInteger($this->accountid));
			return $ret->toString();
		}
		return (string) (($this->universe << 56) | ($this->type << 52) | ($this->instance << 32) | ($this->accountid));
	}