Compare commits

...

2 Commits

Author SHA1 Message Date
Karson 7a4d05bbd9 优化语言包
优化cdnurl计算
2023-07-06 18:19:21 +08:00
Karson a9003ecce4 优化获取类名兼容性 2023-07-06 17:31:21 +08:00
6 changed files with 54 additions and 67 deletions

View File

@ -98,13 +98,13 @@ class Api extends Command
foreach ($files as $name => $file) { foreach ($files as $name => $file) {
if (!$file->isDir() && $file->getExtension() == 'php') { if (!$file->isDir() && $file->getExtension() == 'php') {
$filePath = $file->getRealPath(); $filePath = $file->getRealPath();
$classes[] = $this->get_class_from_file($filePath); $classes[] = $this->getClassFromFile($filePath);
} }
} }
} else { } else {
foreach ($controller as $index => $item) { foreach ($controller as $index => $item) {
$filePath = $moduleDir . Config::get('url_controller_layer') . DS . $item . '.php'; $filePath = $moduleDir . Config::get('url_controller_layer') . DS . $item . '.php';
$classes[] = $this->get_class_from_file($filePath); $classes[] = $this->getClassFromFile($filePath);
} }
} }
@ -129,67 +129,61 @@ class Api extends Command
} }
/** /**
* get full qualified class name * 从文件获取命名空间和类名
* *
* @param string $path_to_file * @param string $filename
* @return string * @return string
* @author JBYRNE http://jarretbyrne.com/2015/06/197/
*/ */
protected function get_class_from_file($path_to_file) protected function getClassFromFile($filename)
{ {
//Grab the contents of the file $getNext = null;
$contents = file_get_contents($path_to_file); $isNamespace = false;
$skipNext = false;
//Start with a blank namespace and class $namespace = '';
$namespace = $class = ""; $class = '';
foreach (\PhpToken::tokenize(file_get_contents($filename)) as $token) {
//Set helper values to know that we have found the namespace/class token and need to collect the string values after them if (!$token->isIgnorable()) {
$getting_namespace = $getting_class = false; $name = $token->getTokenName();
switch ($name) {
//Go through each token and evaluate it as necessary case 'T_NAMESPACE':
foreach (token_get_all($contents) as $token) { $isNamespace = true;
break;
//If this token is the namespace declaring, then flag that the next tokens will be the namespace name case 'T_EXTENDS':
if (is_array($token) && $token[0] == T_NAMESPACE) { case 'T_USE':
$getting_namespace = true; case 'T_IMPLEMENTS':
} $skipNext = true;
break;
//If this token is the class declaring, then flag that the next tokens will be the class name case 'T_CLASS':
if (is_array($token) && $token[0] == T_CLASS) { if ($skipNext) {
$getting_class = true; $skipNext = false;
} } else {
$getNext = strtolower(substr($name, 2));
//While we're grabbing the namespace name... }
if ($getting_namespace === true) { break;
case 'T_NAME_QUALIFIED':
//If the token is a string or the namespace separator... case 'T_NS_SEPARATOR':
if (is_array($token) && in_array($token[0], [T_STRING, T_NS_SEPARATOR])) { case 'T_STRING':
case ';':
//Append the token's value to the name of the namespace if ($isNamespace) {
$namespace .= $token[1]; if ($name == ';') {
} elseif ($token === ';') { $isNamespace = false;
} else {
//If the token is the semicolon, then we're done with the namespace declaration $namespace .= $token->text;
$getting_namespace = false; }
} } elseif ($skipNext) {
} $skipNext = false;
} elseif ($getNext == 'class') {
//While we're grabbing the class name... $class = $token->text;
if ($getting_class === true) { $getNext = null;
break 2;
//If the token is a string, it's the name of the class }
if (is_array($token) && $token[0] == T_STRING) { break;
default:
//Store the token's value as the class name $getNext = null;
$class = $token[1];
//Got what we need, stope here
break;
} }
} }
} }
//Build the fully-qualified class name and return it return $namespace . '\\' . $class;
return $namespace ? $namespace . '\\' . $class : $class;
} }
} }

View File

