From 705899ffc78ca6d377a419a26c042d54a3af2ff7 Mon Sep 17 00:00:00 2001 From: Pantelis Roditis Date: Thu, 28 Nov 2024 03:07:38 +0200 Subject: [PATCH 1/2] issue #1325 --- backend/components/WebhookTrigger.php | 2 -- backend/modules/content/models/News.php | 2 -- backend/modules/gameplay/models/Target.php | 2 -- backend/modules/infrastructure/models/NetworkTargetSchedule.php | 2 -- 4 files changed, 8 deletions(-) diff --git a/backend/components/WebhookTrigger.php b/backend/components/WebhookTrigger.php index 807d43bd9..bd80f6c8c 100644 --- a/backend/components/WebhookTrigger.php +++ b/backend/components/WebhookTrigger.php @@ -22,8 +22,6 @@ public function run() { if (trim($this->url)=="") return; - - // init the request, set some info, send it and finally close it $ch = curl_init($this->url); curl_setopt($ch, CURLOPT_POST, 1); diff --git a/backend/modules/content/models/News.php b/backend/modules/content/models/News.php index b8ac66f5d..ca30bb67b 100644 --- a/backend/modules/content/models/News.php +++ b/backend/modules/content/models/News.php @@ -72,8 +72,6 @@ public function attributeLabels() public function toDiscord() { if(Yii::$app->sys->discord_news_webhook!==false){ - $data["avatar_url"]=sprintf("https://%s/images/appicon.png",Yii::$app->sys->offense_domain); - $data['username']='echoCTF.RED'; $data['content']=$this->body; $client = new Webhook(['url' => Yii::$app->sys->discord_news_webhook,'data'=>json_encode($data)]); return $client->run(); diff --git a/backend/modules/gameplay/models/Target.php b/backend/modules/gameplay/models/Target.php index cbade5eb7..dadf22ec2 100644 --- a/backend/modules/gameplay/models/Target.php +++ b/backend/modules/gameplay/models/Target.php @@ -401,8 +401,6 @@ public function addNews() if(Yii::$app->sys->discord_news_webhook!==false) { $bodyPlain.="\n\nWe hope you enjoy and as always Happy Hacking :heart:"; - $data["avatar_url"]=sprintf("https://%s/images/appicon.png",Yii::$app->sys->offense_domain); - $data['username']='echoCTF.RED'; $data['content']=$bodyPlain; $client = new Webhook(['url' => Yii::$app->sys->discord_news_webhook,'data'=>json_encode($data)]); $client->run(); diff --git a/backend/modules/infrastructure/models/NetworkTargetSchedule.php b/backend/modules/infrastructure/models/NetworkTargetSchedule.php index 353961970..357860217 100644 --- a/backend/modules/infrastructure/models/NetworkTargetSchedule.php +++ b/backend/modules/infrastructure/models/NetworkTargetSchedule.php @@ -142,8 +142,6 @@ public function addNews() } if(Yii::$app->sys->discord_news_webhook!==false) { - $data["avatar_url"]=sprintf("https://%s/images/appicon.png",Yii::$app->sys->offense_domain); - $data['username']='echoCTF.RED'; $data['content']=$bodyPlain; $client = new Webhook(['url' => Yii::$app->sys->discord_news_webhook,'data'=>json_encode($data)]); $client->run(); From f0d848f0b4bd28212120fd06e22a4c03c314238a Mon Sep 17 00:00:00 2001 From: Pantelis Roditis Date: Thu, 28 Nov 2024 03:08:30 +0200 Subject: [PATCH 2/2] API target/view show IP when always on machine --- frontend/modules/api/models/Target.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/modules/api/models/Target.php b/frontend/modules/api/models/Target.php index aa48d3199..96be7e0e8 100644 --- a/frontend/modules/api/models/Target.php +++ b/frontend/modules/api/models/Target.php @@ -40,10 +40,11 @@ public function afterFind() if (Yii::$app->user->identity->instance) $this->ip = long2ip(Yii::$app->user->identity->instance->ip); else if($this->ondemand && $this->ondemand->state==1) - { $this->ip = long2ip($this->ip); - } + else if($this->ondemand && $this->ondemand->state!=1) + $this->ip = long2ip(0); else - $this->ip=0; - } + $this->ip=long2ip($this->ip); + } + }