Exemplo n.º 1
0
 protected function main()
 {
     $this->set_title(Nw::$site_slogan);
     $this->set_tpl('mobile/users/login.html');
     $this->load_lang_file('users');
     // Si le membre est déjà connecté
     if (is_logged_in()) {
         redir(Nw::$lang['common']['already_connected'], false, 'mobile-2.html');
     }
     //Si on a soumis le formulaire
     if (!multi_empty(trim($_POST['nw_nickname']), trim($_POST['nw_password']))) {
         $array_post = array('pseudo' => $_POST['nw_nickname'], 'remember' => isset($_POST['nw_remember']));
         //On vérifie que la paire pseudo/mot de passe existe
         inc_lib('users/get_info_account');
         if ($dn_info_account = get_info_account($_POST['nw_nickname'], $_POST['nw_password'])) {
             //Si le compte est actif
             if ($dn_info_account['u_active'] == 1) {
                 $link_redir = 'mobile-2.html';
                 $connex_auto = 1;
                 inc_lib('users/connect_auto_user');
                 connect_auto_user($dn_info_account['u_id'], $_POST['nw_password'], $connex_auto);
                 // On redirige le membre
                 redir(sprintf(Nw::$lang['users']['welcome_user'], $_POST['nw_nickname']), true, $link_redir);
             } else {
                 display_form($array_post, Nw::$lang['users']['not_active']);
             }
             return;
         } else {
             display_form($array_post, Nw::$lang['users']['account_no_exist']);
         }
         return;
     }
     display_form(array('pseudo' => '', 'remember' => true));
     Nw::$tpl->set('INC_HEAD', empty($_SERVER['HTTP_AJAX']));
 }
Exemplo n.º 2
0
 protected function main()
 {
     $this->set_title('hey');
     $this->set_tpl('invit/programme.html');
     Nw::$tpl->set('RPX_URL_INVIT', urlencode(Nw::$site_url . 'users-40.html?invit'));
     if (isset($_POST['submit_invit']) && !empty($_POST['code'])) {
         $query = Nw::$DB->query('SELECT COUNT(*) as count, i_id, i_nb_max_auth, i_nb_auth FROM invits WHERE i_code = \'' . insertBD(trim($_POST['code'])) . '\' GROUP BY i_id') or Nw::$DB->trigger(__LINE__, __FILE__);
         $dn = $query->fetch_assoc();
         if ($dn['count'] > 0) {
             if ($dn['i_nb_auth'] < $dn['i_nb_max_auth']) {
                 Nw::$DB->query('UPDATE invits SET i_nb_auth = i_nb_auth + 1 WHERE i_id = ' . intval($dn['i_id']));
                 $_SESSION['nw_invit'] = true;
                 redir('Bienvenue sur la version bêta privée de Nouweo.', true, './');
             } else {
                 redir('Ce code d\'invitation a expiré.', false, './');
             }
         } else {
             redir('Ce code d\'invitation n\'existe pas.', false, './');
         }
     }
     if (isset($_POST['submit_request']) && !empty($_POST['pseudo']) && !empty($_POST['email'])) {
         // L'email est bien sous la bonne forme (name@domain.tld)
         if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
             $query = Nw::$DB->query('SELECT COUNT(*) as count FROM invits_request WHERE r_email = \'' . insertBD(trim($_POST['email'])) . '\' GROUP BY r_email') or Nw::$DB->trigger(__LINE__, __FILE__);
             $dn = $query->fetch_assoc();
             if ($dn['count'] == 0) {
                 Nw::$DB->query('INSERT INTO invits_request (r_pseudo, r_email, r_date, r_ip) VALUES(\'' . insertBD(trim($_POST['pseudo'])) . '\', \'' . insertBD(trim($_POST['email'])) . '\', NOW(), \'' . get_ip() . '\')');
                 redir('Vous avez bien été noté sur la liste d\'attente.', true, './');
             } else {
                 redir('Cette adresse email est déjà utilisée.', false, './');
             }
         } else {
             redir('Cette adresse email n\'est pas valide.', false, './');
         }
     }
     if (isset($_POST['submit_login']) && !empty($_POST['pseudo']) && !empty($_POST['mdp'])) {
         inc_lib('users/get_info_account');
         if ($dn_info_account = get_info_account($_POST['pseudo'], $_POST['mdp'])) {
             if ($dn_info_account['u_active'] == 1) {
                 inc_lib('users/connect_auto_user');
                 connect_auto_user($dn_info_account['u_id'], $_POST['mdp'], true);
                 $_SESSION['nw_invit'] = true;
                 redir('Bienvenue sur la version bêta privée de Nouweo.', true, './');
             } else {
                 redir('Votre compte n\'est pas activé, il ne peut être utilisé.', false, './');
             }
         } else {
             redir('Aucun compte ne correspond à ce pseudo  et mot de passe.', false, './');
         }
     }
 }
