|
@@ -4,9 +4,7 @@ declare(strict_types=1);
|
|
|
namespace SixShop\Core;
|
|
namespace SixShop\Core;
|
|
|
|
|
|
|
|
use SixShop\Core\Exception\LogicException;
|
|
use SixShop\Core\Exception\LogicException;
|
|
|
-use SixShop\Core\Response\Xml;
|
|
|
|
|
use SixShop\Core\Service\CoreService;
|
|
use SixShop\Core\Service\CoreService;
|
|
|
-use think\Container;
|
|
|
|
|
use think\Paginator;
|
|
use think\Paginator;
|
|
|
use think\Response;
|
|
use think\Response;
|
|
|
|
|
|
|
@@ -23,23 +21,7 @@ final class Helper
|
|
|
*/
|
|
*/
|
|
|
public static function success_response(mixed $data = [], string $status = 'ok', int $code = 200, string $msg = 'success', string $type = 'json', string $xslt = ''): Response
|
|
public static function success_response(mixed $data = [], string $status = 'ok', int $code = 200, string $msg = 'success', string $type = 'json', string $xslt = ''): Response
|
|
|
{
|
|
{
|
|
|
- if ($xslt) {
|
|
|
|
|
- $type = 'xml';
|
|
|
|
|
- }
|
|
|
|
|
- $responseData = [
|
|
|
|
|
- 'code' => $code,
|
|
|
|
|
- 'status' => $status,
|
|
|
|
|
- 'msg' => $msg,
|
|
|
|
|
- 'data' => $data
|
|
|
|
|
- ];
|
|
|
|
|
- if ($type == 'xml') {
|
|
|
|
|
- /* @var Xml $response */
|
|
|
|
|
- $response = Container::getInstance()->invokeClass(Xml::class, [$responseData, 200]);
|
|
|
|
|
- $response = $response->options(['root_node' => 'root', 'xslt' => $xslt]);
|
|
|
|
|
- } else {
|
|
|
|
|
- $response = Response::create($responseData, $type);
|
|
|
|
|
- }
|
|
|
|
|
- return $response;
|
|
|
|
|
|
|
+ return success_response($data, $status, $code, $msg, $type, $xslt);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -143,26 +125,7 @@ final class Helper
|
|
|
*/
|
|
*/
|
|
|
public static function secret_password(int $length = 16): string
|
|
public static function secret_password(int $length = 16): string
|
|
|
{
|
|
{
|
|
|
- // 确保密码包含各种字符类型
|
|
|
|
|
- $lowercase = 'abcdefghijklmnopqrstuvwxyz';
|
|
|
|
|
- $uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
|
|
|
- $numbers = '0123456789';
|
|
|
|
|
- $specialChars = '!@#$%^&*()_+-=[]{}|;:,.<>?';
|
|
|
|
|
-
|
|
|
|
|
- // 至少包含每种类型的一个字符
|
|
|
|
|
- $password = $lowercase[random_int(0, strlen($lowercase) - 1)];
|
|
|
|
|
- $password .= $uppercase[random_int(0, strlen($uppercase) - 1)];
|
|
|
|
|
- $password .= $numbers[random_int(0, strlen($numbers) - 1)];
|
|
|
|
|
- $password .= $specialChars[random_int(0, strlen($specialChars) - 1)];
|
|
|
|
|
-
|
|
|
|
|
- // 剩余字符随机生成
|
|
|
|
|
- $allChars = $lowercase . $uppercase . $numbers . $specialChars;
|
|
|
|
|
- for ($i = 4; $i < $length; $i++) {
|
|
|
|
|
- $password .= $allChars[random_int(0, strlen($allChars) - 1)];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 打乱字符顺序
|
|
|
|
|
- return str_shuffle($password);
|
|
|
|
|
|
|
+ return secret_password($length);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -173,17 +136,7 @@ final class Helper
|
|
|
*/
|
|
*/
|
|
|
public static function extension_path(string $extensionID = ''): string
|
|
public static function extension_path(string $extensionID = ''): string
|
|
|
{
|
|
{
|
|
|
- if (!$extensionID) {
|
|
|
|
|
- return CoreService::$extensionPath;
|
|
|
|
|
- }
|
|
|
|
|
- if (isset(CoreService::$extensionComposerMap[$extensionID]['name'])) {
|
|
|
|
|
- $extensionName = CoreService::$extensionComposerMap[$extensionID]['name'];
|
|
|
|
|
- $versions = Plugin::getInstalledSixShopExtensions()['versions'];
|
|
|
|
|
- if (isset($versions[$extensionName]['install_path'])) {
|
|
|
|
|
- return realpath($versions[$extensionName]['install_path']) . DIRECTORY_SEPARATOR;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return CoreService::$extensionPath . $extensionID . DIRECTORY_SEPARATOR;
|
|
|
|
|
|
|
+ return extension_path($extensionID);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|