-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreels.php
86 lines (73 loc) · 2.17 KB
/
reels.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
<?php
/**
* reels
*
* @package Delus
* @author Dmitry
*/
// fetch bootloader
require('bootloader.php');
// user access
user_access();
// reels enabled
if (!$system['reels_enabled']) {
_error(404);
}
// user access
if (!$system['system_public']) {
user_access();
}
try {
// get view content
switch ($_GET['view']) {
case '':
// get posts (reels)
/* first get the reels from discover */
$reels_discover = $user->get_posts(['get' => 'discover', 'filter' => 'reel']);
/* second get the reels from newsfeed */
$reels_newsfeed = $user->get_posts(['get' => 'newsfeed', 'filter' => 'reel']);
/* merge the two arrays */
$posts = array_merge($reels_discover, $reels_newsfeed);
/* randomize the array */
shuffle($posts);
/* assign variables */
$smarty->assign('posts', $posts);
// page header
page_header(__("Reels") . ' | ' . __($system['system_title']));
break;
case 'reel':
// get post
$post = $user->get_post($_GET['post_id']);
if (!$post || $post['post_type'] != "reel") {
_error(404);
}
/* assign variables */
$smarty->assign('post', $post);
// get posts (reels)
/* first get the reels from discover */
$reels_discover = $user->get_posts(['get' => 'discover', 'filter' => 'reel']);
/* second get the reels from newsfeed */
$reels_newsfeed = $user->get_posts(['get' => 'newsfeed', 'filter' => 'reel']);
/* merge the two arrays */
$posts = array_merge($reels_discover, $reels_newsfeed);
/* randomize the array */
shuffle($posts);
/* remove the post from the array if exists */
foreach ($posts as $key => $value) {
if ($value['post_id'] == $post['post_id']) {
unset($posts[$key]);
}
}
/* add the post to the beginning of the array */
array_unshift($posts, $post);
/* assign variables */
$smarty->assign('posts', $posts);
// page header
page_header($post['og_title'], $post['og_description'], $post['og_image']);
break;
}
} catch (Exception $e) {
_error(__("Error"), $e->getMessage());
}
// page footer
page_footer('reels');