Exemplo n.º 3
0
 /**
  *  Formulaire de connexion à l'espace membre
  *  @author Cam
  *  @return tpl
  */
 protected function main()
 {
     // Si le membre est déjà connecté
     if (is_logged_in()) {
         redir(Nw::$lang['common']['already_connected'], false, './');
     }
     // On modifie le titre de la page
     $this->set_title(Nw::$lang['users']['title_connexion']);
     // Pour rediriger le visiteur d'où il est venu
     if (!empty($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], Nw::$site_url) !== false && strpos($_SERVER['HTTP_REFERER'], Nw::$site_url . 'users-10.html') === false) {
         $_SESSION['nw_referer_login'] = $_SERVER['HTTP_REFERER'];
     }
     // Affichage du template
     $this->add_css('forms.css');
     $this->set_tpl('membres/login.html');
     // Fil ariane
     $this->set_filAriane(Nw::$lang['users']['fa_connexion']);
     //Si on a soumis le formulaire
     if (isset($_POST['submit'])) {
         $array_post = array('pseudo' => $_POST['nw_nickname'], 'remember' => isset($_POST['nw_remember']));
         //On vérifie que les deux champs sont remplis
         if (!multi_empty(trim($_POST['nw_nickname']), trim($_POST['nw_password']))) {
             //wtf ? =D
             //echo 'oook';
             //On vérifie que la paire pseudo/mot de passe existe
             inc_lib('users/get_info_account');
             if ($dn_info_account = get_info_account($_POST['nw_nickname'], $_POST['nw_password'])) {
                 //Si le compte est actif
                 if ($dn_info_account['u_active'] == 1) {
                     $link_redir = !empty($_SESSION['nw_referer_login']) ? $_SESSION['nw_referer_login'] : '******';
                     $connex_auto = (bool) isset($_POST['nw_remember']);
                     inc_lib('users/connect_auto_user');
                     connect_auto_user($dn_info_account['u_id'], $_POST['nw_password'], $connex_auto);
                     // On redirige le membre
                     redir(sprintf(Nw::$lang['users']['welcome_user'], $_POST['nw_nickname']), true, $link_redir);
                 } else {
                     display_form($array_post, Nw::$lang['users']['not_active']);
                 }
                 return;
             } else {
                 display_form($array_post, Nw::$lang['users']['account_no_exist']);
             }
             return;
         } else {
             display_form($array_post, Nw::$lang['users']['champ_obligatoire']);
         }
         return;
     }
     display_form(array('pseudo' => '', 'remember' => true));
 }
