This repository has been archived by the owner on Jan 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
164 lines (131 loc) · 4.98 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php
ini_set('display_errors', 0);
require_once 'init.php';
use \Glynet\Viewer\UI as viewer,
\Glynet\Router\Router as app,
\Glynet\Database\Database as db;
use \Glynet\UserService\User as user,
\Glynet\PostService\Posts as posts,
\Glynet\PostService\Stories as stories,
\Glynet\Suggestions\Trends as trends,
\Glynet\Suggestions\Contacts as contacts,
\Glynet\Suggestions\Explore as explore,
\Glynet\Suggestions\Search as search,
\Glynet\ClientService\Client as client,
\Glynet\ClientService\ClientUpdate,
\Glynet\ClientService\Notifications as notifications;
$token_list = ["245868998", "262923799", "5362721370146281", "2458689931", "483588160", "483588189", "591554326"];
$token = $_COOKIE['token'];
$token = $token_list[2];
db::connect($GLOBALS['db']);
client::setToken($token);
$user = client::collectData();
app::listen('/', function() {
if ($GLOBALS['user']->id == '') {
viewer::render('login');
} else {
$GLOBALS['default']['trending_topics'] = trends::getTopics();
$GLOBALS['default']['recommended_contacts'] = contacts::collect($GLOBALS['token']);
viewer::render('main', $GLOBALS['default']);
}
});
app::listen('/login', function() {
viewer::render('login');
});
app::listen('/:page', function() {
if ($GLOBALS['user']->id == '') {
viewer::render('login');
} else {
$GLOBALS['default']['trending_topics'] = trends::getTopics();
$GLOBALS['default']['recommended_contacts'] = contacts::collect($GLOBALS['token']);
viewer::render('main', $GLOBALS['default']);
}
});
app::listen('/@:username', function() {
if ($GLOBALS['user']->id == '') {
viewer::render('login');
} else {
$GLOBALS['default']['trending_topics'] = trends::getTopics();
$GLOBALS['default']['recommended_contacts'] = contacts::collect($GLOBALS['token']);
viewer::render('main', $GLOBALS['default']);
}
});
app::listen('/pages/:name', function(string $name) {
viewer::render($name, match ($name) {
'profile' => [
'profile' => user::getData($_GET['username'], $GLOBALS['token'])
],
'bookmarks' => [
'post_count' => posts::getBookmarkedPostsDetails($GLOBALS['token'])
],
'settings' => [
'user' => [ 'email' => $GLOBALS['user']->{'email'}, 'number' => $GLOBALS['user']->{'phone'} ],
'profile' => user::getData($GLOBALS['user']->{'username'}, $GLOBALS['token']),
'privacy' => client::privacyPreferences(),
'last_sessions' => client::lastSessions(),
'colors' => AVAILABLE_COLORS
],
default => [],
});
});
// API
app::listen('/api/@me/client', function() {
client::sessionControl();
echo json_encode([
'id' => (int)$GLOBALS['user']->id,
'token' => (int)$GLOBALS['user']->token,
'name' => $GLOBALS['user']->name,
'username' => $GLOBALS['user']->username,
'avatar' => $GLOBALS['user']->avatar,
'color' => $GLOBALS['user']->color,
'theme' => (int)$GLOBALS['user']->theme
]);
});
app::listen('/api/@me/client/level', function() {
echo client::getRank($GLOBALS['user']->{'points'});
});
app::listen('/api/@me/client/theme/update/:id', function(int $id) {
echo ClientUpdate::updateTheme($id);
});
app::listen('/api/@me/client/settings/update/:type/:data', function(string $type, string $data) {
echo ClientUpdate::changePreferences($type, $data);
});
app::listen('/api/@me/client/account/update/:type', function(int $type) {
echo ClientUpdate::changeAccountPreferences($type, $_REQUEST['value'], $_REQUEST['password']);
});
app::listen('/api/@me/client/color/update', function() {
echo ClientUpdate::setColor("#" . $_GET['code']);
});
app::listen('/api/@me/client/settings/password', function() {
echo ClientUpdate::updatePassword();
});
app::listen('/api/@me/client/contents/update/:type', function(string $type) {
echo ClientUpdate::uploadContents($type, $_FILES['file']);
});
app::listen('/api/@me/client/contents/remove/:type', function(string $type) {
echo ClientUpdate::changeContents($type);
});
app::listen('/api/@me/search/suggestions', function() {
echo search::query(mb_strtolower(trim($_GET['q'])));
});
app::listen('/api/@me/posts/:type/:query', function(string $type, string $query) {
echo posts::query($type, $query);
});
app::listen('/api/@me/profile/:type/:id', function(string $type, string $id) {
echo user::query($type, $id);
});
app::listen('/api/@me/notifications', function() {
echo notifications::get($GLOBALS['user']->id, $GLOBALS['user']->language);
});
app::listen('/api/@me/stories/collect', function() {
echo stories::collect();
});
app::listen('/api/@me/explore/categories/collect', function() {
echo explore::getCategories();
});
// Others
app::listen('/mommycanigoout/', function() {
header('Location: http://' . str_replace(['https://', 'http://'], '', base64_decode($_GET['r'])));
});
app::checkErrors();
db::end();