<?php
/**
 * @version 1.0
 * @author [飄在北京] <week9@263.net>
 * @write 2003-03-29
 * 社區虛擬形象系統
 * 版權所有: 飄在北京
 * http://www.week9.com
 */

error_reporting(7);
define('IN_PHPBB', 1);
$phpbb_root_path = "./";
require($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
require($phpbb_root_path."includes/functions_face.php");
$userdata = session_pagestart($user_ip, PAGE_FACE);
init_userprefs($userdata);

if ( !$userdata['session_logged_in'] )
{
	$redirect = ( isset($post_id) ) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id";
	$redirect .= ( isset($start) ) ? "&start=$start" : '';
	redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&$redirect", true));
}
$action = trim($action);


/******************* 顯示首頁 **********************/
$userbankmoney = $userdata[user_bank];
$usernm = $userdata[uname];
$usermoney = $userdata[user_money];
$allmoney = $userdata[user_money]+$userdata[user_bank];
$gender = $userdata[user_gender];

if ($gender == 1)
{
	$sex = "m";
	$usergender = "帥哥";
	$tempequip = '0-0-0-0-0-0-0-0-init-init-0-init-0-init-init-0-0-0-init-0-0-0-0-0-0-0';	
}
elseif($gender == 2)
{
	$usergender = "美女";
	$tempequip = '0-0-0-0-0-0-0-0-initf-initf-0-initf-0-initf-initf-0-0-0-initf-0-0-0-0-0-0-0'; 
	$sex = "f";	
}
else
{
	message_die(GENERAL_MESSAGE,"你還沒有選擇性別，本功能需要用戶選擇性別，如果你要使用本功能，請你返回修改你的論壇性別！");
}

$facecookie = $db->sql_query("SELECT * FROM week9_userdata where userid = $userdata[uid]  and dafaultuse = '1'");
while ($usercaifu = $db->sql_fetchrow($facecookie))
{
	$cookiearray = split('-', $tempequip);		
	$tempequip = "0";
	if ($cookiearray[6] != '0')
	{
		$cookiearray[8] = '0';
		$cookiearray[9] = '0';
	}
	for ($i=1; $i<26; $i++)
	{
		if($i != $usercaifu[classid])
		{
			$temp = $cookiearray[$i];
			$tempequip .= "-".$temp."";
		}
		else
		{
			$tempequip .= "-".$usercaifu[facepicid]."";
		}
	}
	$rtempequip = $tempequip;	
}
$db->sql_freeresult($facecookie);

$cookie = $_REQUEST[tempequip];

$userfacecookie = $tempequip;

if ("" == $cookie)
{	
	if ($userfacecookie != "")
	{
		$tempequip = $userfacecookie;
	}
	setcookie("tempequip", "$tempequip");
}

/************************************************/
//顯示物品內容開始
$facedatas = $db->sql_query("SELECT * FROM week9_userdata where userid = $userdata[uid] and dafaultuse = '3'");
$break = 1;
while ($facedata=$db->sql_fetchrow($facedatas))
{	
	$result = $db->sql_query("SELECT * FROM week9_data WHERE sort = '$facedata[classid]' and sp_graphic = '$facedata[facepicid].gif'");
	$spname =$db->sql_fetchrow($result);
	$result = $db->sql_query("SELECT name1 FROM week9_class WHERE id = '$facedata[classid]'");
	$leibiename =$db->sql_fetchrow($result);

	$pic = "<img src = images/face/".$facedata[classid]."/".$facedata[facepicid]."x.gif height=84 border=0>";	
	if($facedata[face_fitherd] == 'm')
	{
		$face_fitherd = "帥哥";
	}
	elseif($facedata[face_fitherd] == 'f')
	{
		$face_fitherd = "美女";
	}
	else
	{
		$face_fitherd = "全部";
	}	

	eval('$yifu1 .= "' . gettemplate('face_bad_yifu') . '";');	
	if ($break%2 == 0)
	{
		$huanhang = "</tr><tr>";
	}
	else
	{
		$huanhang = "";
	}
	$break++;
	$yifu1 = $yifu1.$huanhang;
}
//顯示物品內容結束
$db->sql_freeresult($facedatas);
eval("\$left = \"".gettemplate('face_left')."\";");
eval("\$center = \"".gettemplate('face_bad_center')."\";");
//##### phpbb templates #######
$banklocation = ' -> <a href="'.append_sid("face.".$phpEx).'" class="nav">'.$lang['Face'].'</a>'.' -> <a href="'.append_sid("facebad.".$phpEx).'" class="nav">舊衣服</a>';
$template->set_filenames(array( 'body' => 'face_body.tpl'));
$template->assign_vars(array(
	'BANKLOCATION' => $banklocation,
	'LEFT' => $left,
	'CENTER' => $center,
	'SITENAME'=>$board_config['sitename']
));
//
// Start output of page
//
include($phpbb_root_path . 'includes/page_header.' . $phpEx);

//
// Generate the page
//
$template->pparse('body');

include($phpbb_root_path . 'includes/page_tail.' . $phpEx);

?>
