Skip to content

Commit

Permalink
Fix. Code. Code inspections implemented and the code has been fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Glomberg committed Apr 17, 2024
1 parent 21c319a commit 422b17b
Show file tree
Hide file tree
Showing 26 changed files with 2,679 additions and 2,150 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/releaseNotice.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Notice about releases via Telegram

on:
release:
types: [published]

jobs:

build:
runs-on: ubuntu-latest
steps:
- name: send telegram message on release
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
${{ github.event.repository.description }} <strong>v${{github.event.release.name}}</strong> released
${{github.event.release.html_url}}
${{ github.event.release.body }}
format: html
disable_web_page_preview: true
27 changes: 27 additions & 0 deletions .github/workflows/reviewNotice.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Notice about review approved via Telegram

on:
pull_request_review:
types: [ submitted ]

jobs:

build:
if: github.event.review.state == 'approved' && toJSON(github.event.pull_request.requested_reviewers) == '[]'
runs-on: ubuntu-latest
steps:
- name: Convert date format
id: date
run: echo "::set-output name=date::$(date -d "${{ github.event.pull_request.created_at }}" +"%Y-%m-%d")"
- name: Send telegram message on review approved
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_PLUGINS_TO }}
token: ${{ secrets.TELEGRAM_REVIEWER_TOKEN }}
message: |
💥🎉🎉🎉💥 Pull-request <a href="${{ github.event.pull_request.html_url }}"><strong>${{ github.event.pull_request.title }}</strong></a>
submitted by <strong>${{ github.event.pull_request.user.login }}</strong> at <strong>${{ steps.date.outputs.date }}</strong>
was <strong>approved</strong> and is ready to merge <a href="${{ github.event.pull_request.html_url }}">➡️</a> !!!
format: html
disable_web_page_preview: true
48 changes: 48 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: PHPUnit, PHPCS, Psalm

on: # event list
push: # on push to each of these branches
branches:
- dev
- fix
- master
pull_request:
branches:
- dev
- master

env: # environment variables (available in any part of the action)
PHP_VERSION: 7.4

jobs:
build:
name: PHPUnit, PHPCS, Psalm
runs-on: ubuntu-latest

steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}

- name: Code Checkout
uses: actions/checkout@v4

- name: Install Dependencies
run: composer i

- name: Running tests
run: composer test

- name: Telegram notify
if: failure()
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_PLUGINS_TO }}
token: ${{ secrets.TELEGRAM_REVIEWER_TOKEN }}
message: |
Hi, <strong>${{ github.actor }}</strong>! Your commit for <strong>${{ github.repository }}</strong>
contains 💯 the best solution but it have to be fixed!
<a href="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}">Auto-Tests (PHPUnit, PHPCS, Psalm)</a> build failed ⛔!
format: html
disable_web_page_preview: true
82 changes: 51 additions & 31 deletions admin/controller/module/antispambycleantalk.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,29 @@ public function index()

$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_extension'),
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true)
'href' => $this->url->link(
'marketplace/extension',
'user_token=' . $this->session->data['user_token'] . '&type=module',
true
)
);

$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title_without_logo'),
'href' => $this->url->link($this->path, 'user_token=' . $this->session->data['user_token'], true)
);

$data['action'] = $this->url->link($this->path . '|save', 'user_token=' . $this->session->data['user_token'], true);
$data['action'] = $this->url->link(
$this->path . '|save',
'user_token=' . $this->session->data['user_token'],
true
);

$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true);
$data['cancel'] = $this->url->link(
'marketplace/extension',
'user_token=' . $this->session->data['user_token'] . '&type=module',
true
);


$data['header'] = $this->load->controller('common/header');
Expand All @@ -78,18 +90,22 @@ public function save()
$this->load->language($this->path);
$json = [];

