Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
azpanel committed Aug 13, 2023
1 parent 54570df commit 15949bf
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 57 deletions.
78 changes: 26 additions & 52 deletions app/controller/UserAws.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ public function save()

try {
if ($add_mode === 'single') {
$batch_addition = $email . PHP_EOL . $passwd . PHP_EOL . $aws_ak . PHP_EOL . $aws_sk;
}
$accounts = explode(PHP_EOL, $batch_addition);
if (count($accounts) % 4 !== 0) {
throw new \Exception("内容与数量不匹配");
}
$array = [];
$pointer = 0;
while ($pointer < count($accounts) - 1) {
$email = $accounts[$pointer++];
$passwd = $accounts[$pointer++];
$aws_ak = $accounts[$pointer++];
$aws_sk = $accounts[$pointer++];
// check format
self::awsCertificateVerify([
$email,
Expand All @@ -101,56 +114,19 @@ public function save()
$quota[$region] = AwsApi::getQuota($region, $aws_ak, $aws_sk);
}
// save data
$add = new Aws();
$add->email = $email;
$add->passwd = $passwd;
$add->ak = $aws_ak;
$add->sk = $aws_sk;
$add->mark = $remark_filling === 'input' ? $user_mark : $remark_filling;
$add->quota = $quota;
$add->disable = $quota['ap-northeast-1'] === 'null' ? 1 : 0;
$add->user_id = session('user_id');
$add->created_at = time();
$add->save();
} else {
$accounts = explode(PHP_EOL, $batch_addition);
if (count($accounts) % 4 !== 0) {
throw new \Exception("内容与数量不匹配");
}
$array = [];
$pointer = 0;
while ($pointer < count($accounts) - 1) {
$email = $accounts[$pointer++];
$passwd = $accounts[$pointer++];
$aws_ak = $accounts[$pointer++];
$aws_sk = $accounts[$pointer++];
// check format
self::awsCertificateVerify([
$email,
$passwd,
$aws_ak,
$aws_sk,
]);
// query quota
$quota = [];
foreach ($regions as $region) {
$quota[$region] = AwsApi::getQuota($region, $aws_ak, $aws_sk);
}
// save data
$array[] = [
'email' => $email,
'passwd' => $passwd,
'ak' => $aws_ak,
'sk' => $aws_sk,
'mark' => $remark_filling === 'input' ? $user_mark : $remark_filling,
'quota' => $quota,
'disable' => $quota['ap-northeast-1'] === 'null' ? 1 : 0,
'user_id' => session('user_id'),
'created_at' => time(),
];
}
Aws::insertAll($array);
$array[] = [
'email' => $email,
'passwd' => $passwd,
'ak' => $aws_ak,
'sk' => $aws_sk,
'mark' => $remark_filling === 'input' ? $user_mark : $remark_filling,
'quota' => $quota,
'disable' => $quota['ap-northeast-1'] === 'null' ? 1 : 0,
'user_id' => session('user_id'),
'created_at' => time(),
];
}
Aws::insertAll($array);
return json(Tools::msg('1', '保存结果', '保存成功'));
} catch (\Exception $e) {
return json(Tools::msg('0', '保存失败', $e->getMessage()));
Expand Down Expand Up @@ -182,9 +158,7 @@ public function edit($id)
return View::fetch('../app/view/user/reject.html');
}

View::assign([
'account' => $account,
]);
View::assign('account', $account);
return View::fetch('../app/view/user/aws/edit.html');
}

Expand Down
2 changes: 1 addition & 1 deletion app/controller/UserAwsServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function create()
View::assign([
'accounts' => $accounts,
'personalise' => $personalise,
'disk_sizes' => [32, 64, 128],
'disk_sizes' => [16, 32, 64, 128],
'sizes' => AwsList::instanceSizes(),
'images' => AwsList::instanceImage(),
'locations' => AwsList::instanceRegion(),
Expand Down
4 changes: 2 additions & 2 deletions flush-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

version=$(git log --format="%ct" | wc -l)
big_v='1'
medium_v='1'
small_v=$(expr ${version} - 105)
medium_v='2'
small_v=$(expr ${version} - 211)
hash=$(git log -1 --format="%h")

if [[ -e "/usr/local/php8.1/bin/php" ]];then
Expand Down
4 changes: 2 additions & 2 deletions upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ modifyVersion()
version=$(git log --format="%ct" | wc -l)

big_v='1'
medium_v='1'
small_v=$(expr ${version} - 105)
medium_v='2'
small_v=$(expr ${version} - 211)
hash=$(git log -1 --format="%h")

# tvl = tpl version line
Expand Down

0 comments on commit 15949bf

Please sign in to comment.