Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Glomberg committed Sep 5, 2022
2 parents e7f140e + 505d35f commit 6d8d579
Show file tree
Hide file tree
Showing 18 changed files with 1,354 additions and 364 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ php-uni
=======
[![Build Status](https://travis-ci.org/CleanTalk/php-uni.svg)](https://travis-ci.org/CleanTalk/php-uni)

# Version 2.5.4
# Version 2.6.0

Module for any CMS
## Installation
Expand Down
1 change: 1 addition & 0 deletions cleantalk/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
$registrations_test = true;
$general_postdata_test = false;
$spam_firewall = true;
$general_post_exclusion_usage = false;

// Statistics
$sfw_last_update = 0;
Expand Down
23 changes: 15 additions & 8 deletions cleantalk/inc/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,27 @@ function install_config( $modified_files, $api_key, $cms, $exclusions ){
// Attention. Backwards order because inserting it step by step

$pass = 'NO PASS';
$email = '';
$uni_email = '';

if( Post::get( 'admin_password' ) ) {
$pass = trim( Post::get( 'admin_password' ) );
File::inject__variable( $path_to_config, 'password', hash( 'sha256', trim( Post::get( 'admin_password' ) ) ) );
}

if( Post::get( 'email' ) ) {
$email = trim( Post::get( 'email' ) );
File::inject__variable( $path_to_config, 'email', trim( Post::get( 'email' ) ) );
$uni_email = trim( Post::get( 'email' ) );
File::inject__variable( $path_to_config, 'uni_email', trim( Post::get( 'email' ) ) );
}

if( Post::get( 'user_token' ) )
File::inject__variable( $path_to_config, 'user_token', trim( Post::get( 'user_token' ) ) );
if( Post::get( 'account_name_ob' ) )
File::inject__variable( $path_to_config, 'account_name_ob', trim( Post::get( 'account_name_ob' ) ) );

if($email) {
if($uni_email) {
$host = $_SERVER['HTTP_HOST'] ?: 'Your Site';
$to = $email;
$login = $email;
$to = $uni_email;
$login = $uni_email;
$subject = 'Universal Anti-Spam Plugin settings for ' . $host;
$message = "Hi,<br><br>
Your credentials to get access to settings of Universal Anti-Spam Plugin by CleanTalk are bellow,<br><br>
Expand Down Expand Up @@ -125,6 +125,7 @@ function install_config( $modified_files, $api_key, $cms, $exclusions ){
if( $exclusions )
File::inject__variable( $path_to_config, 'exclusions', $exclusions, true );
File::inject__variable( $path_to_config, 'apikey', $api_key );
File::inject__variable( $path_to_config, 'exclusion_key', md5($api_key) );
File::inject__variable( $path_to_config, 'detected_cms', $cms );
File::inject__variable( $path_to_config, 'is_installed', true );
}
Expand All @@ -149,7 +150,8 @@ function uninstall( $files = array() ){
File::clean__variable( $path_to_config, 'password' );
File::clean__variable( $path_to_config, 'salt' );
File::clean__variable( $path_to_config, 'apikey' );
File::clean__variable( $path_to_config, 'email' );
File::clean__variable( $path_to_config, 'exclusion_key' );
File::clean__variable( $path_to_config, 'uni_email' );
File::clean__variable( $path_to_config, 'user_token' );
File::clean__variable( $path_to_config, 'account_name_ob' );
File::clean__variable( $path_to_config, 'detected_cms' );
Expand All @@ -166,6 +168,7 @@ function uninstall( $files = array() ){
File::replace__variable( $path_to_config, 'registrations_test', true );
File::replace__variable( $path_to_config, 'general_postdata_test', false );
File::replace__variable( $path_to_config, 'spam_firewall', true );
File::replace__variable( $path_to_config, 'general_post_exclusion_usage', false );

// Deleting cron tasks
File::replace__variable( CLEANTALK_CRON_FILE, 'tasks', array() );
Expand Down Expand Up @@ -229,11 +232,15 @@ function detect_cms( $path_to_index, $out = 'Unknown' ){
function apbct__plugin_update_message() {
global $latest_version;

if (!$latest_version) {
$latest_version = APBCT_VERSION;
}

if( version_compare( APBCT_VERSION, $latest_version ) === -1 ){
echo '<p class="text-center">There is a newer version. Update to the latest ' . $latest_version . '</p>';
echo '<p class="text-center"><button id="btn-update" form="none" class="btn btn-setup" value="">Update</button><img class="ajax-preloader" src="img/preloader.gif"></p>';
}elseif( version_compare( APBCT_VERSION, $latest_version ) === 1 ){
echo '<p class="text-center">You are using more than the latest version '. APBCT_VERSION . '</p>';
echo '<p class="text-center">You are using a higher version than the latest version '. APBCT_VERSION . '</p>';
}else{
echo '<p class="text-center">You are using the latest version '. APBCT_VERSION . '</p>';
}
Expand Down
6 changes: 4 additions & 2 deletions cleantalk/inc/common.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

define('APBCT_PLUGIN', 'uni');
define('APBCT_VERSION', '2.5.4');
define('APBCT_VERSION', '2.6.0');
define('APBCT_AGENT', APBCT_PLUGIN . '-' . str_replace( '.', '', APBCT_VERSION ) );
define('APBCT_USER_AGENT', 'Cleantalk-Antispam-Universal-Plugin/' . APBCT_VERSION);

Expand All @@ -14,7 +14,9 @@ function apbct_restore_include_path(){
}

$ds = DIRECTORY_SEPARATOR;
define( 'DS', DIRECTORY_SEPARATOR );
if ( ! defined('DS') ) {
define( 'DS', DIRECTORY_SEPARATOR );
}
define( 'CLEANTALK_SITE_ROOT', realpath(__DIR__ . "$ds..$ds..$ds" ) . $ds );
define( 'CLEANTALK_ROOT', CLEANTALK_SITE_ROOT . 'cleantalk' . $ds );
define( 'CLEANTALK_LIB', CLEANTALK_ROOT . 'lib' . $ds );
Expand Down
12 changes: 9 additions & 3 deletions cleantalk/inc/cron_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,15 @@ function apbct__plugin_get_latest_version() {
global $antispam_activity_status;

$updater = new \Cleantalk\Updater\Updater( CLEANTALK_ROOT );
$latest_version = $updater->getLatestVersion();
File::clean__variable($path_to_config, 'latest_version');
File::inject__variable($path_to_config, 'latest_version', $latest_version);
$latest_version = $updater->getLatestRelease();

if (isset($latest_version['error'])){
Err::add($latest_version['error']);
} else {
File::clean__variable($path_to_config, 'latest_version');
File::inject__variable($path_to_config, 'latest_version', $latest_version);
}

if (! isset($antispam_activity_status)) {
File::clean__variable($path_to_config, 'antispam_activity_status');
File::inject__variable($path_to_config, 'antispam_activity_status', true);
Expand Down
Loading

0 comments on commit 6d8d579

Please sign in to comment.