if (!$this->user->hasPermission('modify', $this->path)) {
if ( !$this->user->hasPermission('modify', $this->path) ) {
$json['error'] = $this->language->get('error_permission');
}

if (isset($this->request->post['module_antispambycleantalk_enable_sfw']) && isset($this->request->post['module_antispambycleantalk_access_key'])) {
$this->extension_antispambycleantalk_core->sfw->sfw_update($this->request->post['module_antispambycleantalk_access_key']);
$this->extension_antispambycleantalk_core->sfw->logs__send($this->request->post['module_antispambycleantalk_access_key']);
if ( isset($this->request->post['module_antispambycleantalk_enable_sfw']) && isset($this->request->post['module_antispambycleantalk_access_key']) ) {
$this->extension_antispambycleantalk_core->sfw->sfwUpdate(
$this->request->post['module_antispambycleantalk_access_key']
);
$this->extension_antispambycleantalk_core->sfw->logsSend(
$this->request->post['module_antispambycleantalk_access_key']
);
$this->request->post['module_antispambycleantalk_int_sfw_last_check'] = time();
$this->request->post['module_antispambycleantalk_int_sfw_last_send_logs'] = time();
}

if (!$json) {
if ( !$json ) {
$this->init();
$this->load->model('setting/setting');
$this->model_setting_setting->editSetting($this->module, $this->request->post);
Expand All @@ -104,18 +120,18 @@ private function init()
{
$this->model_setting_startup->deleteStartupByCode($this->module);
$this->model_setting_startup->addStartup([
'code' => $this->module,
'description' => 'Anti-Spam by CleanTalk',
'action' => 'catalog/extension/antispambycleantalk/startup/antispambycleantalk',
'status' => true,
'sort_order' => 1
'code' => $this->module,
'description' => 'Anti-Spam by CleanTalk',
'action' => 'catalog/extension/antispambycleantalk/startup/antispambycleantalk',
'status' => true,
'sort_order' => 1
]);
$this->model_setting_startup->addStartup([
'code' => $this->module,
'description' => 'Anti-Spam by CleanTalk',
'action' => 'admin/extension/antispambycleantalk/startup/antispambycleantalk',
'status' => true,
'sort_order' => 1
'code' => $this->module,
'description' => 'Anti-Spam by CleanTalk',
'action' => 'admin/extension/antispambycleantalk/startup/antispambycleantalk',
'status' => true,
'sort_order' => 1
]);

$this->model_setting_event->deleteEventByCode($this->module);
Expand Down Expand Up @@ -165,42 +181,46 @@ private function init()
foreach ( $event_group as $event_name => $events ) {
foreach ( $events as $event ) {
$this->model_setting_event->addEvent([
'code' => $this->module,
'description' => 'Hook: Anti-Spam by CleanTalk ' . $event_description,
'trigger' => $event,
'action' => $event_name,
'status' => true,
'sort_order' => 1
'code' => $this->module,
'description' => 'Hook: Anti-Spam by CleanTalk ' . $event_description,
'trigger' => $event,
'action' => $event_name,
'status' => true,
'sort_order' => 1
]);
}
}
}

$this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "cleantalk_sfw` (
$this->db->query(
"CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "cleantalk_sfw` (
`network` int(10) unsigned NOT NULL,
`mask` int(10) unsigned NOT NULL,
`status` TINYINT(1) NOT NULL DEFAULT 0,
INDEX ( `network` , `mask` )
)");
$this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "cleantalk_sfw_logs` (
)"
);
$this->db->query(
"CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "cleantalk_sfw_logs` (
`ip` varchar(15) NOT NULL,
`all_entries` int(11) NOT NULL,
`blocked_entries` int(11) NOT NULL,
`entries_timestamp` int(11) NOT NULL,
PRIMARY KEY `ip` (`ip`)
)");
)"
);
}

public function install()
{
if ($this->user->hasPermission('modify', $this->path)) {
if ( $this->user->hasPermission('modify', $this->path) ) {
$this->init();
}
}

public function uninstall()
{
if ($this->user->hasPermission('modify', $this->path)) {
if ( $this->user->hasPermission('modify', $this->path) ) {
$this->load->model('setting/setting');
$this->model_setting_setting->deleteSetting($this->module);
$this->model_setting_startup->deleteStartupByCode($this->module);
Expand All @@ -209,4 +229,4 @@ public function uninstall()
$this->db->query("DROP TABLE IF EXISTS " . DB_PREFIX . "cleantalk_sfw_logs");
}
}
}
}
2 changes: 1 addition & 1 deletion admin/controller/startup/antispambycleantalk.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AntispamByCleantalk extends \Opencart\System\Engine\Controller
{
public function index()
{
if ( ! $this->registry->get('extension_antispambycleantalk_core') ) {
if ( !$this->registry->get('extension_antispambycleantalk_core') ) {
$constructor_parameters = [
$this->registry->db,
$this->config
Expand Down
42 changes: 21 additions & 21 deletions admin/language/en-gb/module/antispambycleantalk.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@

// Heading
$_['heading_title_without_logo'] = 'Antispam by Cleantalk';
$_['heading_title'] = '<img src="'.$cleantalk_logo_svg.'" alt="CleanTalk logo" width="30" /> Antispam by Cleantalk';
$_['heading_title'] = '<img src="' . $cleantalk_logo_svg . '" alt="CleanTalk logo" width="30" /> Antispam by Cleantalk';

// Text
$_['text_extension'] = 'Extensions';
$_['text_success'] = 'Success: You have modified Anti-Spam by CleanTalk module!';
$_['text_edit'] = 'Edit Anti-Spam by CleanTalk Module';
$_['text_all_category'] = 'All';
$_['text_extension'] = 'Extensions';
$_['text_success'] = 'Success: You have modified Anti-Spam by CleanTalk module!';
$_['text_edit'] = 'Edit Anti-Spam by CleanTalk Module';
$_['text_all_category'] = 'All';

// Entry
$_['entry_enable'] = 'Enable Anti-Spam';
$_['entry_enable'] = 'Enable Anti-Spam';
$_['entry_check_registrations'] = 'Check registrations';
$_['entry_check_orders'] = 'Check orders';
$_['entry_check_return'] = 'Check returns';
$_['entry_check_contact_form'] = 'Check contact form';
$_['entry_check_reviews'] = 'Check reviews';
$_['entry_enable_sfw'] = 'Enable SpamFireWall';
$_['entry_access_key'] = 'Access key';
$_['entry_check_orders'] = 'Check orders';
$_['entry_check_return'] = 'Check returns';
$_['entry_check_contact_form'] = 'Check contact form';
$_['entry_check_reviews'] = 'Check reviews';
$_['entry_enable_sfw'] = 'Enable SpamFireWall';
$_['entry_access_key'] = 'Access key';

// Help
$_['help_enable'] = 'Enable Anti-Spam by CleanTalk';
$_['help_check_registrations'] = 'Anti-Spam by CleanTalk will check registrations on your website';
$_['help_check_orders'] = 'Anti-Spam by CleanTalk will check orders on your website';
$_['help_check_return'] = 'Anti-Spam by CleanTalk will check returns on your website';
$_['help_check_contact_form'] = 'Anti-Spam by CleanTalk will check contact form on your website';
$_['help_check_reviews'] = 'Anti-Spam by CleanTalk will check product reviews on your website';
$_['help_enable_sfw'] = 'Reduces webserver load and prevents bots to access the website';
$_['help_access_key'] = 'To get an access key, please visit: https://cleantalk.org';
$_['help_enable'] = 'Enable Anti-Spam by CleanTalk';
$_['help_check_registrations'] = 'Anti-Spam by CleanTalk will check registrations on your website';
$_['help_check_orders'] = 'Anti-Spam by CleanTalk will check orders on your website';
$_['help_check_return'] = 'Anti-Spam by CleanTalk will check returns on your website';
$_['help_check_contact_form'] = 'Anti-Spam by CleanTalk will check contact form on your website';
$_['help_check_reviews'] = 'Anti-Spam by CleanTalk will check product reviews on your website';
$_['help_enable_sfw'] = 'Reduces webserver load and prevents bots to access the website';
$_['help_access_key'] = 'To get an access key, please visit: https://cleantalk.org';

// Error
$_['error_permission'] = 'Warning: You do not have permission to modify Anti-Spam by CleanTalk module!';
$_['error_permission'] = 'Warning: You do not have permission to modify Anti-Spam by CleanTalk module!';
Loading

0 comments on commit 422b17b

Please sign in to comment.