加密
@param  string $data  原数据
@param  bool   $isRaw 是否输出加密原值，否则输出16进制表示
@return string|null   加密失败返回null
779720
public function encrypt(string $data, bool $isRaw = false):  ? string
    {
        //1.数据预处理
        $n = strlen($data);
        if ($n === 0) {
            return null;
        }
        $m       = 16 - $n;
        $padding = false;
        if ($m > 0) {
            for ($i = 0; $i < $m - 1; $i++) {
                $data .= chr(0); //补位0直到15字节
            }
            $data .= chr($m); //最后一位补位长度
            $padding = true;
            $n       = 16; //n的大小置为16
        }

        //2.加密数据
        $b = array(16); //生成16个随机偏置
        for ($i = 0; $i < 16; $i++) {
            $b[$i] = mt_rand(0, 255);
        }
        if ($padding) {
            $b[0] = ($m + $b[1]) % 256; //补位长度存储在偏置中,加上相邻随机偏置，可防止b[0]在同一密钥下不变问题
        }
        $_data = $this->handle($data, $b, $n);

        //3.加密偏置
        $b  = $this->handleB($b);
        $_b = '';
        for ($i = 0; $i < 16; $i++) {
            $_b .= chr($b[$i]); //转化为16个ascii字符
        }
        $b = $_b;

        //4.输出
        if ($isRaw) {
            return $b . $_data; //输出原始数据
        }

        //输出16进制编码数据
        $encrypt = '';
        for ($i = 0; $i < $n; $i++) {
            $encrypt .= $this->hex($_data[$i]); //data和_data长度一样
        }
        $_b = '';
        for ($i = 0; $i < 16; $i++) {
            $_b .= $this->hex($b[$i]);
        }
        return $_b . $encrypt;
    }
484696
public function load($data = null, $key = null, $excludes = []) {
        if (is_string($data)) {
            list($key, $excludes, $data) = [$data, $key, null];
        }
        if (is_array($key)) {
            list($key, $excludes) = [null, $key];
        }
        if (!is_array($data) && app('request')->isPost()) {
            $data = app('request')->get($key);
        }
        if (empty($data)) {
            return false;
        }
        if (!empty($excludes)) {
            $data = array_diff_key($data, array_flip((array)$excludes));
        }
        $this->set($data);
        return true;
    }
1143643
public function add(array $data)
    {
        $result = null;
        $this->hook->attach('category.add.before', $data, $result, $this);

        if (isset($result)) {
            return (int) $result;
        }

        $result = $data['category_id'] = $this->db->insert('category', $data);

        $this->setTranslations($data, $this->translation_entity, 'category', false);
        $this->setImages($data, $this->file, 'category');
        $this->setAlias($data, $this->alias, 'category', false);

        $this->hook->attach('category.add.after', $data, $result, $this);
        return (int) $result;
    }
577322
public function postRaw($data)
    {
        $this->content = $data;
        $url = $this->url;
        if (!empty($this->replaceParams)) {
            $url = self::buildUri($url, $this->replaceParams);
        }
        $this->adapter->setResponseTimeout($this->getResponseTimeout());
        $this->adapter->setConnectTimeout($this->getConnectTimeout());

        return $this->adapter->post(
            $url,
            array(
                self::HEADERS => $this->headers,
                self::CONTENT => $this->content,
            )
        );
    }
773986
public function replace($data = null): IResult
    {
        $builder = new ReplaceBuilder($this);
        $sql = $builder->build($data);
        return $this->execute($sql);
    }
457537
public function insert($data = [])
	{
		$created = $this->model->insert($data);

		if( ! $created)
		{
			return new Payload(null, 'not_created');
		}

		return new Payload($created, 'created');
	}
660410
public function execute($data = null)
    {
        $this->controller->setResponse(new HtmlResponse(
            '',
            $data->response->getStatusCode(),
            $data->response->getHeaders()
        ));

        $result = $this->next->execute($data);

        $this->controller->setRedirect(null);

        return $result;
    }