Exemplo n.º 4
0
 /**
  *  Formulaire de connexion à l'espace membre
  *  @author Cam
  *  @return tpl
  */
 protected function main()
 {
     // Si le membre est déjà connecté
     if (is_logged_in()) {
         redir(Nw::$lang['common']['already_connected'], false, './');
     }
     $token = !empty($_GET['token']) ? $_GET['token'] : $_GET['auth_token'];
     if (empty($token)) {
         header('Location: ./');
     }
     // On modifie le titre de la page
     $this->set_title(Nw::$lang['users']['login_rpx_title']);
     $post_data = array('token' => $token, 'apiKey' => Nw::$rpx_login['api_key'], 'format' => 'json');
     // make the api call using libcurl
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl, CURLOPT_URL, 'https://rpxnow.com/api/v2/auth_info');
     curl_setopt($curl, CURLOPT_POST, true);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
     curl_setopt($curl, CURLOPT_HEADER, false);
     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
     $raw_json = curl_exec($curl);
     curl_close($curl);
     // parse the json response into an associative array
     $auth_info = json_decode($raw_json, true);
     // process the auth_info response
     if ($auth_info['stat'] == 'ok') {
         inc_lib('users/identifier_exists');
         $profile = $auth_info['profile'];
         $identifier = $profile['identifier'];
         /**
          *   Le membre est déjà inscrit, on le loggue
          **/
         if (identifier_exists($identifier) == true) {
             inc_lib('users/get_info_mbr');
             inc_lib('users/connect_auto_user');
             $donnees_ident = get_info_mbr($identifier, 'identifier');
             if ($donnees_ident['u_active'] == 1) {
                 connect_auto_user($donnees_ident['u_id'], $donnees_ident['u_password'], true, False);
                 redir(sprintf(Nw::$lang['users']['welcome_user'], $donnees_ident['u_pseudo']), true, './');
             } else {
                 redir(Nw::$lang['users']['not_active'], false, 'users-10.html');
             }
         } else {
             $this->set_tpl('membres/rpx.html');
             $this->add_css('forms.css');
             $need_define_email = 0;
             $need_define_nick = 0;
             $email_inscription = isset($profile['email']) ? $profile['email'] : '';
             $nick_inscription = $profile['preferredUsername'];
             $no_errors = false;
             if (empty($email_inscription)) {
                 $need_define_email = 1;
             }
             inc_lib('users/pseudo_exists');
             if (pseudo_exists($nick_inscription) == true) {
                 $need_define_nick = 1;
             }
             Nw::$tpl->set(array('TXT_EDITO' => sprintf(Nw::$lang['users']['txt_register_rpx'], $profile['preferredUsername'], $profile['providerName']), 'TITLE' => sprintf(Nw::$lang['users']['title_register_rpx'], $profile['providerName']), 'DEF_NICK' => $need_define_nick, 'DEF_EMAIL' => $need_define_email, 'TXT_DEF_NICK' => $need_define_nick ? '<span style="color: red;">' . sprintf(Nw::$lang['users']['need_def_nick'], $profile['preferredUsername']) . '</span>' : ''));
             display_form(array('nw_pseudo' => $nick_inscription, 'nw_email' => ''));
             $value_form_email = isset($_POST['nw_email']) ? $_POST['nw_email'] : '';
             $value_form_nick = isset($_POST['nw_pseudo']) ? $_POST['nw_pseudo'] : '';
             /**
              *   L'utilisateur doit spécifier une adresse email pour terminer son inscription
              **/
             if ($need_define_email) {
                 if (isset($_POST['submit']) && !empty($_POST['nw_email'])) {
                     $array_post = array('nw_email' => $value_form_email, 'nw_pseudo' => $value_form_nick);
                     // L'email est bien sous la bonne forme (name@domain.tld)
                     if (!filter_var($_POST['nw_email'], FILTER_VALIDATE_EMAIL)) {
                         display_form($array_post, Nw::$lang['users']['format_email_false']);
                         $no_errors = true;
                         return;
                     }
                     // On vérifie bien que cet email n'a jamais utilisé lors de l'inscription (doubles comptes)
                     inc_lib('users/email_exists');
                     if (email_exists($_POST['nw_email']) == true) {
                         display_form($array_post, Nw::$lang['users']['email_already_used']);
                         $no_errors = true;
                         return;
                     }
                     $email_inscription = $_POST['nw_email'];
                 }
             }
             /**
              *   Le pseudo du gars est déjà utilisé, on lui demande d'en prendre un autre
              **/
             if (isset($_POST['submit']) && !empty($_POST['nw_pseudo'])) {
                 $array_post = array('nw_email' => $value_form_email, 'nw_pseudo' => $value_form_nick);
                 // L'email est bien sous la bonne forme (name@domain.tld)
                 inc_lib('users/pseudo_exists');
                 if (pseudo_exists($_POST['nw_pseudo']) == true) {
                     display_form($array_post, Nw::$lang['users']['nickname_used']);
                     $no_errors = true;
                     return;
                 }
                 $nick_inscription = $_POST['nw_pseudo'];
                 /**
                  *   On a toutes les infos pour inscrire le membre
                  **/
                 if (!$no_errors && !empty($nick_inscription) && !empty($email_inscription)) {
                     inc_lib('users/add_mbr');
                     $pass_compte = '?ZjZ' . $identifier . uniqid();
                     $active_compte = $need_define_email == 1 ? 0 : 1;
                     $new_id = add_mbr($nick_inscription, $pass_compte, $email_inscription, $identifier, $active_compte);
                     // Le compte est validé tout seul, pas besoin de validation par mail
                     if (!$need_define_email) {
                         inc_lib('users/connect_auto_user');
                         connect_auto_user($new_id, $pass_compte, true);
                         redir(sprintf(Nw::$lang['users']['inscrit_rpx_no_valid'], $nick_inscription, $profile['providerName']), true, './');
                     } else {
                         redir(sprintf(Nw::$lang['users']['inscrit_rpx_with_val'], $nick_inscription, $profile['providerName']), true, './');
                     }
                 }
             }
         }
     } else {
         header('Location: ./');
     }
 }