<?php
include_once 'auth.php';
//Get information of local data storage from auth.php
$userAccountName = $_SESSION['login']; //使用者登入名稱，不可重複
$dataStorage = $sysConfigDir . '/userdata/' .  $_SESSION['login'] . "/"; //使用者個人資料資料夾
if (!file_exists($dataStorage)){
	//如果使用者是第一次使用 TeaBag，幫他開個新資料夾，並創建用家資料檔
	mkdir($dataStorage,0777,true);
	file_put_contents($dataStorage . "userdata.json",'{"username":"' . $userAccountName .'",
	  "accountCreationTime":"' . time() . '",
	  "invitedByUser":"Admin",
	  "permissionLevel":3,
	  "banned":false
	}');
	include_once("functions/createUserDirectories.php");
}

?>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>TeaBag.tw</title>
<link rel="stylesheet" href="script/tocas/tocas.css">
<script src="script/tocas/tocas.js"></script>
<script src="script/jquery.min.js"></script>
<style>
.extrapadding{
	padding-left:10%;
	padding-right:10%;
}
.removePadding{
	padding:0px !important;
}
.active.item{
	color:#4287f5 !important;
	font-weight: bold !important;
}
.postAvator{
	height:50px !important;
	padding-right:25px;
}
.teabag.card{
	max-width:350px;
}
.nopadding{
	padding:0px !important;
}
.selectable{
	cursor:pointer;
	padding:5px !important;
}
.selectable:hover{
	background-color:#f2f2f2 !important;
}
.online{
	color: #88db99;
}
</style>
</head>
<body>
<div class="ts tabbed menu extrapadding">
	<a class="item" href="index.php"><img src="img/minilogo.png" style="height:25px;"></a>
    <a class="active item" href="index.php"><i class="home icon"></i> 主頁</a>
    <a class="item"><i class="user outline icon"></i>個人檔案</a>
	<a class="item"><i class="mail outline icon"></i>通知</a>
	<div class="right item removePadding">
	<div class="ts icon tiny input">
		<input type="text" placeholder="搜尋...">
		<i class="circular search link icon"></i>
	</div>
	<a class="item" href="logout.php"><i class="log out icon"></i>登出</a>
	</div>
</div>
<div class="ts container">
<div class="ts grid">
    <div class="four wide column">
		<!-- 個人檔案卡 -->
		<div class="ts teabag card">
			<div class="image">
				<img src="functions/contentDelivery.php?filename=user/profile/banner.png&time=<?php echo time();?>" style="max-width:300px;">
			</div>
			<div class="content">
				<div class="ts comments">
					<div class="comment">
						<div class="avatar">
							<img src="img/dummy.png">
						</div>
						<div class="content">
							<a class="author"><?php include_once("functions/getUserName.php");?></a>
							<div class="text">@<?php echo $_SESSION['login']; ?></div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- 聊天室列表--> 
		<div class="ts segment">
			<div class="ts nopadding comments">
				<div class="comment selectable">
					<a class="avatar">
						<img src="img/dummy.png">
					</a>
					<div class="content">
						<a class="author">小白</a>
						<div class="inline text">
							現時在線
						</div>
						<div class="middoted actions">
							<a>
								<i class="comment online icon"></i> 打開聊天室
							</a>
						</div>
					</div>
				</div>
				<div class="comment selectable">
					<a class="avatar">
						<img src="img/dummy.png">
					</a>
					<div class="content">
						<a class="author">小綠</a>
						<div class="inline text">
							10分鐘前在線
						</div>
						<div class="middoted actions">
							<a>
								<i class="comment icon"></i> 留言
							</a>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
    <div class="twelve wide column">
		<!-- 帖子 -->
		<div class="ts text container">
		<div class="ts segment">
			<div class="ts form">
				<div class="field">
					<label>分享帖子</label>
					<textarea rows="4" placeholder="要說點甚麼嗎？"></textarea>
				</div>
				<button class="ts primary fluid button">發帖</button>
			</div>
		</div>
		<div class="ts card">
			<div class="content">
				<div class="header"><img class="ts circular image postAvator" src="img/dummy.png">不是小安</div>
				<div class="meta">
					<a>@not-yami</a>
					<a>30/6/2019 15:24:00</a>
				</div>
				<div class="description">
					<p>你將會在這裡看見一個魔法師的日常生活，</p>
					<p>沒錯，只要你能夠單身三十年，</p>
					<p>你也可以跟我一樣成為魔法師。</p>
				</div>
			</div>
		</div>
		
		<div class="ts card">
			<div class="content">
				<div class="header"><img class="ts circular image postAvator" src="img/dummy.png">不是小安</div>
				<div class="meta">
					<a>@not-yami</a>
					<a>30/6/2019 13:18:00</a>
				</div>
				<div class="description">
					<p>沒錯，這是一篇看上去很廢實際上也是很廢的廢文。</p>
				</div>
			</div>
		</div>
	   </div>
	</div>
</div>

</div>

</body>
</html>