diff --git a/composer.json b/composer.json index 1afa2cb..770723b 100644 --- a/composer.json +++ b/composer.json @@ -26,10 +26,11 @@ "ext-json": "*", "ext-simplexml": "*", "ext-zip": "*", + "ext-openssl": "*", + "ext-bcmath": "*", + "ext-iconv": "*", "topthink/framework": "^6.0.0", "topthink/think-orm": "^2.0", - "liguangchun/ip": "^1.1", - "ext-bcmath": "*", "aliyuncs/oss-sdk-php": "^2.3", "obs/esdk-obs-php": "^3.19", "baidubce/bce-sdk-php": "^0.8.22", diff --git a/src/common.php b/src/common.php index 6f785d0..e232650 100644 --- a/src/common.php +++ b/src/common.php @@ -14,8 +14,8 @@ // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library // +---------------------------------------------------------------------- -use DtApp\Ip\IpException; -use DtApp\Ip\QqWry; +use DtApp\ThinkLibrary\exception\IpException; +use DtApp\ThinkLibrary\service\ip\QqWryService; if (!function_exists('get_ip_info')) { @@ -36,8 +36,7 @@ if (!function_exists('get_ip_info')) { $ip = $_SERVER['REMOTE_ADDR']; } } - $qqwry = new QqWry(); - return $qqwry->getLocation($ip); + return QqWryService::instance()->getLocation($ip); } } diff --git a/src/exception/IpException.php b/src/exception/IpException.php new file mode 100644 index 0000000..49510fc --- /dev/null +++ b/src/exception/IpException.php @@ -0,0 +1,32 @@ +getMessage(); + } +} diff --git a/src/facade/Arrays.php b/src/facade/Arrays.php new file mode 100644 index 0000000..19109fd --- /dev/null +++ b/src/facade/Arrays.php @@ -0,0 +1,44 @@ +key = $str; + return $this; + } + + public function iv($str) + { + $this->iv = $str; + return $this; + } + + /** + * 加密 + * @param $data + * @return string + */ + public function encrypt($data) + { + if (!empty(is_array($data))) $data = json_encode($data); + return urlencode(base64_encode(openssl_encrypt($data, 'AES-128-CBC', $this->key, 1, $this->iv))); + } + + /** + * 解密 + * @param $data + * @return false|string + */ + public function decrypt($data) + { + return openssl_decrypt(base64_decode(urldecode($data)), "AES-128-CBC", $this->key, true, $this->iv); + } +}