test.php
程式碼:
<?
if (!defined( "PLOG_CLASS_PATH" )) {
define( "PLOG_CLASS_PATH", "F:\AppServ\www\lifetype/");
}
include_once( PLOG_CLASS_PATH."class/bootstrap.php" );
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/users.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/bloginfo.class.php" );
//include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
//include_once( PLOG_CLASS_PATH.'class/template/templatesets/templatesets.class.php' );
include_once( PLOG_CLASS_PATH."class/action/action.class.php" );
include_once( PLOG_CLASS_PATH."class/view/admin/admindashboardview.class.php" );
include_once( PLOG_CLASS_PATH."class/view/admin/admindefaultview.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
//include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
include_once( PLOG_CLASS_PATH."class/net/http/session/sessioninfo.class.php" );
include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
include_once( PLOG_CLASS_PATH."class/misc/version.class.php" );
include_once( PLOG_CLASS_PATH."class/locale/locales.class.php" );
include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
include_once( PLOG_CLASS_PATH."class/view/admin/adminnewpostview.class.php" );
ini_set("arg_seperator.output", "&");
ini_set("magic_quotes_runtime", 0 );
// initialize the session
SessionManager::init();
// 產生一個新的 user 物件
$users = new Users();
// 取得 userInfo 物件 (透過正確的 username 與 password)
$userName="test5";
$userPassword="111111";
$userInfo = $users->getUserInfo( $userName, $userPassword );
// 取得使用者的 blog list
$userBlogs = $users->getUsersBlogs( $userInfo->getId(), BLOG_STATUS_ACTIVE );
// 用第一個 blog 來當作 blogID,並取得這個 blog ID 的 blogInfo
$blogInfo = end( $userBlogs );
// 取得 session
//echo "<pre>";
$session = HttpVars::getSession();
$sessionInfo = $session["SessionInfo"];
// 並且把資料寫入session
$sessionInfo->setValue( "userInfo", $userInfo );
$sessionInfo->setValue( "blogInfo", $blogInfo );
$session["SessionInfo"] = $sessionInfo;
HttpVars::setSession( $session );
echo "<pre>";print_R($_SESSION);
?>