protected function main()
 {
     if (empty($_GET['e']) || empty($_GET['t'])) {
         header('Location: ./');
     }
     inc_lib('newsletter/count_abonnement');
     $count_abonne = count_abonnement('a_email = \'' . insertBD(trim($_GET['e'])) . '\' AND a_token = \'' . insertBD(trim($_GET['t'])) . '\'');
     if ($count_abonne == 1) {
         inc_lib('newsletter/remove_abonnement');
         remove_abonnement($_GET['e']);
         redir(Nw::$lang['newsletter']['desinscription_r'], true, 'newsletter.html');
     } else {
         redir(Nw::$lang['newsletter']['abo_dont_exist'], false, 'newsletter.html');
     }
 }
Esempio n. 2
0
 protected function main()
 {
     $this->set_title(Nw::$lang['newsletter']['sabonner']);
     $this->add_css('code.css');
     $this->set_tpl('newsletter/abonnement.html');
     $this->set_filAriane(Nw::$lang['newsletter']['sabonner']);
     $this->load_lang_file('users');
     $is_already_abonne = false;
     $id_membre_login = is_logged_in() ? Nw::$dn_mbr['u_id'] : 0;
     $phrase_abonne = '';
     $token_url = '';
     $email_url = '';
     if (is_logged_in()) {
         inc_lib('newsletter/count_abonnement');
         $is_already_abonne = count_abonnement('a_id_membre = ' . intval(Nw::$dn_mbr['u_id']));
         if ($is_already_abonne == 1) {
             inc_lib('newsletter/get_info_abonnement');
             $donnees_abo = get_info_abonnement('a_id_membre = ' . intval(Nw::$dn_mbr['u_id']));
             $phrase_abonne = sprintf(Nw::$lang['newsletter']['already_register'], $donnees_abo['a_email']);
             $token_url = $donnees_abo['a_token'];
             $email_url = urlencode($donnees_abo['a_email']);
         }
     }
     // S'enregistrer à la newsletter
     if (isset($_POST['submit']) && !empty($_POST['email_newsletter']) && filter_var($_POST['email_newsletter'], FILTER_VALIDATE_EMAIL)) {
         inc_lib('newsletter/count_abonnement');
         $is_already_abonne = count_abonnement('a_email = \'' . insertBD(trim($_POST['email_newsletter'])) . '\'');
         // Cette adresse email n'est pas déjà enregistrée dans la bdd
         if ($is_already_abonne == 0) {
             inc_lib('newsletter/add_abonnement');
             add_abonnement($_POST['email_newsletter'], $id_membre_login);
             redir(Nw::$lang['newsletter']['register_r_ok'], true, 'newsletter.html');
         } else {
             redir(Nw::$lang['newsletter']['email_used'], false, 'newsletter.html');
         }
     }
     Nw::$tpl->set(array('IS_ABONNE' => $is_already_abonne, 'PHRASE_ABO' => $phrase_abonne, 'TOKEN' => $token_url, 'EMAIL' => $email_url));
 }