This commit is contained in:
Tóth Richárd
2018-10-18 23:50:57 +02:00
parent 59c984dd9b
commit 19aaa4a770
15 changed files with 8753 additions and 1653 deletions

View File

@@ -0,0 +1,39 @@
<?php
/**
* PHPMailer Exception class.
* PHP Version 5.5.
*
* @see https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
*
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2017 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @note This program is distributed in the hope that it will be useful - WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
//namespace PHPMailer\PHPMailer;
/**
* PHPMailer exception handler.
*
* @author Marcus Bointon <phpmailer@synchromedia.co.uk>
*/
class Exception extends \Exception
{
/**
* Prettify error message output.
*
* @return string
*/
public function errorMessage()
{
return '<strong>' . htmlspecialchars($this->getMessage()) . "</strong><br />\n";
}
}

138
_class/class_OAuth.php Normal file
View File

@@ -0,0 +1,138 @@
<?php
/**
* PHPMailer - PHP email creation and transport class.
* PHP Version 5.5.
*
* @see https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
*
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2015 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @note This program is distributed in the hope that it will be useful - WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
//namespace PHPMailer\PHPMailer;
use League\OAuth2\Client\Grant\RefreshToken;
use League\OAuth2\Client\Provider\AbstractProvider;
use League\OAuth2\Client\Token\AccessToken;
/**
* OAuth - OAuth2 authentication wrapper class.
* Uses the oauth2-client package from the League of Extraordinary Packages.
*
* @see http://oauth2-client.thephpleague.com
*
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
*/
class OAuth
{
/**
* An instance of the League OAuth Client Provider.
*
* @var AbstractProvider
*/
protected $provider;
/**
* The current OAuth access token.
*
* @var AccessToken
*/
protected $oauthToken;
/**
* The user's email address, usually used as the login ID
* and also the from address when sending email.
*
* @var string
*/
protected $oauthUserEmail = '';
/**
* The client secret, generated in the app definition of the service you're connecting to.
*
* @var string
*/
protected $oauthClientSecret = '';
/**
* The client ID, generated in the app definition of the service you're connecting to.
*
* @var string
*/
protected $oauthClientId = '';
/**
* The refresh token, used to obtain new AccessTokens.
*
* @var string
*/
protected $oauthRefreshToken = '';
/**
* OAuth constructor.
*
* @param array $options Associative array containing
* `provider`, `userName`, `clientSecret`, `clientId` and `refreshToken` elements
*/
public function __construct($options)
{
$this->provider = $options['provider'];
$this->oauthUserEmail = $options['userName'];
$this->oauthClientSecret = $options['clientSecret'];
$this->oauthClientId = $options['clientId'];
$this->oauthRefreshToken = $options['refreshToken'];
}
/**
* Get a new RefreshToken.
*
* @return RefreshToken
*/
protected function getGrant()
{
return new RefreshToken();
}
/**
* Get a new AccessToken.
*
* @return AccessToken
*/
protected function getToken()
{
return $this->provider->getAccessToken(
$this->getGrant(),
['refresh_token' => $this->oauthRefreshToken]
);
}
/**
* Generate a base64-encoded OAuth token.
*
* @return string
*/
public function getOauth64()
{
// Get a new token if it's not available or has expired
if (null === $this->oauthToken or $this->oauthToken->hasExpired()) {
$this->oauthToken = $this->getToken();
}
return base64_encode(
'user=' .
$this->oauthUserEmail .
"\001auth=Bearer " .
$this->oauthToken .
"\001\001"
);
}
}

4483
_class/class_PHPMailer.php Normal file

File diff suppressed because it is too large Load Diff

419
_class/class_POP3.php Normal file
View File

