解密
@param  string $data  密文
@param  bool   $isRaw 密文是否为原始密文，否则已转换为16进制
@return string|null   解密失败返回null
542169
public function decrypt(string $data, bool $isRaw = false) :  ? string
    {
        //1.解密偏置
        $n = strlen($data);
        if ($isRaw) {
            if ($n < 32) {
                return null; //原始数据长度不可能小于32
            }
            $b  = substr($data, 0, 16);
            $_b = array(16);
            for ($i = 0; $i < 16; $i++) {
                $_b[$i] = ord($b[$i]);
            }
        } else {
            if ($n < 64) {
                return null; //16进制长度不可能小于64
            }
            $b  = substr($data, 0, 32); //16进制转化为单字节整数
            $_b = array(16);
            for ($i = 0, $j = 0; $i < 16; $i++, $j += 2) {
                $_b[$i] = hexdec($b[$j] . $b[$j + 1]);
            }
        }
        $b = $this->handleB($_b);

        //2.解密数据
        if ($isRaw) {
            $encrypt = substr($data, 16, $n);
            $n -= 16;
        } else {
            $encrypt = '';
            for ($i = 32; $i < $n; $i += 2) {
                if (isset($data[$i + 1])) {
                    $char = $data[$i] . $data[$i + 1];
                } else {
                    $char = $data[$i];
                }

                $encrypt .= chr(hexdec($char)); //转化data为ascii字符
            }
            $n = ($n - 32) / 2;
        }

        $encrypt = $this->handle($encrypt, $b, $n);

        //3.输出
        if ($n === 16) {
            $m = ord($encrypt[15]); //检查是否有填充数据

            if ($m > 0 && $m < 16 && ($b[0] - $b[1] === $m || $b[0] - $b[1] === $m - 256)) {
                $padding = true;
                while (--$m) {
                    if (ord($encrypt[15 - $m]) !== 0) {
                        $padding = false; //填充位不为0则不是填充
                        break;
                    }
                }
                if ($padding) {
                    $encrypt = substr($encrypt, 0, 16 - ord($encrypt[15]));
                }
            }
        }

        return $encrypt;
    }
966934
public function callback($data = null)
    {
        $data = $data ?: $_POST;
        if ($data['ReturnCode'] != 1) {
            throw new \Exception("交易查询失败：" . $data['ReturnMsg']);
        }
        Datasheet::set($data);
        if (isset($data['Hash']) && $data['Hash'] != Helper::signature(Helper::SIGN_CALLBACK)) {
            throw new \Exception("回调签名验证失败");
        }

        if ($data['PayResult'] != 3) {
            throw new \Exception("交易不成功：" . $data['ReturnMsg']);
        }
        return $data;
    }
853
public function getWithNsQuery($ns, array $data, $mark = true)
    {
        if ($this->hasQuery($ns)) {
            $query = $this->getQuery($ns);
            $url = null;

            if ($mark === true) {
                $url = '?';
            }

            $url .= http_build_query(array($ns => array_merge($query, $data)));
            $url = str_replace('%25s', '%s', $url);

            return $url;
        } else {
            return null;
        }
    }
531288
protected function _getFiles($iStart = 0, $iShopId = null)
    {
        $sSelect = "SELECT * FROM `ddmedia` WHERE 1 " . ($iShopId != null ? "AND `OXSHOPID` = '" . $iShopId . "' " : "") . "ORDER BY `OXTIMESTAMP` DESC LIMIT " . $iStart . ", 18 ";

        return DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->getAll($sSelect);
    }
715757
public static function encode($data, $pad = null) {
		$str = str_replace(array('+', '/'), array('-', '_'), base64_encode($data));
		if (!$pad) {
			$str = rtrim($str, '=');
		}
		return $str;
	}
355389
public function convert($data)
    {
        if (empty($data) || ($out = @serialize($data)) === false)
            return null;

        return $out;
    }
71800
protected function parseData($dataRaw) {
		$data = [];
		
		foreach ($dataRaw as $key => $value) {
			$data = array_replace_recursive($data, $this->parseKey($key, $value));
		}
		
		return $data;
	}
