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) {
if (!$file->isDir() && $file->getExtension() == 'php') {
$filePath = $file->getRealPath();
$classes[] = $this->get_class_from_file($filePath);
$classes[] = $this->getClassFromFile($filePath);
}
}
} else {
foreach ($controller as $index => $item) {
$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
* @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
$contents = file_get_contents($path_to_file);
//Start with a blank namespace and class
$namespace = $class = "";
//Set helper values to know that we have found the namespace/class token and need to collect the string values after them
$getting_namespace = $getting_class = false;
//Go through each token and evaluate it as necessary
foreach (token_get_all($contents) as $token) {
//If this token is the namespace declaring, then flag that the next tokens will be the namespace name
if (is_array($token) && $token[0] == T_NAMESPACE) {
$getting_namespace = true;
}
//If this token is the class declaring, then flag that the next tokens will be the class name
if (is_array($token) && $token[0] == T_CLASS) {
$getting_class = true;
}
//While we're grabbing the namespace name...
if ($getting_namespace === true) {
//If the token is a string or the namespace separator...
if (is_array($token) && in_array($token[0], [T_STRING, T_NS_SEPARATOR])) {
//Append the token's value to the name of the namespace
$namespace .= $token[1];
} elseif ($token === ';') {
//If the token is the semicolon, then we're done with the namespace declaration
$getting_namespace = false;
}
}
//While we're grabbing the class name...
if ($getting_class === true) {
//If the token is a string, it's the name of the class
if (is_array($token) && $token[0] == T_STRING) {
//Store the token's value as the class name
$class = $token[1];
//Got what we need, stope here
break;
$getNext = null;
$isNamespace = false;
$skipNext = false;
$namespace = '';
$class = '';
foreach (\PhpToken::tokenize(file_get_contents($filename)) as $token) {
if (!$token->isIgnorable()) {
$name = $token->getTokenName();
switch ($name) {
case 'T_NAMESPACE':
$isNamespace = true;
break;
case 'T_EXTENDS':
case 'T_USE':
case 'T_IMPLEMENTS':
$skipNext = true;
break;
case 'T_CLASS':
if ($skipNext) {
$skipNext = false;
} else {
$getNext = strtolower(substr($name, 2));
}
break;
case 'T_NAME_QUALIFIED':
case 'T_NS_SEPARATOR':
case 'T_STRING':
case ';':
if ($isNamespace) {
if ($name == ';') {
$isNamespace = false;
} else {
$namespace .= $token->text;
}
} elseif ($skipNext) {
$skipNext = false;
} elseif ($getNext == 'class') {
$class = $token->text;
$getNext = null;
break 2;
}
break;
default:
$getNext = null;
}
}
}
//Build the fully-qualified class name and return it
return $namespace ? $namespace . '\\' . $class : $class;
return $namespace . '\\' . $class;
}
}

View File

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

View File

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

View File

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

View File

@ -51,12 +51,6 @@
<a href="javascript:;" class="viewscore">{$user.score}</a>
</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="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>

View File

@ -103,8 +103,8 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefine
//获取修复后可访问的cdn链接
cdnurl: function (url, domain) {
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;
}
if (domain && !rule.test(url)) {