<?php
header("content-type:text/html;charset=utf-8");
require("foundation/asession.php");
require("configuration.php");
require("includes.php");

//引入公共方法
require("foundation/fcontent_format.php");
require("foundation/module_users.php");
require("foundation/module_mypals.php");
require("foundation/fplugin.php");
        	
	//语言包引入
	$u_langpackage=new userslp;
	$pr_langpackage=new privacylp;
	$pu_langpackage=new publiclp;
	$mn_langpackage=new menulp;
	$s_langpackage=new sharelp;
	$hi_langpackage=new hilp;
	$rp_langpackage=new reportlp;
	$mp_langpackage=new mypalslp;

	//变量获得
	$holder_id=short_check(get_argg('h'));//主人id
	$user_id =get_sess_userid();
	$dress_name=short_check(get_argg('dress_name'));

	//表声明区
	$t_users=$tablePreStr."users";
	$t_holerpals=$tablePreStr."pals_mine";
	$t_plugins=$tablePreStr."plugins";
	$dbo = new dbex;
	//读写分离定义函数
	dbtarget('r',$dbServs);

	if(is_null(get_sess_plugins()))$plugins="''";
		else $plugins=get_sess_plugins();
		$sql="select * from $t_plugins where plugin_id in('8','9','10') and valid=1 and name not in (".$plugins.")";
		$rows=$dbo->getRs($sql);
		$plugin_menu=array();
		$plugin_guest=array();
		$plugin_friends=array();
		foreach($rows as $row)
		{
			if($row['plugin_id']==8) $plugin_menu[]=$row;
			else if($row['plugin_id']==9) $plugin_guest[]=$row;
			else if($row['plugin_id']==10) $plugin_friends[]=$row;
		}
	
	//获取并重写url参数
	$urlParaStr=str_replace('h=','user_id=',getUrlPara());
	if(!strstr($urlParaStr,'app')){
		$urlParaStr=$urlParaStr.'&app=hstart';
	}
	
	//也可以设置为数组
	$select_items='user_name,user_pass,user_ico,user_sex,access_limit,access_questions,access_answers';
	$user_info=get_user_info_item($dbo,$select_items,$t_users,$holder_id);
	
	//定义第三人称及页面
	$friendHref='friend_all';
	$usrinfoHref='user_archives';
	$is_self=0;
	if($holder_id==$user_id){
		$friendHref='mypals';
		$usrinfoHref='user_info';
		$is_self=1;			
	}
	
	$user_thirdperson=get_thirdperson($user_info['user_sex']);
	
	//主人好友列表
	$holder_pals=','.getMypals($dbo,$holder_id,$t_holerpals).',';
	set_session($holder_id.'_holder_pals',$holder_pals);
	set_session($holder_id.'_holder_name',$user_info['user_name']);

	//显示控制
	$show_error="content_none";
	$show_ques="content_none";
	$is_visible=0;
	$show_info="";
	
	if(!empty($user_info)){
	$is_admin=get_sess_admin();
		if($is_admin==''){
				if($user_info['user_pass']==0){
					$show_error="";$show_info=$pu_langpackage->pu_lock;
				}elseif($user_info['access_limit']==1&&$user_id==''){
					$show_error="";$show_info=$pr_langpackage->pr_acc_false;
				}elseif($user_info['access_limit']==2&&!strstr(get_session($holder_id.'_holder_pals'),",".$user_id.",")&&$is_self==0){
					$show_error="";$show_info=$pr_langpackage->pr_acc_false;
				}elseif($user_info['access_limit']==3&&$is_self==0&&get_session($holder_id.'homeAccessPass')!='1'){
					$show_ques="";
				}else{
					$is_visible=1;
				}
		}else{
			$is_visible=1;
		}
	}else{
		$show_error="";$show_info=$pu_langpackage->pu_no_user;
	}
	if(isset($user_id)){
	    $inc_header="uiparts/homeheader.php";
	}else{
		  $inc_header="uiparts/guestheader.php";
	}
?>