浏览代码

TC:autopush funct

Toby Chui 5 年之前
父节点
当前提交
aefe10d1fa
共有 5 个文件被更改,包括 39 次插入7 次删除
  1. 8 3
      db/teabag-4-11-2019.sql
  2. 9 0
      src/getUserImage.php
  3. 21 3
      src/home.php
  4. 1 1
      src/index.php
  5. 二进制
      src/userdata/userdata/kent/files/image/usericon.png

+ 8 - 3
db/teabag-4-11-2019.sql

@@ -3,7 +3,7 @@
 -- http://www.phpmyadmin.net
 --
 -- 主機: 127.0.0.1
--- 產生時間: 2019-11-04 05:41:42
+-- 產生時間: 2019-11-04 06:43:21
 -- 伺服器版本: 5.7.11
 -- PHP 版本: 5.6.19
 
@@ -80,7 +80,12 @@ CREATE TABLE `post` (
 
 INSERT INTO `post` (`postid`, `username`, `content`, `posttime`) VALUES
 (2, 'admin', 'Hello World Welcome to Teabag!', '2019-11-04 05:17:32'),
-(3, 'admin', 'This is my 2nd meme post haha!', '2019-11-04 05:17:44');
+(3, 'admin', 'This is my 2nd meme post haha!', '2019-11-04 05:17:44'),
+(4, 'admin', 'Hello World This is my third message', '2019-11-04 06:12:32'),
+(6, 'admin', 'Hello World!', '2019-11-04 06:19:36'),
+(7, 'kent', 'Today is a wonderful day.', '2019-11-04 06:30:42'),
+(8, 'kent', 'Do anyone know who is the smaller brother of USA?', '2019-11-04 06:31:18'),
+(9, 'admin', 'I know! You mean USB?', '2019-11-04 06:31:32');
 
 --
 -- 已匯出資料表的索引
@@ -102,7 +107,7 @@ ALTER TABLE `post`
 -- 使用資料表 AUTO_INCREMENT `post`
 --
 ALTER TABLE `post`
-  MODIFY `postid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
+  MODIFY `postid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
 /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
 /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
 /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

+ 9 - 0
src/getUserImage.php

@@ -10,4 +10,13 @@ function getUserIconPath(){
 	}
 }
 
+function getUserIconPathByUsername($username){
+	global $sysConfigDir;
+	if (file_exists("$sysConfigDir/userdata/$username/files/image/usericon.png")){
+		return "$sysConfigDir/userdata/$username/files/image/usericon.png";
+	}else{
+		return "img/user.jpg";
+	}
+}
+
 ?>

+ 21 - 3
src/home.php

@@ -53,7 +53,7 @@ $dataStorage = $sysConfigDir . '/userdata/' .  $_SESSION['login'] . "/";
 	<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="home.php"><i class="home icon"></i> Home</a>
+		<a class="active 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="item"><i class="mail outline icon"></i>Notification</a>
 		<div class="right item removePadding">
@@ -67,9 +67,27 @@ $dataStorage = $sysConfigDir . '/userdata/' .  $_SESSION['login'] . "/";
 	<div class="ts container">
 		<?php
 			//Show all the other's post in this page
-			
-			
+			include_once("requestDB.php"); //Handle all Database access, see the query command below
+			$username = $_SESSION['login'];
+			$postData = query("select * from post where (username IN (SELECT `targetName` FROM `following` WHERE `followerName`='" . $username . "')) OR username='" . $username . "'  ORDER BY postid DESC","teabag");
+			include_once("getUserImage.php");
+			foreach ($postData as $post){
+				echo '
+				<div class="ts card">
+					<div class="content">
+						<div class="header"><img class="ts image postAvator" src="' . getUserIconPathByUsername($post["username"]) .'" style="margin-right:-20px;">' . $post["username"] . '</div>
+						<div class="meta">
+							<a>@ '.$post["posttime"].'</a>
+						</div>
+						<div class="description">
+							<p>'.$post["content"].'</p>
+						</div>
+					</div>
+				</div>
+				';
+			}
 		?>
 	</div>
+	<br><br><br><br><br>
 	</body>
 </html>

+ 1 - 1
src/index.php

@@ -68,7 +68,7 @@ $userIcon = getUserIconPath();
 <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> Home</a>
+    <a class="item" href="home.php"><i class="home icon"></i> Following</a>
     <a class="active item" href="index.php"><i class="user outline icon"></i>Timeline</a>
 	<a class="item"><i class="mail outline icon"></i>Notification</a>
 	<div class="right item removePadding">

二进制
src/userdata/userdata/kent/files/image/usericon.png