From abd56ffb22d0e45b0f545ac690ea0a7316a2f9b5 Mon Sep 17 00:00:00 2001 From: davydovct Date: Mon, 29 Oct 2018 15:35:16 +0500 Subject: [PATCH] remove unused vars fix notices --- Antispam/Antispam.body.php | 48 ++++++++++++++++++++----------------- Antispam/Antispam.hooks.php | 6 ++--- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/Antispam/Antispam.body.php b/Antispam/Antispam.body.php index 544f59f..5e2e379 100644 --- a/Antispam/Antispam.body.php +++ b/Antispam/Antispam.body.php @@ -243,33 +243,37 @@ public static function SendAdminEmail( $title, $body ) { if ( file_exists($wgCTDataStoreFile) ) { $settings = file_get_contents ( $wgCTDataStoreFile ); - if ( $settings ) { + if ( $settings ) + { $settings = json_decode($settings, true); + if (!isset($settings['lastAdminNotificaionSent'])) + { + $fp = fopen( $wgCTDataStoreFile, 'w' ) or error_log( 'Could not open file:' . $wgCTDataStoreFile ); + $settings['lastAdminNotificaionSent'] = time(); + fwrite( $fp, json_encode($settings) ); + fclose( $fp ); + } + // Skip notification if permitted interval doesn't exhaust + if ( isset( $settings['lastAdminNotificaionSent'] ) && time() - $settings['lastAdminNotificaionSent'] < $wgCTAdminNotificaionInteval ) { + return false; + } + + $u = User::newFromId( $wgCTAdminAccountId ); + + $status = $u->sendMail( $title , $body ); + + if ( $status->ok ) { + $fp = fopen( $wgCTDataStoreFile, 'w' ) or error_log( 'Could not open file:' . $wgCTDataStoreFile ); + $settings['lastAdminNotificaionSent'] = time(); + fwrite( $fp, json_encode($settings) ); + fclose( $fp ); + } + return $status->ok; } } - if (!isset($settings['lastAdminNotificaionSent'])) - { - $settings['lastAdminNotificaionSent'] = time(); - fwrite( $fp, json_encode($settings) ); - fclose( $fp ); - } - // Skip notification if permitted interval doesn't exhaust - if ( isset( $settings['lastAdminNotificaionSent'] ) && time() - $settings['lastAdminNotificaionSent'] < $wgCTAdminNotificaionInteval ) { - return false; - } - - $u = User::newFromId( $wgCTAdminAccountId ); - - $status = $u->sendMail( $title , $body ); - if ( $status->ok ) { - $fp = fopen( $wgCTDataStoreFile, 'w' ) or error_log( 'Could not open file:' . $wgCTDataStoreFile ); - $settings['lastAdminNotificaionSent'] = time(); - fwrite( $fp, json_encode($settings) ); - fclose( $fp ); - } + return false; - return $status->ok; } } diff --git a/Antispam/Antispam.hooks.php b/Antispam/Antispam.hooks.php index 8ae418c..9f1506a 100644 --- a/Antispam/Antispam.hooks.php +++ b/Antispam/Antispam.hooks.php @@ -10,7 +10,7 @@ class CTHooks { * @return none */ public static function onUploadFilter ( $upload, $mime, &$error ) { - global $wgCTAccessKey, $wgCTServerURL, $wgRequest, $wgCTAgent, $wgCTExtName, $wgCTNewEditsOnly, $wgCTMinEditCount, $wgUser; + global $wgRequest, $wgCTExtName, $wgCTMinEditCount, $wgUser; # Skip spam check if error exists already if ($error !== TRUE) { @@ -73,7 +73,7 @@ public static function onUploadFilter ( $upload, $mime, &$error ) { * @return bool */ public static function onEditFilter ( $editor, $text, $section, &$error, $summary ) { - global $wgCTAccessKey, $wgCTServerURL, $wgRequest, $wgCTAgent, $wgCTExtName, $wgCTNewEditsOnly, $wgCTMinEditCount; + global $wgCTExtName, $wgCTNewEditsOnly, $wgCTMinEditCount; $allowEdit = true; @@ -146,7 +146,7 @@ public static function onEditFilter ( $editor, $text, $section, &$error, $summa * @return bool */ public static function onAbortNewAccount ( $user, &$message ) { - global $wgCTAccessKey, $wgCTServerURL, $wgRequest, $wgCTAgent, $wgCTExtName; + global $wgCTExtName; $allowAccount = true;