169908
public function get($url, $base = null, $re = false, $isImg = false) {
        set_time_limit(0);
        if ($base) {
            $uinfo = CurlClient::getUrlInfo($url);
            if ($uinfo ['root'] != $this->domain) {
                $ip = rtrim($base, DS) . DS . 'o_tfs' . DS . ($uinfo ['path'] ? $uinfo ['path'] . DS : '');
            } else {
                $ip = rtrim($base, DS) . DS . ($uinfo ['path'] ? $uinfo ['path'] . DS : '');
            }

            if (!file_exists($ip)) {
                if (!@mkdir($ip, 0777, true)) {
                    return false;
                }
            }

            $tmpName = $ip . $uinfo ['file'];
            if (file_exists($tmpName)) {
                if ($re) {
                    return @file_get_contents($tmpName);
                } else {
                    return true;
                }
            }
        }
        $curl = $this->ch;
        curl_setopt($curl, CURLOPT_URL, $url);
        $rst = curl_exec($curl);
        if ($rst === false) {
            $this->error     = curl_error($this->ch);
            $this->errorCode = '500';
            $rst             = false;
        } else {
            $code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
            if ($code != '200') {
                $this->error     = '[' . $code . ']' . get_status_header_desc($code);
                $this->errorCode = $code;
                $rst             = false;
            }
        }
        if ($rst) {
            if (!$isImg && $this->encoding != 'UTF-8') {
                $rst = CurlClient::convertString($rst, $this->encoding);
            }
            if (isset ($tmpName)) {
                if (!@file_put_contents($tmpName, $rst)) {
                    return false;
                }
            }
        }

        return $rst;
    }
764182
public function w($type, $data) {
    switch ($type) {
      case self::uint8:
        return $this->writeUInt8($data);
      case self::int8:
        return $this->writeInt8($data);
      case self::uint16:
        return $this->writeUInt16($data);
      case self::int16:
        return $this->writeInt16($data);
      case self::uint32:
        return $this->writeUInt32($data);
      case self::int32:
        return $this->writeUInt32($data);
      case self::shortFrac:
        return $this->writeFixed($data);
      case self::Fixed:
        return $this->writeFixed($data);
      case self::FWord:
        return $this->writeInt16($data);
      case self::uFWord:
        return $this->writeUInt16($data);
      case self::F2Dot14:
        return $this->writeInt16($data);
      case self::longDateTime:
        return $this->writeLongDateTime($data);
      case self::char:
        return $this->write($data, 1);
      default:
        if (is_array($type)) {
          if ($type[0] == self::char) {
            return $this->write($data, $type[1]);
          }

          $ret = 0;
          for ($i = 0; $i < $type[1]; $i++) {
            if (isset($data[$i])) {
              $ret += $this->w($type[0], $data[$i]);
            }
          }

          return $ret;
        }

        return null;
    }
  }
1066593
private function checkRequiredData($data, $isNew)
    {
        $this->checkDataSet($data, 'order', $isNew) && $this->checkDataSet($data['order'], 'id', $isNew);
        $this->checkDataSet($data, 'deliveryAddress', $isNew);
    }
260567
public function replyXml(array $data, $isReturn = false)
    {
        $xml = Tools::arr2xml($data);
        if ($isReturn) {
            return $xml;
        }
        ob_clean();
        exit($xml);
    }
295474
private function checkDataSet(array $data, $key, $isNew)
    {
        $keyExists = array_key_exists($key, $data);

        if (($isNew && !($keyExists && $data[$key] !== null)) || (!$keyExists || $data[$key] === null)) {
            throw new MissingOrderAttributeException($key);
        }

        return $keyExists;
    }
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;
    }
569172
public function rawResponseToArray($responseRaw, $format)
    {
        if (strstr($responseRaw, 'winstrom')) {
            $nsbackup        = $this->nameSpace;
            $this->nameSpace = 'winstrom';
            $response        = parent::rawResponseToArray($responseRaw, $format);
            $this->nameSpace = $nsbackup;
        } else {
            $response = parent::rawResponseToArray($responseRaw, $format);
        }
        return $response;
    }
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;
    }
112309
public function reverseTransform($data)
    {
        $value = parent::reverseTransform($data);

        return ! is_null($value) ? (int) $value : null;
    }
641208
public function yesNo($data = null) {
		if ((bool)$data) {
			$result = $this->_getOptionsForElem('yesNo.yes');
		} else {
			$result = $this->_getOptionsForElem('yesNo.no');
		}

		return $result;
	}