Przeglądaj źródła

TC:autopush funct

Toby Chui 6 lat temu
rodzic
commit
aa65a01166

+ 12 - 2
src/index.php

@@ -82,7 +82,6 @@ $userIcon = getUserIconPath();
 <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;">
@@ -99,6 +98,12 @@ $userIcon = getUserIconPath();
 						</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>
 		<!-- 聊天室列表--> 
@@ -159,7 +164,7 @@ $userIcon = getUserIconPath();
 				echo '
 				<div class="ts card">
 					<div class="content">
-						<div class="header"><img class="ts circular image postAvator" src="' . $userIcon .'" style="margin-right:-20px;">' . $post["username"] . '</div>
+						<div class="header"><img class="ts image postAvator" src="' . $userIcon .'" style="margin-right:-20px;width:80px;height:80px;">' . $post["username"] . '</div>
 						<div class="meta">
 							<a>@ '.$post["posttime"].'</a>
 						</div>
@@ -176,6 +181,11 @@ $userIcon = getUserIconPath();
 </div>
 
 </div>
+<script>
 
+function refreshPage(){
+	window.location.reload();
+}
+</script>
 </body>
 </html>

+ 35 - 0
src/uploadIcon.php

@@ -0,0 +1,35 @@
+<?php
+include_once(__DIR__ . "/auth.php");
+$username = $_SESSION['login'];
+?>
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Upload your icon</title>
+</head>
+<body>
+  <form enctype="multipart/form-data" action="uploadIcon.php" method="POST">
+    <p>Upload your icon</p>
+    <input type="file" name="uploaded_file"></input><br />
+    <input type="submit" value="Upload"></input>
+  </form>
+</body>
+</html>
+<?PHP
+
+  if(!empty($_FILES['uploaded_file']))
+  {
+	if (!file_exists($sysConfigDir . "userdata/" .  $username . "/files/image/")){
+		mkdir($sysConfigDir . "userdata/" .  $username . "/files/image/",0777,true);
+	}
+    $path = $sysConfigDir . "userdata/" .  $username . "/files/image/usericon.png" ;
+    //$path = $path . basename( $_FILES['uploaded_file']['name']);
+    if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $path)) {
+      echo "The file ".  basename( $_FILES['uploaded_file']['name']). 
+      " has been uploaded";
+	  echo '<script>parent.window.location.href = "index.php";</script>';
+    } else{
+        echo "There was an error uploading the file, please try again!";
+    }
+  }
+?>

BIN
src/userdata/userdata/admin/files/image/usericon.png