|
@@ -0,0 +1,354 @@
|
|
|
+<?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");
|
|
|
+}
|
|
|
+date_default_timezone_set("Asia/Hong_Kong");
|
|
|
+$time = date("Y-m-d H:m:s");
|
|
|
+
|
|
|
+include_once("getUserImage.php"); //Handle user image location. Call with getUserIconpath()
|
|
|
+$userIcon = getUserIconPath();
|
|
|
+
|
|
|
+?>
|
|
|
+<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>
|
|
|
+<script>
|
|
|
+var activeChat = "";
|
|
|
+
|
|
|
+function showChat(id) {
|
|
|
+
|
|
|
+ var x = document.getElementById("chatPop");
|
|
|
+ if (x.style.visibility === "hidden") {
|
|
|
+ x.style.visibility = "visible";
|
|
|
+ } else if(activeChat == id){
|
|
|
+ x.style.visibility = "hidden";
|
|
|
+ }
|
|
|
+ activeChat = id;
|
|
|
+ refresh();
|
|
|
+ document.getElementById("chatTarget").innerHTML = activeChat;
|
|
|
+}
|
|
|
+
|
|
|
+function update() {
|
|
|
+ var xhttp = new XMLHttpRequest();
|
|
|
+ xhttp.onreadystatechange = function() {
|
|
|
+ if (this.readyState == 4 && this.status == 200) {
|
|
|
+ document.getElementById("chatHistory").innerHTML = this.responseText;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ var touser = activeChat;
|
|
|
+ var fromuser = "<?php echo $_SESSION['login'];?>";
|
|
|
+ var myText = document.getElementById("message").value;
|
|
|
+ if(myText != "" && myText != null)
|
|
|
+ {
|
|
|
+ xhttp.open("POST", "getChatHistory.php", true);
|
|
|
+ xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
|
|
+ xhttp.send("touser="+touser+"&fromuser="+fromuser+"&message="+myText);
|
|
|
+ }
|
|
|
+ document.getElementById("message").value = "";
|
|
|
+
|
|
|
+ var objDiv = document.getElementById("chatHistory");
|
|
|
+ objDiv.scrollTop = objDiv.scrollHeight;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+function refresh() {
|
|
|
+ var xhttp = new XMLHttpRequest();
|
|
|
+ xhttp.onreadystatechange = function() {
|
|
|
+ if (this.readyState == 4 && this.status == 200) {
|
|
|
+ document.getElementById("chatHistory").innerHTML = this.responseText;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ var touser = activeChat;
|
|
|
+ var fromuser = "<?php echo $_SESSION['login']; ?>";
|
|
|
+ xhttp.open("POST", "getChatHistory.php", true);
|
|
|
+ xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
|
|
+ xhttp.send("touser="+touser+"&fromuser="+fromuser);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+setInterval(refresh,1000);
|
|
|
+
|
|
|
+</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;
|
|
|
+}
|
|
|
+.linebreak{
|
|
|
+ white-space: pre-wrap;
|
|
|
+}
|
|
|
+
|
|
|
+.chatroomWindow{
|
|
|
+ visibility: hidden;
|
|
|
+ width:320px !important;
|
|
|
+ height:500px !important;
|
|
|
+ padding:5px !important;
|
|
|
+ position:fixed;
|
|
|
+ bottom:0;
|
|
|
+ right:0;
|
|
|
+ z-index: 99 !important;
|
|
|
+ border-style: solid;
|
|
|
+ border-width: 1px;
|
|
|
+ background-color: white;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+.chathistory{
|
|
|
+ width:305px !important;
|
|
|
+ height:300px !important;
|
|
|
+ padding:5px !important;
|
|
|
+ border: 1px solid #000;
|
|
|
+ overflow-y: scroll;
|
|
|
+}
|
|
|
+
|
|
|
+.typing {
|
|
|
+ border: 1px solid #000;
|
|
|
+ padding:5px !important;
|
|
|
+ width:305px !important;
|
|
|
+}
|
|
|
+</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="item" href="home.php"><i class="home icon"></i> Following</a>
|
|
|
+ <a class="item" href="index.php"><i class="user outline icon"></i>Timeline</a>
|
|
|
+ <a class="active item" href="fdList.php"><i class="users outline icon"></i>Friend List</a>
|
|
|
+ <div class="right item removePadding">
|
|
|
+ <div class="ts icon tiny input">
|
|
|
+ <input type="text" placeholder="Search...">
|
|
|
+ <i class="circular search link icon"></i>
|
|
|
+ </div>
|
|
|
+ <a class="item" href="logout.php"><i class="log out icon"></i>Logout</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="<?php echo $userIcon;?>" style="max-width:300px;">
|
|
|
+ </div>
|
|
|
+ <div class="content">
|
|
|
+ <div class="ts comments">
|
|
|
+ <div class="comment">
|
|
|
+ <div class="avatar">
|
|
|
+ <img src="<?php echo $userIcon; ?>">
|
|
|
+ </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>
|
|
|
+ <button class="ts basic mini button" onClick='$("#changeIconDiv").slideToggle();'>Change Icon</button>
|
|
|
+ <div id="changeIconDiv" style="display:none;">
|
|
|
+ <iframe src="uploadIcon.php">
|
|
|
+
|
|
|
+ </iframe>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- Advertisment -->
|
|
|
+ <div class="ts segment" style='height:300px; overflow-y:auto;'>
|
|
|
+ <?php
|
|
|
+ include_once("loadads.php");
|
|
|
+ $adspath = initAds();
|
|
|
+ echo '<img class="ts fluid image" src="'. $adspath .'"/>';
|
|
|
+ ?>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <!-- Chatroom List-->
|
|
|
+ <div class="ts segment" style='height:300px; overflow-y:auto;'>
|
|
|
+ <?php
|
|
|
+ $query = "select * from following where followerName = '".$_SESSION['login']. "'";
|
|
|
+ include_once("requestDB.php"); //Handle all Database access, see the query command below
|
|
|
+ $followerResult = query($query,"teabag");
|
|
|
+ foreach ($followerResult as $chat){
|
|
|
+ echo '
|
|
|
+ <div class="ts nopadding comments">
|
|
|
+ <div class="comment selectable" id='.$chat["targetName"].' onClick="showChat(this.id)">
|
|
|
+ <a class="avatar">
|
|
|
+ <img src="img/dummy.png">
|
|
|
+ </a>
|
|
|
+ <div class="content">
|
|
|
+ <a class="author">'.$chat["targetName"].'</a>
|
|
|
+ <div class="inline text">
|
|
|
+ 現時在線
|
|
|
+ </div>
|
|
|
+ <div class="middoted actions">
|
|
|
+ <a>
|
|
|
+ <i class="comment online icon"></i> 打開聊天室
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ ';
|
|
|
+ }
|
|
|
+ ?>
|
|
|
+<!--
|
|
|
+ <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">
|
|
|
+<?php
|
|
|
+ if (filesize("root.inf") > 0){
|
|
|
+ //Use the special path instead.
|
|
|
+ $rootPath = trim(file_get_contents("root.inf"));
|
|
|
+ }
|
|
|
+ $databasePath = $rootPath . "whitelist.config";
|
|
|
+ $h = fopen($databasePath, "r");
|
|
|
+ $userlist = [];
|
|
|
+ while (($buffer = fgets($h, 4096)) !== false) {
|
|
|
+ array_push($userlist, '"'.explode(",",$buffer)[0].'"');
|
|
|
+ }
|
|
|
+ unset($userlist[ array_search('"'.$_SESSION['login'].'"',$userlist)]);
|
|
|
+ $userListString = implode(",",$userlist);
|
|
|
+
|
|
|
+ $query1 = "select * from following where followerName = '".$_SESSION['login']."' and targetname in (".$userListString.")";
|
|
|
+ include_once("requestDB.php"); //Handle all Database access, see the query command below
|
|
|
+ include_once("getUserImage.php");
|
|
|
+ $followerResult = query($query1,"teabag");
|
|
|
+ ?>
|
|
|
+ <div class="ts segment">
|
|
|
+ <div class="field">
|
|
|
+ <label>Followed</label>
|
|
|
+ <?php
|
|
|
+ foreach ($followerResult as $follower){
|
|
|
+ echo '
|
|
|
+ <div class="ts card">
|
|
|
+ <div class="header"><img class="ts image postAvator" src="' . getUserIconPathByUsername($follower["targetName"]) .'" style="margin-right:-20px;width:80px;height:80px;">' . $follower["targetName"] . '
|
|
|
+ <a href="unfollow.php?target='.$follower["targetName"].'">Unfollow</a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ ';
|
|
|
+ unset($userlist[ array_search('"'.$follower["targetName"].'"',$userlist)]);
|
|
|
+ }
|
|
|
+ ?>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="ts segment">
|
|
|
+ <div class="field">
|
|
|
+ <label>Not Followed</label>
|
|
|
+ <?php
|
|
|
+ foreach ($userlist as $user){
|
|
|
+ echo '
|
|
|
+ <div class="ts card">
|
|
|
+ <div class="header"><img class="ts image postAvator" src="' . getUserIconPathByUsername(trim($user,'"')) .'" style="margin-right:-20px;width:80px;height:80px;">' . trim($user,'"') . '
|
|
|
+ <a href="follow.php?target='.trim($user,'"').'">Follow</a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ ';
|
|
|
+ }
|
|
|
+
|
|
|
+?>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+
|
|
|
+</div>
|
|
|
+
|
|
|
+<div class="chatroomWindow" id="chatPop">
|
|
|
+<script>
|
|
|
+refresh();
|
|
|
+</script>
|
|
|
+<div id="chatHistory" class="chathistory"></div>
|
|
|
+<form name="message" method="post">
|
|
|
+ <a id="chatTarget" class="author"></a><br/>
|
|
|
+ <textarea rows="4" placeholder="Write something here to chat!" name="message" cols="40" class="typing" id="message"></textarea>
|
|
|
+ <input type="button" onclick="update()" class="ts primary fluid button" value="Send">
|
|
|
+</form>
|
|
|
+</div>
|
|
|
+
|
|
|
+
|
|
|
+<script>
|
|
|
+
|
|
|
+function refreshPage(){
|
|
|
+ window.location.reload();
|
|
|
+}
|
|
|
+</script>
|
|
|
+</body>
|
|
|
+</html>
|