<?php

/*
  * @name        JMY CMS
  * @link        https://jmy.su/
  * @copyright   Copyright (C) 2012-2025 JMY LTD
  * @license     LICENSE.txt (see attached file)
  * @version     VERSION.txt (see attached file)
  * @author      Orlov Alexsey
  */

if (!defined('ACCESS')) {
    header('Location: /');
    exit;
}
global $core, $db, $adminTpl, $admin_conf, $config, $email_conf, $lang;
loadConfig('feedback');
loadLang('feedback');
require(ROOT . 'etc/email.config.php');
switch ($url[1] ?? null) {
    default:
        if (isset($url[1])) {
            main();
        } else {
            set_title(array($lang['welcom_profile']));
            $core->tpl->loadFile('profile/login');
            $core->tpl->end();
        }
        break;

    case 'newsletterunsubscribe':
        if (isset($url[1]) && isset($url[2])) {
            $email = $url[2];
            $md5 = $url[3];
            if ($md5 == mb_substr(md5($email . 'eduard_laas_loh'), 0, 10)) {
                $formatemail = filter(str_replace(array('[gav]', '[dot]'), array('@', '.'), $email), 'mail');
                if (!empty($formatemail)) {
                    list($uid) = $core->fetch_data('users', 'email ="' . $formatemail . '"');
                    $core->upd_data('users', '`no_mail` = 0', 'id ="' . $uid . '"');
                    $core->tpl->info($lang['n_unsubscribe_ok']);
                } else {
                    $core->tpl->info($lang['n_unsubscribe_err']);
                }
            } else {
                $core->tpl->info($lang['n_unsubscribe_err']);
            }
        } else {
            $core->tpl->info($lang['n_unsubscribe_err']);
        }
        break;

}