@@ -0,0 +1,419 @@
<?php
/**
* PHPMailer POP-Before-SMTP Authentication Class.
* PHP Version 5.5.
*
* @see https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
*
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2017 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @note This program is distributed in the hope that it will be useful - WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
//namespace PHPMailer\PHPMailer;
/**
* PHPMailer POP-Before-SMTP Authentication Class.
* Specifically for PHPMailer to use for RFC1939 POP-before-SMTP authentication.
* 1) This class does not support APOP authentication.
* 2) Opening and closing lots of POP3 connections can be quite slow. If you need
* to send a batch of emails then just perform the authentication once at the start,
* and then loop through your mail sending script. Providing this process doesn't
* take longer than the verification period lasts on your POP3 server, you should be fine.
* 3) This is really ancient technology; you should only need to use it to talk to very old systems.
* 4) This POP3 class is deliberately lightweight and incomplete, and implements just
* enough to do authentication.
* If you want a more complete class there are other POP3 classes for PHP available.
*
* @author Richard Davey (original author) <rich@corephp.co.uk>
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
*/
class POP3
{
/**
* The POP3 PHPMailer Version number.
*
* @var string
*/
const VERSION = '6.0.5';
/**
* Default POP3 port number.
*
* @var int
*/
const DEFAULT_PORT = 110;
/**
* Default timeout in seconds.
*
* @var int
*/
const DEFAULT_TIMEOUT = 30;
/**
* Debug display level.
* Options: 0 = no, 1+ = yes.
*
* @var int
*/
public $do_debug = 0;
/**
* POP3 mail server hostname.
*
* @var string
*/
public $host;
/**
* POP3 port number.
*
* @var int
*/
public $port;
/**
* POP3 Timeout Value in seconds.
*
* @var int
*/
public $tval;
/**
* POP3 username.
*
* @var string
*/
public $username;
/**
* POP3 password.
*
* @var string
*/
public $password;
/**
* Resource handle for the POP3 connection socket.
*
* @var resource
*/
protected $pop_conn;
/**
* Are we connected?
*
* @var bool
*/
protected $connected = false;
/**
* Error container.
*
* @var array
*/
protected $errors = [];
/**
* Line break constant.
*/
const LE = "\r\n";
/**
* Simple static wrapper for all-in-one POP before SMTP.
*
* @param string $host The hostname to connect to
* @param int|bool $port The port number to connect to
* @param int|bool $timeout The timeout value
* @param string $username
* @param string $password
* @param int $debug_level
*
* @return bool
*/
public static function popBeforeSmtp(
$host,
$port = false,
$timeout = false,
$username = '',
$password = '',
$debug_level = 0
) {
$pop = new self();
return $pop->authorise($host, $port, $timeout, $username, $password, $debug_level);
}
/**
* Authenticate with a POP3 server.
* A connect, login, disconnect sequence
* appropriate for POP-before SMTP authorisation.
*
* @param string $host The hostname to connect to
* @param int|bool $port The port number to connect to
* @param int|bool $timeout The timeout value
* @param string $username
* @param string $password
* @param int $debug_level
*
* @return bool
*/
public function authorise($host, $port = false, $timeout = false, $username = '', $password = '', $debug_level = 0)
{
$this->host = $host;
// If no port value provided, use default
if (false === $port) {
$this->port = static::DEFAULT_PORT;
} else {
$this->port = (int) $port;
}
// If no timeout value provided, use default
if (false === $timeout) {
$this->tval = static::DEFAULT_TIMEOUT;
} else {
$this->tval = (int) $timeout;
}
$this->do_debug = $debug_level;
$this->username = $username;
$this->password = $password;
// Reset the error log
$this->errors = [];
// connect
$result = $this->connect($this->host, $this->port, $this->tval);
if ($result) {
$login_result = $this->login($this->username, $this->password);
if ($login_result) {
$this->disconnect();
return true;
}
}
// We need to disconnect regardless of whether the login succeeded
$this->disconnect();
return false;
}
/**
* Connect to a POP3 server.
*
* @param string $host
* @param int|bool $port
* @param int $tval
*
* @return bool
*/
public function connect($host, $port = false, $tval = 30)
{
// Are we already connected?
if ($this->connected) {
return true;
}
//On Windows this will raise a PHP Warning error if the hostname doesn't exist.
//Rather than suppress it with @fsockopen, capture it cleanly instead
set_error_handler([$this, 'catchWarning']);
if (false === $port) {
$port = static::DEFAULT_PORT;
}
// connect to the POP3 server
$this->pop_conn = fsockopen(
$host, // POP3 Host
$port, // Port #
$errno, // Error Number
$errstr, // Error Message
$tval
); // Timeout (seconds)
// Restore the error handler
restore_error_handler();
// Did we connect?
if (false === $this->pop_conn) {
// It would appear not...
$this->setError(
"Failed to connect to server $host on port $port. errno: $errno; errstr: $errstr"
);
return false;
}
// Increase the stream time-out
stream_set_timeout($this->pop_conn, $tval, 0);
// Get the POP3 server response
$pop3_response = $this->getResponse();
// Check for the +OK
if ($this->checkResponse($pop3_response)) {
// The connection is established and the POP3 server is talking
$this->connected = true;
return true;
}
return false;
}
/**
* Log in to the POP3 server.
* Does not support APOP (RFC 2828, 4949).
*
* @param string $username
* @param string $password
*
* @return bool
*/
public function login($username = '', $password = '')
{
if (!$this->connected) {
$this->setError('Not connected to POP3 server');
}
if (empty($username)) {
$username = $this->username;
}
if (empty($password)) {
$password = $this->password;
}
// Send the Username
$this->sendString("USER $username" . static::LE);
$pop3_response = $this->getResponse();
if ($this->checkResponse($pop3_response)) {
// Send the Password
$this->sendString("PASS $password" . static::LE);
$pop3_response = $this->getResponse();
if ($this->checkResponse($pop3_response)) {
return true;
}
}
return false;
}
/**
* Disconnect from the POP3 server.
*/
public function disconnect()
{
$this->sendString('QUIT');
//The QUIT command may cause the daemon to exit, which will kill our connection
//So ignore errors here
try {
@fclose($this->pop_conn);
} catch (Exception $e) {
//Do nothing
}
}
/**
* Get a response from the POP3 server.
*
* @param int $size The maximum number of bytes to retrieve
*
* @return string
*/
protected function getResponse($size = 128)
{
$response = fgets($this->pop_conn, $size);
if ($this->do_debug >= 1) {
echo 'Server -> Client: ', $response;
}
return $response;
}
/**
* Send raw data to the POP3 server.
*
* @param string $string
*
* @return int
*/
protected function sendString($string)
{
if ($this->pop_conn) {
if ($this->do_debug >= 2) { //Show client messages when debug >= 2
echo 'Client -> Server: ', $string;
}
return fwrite($this->pop_conn, $string, strlen($string));
}
return 0;
}
/**
* Checks the POP3 server response.
* Looks for for +OK or -ERR.
*
* @param string $string
*
* @return bool
*/
protected function checkResponse($string)
{
if (substr($string, 0, 3) !== '+OK') {
$this->setError("Server reported an error: $string");
return false;
}
return true;
}
/**
* Add an error to the internal error store.
* Also display debug output if it's enabled.
*
* @param string $error
*/
protected function setError($error)
{
$this->errors[] = $error;
if ($this->do_debug >= 1) {
echo '<pre>';
foreach ($this->errors as $e) {
print_r($e);
}
echo '</pre>';
}
}
/**
* Get an array of error messages, if any.
*
* @return array
*/
public function getErrors()
{
return $this->errors;
}
/**
* POP3 connection error handler.
*
* @param int $errno
* @param string $errstr
* @param string $errfile
* @param int $errline
*/
protected function catchWarning($errno, $errstr, $errfile, $errline)
{
$this->setError(
'Connecting to the POP3 server raised a PHP warning:' .
"errno: $errno errstr: $errstr; errfile: $errfile; errline: $errline"
);
}
}

