-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeed.php
47 lines (39 loc) · 1.06 KB
/
feed.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
<?php
function feed(&$firebase, $user){
$posts = [];
$yourPosts = getAllPosts($firebase, $user);
if(!empty($yourPosts)){
foreach($yourPosts as $key => $value){
$posts[$key] = $value;
}
}
$users = getAllLogins($firebase);
$otherPeoplesPosts = [];
foreach($users as $value){
$username = readByKey("username", $value);
if($username == $user){
continue;
}
$otherUserPosts = getAllPosts($firebase, $username);
if(empty($otherUserPosts)){
continue;
}
foreach($otherUserPosts as $post){
if(rand(1, 100) > 75){
$otherPeoplesPosts[] = $post;
}
}
}
#echo json_encode($otherPeoplesPosts);
foreach($otherPeoplesPosts as $key => $value){
$posts[] = $value;
}
$news = readData('data.json');
foreach($news as $key => $entry){
foreach($entry as $key => $value){
$posts[] = $value;
}
}
#echo json_encode($newsFlatter);
return $posts;
}