- added email notifications for "rally points", closed #279
This commit is contained in:
@@ -35,7 +35,9 @@ class User extends Controller\Controller{
|
||||
const SESSION_KEY_CHARACTER_REFRESH_TOKEN = 'SESSION.CHARACTER.REFRESH_TOKEN';
|
||||
|
||||
// log text
|
||||
const LOG_LOGGED_IN = 'userId: %s, userName: %s, charId: %s, charName: %s';
|
||||
const LOG_LOGGED_IN = 'userId: [%10s], userName: [%30s], charId: [%20s], charName: %s';
|
||||
const LOG_DELETE_ACCOUNT = 'userId: [%10s], userName: [%30s], ip: [%45s]';
|
||||
|
||||
|
||||
/**
|
||||
* valid reasons for captcha images
|
||||
@@ -340,9 +342,8 @@ class User extends Controller\Controller{
|
||||
|
||||
if($status){
|
||||
// save log
|
||||
$logText = "id: %s, name: %s, ip: %s";
|
||||
self::getLogger('DELETE_ACCOUNT')->write(
|
||||
sprintf($logText, $user->id, $user->name, $f3->get('IP'))
|
||||
sprintf(self::LOG_DELETE_ACCOUNT, $user->id, $user->name, $f3->get('IP'))
|
||||
);
|
||||
|
||||
// remove user
|
||||
|
||||
@@ -19,9 +19,8 @@ class Controller {
|
||||
const COOKIE_NAME_STATE = 'cookie';
|
||||
const COOKIE_PREFIX_CHARACTER = 'char';
|
||||
|
||||
const LOG_UNAUTHORIZED = 'IP: [%-20s] Agent: [%s]';
|
||||
|
||||
const ERROR_SESSION_SUSPECT = 'Suspect id: [%30s], ip: [%40s], new ip: [%40s], User-Agent: %s ';
|
||||
const LOG_UNAUTHORIZED = 'ip: [%45s], User-Agent: [%s]';
|
||||
const ERROR_SESSION_SUSPECT = 'Suspect id: [%45s], ip: [%45s], new ip: [%45s], User-Agent: %s ';
|
||||
/**
|
||||
* @var \Base
|
||||
*/
|
||||
|
||||
@@ -41,4 +41,19 @@ class MailController extends \SMTP{
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* send notification mail for new rally point systems
|
||||
* @param $to
|
||||
* @param $msg
|
||||
* @return bool
|
||||
*/
|
||||
public function sendRallyPoint($to, $msg){
|
||||
$this->set('To', '<' . $to . '>');
|
||||
$this->set('From', 'Pathfinder <' . Controller::getEnvironmentData('SMTP_FROM') . '>');
|
||||
$this->set('Subject', 'PATHFINDER - New rally point');
|
||||
$status = $this->send($msg);
|
||||
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ class Config extends \Prefab {
|
||||
|
||||
const PREFIX_KEY = 'PF';
|
||||
const ARRAY_DELIMITER = '-';
|
||||
const HIVE_KEY_PATHFINDER = 'PATHFINDER';
|
||||
const HIVE_KEY_ENVIRONMENT = 'ENVIRONMENT';
|
||||
|
||||
/**
|
||||
@@ -147,4 +148,20 @@ class Config extends \Prefab {
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* get email for notifications by hive key
|
||||
* @param $key
|
||||
* @return bool|mixed
|
||||
*/
|
||||
static function getNotificationMail($key){
|
||||
$f3 = \Base::instance();
|
||||
$hiveKey = self::HIVE_KEY_PATHFINDER . '.NOTIFICATION.' . $key;
|
||||
$mail = false;
|
||||
if( $f3->exists($hiveKey) ){
|
||||
$mail = $f3->get($hiveKey);
|
||||
}
|
||||
|
||||
return $mail;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,9 @@
|
||||
|
||||
namespace Model;
|
||||
|
||||
use controller\MailController;
|
||||
use DB\SQL\Schema;
|
||||
use lib\Config;
|
||||
|
||||
class SystemModel extends BasicModel {
|
||||
|
||||
@@ -328,7 +330,11 @@ class SystemModel extends BasicModel {
|
||||
if($rally === 0){
|
||||
$rally = null;
|
||||
}elseif($rally === 1){
|
||||
$rally = date('Y-m-d H:i:s');
|
||||
// new rally point set
|
||||
$currentTimestamp = time();
|
||||
$rally = date('Y-m-d H:i:s', $currentTimestamp);
|
||||
// send rally point notification mail
|
||||
$this->sendRallyPointMail($currentTimestamp);
|
||||
}else{
|
||||
$rally = date('Y-m-d H:i:s', $rally);
|
||||
}
|
||||
@@ -484,6 +490,28 @@ class SystemModel extends BasicModel {
|
||||
return $wormholeData;
|
||||
}
|
||||
|
||||
protected function sendRallyPointMail($timestamp){
|
||||
$recipient = Config::getNotificationMail('RALLY_SET');
|
||||
|
||||
if(
|
||||
$recipient &&
|
||||
\Audit::instance()->email($recipient)
|
||||
){
|
||||
$body = [];
|
||||
$body[] = "Map:\t\t" . $this->mapId->name;
|
||||
$body[] = "System:\t\t" . $this->name;
|
||||
$body[] = "Region:\t\t" . $this->region;
|
||||
$body[] = "Security:\t" . $this->security;
|
||||
if(is_object($this->createdCharacterId)){
|
||||
$body[] = "Character:\t" . $this->createdCharacterId->name;
|
||||
}
|
||||
$body[] = "Time:\t\t" . date('g:i a; F j, Y', $timestamp);
|
||||
$bodyMsg = implode("\r\n", $body);
|
||||
|
||||
(new MailController())->sendRallyPoint('exodus4d@gmail.com', $bodyMsg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* see parent
|
||||
*/
|
||||
|
||||
@@ -27,7 +27,7 @@ MSG_DISABLED = User registration is currently not allowed
|
||||
COOKIE_EXPIRE = 30
|
||||
|
||||
; restrict login to specific corporations/alliances by id (e.g. 1000166,1000080)
|
||||
CORPORATION =
|
||||
CORPORATION =
|
||||
ALLIANCE =
|
||||
|
||||
; View ============================================================================================
|
||||
@@ -69,6 +69,12 @@ MAX_SHARED = 2
|
||||
; decrease it on performance problems
|
||||
SEARCH_DEPTH = 7000
|
||||
|
||||
; Email notifications =============================================================================
|
||||
; Requires SMTP configuration (see environment.ini)
|
||||
; Set mail address for recipient (e.g. pathfinder.notification@[YOUR_DOMAIN] )
|
||||
[PATHFINDER.NOTIFICATION]
|
||||
RALLY_SET =
|
||||
|
||||
; TIMER ===========================================================================================
|
||||
[PATHFINDER.TIMER]
|
||||
; login time (minutes)
|
||||
|
||||
Reference in New Issue
Block a user