PEAK XOOPS - logit with e-mail in englishin japanese

logit with e-mail

  • You cannot open a new topic into this forum
  • Guests cannot post into this forum
Previous post - Next post | Parent - Children.1 | Posted on 2006/11/28 17:36
acikdeli  ÆóÅùʼ   Posts: 2
i want to use e-mail field,not the member name for the login.how can i do ?
Votes:57 Average:8.60
Previous post - Next post | Parent - Children.1 | Posted on 2006/12/3 3:41
GIJOE  ÀèǤ·³Áâ   Posts: 4110
Just modify checklogin.php like this.

// uname&email hack GIJ
$uname4sql = addslashes( $myts->stripSlashesGPC($uname) ) ;
$pass4sql = addslashes( $myts->stripSlashesGPC($pass) ) ;
if( strstr( $uname , '@' ) ) {
	// check by email if uname includes '@'
	$criteria = new CriteriaCompo(new Criteria('email', $uname4sql ));
	$criteria->add(new Criteria('pass', md5( $pass4sql )));
	$user_handler =& xoops_gethandler('user');
	$users =& $user_handler->getObjects($criteria, false);
	if( empty( $users ) || count( $users ) != 1 ) $user = false ;
	else $user = $users[0] ;
	unset( $users ) ;
}
if( empty( $user ) || ! is_object( $user ) ) {
	$user =& $member_handler->loginUser($uname4sql,$pass4sql);
}
// end of uname&email hack GIJ
Votes:36 Average:8.61
Previous post - Next post | Parent - Children.1 | Posted on 2007/6/2 2:22
slyss79  »°Åù·³Áâ   Posts: 143
hi gijoe

this is my checklogin.php in xoops 2.2.5

<?php
// $Id: checklogin.php 185 2006-01-22 23:49:01Z skalpa $
//  ------------------------------------------------------------------------ //
//                XOOPS - PHP Content Management System                      //
//                    Copyright (c) 2000 XOOPS.org                           //
//                       <http://www.xoops.org/>                             //
//  ------------------------------------------------------------------------ //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the GNU General Public License as published by     //
//  the Free Software Foundation; either version 2 of the License, or        //
//  (at your option) any later version.                                      //
//                                                                           //
//  You may not change or alter any portion of this comment or credits       //
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //
// Author: Kazumi Ono (AKA onokazu)                                          //
// URL: http://www.xoops.org/ http://jp.xoops.org/  http://www.myweb.ne.jp/  //
// Project: The XOOPS Project (http://www.xoops.org/)                        //
// ------------------------------------------------------------------------- //

if (!defined('XOOPS_ROOT_PATH')) {
    exit();
}
include_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/user.php';
$uname = !isset($_POST['uname']) ? '' : trim($_POST['uname']);
$pass = !isset($_POST['pass']) ? '' : trim($_POST['pass']);
if ($uname == '' || $pass == '') {
    redirect_header(XOOPS_URL.'/user.php', 1, _US_INCORRECTLOGIN);
    exit();
}
$member_handler =& xoops_gethandler('member');
$myts =& MyTextsanitizer::getInstance();

// Place here the Auth class calls
//**** BEGIN AUTH ****
require_once XOOPS_ROOT_PATH.'/class/auth/authfactory.php';
$xoopsAuth =& XoopsAuthFactory::getAuthConnection();
$auth = $xoopsAuth->authenticate($myts->addSlashes($uname), $myts->addSlashes($pass));
if (!$auth) {
	redirect_header(XOOPS_URL . '/user.php', 5, _US_INCORRECTLOGIN. $xoopsAuth->getHtmlErrors());
	exit();
}
//**** END AUTH ****