@ -4,6 +4,8 @@ return [
'User id' => '会员ID', 'User id' => '会员ID',
'Username' => '用户名', 'Username' => '用户名',
'Nickname' => '昵称', 'Nickname' => '昵称',
'Mobile' => '手机',
'Email' => '邮箱',
'Password' => '密码', 'Password' => '密码',
'Sign up' => '注 册', 'Sign up' => '注 册',
'Sign in' => '登 录', 'Sign in' => '登 录',

View File

@ -17,8 +17,6 @@ return [
'Online store' => '在线商店', 'Online store' => '在线商店',
'Local addon' => '本地插件', 'Local addon' => '本地插件',
'Conflict tips' => '此插件中发现和现有系统中部分文件发现冲突!以下文件将会被影响,请备份好相关文件后再继续操作', 'Conflict tips' => '此插件中发现和现有系统中部分文件发现冲突!以下文件将会被影响,请备份好相关文件后再继续操作',
'Login tips' => '此处登录账号为<a href="https://www.fastadmin.net" target="_blank">FastAdmin官网账号</a>',
'Logined tips' => '你好!%s<br />当前你已经登录,将同步保存你的购买记录',
'Pay tips' => '扫码支付后如果仍然无法安装,请不要重复支付,请稍后再重试安装!', 'Pay tips' => '扫码支付后如果仍然无法安装,请不要重复支付,请稍后再重试安装!',
'Pay successful tips' => '购买成功!请点击继续安装按钮完成安装!', 'Pay successful tips' => '购买成功!请点击继续安装按钮完成安装!',
'Pay click tips' => '请点击这里在新窗口中进行支付!', 'Pay click tips' => '请点击这里在新窗口中进行支付!',

View File

@ -251,7 +251,6 @@ class User extends Frontend
$result = $validate->check($data); $result = $validate->check($data);
if (!$result) { if (!$result) {
$this->error(__($validate->getError()), null, ['token' => $this->request->token()]); $this->error(__($validate->getError()), null, ['token' => $this->request->token()]);
return false;
} }
$ret = $this->auth->changepwd($newpassword, $oldpassword); $ret = $this->auth->changepwd($newpassword, $oldpassword);

View File

@ -51,12 +51,6 @@
<a href="javascript:;" class="viewscore">{$user.score}</a> <a href="javascript:;" class="viewscore">{$user.score}</a>
</div> </div>
</div> </div>
<div class="row">
<div class="col-xs-4 col-md-2">{:__('Successions')}</div>
<div class="col-xs-8 col-md-4">{$user.successions} {:__('Day')}</div>
<div class="col-xs-4 col-md-2">{:__('Maxsuccessions')}</div>
<div class="col-xs-8 col-md-4">{$user.maxsuccessions} {:__('Day')}</div>
</div>
<div class="row"> <div class="row">
<div class="col-xs-4 col-md-2">{:__('Logintime')}</div> <div class="col-xs-4 col-md-2">{:__('Logintime')}</div>
<div class="col-xs-8 col-md-4">{$user.logintime|date="Y-m-d H:i:s",###}</div> <div class="col-xs-8 col-md-4">{$user.logintime|date="Y-m-d H:i:s",###}</div>

View File

@ -103,8 +103,8 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefine
//获取修复后可访问的cdn链接 //获取修复后可访问的cdn链接
cdnurl: function (url, domain) { cdnurl: function (url, domain) {
var rule = new RegExp("^((?:[a-z]+:)?\\/\\/|data:image\\/)", "i"); var rule = new RegExp("^((?:[a-z]+:)?\\/\\/|data:image\\/)", "i");
if(typeof domain === 'undefined' || domain === true){ var cdnurl = Config.upload.cdnurl;
var cdnurl = Config.upload.cdnurl; if (typeof domain === 'undefined' || domain === true || cdnurl.indexOf("/") === 0) {
url = rule.test(url) || (cdnurl && url.indexOf(cdnurl) === 0) ? url : cdnurl + url; url = rule.test(url) || (cdnurl && url.indexOf(cdnurl) === 0) ? url : cdnurl + url;
} }
if (domain && !rule.test(url)) { if (domain && !rule.test(url)) {