From add853fadaebeed99d2eadcf6ec2fa9396bf6ccd Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Mon, 20 Feb 2023 20:59:55 +0330 Subject: update pack 3 user pass will be generated randomly upgrade all dependencies move add client buttom --- web/assets/js/util/utils.js | 2 +- web/html/xui/form/protocol/trojan.html | 213 +++++++++++++++------------------ web/html/xui/form/protocol/vless.html | 64 ++++------ web/html/xui/form/protocol/vmess.html | 67 ++++------- web/html/xui/inbound_modal.html | 22 +--- web/job/stats_notify_job.go | 2 +- web/service/inbound.go | 20 ++-- web/service/user.go | 3 +- web/translation/translate.fa_IR.toml | 2 +- 9 files changed, 164 insertions(+), 231 deletions(-) (limited to 'web') diff --git a/web/assets/js/util/utils.js b/web/assets/js/util/utils.js index f3a412e5..bb897047 100644 --- a/web/assets/js/util/utils.js +++ b/web/assets/js/util/utils.js @@ -179,7 +179,7 @@ class ObjectUtil { } } } else { - return obj.toString().indexOf(key) >= 0; + return obj.toString().toLowerCase().indexOf(key.toLowerCase()) >= 0; } return false; } diff --git a/web/html/xui/form/protocol/trojan.html b/web/html/xui/form/protocol/trojan.html index fa5a2032..6d43bc34 100644 --- a/web/html/xui/form/protocol/trojan.html +++ b/web/html/xui/form/protocol/trojan.html @@ -1,141 +1,126 @@ {{define "form/trojan"}} + - - - Account is (Expired|Traffic Ended) And Disabled - + + Account is (Expired|Traffic Ended) And Disabled + + + + Email + + + + + + + + + + + + + + + {{ i18n "none" }} + [[ key ]] + + - Email + {{ i18n "pages.inbounds.totalFlow" }}(GB) - - + - + - - - - - - - none - [[ key ]] - + + + {{ i18n "pages.inbounds.expireDate" }} + + + + + + - - - {{ i18n "pages.inbounds.totalFlow" }}(GB) - + + - + + + - - - - - - {{ i18n "pages.inbounds.expireDate" }} - - - - - - - - - - - - - - - [[ sizeFormat(getUpStats(trojan.email)) ]] / [[ sizeFormat(getDownStats(trojan.email)) ]] - used : [[ sizeFormat(getUpStats(trojan.email) + getDownStats(trojan.email)) ]] - - - - - - - - - - - - - - + [[ sizeFormat(getUpStats(trojan.email)) ]] / [[ sizeFormat(getDownStats(trojan.email)) ]] + used : [[ sizeFormat(getUpStats(trojan.email) + getDownStats(trojan.email)) ]] + + + + + + + + + + + + + + + + - - - + - + + + + + - - fallback[[ index + 1 ]] - - - - - - - - - - - - - - - - - - + + fallback[[ index + 1 ]] + + + + + + + + + + + + + + + + + + {{end}} \ No newline at end of file diff --git a/web/html/xui/form/protocol/vless.html b/web/html/xui/form/protocol/vless.html index 5d56fdd3..fc7ffaa6 100644 --- a/web/html/xui/form/protocol/vless.html +++ b/web/html/xui/form/protocol/vless.html @@ -1,6 +1,7 @@ {{define "form/vless"}} -{{ i18n "clients"}} + @@ -26,20 +27,20 @@ - + - none + {{ i18n "none" }} [[ key ]] - + - none + {{ i18n "none" }} [[ key ]] - - + + [[ key ]] @@ -71,7 +72,7 @@ @@ -79,43 +80,26 @@ [[ sizeFormat(getUpStats(vless.email)) ]] / [[ sizeFormat(getDownStats(vless.email)) ]] used : [[ sizeFormat(getUpStats(vless.email) + getDownStats(vless.email)) ]] - - + + + - - - - - - - - - - + + + + + + + + diff --git a/web/html/xui/form/protocol/vmess.html b/web/html/xui/form/protocol/vmess.html index 9ed444c6..f7050a5e 100644 --- a/web/html/xui/form/protocol/vmess.html +++ b/web/html/xui/form/protocol/vmess.html @@ -1,5 +1,6 @@ {{define "form/vmess"}} + @@ -56,7 +57,7 @@ @@ -64,56 +65,34 @@ [[ sizeFormat(getUpStats(vmess.email)) ]] / [[ sizeFormat(getDownStats(vmess.email)) ]] used : [[ sizeFormat(getUpStats(vmess.email) + getDownStats(vmess.email)) ]] - - - - - - + + + + + - - - - - - - - - + - + + + + + + + - - - - - + + + -{{end}} +{{end}} \ No newline at end of file diff --git a/web/html/xui/inbound_modal.html b/web/html/xui/inbound_modal.html index 4fec0ded..80ea2286 100644 --- a/web/html/xui/inbound_modal.html +++ b/web/html/xui/inbound_modal.html @@ -77,7 +77,7 @@ this.inModal.inbound.tls = false; } }, - addClient(protocol,value, clients) { + addClient(protocol, clients) { switch (protocol) { case Protocols.VMESS: return clients.push(new Inbound.VmessSettings.Vmess()); case Protocols.VLESS: return clients.push(new Inbound.VLESSSettings.VLESS()); @@ -88,7 +88,6 @@ removeClient(index, clients) { clients.splice(index, 1); }, - async resetClientTraffic(client,event) { const msg = await HttpUtil.post('/xui/inbound/resetClientTraffic/'+ client.email); if (!msg.success) { @@ -122,7 +121,6 @@ } } } - }, getDownStats(email) { clientStats = this.inbound.clientStats @@ -138,30 +136,18 @@ } }, isClientEnable(email) { - clientStats = this.inbound.clientStats - if(clientStats.length > 0) - { - for (const key in clientStats) { - if (Object.hasOwnProperty.call(clientStats, key)) { - if(clientStats[key]['email'] == email) - return clientStats[key]['enable'] - - } - } - } + clientStats = this.dbInbound.clientStats ? this.dbInbound.clientStats.find(stats => stats.email === email) : null + return clientStats ? clientStats['enable'] : true }, - getHeaderText(email) { if(email == "") return "Add Client" return email + (this.isClientEnable(email) == true ? ' Active' : ' Deactive') }, - getHeaderStyle(email) { return (this.isClientEnable(email) == true ? '' : 'deactive-client') }, - getNewEmail(client) { var chars = 'abcdefghijklmnopqrstuvwxyz1234567890'; var string = ''; @@ -175,4 +161,4 @@ }); -{{end}} +{{end}} \ No newline at end of file diff --git a/web/job/stats_notify_job.go b/web/job/stats_notify_job.go index 92963127..21f61a1e 100644 --- a/web/job/stats_notify_job.go +++ b/web/job/stats_notify_job.go @@ -240,7 +240,7 @@ func (j *StatsNotifyJob) getClientUsage(id string) string { } else { total = fmt.Sprintf("%s", common.FormatTraffic((traffic.Total))) } - output := fmt.Sprintf("💡 Active: %t\r\n📧 Email: %s\r\n🔼 Upload↑: %s\r\n🔽 Download↓: %s\r\n🔄 Total: %s / %s\r\n📅 Expire in: %s\r\n", + output := fmt.Sprintf("💡 Active: %t\r\n📧 Email: %s\r\n🔼 Download↑: %s\r\n🔽 Upload↓: %s\r\n🔄 Total: %s / %s\r\n📅 Expire in: %s\r\n", traffic.Enable, traffic.Email, common.FormatTraffic(traffic.Up), common.FormatTraffic(traffic.Down), common.FormatTraffic((traffic.Up + traffic.Down)), total, expiryTime) diff --git a/web/service/inbound.go b/web/service/inbound.go index dedf76a0..5c1cfedc 100644 --- a/web/service/inbound.go +++ b/web/service/inbound.go @@ -238,9 +238,9 @@ func (s *InboundService) AddTraffic(traffics []*xray.Traffic) (err error) { for _, traffic := range traffics { if traffic.IsInbound { err = tx.Where("tag = ?", traffic.Tag). - UpdateColumn("up", gorm.Expr("up + ?", traffic.Up)). - UpdateColumn("down", gorm.Expr("down + ?", traffic.Down)). - Error + UpdateColumns(map[string]interface{}{ + "up": gorm.Expr("up + ?", traffic.Up), + "down": gorm.Expr("down + ?", traffic.Down)}).Error if err != nil { return } @@ -298,11 +298,12 @@ func (s *InboundService) AddClientTraffic(traffics []*xray.ClientTraffic) (err e } } if tx.Where("inbound_id = ?", inbound.Id).Where("email = ?", traffic.Email). - UpdateColumn("enable", true). - UpdateColumn("expiry_time", traffic.ExpiryTime). - UpdateColumn("total", traffic.Total). - UpdateColumn("up", gorm.Expr("up + ?", traffic.Up)). - UpdateColumn("down", gorm.Expr("down + ?", traffic.Down)).RowsAffected == 0 { + UpdateColumns(map[string]interface{}{ + "enable": true, + "expiry_time": traffic.ExpiryTime, + "total": traffic.Total, + "up": gorm.Expr("up + ?", traffic.Up), + "down": gorm.Expr("down + ?", traffic.Down)}).RowsAffected == 0 { err = tx.Create(traffic).Error } @@ -374,8 +375,7 @@ func (s *InboundService) ResetClientTraffic(clientEmail string) error { result := db.Model(xray.ClientTraffic{}). Where("email = ?", clientEmail). - Update("up", 0). - Update("down", 0) + Updates(map[string]interface{}{"up": 0, "down": 0}) err := result.Error diff --git a/web/service/user.go b/web/service/user.go index e4e7572d..6da8bd1e 100644 --- a/web/service/user.go +++ b/web/service/user.go @@ -46,8 +46,7 @@ func (s *UserService) UpdateUser(id int, username string, password string) error db := database.GetDB() return db.Model(model.User{}). Where("id = ?", id). - Update("username", username). - Update("password", password). + Updates(map[string]interface{}{"username": username, "password": password}). Error } diff --git a/web/translation/translate.fa_IR.toml b/web/translation/translate.fa_IR.toml index 76e849b6..7d439fea 100644 --- a/web/translation/translate.fa_IR.toml +++ b/web/translation/translate.fa_IR.toml @@ -48,7 +48,7 @@ [menu] "dashboard" = "وضعیت سیستم" -"inbounds" = "سروریس ها" +"inbounds" = "سرویس ها" "setting" = "تنظیمات پنل" "logout" = "خروج" "link" = "دیگر" -- cgit v1.2.3