- update common.php

- add facade Arrays.php
- add AesService.php
v6
Chaim 4 years ago
parent 9a84f1b8e0
commit f418237ee3

@ -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",

@ -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);
}
}

@ -0,0 +1,32 @@
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\exception;
use Exception;
/**
* IP错误处理
* Class IpException
* @package DtApp\ThinkLibrary\exception
*/
class IpException extends Exception
{
public function errorMessage()
{
return $this->getMessage();
}
}

@ -0,0 +1,44 @@
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\facade;
use DtApp\ThinkLibrary\helper\Arrays as helper;
use think\Facade;
/**
* 数组门面
* Class Arrays
* @see \DtApp\ThinkLibrary\helper\Arrays
* @package DtApp\ThinkLibrary\facade
* @package think\facade
* @mixin helper
*
* @method helper rand(int $num) mixed 数组随机返回一个下标
* @method helper randValue(int $num) mixed 数组随机返回一个值
*/
class Arrays extends Facade
{
/**
* 获取当前Facade对应类名或者已经绑定的容器对象标识
* @access protected
* @return string
*/
protected static function getFacadeClass()
{
return helper::class;
}
}

@ -0,0 +1,46 @@
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\helper;
/**
* 数组管理类
* Class Arrays
* @package DtApp\ThinkLibrary\helper
*/
class Arrays
{
/**
* 数组随机返回一个下标
* @param $arr
* @return mixed
*/
public function rand($arr)
{
return array_rand($arr);
}
/**
* 数组随机返回一个值
* @param $arr
* @return mixed
*/
public function randValue($arr)
{
return $arr[array_rand($arr)];
}
}

@ -0,0 +1,58 @@
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\service\crypt;
use DtApp\ThinkLibrary\Service;
class AesService extends Service
{
private $key;
private $iv;
public function key($str)
{
$this->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);
}
}
Loading…
Cancel
Save