1326
_class/class_SMTP.php Normal file

File diff suppressed because it is too large Load Diff

187
_class/class_email_log.php Normal file
View File

@@ -0,0 +1,187 @@
<?php
class email_log {
private $el_id;
private $el_message;
private $el_subject;
private $el_from_name;
private $el_from_email;
private $el_sent_date;
private $el_exception;
private $el_email_template_et_id;
public function set_et_data_by_id($_id) {
global $sql;
$et_data_assoc_array = $sql->assoc_array("select * from email_template where et_id = " . $_id);
$et_data_array = $et_data_assoc_array[0];
foreach ($et_data_array as $field => $value) {
$function_name = "set_" . $field;
$this->$function_name($value);
}
}
/**
* @return mixed
*/
public function get_el_id()
{
return $this->el_id;
}
/**
* @param mixed $el_id
*
* @return self
*/
public function set_el_id($el_id)
{
$this->el_id = $el_id;
return $this;
}
/**
* @return mixed
*/
public function get_el_message()
{
return $this->el_message;
}
/**
* @param mixed $el_message
*
* @return self
*/
public function set_el_message($el_message)
{
$this->el_message = $el_message;
return $this;
}
/**
* @return mixed
*/
public function get_el_subject()
{
return $this->el_subject;
}
/**
* @param mixed $el_subject
*
* @return self
*/
public function set_el_subject($el_subject)
{
$this->el_subject = $el_subject;
return $this;
}
/**
* @return mixed
*/
public function get_el_from_name()
{
return $this->el_from_name;
}
/**
* @param mixed $el_from_name
*
* @return self
*/
public function set_el_from_name($el_from_name)
{
$this->el_from_name = $el_from_name;
return $this;
}
/**
* @return mixed
*/
public function get_el_from_email()
{
return $this->el_from_email;
}
/**
* @param mixed $el_from_email
*
* @return self
*/
public function set_el_from_email($el_from_email)
{
$this->el_from_email = $el_from_email;
return $this;
}
/**
* @return mixed
*/
public function get_el_sent_date()
{
return $this->el_sent_date;
}
/**
* @param mixed $el_sent_date
*
* @return self
*/
public function set_el_sent_date($el_sent_date)
{
$this->el_sent_date = $el_sent_date;
return $this;
}
/**
* @return mixed
*/
public function get_el_exception()
{
return $this->el_exception;
}
/**
* @param mixed $el_exception
*
* @return self
*/
public function set_el_exception($el_exception)
{
$this->el_exception = $el_exception;
return $this;
}
/**
* @return mixed
*/
public function get_el_email_template_et_id()
{
return $this->el_email_template_et_id;
}
/**
* @param mixed $el_email_template_et_id
*
* @return self
*/
public function set_el_email_template_et_id($el_email_template_et_id)
{
$this->el_email_template_et_id = $el_email_template_et_id;
return $this;
}
}
?>

