2017-08-28 14:30:30 +02:00
|
|
|
<?php
|
|
|
|
if(isset($_SERVER['REMOTE_ADDR'])) exit;
|
|
|
|
$_SERVER['SERVER_PORT'] = 80;
|
|
|
|
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
|
|
|
|
|
|
|
include(dirname(__FILE__).'/../../config/config.inc.php');
|
|
|
|
include dirname(__FILE__).'/../../init.php';
|
|
|
|
|
|
|
|
$sending_date = Configuration::get('ANT_RESETBOPASSWORD_DATE');
|
|
|
|
$frequency = Configuration::get('ANT_RESETBOPASSWORD_FREQ');
|
|
|
|
$limit = Configuration::get('ANT_RESETBOPASSWORD_LIMIT');
|
|
|
|
|
2017-09-18 11:00:12 +02:00
|
|
|
// First sending
|
|
|
|
|
|
|
|
$now = new Datetime("now");
|
2017-08-28 14:30:30 +02:00
|
|
|
$last_sent = new Datetime($sending_date);
|
|
|
|
|
2017-09-18 11:00:12 +02:00
|
|
|
$intervale = (int)$frequency>1?'+'.$frequency.' months':'+1 month';
|
|
|
|
$last_sent->modify($intervale);
|
|
|
|
|
|
|
|
if($now >= $last_sent){
|
2017-08-28 14:30:30 +02:00
|
|
|
|
|
|
|
$employees = Db::getInstance()->ExecuteS('
|
|
|
|
SELECT `id_employee`, CONCAT(`firstname`, \' \', `lastname`) AS "name", email
|
|
|
|
FROM `'._DB_PREFIX_.'employee`
|
|
|
|
WHERE `active` = 1
|
|
|
|
ORDER BY `email`
|
|
|
|
');
|
|
|
|
foreach ($employees as $key => $employee) {
|
2017-09-21 15:26:55 +02:00
|
|
|
$data = array(
|
|
|
|
'{limit}' => (int)$limit,
|
|
|
|
'{employee}' => $employee['name'],
|
|
|
|
);
|
|
|
|
Mail::Send(2, 'resetpassword', 'Sécurité Prestashop', $data, $employee['email']);
|
2017-08-28 14:30:30 +02:00
|
|
|
}
|
|
|
|
Configuration::updateValue('ANT_RESETBOPASSWORD_DATE', date('Y-m-d H:i:s'));
|
|
|
|
}
|
|
|
|
|
2017-09-18 11:00:12 +02:00
|
|
|
|
|
|
|
// Resending !
|
2017-09-21 15:26:55 +02:00
|
|
|
$reset_link = __PS_BASE_URI__.'adm/resetpasswd.php';
|
2017-09-18 11:00:12 +02:00
|
|
|
$updated_date_send = new Datetime(Configuration::get('ANT_RESETBOPASSWORD_DATE'));
|
|
|
|
$sending_date = $updated_date_send;
|
|
|
|
|
|
|
|
$day_limit = $limit>1?'+'.$limit.' days':'+1 day';
|
|
|
|
$updated_date_send->modify($day_limit);
|
|
|
|
|
2017-08-28 14:30:30 +02:00
|
|
|
$employees = Db::getInstance()->ExecuteS('
|
|
|
|
SELECT `id_employee`, CONCAT(`firstname`, \' \', `lastname`) AS "name", `email`, `date_passwd_upd`
|
|
|
|
FROM `'._DB_PREFIX_.'employee`
|
|
|
|
WHERE `active` = 1 AND
|
|
|
|
ORDER BY `email`
|
|
|
|
');
|
|
|
|
foreach ($employees as $key => $employee) {
|
|
|
|
$date_passwd_upd = new Datetime($employee['date_passwd_upd']);
|
2017-09-18 11:00:12 +02:00
|
|
|
if($now > $updated_date_send && $date_passwd_upd < $sending_date){
|
2017-09-21 15:26:55 +02:00
|
|
|
$data = array(
|
|
|
|
'{limit}' => (int)$limit,
|
|
|
|
'{employee}' => $employee['name'],
|
|
|
|
'{reset_link}' => $reset_link,
|
|
|
|
);
|
|
|
|
Mail::Send(2, 'resetpassword_2', 'Sécurité Prestashop', $data, $employee['email']);
|
2017-08-28 14:30:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exit;
|