请大家帮帮忙,我用的是1.1.3版
程式碼:
<?php
define( "PLOG_CLASS_PATH", dirname(__FILE__)."/");
include_once( PLOG_CLASS_PATH."class/controller/admincontroller.class.php" );
include_once( PLOG_CLASS_PATH."class/net/http/session/sessionmanager.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/userinfo.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/bloginfo.class.php" );
//$userName = $_REQUEST["user_name"];
//$userPassword = $_REQUEST["password"];
$userName = "admin";
$userPassword = "admin";
// initialize the session
SessionManager::init();
// 产生一个新的 user 物件
$users = new Users();
if( $users->authenticateUser( $userName, $userPassword )) {
// 取得 userInfo 物件 (透过正确的 username 与 password)
$userInfo = $users->getUserInfo( $userName, $userPassword );
// 取得使用者的 blog list
$userBlogs = $users->getUsersBlogs( $userInfo->getId(), BLOG_STATUS_ACTIVE );
// 用第一个 blog 来当作 blogID,并取得这个 blog ID 的 blogInfo
$blogInfo = end( $userBlogs );
// 取得 session
//print_r($session = HttpVars::getSession());
$session = HttpVars::getSession();
$sessionInfo = $session["SessionInfo"];
// 并且把资料写入session
$sessionInfo->setValue( "userInfo", $userInfo );
$sessionInfo->setValue( "blogInfo", $blogInfo );
$session["SessionInfo"] = $sessionInfo;
HttpVars::setSession( $session );
echo "<script language='Javascript'>";
echo "location.href='../../web/plog/login.php';";
echo "</script>";
//header("location: ../../web/plog/login.php");
}else{
echo "用户名或密码有误!重新<a href='javascript:window.history.back()'>登录</a>";
}
?>