View File

@@ -0,0 +1,200 @@
<?php
class email_template {
private $et_id;
private $et_name;
private $et_title;
private $et_deleted;
private $et_message;
private $et_subject;
private $et_from_name;
private $et_from_email;
public function set_et_data_by_id($_id) {
global $sql;
$et_data_assoc_array = $sql->assoc_array("select * from email_template where et_id = " . $_id);
$et_data_array = $et_data_assoc_array[0];
foreach ($et_data_array as $field => $value) {
$function_name = "set_" . $field;
$this->$function_name($value);
}
}
/**
* @return mixed
*/
public function get_et_id()
{
return $this->et_id;
}
/**
* @param mixed $et_id
*
* @return self
*/
public function set_et_id($et_id)
{
$this->et_id = $et_id;
return $this;
}
/**
* @return mixed
*/
public function get_et_name()
{
return $this->et_name;
}
/**
* @param mixed $et_name
*
* @return self
*/
public function set_et_name($et_name)
{
$this->et_name = $et_name;
return $this;
}
/**
* @return mixed
*/
public function get_et_title()
{
return $this->et_title;
}
/**
* @param mixed $et_title
*
* @return self
*/
public function set_et_title($et_title)
{
$this->et_title = $et_title;
return $this;
}
/**
* @return mixed
*/
public function get_et_deleted()
{
return $this->et_deleted;
}
/**
* @param mixed $et_deleted
*
* @return self
*/
public function set_et_deleted($et_deleted)
{
$this->et_deleted = $et_deleted;
return $this;
}
/**
* @return mixed
*/
public function get_et_message()
{
return $this->et_message;
}
/**
* @param mixed $et_message
*
* @return self
*/
public function set_et_message($et_message)
{
$this->et_message = $et_message;
return $this;
}
/**
* @return mixed
*/
public function get_et_subject()
{
return $this->et_subject;
}
/**
* @param mixed $et_subject
*
* @return self
*/
public function set_et_subject($et_subject)
{
$this->et_subject = $et_subject;
return $this;
}
/**
* @return mixed
*/
public function get_et_from_name()
{
return $this->et_from_name;
}
/**
* @param mixed $et_from_name
*
* @return self
*/
public function set_et_from_name($et_from_name)
{
$this->et_from_name = $et_from_name;
return $this;
}
/**
* @return mixed
*/
public function get_et_from_email()
{
return $this->et_from_email;
}
/**
* @param mixed $et_from_email
*
* @return self
*/
public function set_et_from_email($et_from_email)
{
$this->et_from_email = $et_from_email;
return $this;
}
public function personalize($_raw, $_variable_array)
{
$matches = null;
preg_match_all('/{\$([a-z0-9\_]+)}/', $_raw, $matches);
print_r($matches);
//[0] {$variable}
//[1] variable
foreach ($matches[0] as $key => $match) {
$_raw = str_replace($match, $_variable_array[$matches[1][$key]], $_raw);
}
return $_raw;
}
}
?>

