<?php
// $Id: checklogin.php,v 1.18.2.1 2005/07/01 16:18:07 mithyt2 Exp $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright
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
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 ( empty( $_POST['uname'] ) || empty( $_POST['pass'] ) ) { // GIJ security
redirect_header(XOOPS_URL.'/user.php', 1, _US_INCORRECTLOGIN);
exit();
}
$member_handler =& xoops_gethandler('member');
$myts =& MyTextsanitizer::getInstance();
// $user =& $member_handler->loginUser($myts->addSlashes($uname), $myts->addSlashes($pass));
// 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
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();
}
}
$user->setVar('last_login', time());
if (!$member_handler->insertUser($user)) {
}
$_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);
}
$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')) {
$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';
}
谢谢Lip的鼓励,我现在的整合很土,在xoops注册时在blog的user表和blog表里写记录,并且在xoops的user表里设actblog=1和blogid,由于blog的语系是UTF-8,而xoops的是中文,所以,我就在向blog写表的时候用了iconv('A语系','B语系',要写入的字段),比如我用的GBK所以写入时就是iconv('GBK','UTF-8',$user)(因为我是把xoops的uname默认为blog的用户名和blog名称,而此后如果他想改blog用户还可以自己改),而所有的管理还是在blog,我只是在xoops搞了一个模组,并从blog的articles表里取出文章以各种形式排在页面中,而浏览时还是进入blog自己的页面,所以目前还没有遇到编码的问题,我打算把自动创建Session的问题解决就告一段落了。