893649
public function add(array $data)
    {
        $result = null;
        $this->hook->attach('module.backup.add.before', $data, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $version = null;
        if (isset($data['version'])) {
            $version = $data['version'];
        }

        if ($this->exists($data['id'], $version)) {
            return false;
        }

        if (empty($data['user_id'])) {
            $data['user_id'] = $this->user->getId();
        }

        $data['created'] = GC_TIME;
        $result = $this->db->insert('backup', $data);

        $this->hook->attach('module.backup.add.after', $data, $result, $this);
        return $result;
    }
676806
public static function unpack($data, $isJson = false) {
		self::resetSchema();

		if ( $isJson ) {
			$data = json_decode($data);
		}
		return self::decode($data);
	}
1243457
public function addRow($data = null)
    {
        $this->rowIndex++;
        if (is_array($data)) {
            foreach ($data as $column => $content) {
                $this->rows[ $this->rowIndex ][ $column ] = $content;
            }
        }

        return $this;
    }
924634
protected function newPivot($data = [], $isUpdate = false)
    {
        $class = $this->pivotName ?: '\\think\\model\\Pivot';
        $pivot = new $class($data, $this->parent, $this->middle);

        if ($pivot instanceof Pivot) {
            return $isUpdate ? $pivot->isUpdate(true, $this->getUpdateWhere($data)) : $pivot;
        }

        throw new Exception('pivot model must extends: \think\model\Pivot');
    }
839199
public function provide($data = null, array $options = [])
    {
        $field = $this->config->getField();
        $table = $this->config->getTable();

        $fieldName = $table->aliasField($field);

        $relatedProperties = $this->_getRelatedProperties($options['fieldDefinitions']->getLimit(), (string)$data);
        if (!empty($relatedProperties['dispFieldVal']) && !empty($relatedProperties['config']['parent']['module'])) {
            $relatedParentProperties = $this->_getRelatedParentProperties($relatedProperties);
            if (!empty($relatedParentProperties['dispFieldVal'])) {
                $relatedProperties['dispFieldVal'] = implode(' ' . $this->_separator . ' ', [
                    $relatedParentProperties['dispFieldVal'],
                    $relatedProperties['dispFieldVal']
                ]);
            }
        }

        $params = [
            'field' => $field,
            'association' => $options['association'],
            'type' => 'select',
            'label' => $options['label'],
            'required' => $options['fieldDefinitions']->getRequired(),
            'value' => $data,
            'relatedProperties' => $relatedProperties,
            'embedded' => !empty($options['emDataTarget']) ? $options['emDataTarget'] : $field,
            'icon' => $this->_getInputIcon($relatedProperties),
            'title' => $this->_getInputHelp($relatedProperties),
            'extraClasses' => (!empty($options['extraClasses']) ? implode(' ', $options['extraClasses']) : ''),
            'attributes' => empty($options['attributes']) ? [] : $options['attributes'],
        ];

        $defaultElement = 'CsvMigrations.FieldHandlers/HasManyFieldHandler/input';
        $element = empty($options['element']) ? $defaultElement : $options['element'];

        return $this->renderElement($element, $params);
    }
1316438
public function update($data = null): IResult
    {
        $builder = new UpdateBuilder($this);
        $sql = $builder->build($data);
        return $this->execute($sql);
    }
123075
public function reply(array $data = [], $return = false, $isEncrypt = false)
    {
        $xml = Tools::arr2xml(empty($data) ? $this->message : $data);
        if ($this->isEncrypt() || $isEncrypt) {
            if (!class_exists('Prpcrypt', false)) {
                require __DIR__ . '/Prpcrypt.php';
            }
            $prpcrypt = new \Prpcrypt($this->config->get('encodingaeskey'));
            // 如果是第三方平台，加密得使用 component_appid
            $component_appid = $this->config->get('component_appid');
            $appid = empty($component_appid) ? $this->appid : $component_appid;
            $array = $prpcrypt->encrypt($xml, $appid);
            if ($array[0] > 0) throw new InvalidDecryptException('Encrypt Error.', '0');
            list($timestamp, $encrypt) = [time(), $array[1]];
            $nonce = rand(77, 999) * rand(605, 888) * rand(11, 99);
            $tmpArr = [$this->config->get('token'), $timestamp, $nonce, $encrypt];
            sort($tmpArr, SORT_STRING);
            $signature = sha1(implode($tmpArr));
            $format = "<xml><Encrypt><![CDATA[%s]]></Encrypt><MsgSignature><![CDATA[%s]]></MsgSignature><TimeStamp>%s</TimeStamp><Nonce><![CDATA[%s]]></Nonce></xml>";
            $xml = sprintf($format, $encrypt, $signature, $timestamp, $nonce);
        }
        if ($return) return $xml;
        @ob_clean();
        echo $xml;
    }
1287465
protected function addData($key, $data = null)
    {
        $this->data[self::RS_KEY_DATA]->{$key} = $data;
    }
676336
private function prepareRawContent($name, $data, $isFile = false)
    {
        if (is_array($data)) {
            $preparedData = [];

            foreach ($data as $subName => $subData) {
                $preparedData = array_merge(
                    $preparedData,
                    $this->prepareRawContent($this->prepareName($name, $subName), $subData, $isFile)
                );
            }

            return $preparedData;
        }

        return [$name => $isFile ? $this->createFile($data) : $data];
    }
961858
public function addProduct(array $data)
    {
        $result = $this->wechat->httpRaw(self::WECHAT_PRODUCT_ADD_PREFIX, $data, [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'success' ? $result['product_id'] : false;
    }