$user =& $member_handler->loginUser($myts->addSlashes($uname), $myts->addslashes($pass));
if (false != $user) {
    if (0 >= $user->getVar('level')) {
        redirect_header(XOOPS_URL.'/index.php', 5, _US_NOACTTPADM);
        exit();
    }
    if ($xoopsConfig['closesite'] == 1) {
        $allowed = false;
        foreach ($user->getGroups() as $group) {
            if (in_array($group, $xoopsConfig['closesite_okgrp']) || XOOPS_GROUP_ADMIN == $group) {
                $allowed = true;
                break;
            }
        }
        if (!$allowed) {
            redirect_header(XOOPS_URL.'/index.php', 1, _NOPERM);
            exit();
        }
    }
    $_SESSION = array();
    $_SESSION['xoopsUserId'] = $user->getVar('uid');
    $_SESSION['xoopsUserGroups'] = $user->getGroups();
    if ($xoopsConfig['use_mysession'] && $xoopsConfig['session_name'] != '') {
        setcookie($xoopsConfig['session_name'], session_id(), time()+(60 * $xoopsConfig['session_expire']), '/',  '', 0);
    }
    $_SESSION['xoopsUserLastLogin'] = $user->getVar('last_login');
    if (!$member_handler->updateUserByField($user, 'last_login', time())) {
    }
    $user_theme = $user->getVar('theme');
    if (in_array($user_theme, $xoopsConfig['theme_set_allowed'])) {
        $_SESSION['xoopsUserTheme'] = $user_theme;
    }
    if (!empty($_POST['xoops_redirect']) && !strpos($_POST['xoops_redirect'], 'register')) {
//        if (!preg_match("/^http[s]*:\/\//i", $_POST['xoops_redirect'])) {
//            $url = XOOPS_URL.trim($_POST['xoops_redirect']);
//        }
//        else {
            $url = $_POST['xoops_redirect'];
//        }        
        /*$parsed = parse_url(XOOPS_URL);
        $url = isset($parsed['scheme']) ? $parsed['scheme'].'://' : 'http://';
        if (isset($parsed['host'])) {
            $url .= isset($parsed['port']) ?$parsed['host'].':'.$parsed['port'].trim($_POST['xoops_redirect']): $parsed['host'].trim($_POST['xoops_redirect']);
        } else {
            $url .= xoops_getenv('HTTP_HOST').trim($_POST['xoops_redirect']);
        }*/
    } else {
        $url = XOOPS_URL.'/index.php';
    }

    // RMV-NOTIFY
    // Perform some maintenance of notification records
    $notification_handler =& xoops_gethandler('notification');
    $notification_handler->doLoginMaintenance($user->getVar('uid'));

    redirect_header($url, 1, sprintf(_US_LOGGINGU, $user->getVar('uname')), false); // disable "addredirect"!!
} else {

    redirect_header(XOOPS_URL.'/user.php',1,_US_INCORRECTLOGIN);
}
exit();
?>


can you help me for login with e-mail ?

thaks a lot
Votes:172 Average:2.44

none Re: login with e-mail

msg# 1.1.1.1
Previous post - Next post | Parent - Children.1 | Posted on 2007/6/2 6:31
GIJOE  ÀèǤ·³Áâ   Posts: 4110
I can only advise you to stop using dead-ended version
Votes:5 Average:6.00

none Re: login with e-mail

msg# 1.1.1.1.1
Previous post - Next post | Parent - Children.1 | Posted on 2007/6/2 17:38
slyss79  »°Åù·³Áâ   Posts: 143
Quote:

GIJOE wrotes:
I can only advise you to stop using dead-ended version

mmm this is not a great answer for me

anyway.... can you help for this ?
Votes:6 Average:6.67

none Re: login with e-mail

msg# 1.1.1.1.1.1
Previous post - Next post | Parent - Children.1 | Posted on 2007/6/3 5:42 | Last modified
GIJOE  ÀèǤ·³Áâ   Posts: 4110
You are tough guy like Di Luca

just insert a few lines into include/checklogin.php line 43

$member_handler =& xoops_gethandler('member');
$myts =& MyTextsanitizer::getInstance();

if( strstr( $_POST['uname'] , '@' ) ) {
	list( $uname ) = $xoopsDB->fetchRow( $xoopsDB->query( "SELECT loginname FROM ".$xoopsDB->prefix('users')." WHERE email='".$myts->addSlashes($_POST['uname'])."'" ) ) ;
}


// Place here the Auth class calls
//**** BEGIN AUTH ****
--------
(2007-6-4 edited) fixed from uname -> displayname
Votes:7 Average:5.71

none Re: login with e-mail

msg# 1.1.1.1.1.1.1
Previous post - Next post | Parent - Children.1 | Posted on 2007/6/3 17:55
slyss79  »°Åù·³Áâ   Posts: 143
eheheheh Di Luca is a Great Guy!!!

http://www.sportal.it/sportal/immagini/imagelib/839772.jpg

I have try your code but don't work...

i receive

Quote:
Incorrect login!

Sorry, no corresponding user info was found.

I have correct your code like this:

if( strstr( $_POST['uname'] , '@' ) ) {
	list( $uname ) = $xoopsDB->fetchRow( $xoopsDB->query( "SELECT loginname FROM ".$xoopsDB->prefix('users')." WHERE email='".$myts->addSlashes($_POST['uname'])."'" ) ) ;
}

the code is right and i don't understand where is the problem...
Votes:8 Average:3.75

none Re: login with e-mail

msg# 1.1.1.1.1.1.1.1
Previous post - Next post | Parent - No child | Posted on 2007/6/4 6:35
GIJOE  ÀèǤ·³Áâ   Posts: 4110
hi slyss.
It's my mistake, certainly.
(I forgot the spec of users table of 2.2 )

Your code is right.
Votes:1 Average:10.00

  Advanced search


Login
Username or e-mail:

Password:

Remember Me

Lost Password?

Register now!