View File

@@ -243,6 +243,10 @@ class page {
# csoportok
include('include_milestones.php');
break;
case 'smtp_teszt':
# smtp teszt
include('include_smtp_test.php');
break;
case 'delete_training_type':
# EDZÉS TÍPUS TÖRLÉS
include('include_delete_training_type.php');

View File

@@ -39,6 +39,9 @@ class user_kid extends user_parent {
private $user_contact;
private $user_other;
private $user_balance_transfer;
private $user_notify_name;
private $user_notify_email;
private $user_last_notification;
private $user_deleted;
public function set_uk_id($_uid) {
@@ -258,6 +261,24 @@ class user_kid extends user_parent {
public function get_uk_school() {
return $this->user_school;
}
public function set_uk_notify_name($_notify_name) {
$this->user_notify_name = $_notify_name;
}
public function get_uk_notify_name() {
return $this->user_notify_name;
}
public function set_uk_notify_email($_notify_email) {
$this->user_notify_email = $_notify_email;
}
public function get_uk_notify_email() {
return $this->user_notify_email;
}
public function set_uk_last_notification($_last_notification) {
$this->user_last_notification = $_last_notification;
}
public function get_uk_last_notification() {
return $this->user_last_notification;
}
public function set_uk_balance($_balance) {
$this->user_balance = $_balance;
}
@@ -649,5 +670,140 @@ class user_kid extends user_parent {
}
}
}
public function update_balance() {
global $sql;
$userId = $this->get_uk_id();
$action_list_query = "
SELECT
object_id,
timestamp(object_date) as object_date,
object_type,
(SELECT
count(distinct date(tr_date))
FROM
presence
JOIN
training ON tr_id = pr_training_tr_id
WHERE
YEAR(tr_date) = YEAR(object_date)
AND MONTH(tr_date) = MONTH(object_date)
AND tr_date <= object_date
AND pr_user_kid_uk_id = ".$userId."
AND tr_date > (select
if(max(trd) is null,
'1900-01-01',
max(trd))
from
(select
tr_date trd
from
presence
join training ON tr_id = pr_training_tr_id
join user_kid ON uk_id = pr_user_kid_uk_id
where
pr_user_kid_uk_id = ".$userId."
and tr_date >= (SELECT
tr_date
from
presence
join training ON tr_id = pr_training_tr_id
join user_kid ON uk_id = pr_user_kid_uk_id
where
pr_user_kid_uk_id = ".$userId."
and date(tr_date) = uk_first_training
ORDER BY tr_date ASC
limit 1)
order by tr_date ASC
limit 2) as elso_ket_edzes)) as 'training_per_month',
(SELECT
count(pr_id)
FROM
presence
JOIN
training ON tr_id = pr_training_tr_id
WHERE
DATE(tr_date) = DATE(object_date)
AND tr_date <= object_date
AND pr_user_kid_uk_id = ".$userId.") as 'training_per_day',
(select
if(sum(if(trd = object_date, 1, 0)) > 0,
1,
0)
from
(select
tr_date trd
from
presence
join training ON tr_id = pr_training_tr_id
join user_kid ON uk_id = pr_user_kid_uk_id
where
pr_user_kid_uk_id = ".$userId."
and tr_date >= (SELECT
tr_date
from
presence
join training ON tr_id = pr_training_tr_id
join user_kid ON uk_id = pr_user_kid_uk_id
where
pr_user_kid_uk_id = ".$userId."
and date(tr_date) = uk_first_training
ORDER BY tr_date ASC
limit 1)
order by tr_date ASC
limit 2) elso2edzes) as 'first_two'
FROM
((SELECT
pr_training_tr_id as object_id,
timestamp(tr_date) as object_date,
if(pr_training_tr_id is not null, 'training', null) as object_type
FROM
presence
JOIN training ON tr_id = pr_training_tr_id
WHERE
pr_user_kid_uk_id = ".$userId."
AND tr_deleted = 0) UNION (SELECT
mod_id,
timestamp(mi_date),
if(mod_id is not null, 'money_deposit', null) as object_type
FROM
money_deposit
JOIN
money_income ON mi_id = mod_money_income_mi_id
WHERE
mod_user_kid_uk_id = ".$userId."
and mod_deleted = 0)) actions
order by object_date ASC;
";
$action_assoc_array = $sql->assoc_array($action_list_query);
$actions = array();
$de_array = array();
foreach ($action_assoc_array as $action) {
if ($action['object_type'] == 'training') {
$new_training = new training();
$new_training->set_training_data_by_id($action['object_id']);
//$actions[] = $new_training;
$new_diary_entry = new diary_entry($action['object_id'], $action['object_date'], $action['object_type'], $action['training_per_month'], $action['training_per_day'], $action['first_two'], $new_training);
}
elseif ($action['object_type'] == 'money_deposit') {
$new_mod = new money_deposit();
$new_mod->set_mod_data_by_id($action['object_id']);
//$actions[] = $new_mod;
$new_diary_entry = new diary_entry($action['object_id'], $action['object_date'], $action['object_type'], $action['training_per_month'], $action['training_per_day'], $action['first_two'], null, $new_mod);
}
$de_array[] = $new_diary_entry;
}
//itt csak hivatkozással adjuk át a tömböt, a calculate_balance kiszámolja, belerakja és visszadja
$this->calculate_balance($de_array, $this);
}
}
?>

View File

@@ -1,6 +1,5 @@
<?php
# EDZÉS ZÁROLÁS
if ($this->is_id()) {
@@ -8,6 +7,7 @@ if ($this->is_id()) {
# EDZÉS ZÁROLÁS/FELOLDÁS
$locked = $sql->single_variable('select tr_locked from training where tr_id =' . $this->get_id());
/*
$sql->update_table('training', array(
'tr_locked' => ($locked?0:1)
),
@@ -16,18 +16,104 @@ if ($this->is_id()) {
)
);
log::register(($locked?'training_open':'training_close'), $this->get_id());
header('Location: /admin/presence/' . $this->get_id());
*/
//SEND NOTIFICATION
if (!$locked) {
//get kids from training
$kid_ids = $sql->assoc_array('SELECT pr_user_kid_uk_id FROM presence WHERE pr_training_tr_id = ' . $this->get_id());
//iterate and collect them
$kid_array = array();
foreach ($kid_ids as $k_array) {
$kid = new user_kid();
$kid->set_user_data_by_id($k_array['pr_user_kid_uk_id']);
$kid->update_balance();
if (null === $kid->get_uk_last_notification() && null !== $kid->get_uk_notify_email() && $kid->get_uk_balance() < 0) {
$kid_array[] = $kid;
}
elseif (null !== $kid->get_uk_last_notification() && null !== $kid->get_uk_notify_email() && $kid->get_uk_balance() < 0) {
$notify_hours = $sql->single_variable(' SELECT
setv_int
FROM
setting_value
JOIN
setting ON setv_setting_set_id = set_id
WHERE
set_name = "Értesítések közt eltelt idő";
;');
if (null !== $notify_hours) {
$timestamp = strtotime($kid->get_uk_last_notification()) + $notify_hours*60;
$expireDate = date('Y-m-d H:i:s', $timestamp);
else {
# NEM LEHET
if (time() >= $timestamp) {
$kid_array[] = $kid;
}
}
}
}
//send email
$email_template_id = $sql->single_variable('select et_id from email_template where et_name = \'below_zero\'');
if (null !== $email_template_id) {
$emailTemplate = new email_template();
$emailTemplate->set_et_data_by_id($email_template_id);
$raw_subject = $emailTemplate->get_et_subject();
$raw_message = $emailTemplate->get_et_message();
foreach ($kid_array as $kid) {
$personalizedSubject = $emailTemplate->personalize($raw_subject, array(
'uk_name' => $kid->get_uk_name(),
));
$personalizedMessage = $emailTemplate->personalize($raw_message, array(
'notify_name' => $kid->get_uk_notify_name(),
'uk_name' => $kid->get_uk_name(),
'uk_balance' => $kid->get_uk_balance(),
'uk_password' => $kid->get_uk_password(),
));
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.gginternet.com '; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'hirlevel@tollaslabda.info'; // SMTP username
$mail->Password = 'tollas12'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
//Recipients
$mail->setFrom($emailTemplate->get_et_from_email(), $emailTemplate->get_et_from_name());
$mail->addBCC('tricsusz@gmail.com', 'Tóth Richárd'); // TEST
$mail->addBCC($kid->get_uk_notify_email(), $kid->get_uk_notify_name());
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $personalizedSubject;
$mail->Body = $personalizedMessage;
$mail->AltBody = 'Az Ön levelezője nem támogatja a HTML tartalom megjelenítését!';
//$mail->send();
//LOG SUCCESS
} catch (Exception $e) {
//LOG ERROR
}
}
}
}
//header('Location: /admin/presence/' . $this->get_id());
}
?>

View File

@@ -8,10 +8,6 @@
$user->set_user_data_by_id($value['uk_id']);
# EDZÉS LISTA
$action_list_query = "
SELECT
object_id,

View File

@@ -0,0 +1,45 @@
<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
//use PHPMailer\PHPMailer\PHPMailer;
//use PHPMailer\PHPMailer\Exception;
//Load Composer's autoloader
//require 'vendor/autoload.php';
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.gginternet.com '; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'hirlevel@tollaslabda.info'; // SMTP username
$mail->Password = 'tollas12'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
//Recipients
$mail->setFrom('from@example.com', 'Mailer');
$mail->addAddress('tricsusz@gmail.com', 'Tóth Richárd'); // Add a recipient
//$mail->addAddress('ellen@example.com'); // Name is optional
//$mail->addReplyTo('info@example.com', 'Information');
//$mail->addCC('cc@example.com');
//$mail->addBCC('bcc@example.com');
//Attachments
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}

View File

@@ -254,6 +254,18 @@
</div>
<br>
<div>
<label class="desc" for="uk_notify_name">Értesítési név:</label>
<div><input type="text" name="uk_notify_name" id="uk_notify_name"></div>
</div>
<div>
<label class="desc" for="uk_notify_email">Értesítési e-mail cím:</label>
<div><input type="text" name="uk_notify_email" id="uk_notify_email"></div>
</div>
<br>
<div>

View File

@@ -260,8 +260,17 @@
<div><input type="text" name="parent_2_facebook" id="parent_2_facebook"></div>
</div>
<br>
<div>
<label class="desc" for="uk_notify_name">Értesítési név:</label>
<div><input type="text" name="uk_notify_name" id="uk_notify_name" value="{$user_data.uk_notify_name}"></div>
</div>
<div>
<label class="desc" for="uk_notify_email">Értesítési e-mail cím:</label>
<div><input type="text" name="uk_notify_email" id="uk_notify_email" value="{$user_data.uk_notify_email}"></div>
</div>
<br>