-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
138 lines (127 loc) · 5.12 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<!-- Index.php^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -->
<?php
include 'header.php';
// include 'classes/User.php';
// include 'classes/Post.php';
// include 'classes/Message.php';
if(isset($_POST['post'])){
$uploadOk = 1;
$imageName = $_FILES['fileToUpload']['name'];
$errorMessage = "";
if($imageName != ""){
$targetDir = "assets/images/posts/";
$imageName = $targetDir . uniqid() . basename($imageName);
$imageFileType = pathinfo($imageName, PATHINFO_EXTENSION);
if($uploadOk){
if(move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $imageName)){
//image Upload Okey
$errorMessage = "uploaded";
}
else{
$uploadOk = 0;
$errorMessage = "fail to upload";
}
}
}
if($uploadOk){
$post = new Post($con, $userLoggedIn);
$post->submitPost($_POST['post_text'], $imageName);
}
else{
echo "<div style='text-align: center;' class='alert alert-danger'> $errorMessage </div>";
}
}
$user_detail_query = mysqli_query($con,"select * from users where username='$userLoggedIn'");
$user_array = mysqli_fetch_array($user_detail_query);
$num_friends = (substr_count($user_array['friend_array'],","))-1;
?>
<div class="index-wrapper">
<div class="info-box">
<div class="info-inner">
<div class="info-in-head">
<a href="<?php echo $userLoggedIn; ?>"><img src="<?php echo $user['cover_pic']; ?>"></a>
</div>
<div class="info-in-body">
<div class="in-b-box">
<div class="in-b-img">
<a href="<?php echo $userLoggedIn; ?>"><img src="<?php echo $user['profile_pic']; ?>"></a>
</div>
</div>
<div class="info-body-name">
<div class="in-b-name">
<div><a href="<?php echo $userLoggedIn; ?>"><?php echo $user['first_name'] . " " . $user['last_name']; ?></a>
</div>
<span><small><a href="<?php echo $userLoggedIn; ?>"><?php echo "@" . $user['username'] ?></a></small></span>
</div>
</div>
</div>
<div class="info-in-footer">
<div class="number-wrapper">
<div class="num-box">
<div class="num-head">
POSTS
</div>
<div class="num-body">
<?php echo $user['num_posts']; ?>
</div>
</div>
<div class="num-box">
<div class="num-head">
LIKES
</div>
<div class="num-body">
<span class="count-likes">
<?php echo $user['num_likes']; ?>
</span>
</div>
</div>
<div class="num-box">
<div class="num-head">
Friends
</div>
<div class="num-body">
<?php echo $num_friends ?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="post-wrap">
<div class="post-inner">
<div class="post-h-left">
<div class="post-h-img">
<a href="<?php echo $userLoggedIn; ?>"><img src="<?php echo $user['profile_pic'] ?>"></a>
</div>
</div>
<div class="post-body">
<form class="post_form" action="index.php" method="POST" enctype="multipart/form-data">
<textarea class="status" name="post_text" id="post_text" placeholder="Type Something here!" rows="4" cols="50"></textarea>
<div class="hash-box">
<ul>
</ul>
</div>
</div>
<div class="post-footer">
<div class="p-fo-left">
<ul>
<input type="file" name="fileToUpload" id="fileToUpload"/>
<label for="fileToUpload"> <img src="assets/images/camera.png" alt="" height="30px"></i> </label>
<span class="tweet-error"></span>
<input id="sub-btn" type="submit" name="post" value="SHARE">
</ul>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="show_post">
<?php
$post = new Post($con, $userLoggedIn) ;
$post->indexPosts();
?>
</div>
</div>
</body>
</html>