-
Notifications
You must be signed in to change notification settings - Fork 46
/
index.php
executable file
·213 lines (151 loc) · 5.71 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<?php
/**
*
* @package Kleeja
* @copyright (c) 2007 Kleeja.net
* @license ./docs/license.txt
*
*/
/**
* We are in index.php file, useful for exceptions
*/
define('IN_REAL_INDEX', true);
/**
* We are in the middle of the uploading process, useful for exceptions
*/
define('IN_SUBMIT_UPLOADING', isset($_POST['submitr']) || isset($_POST['submittxt']));
/**
* @ignore
*/
define('IN_KLEEJA', true);
require_once 'includes/common.php';
require_once 'includes/KleejaUploader.php';
//current uploading method
$uploadingMethodClass = 'includes/up_methods/defaultUploader.php';
is_array($plugin_run_result = Plugins::getInstance()->run('begin_index_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
require_once $uploadingMethodClass;
//
//Is kleeja only for members?
//
if (empty($d_groups[2]['exts']) && ! $usrcp->name())
{
// Send a 503 HTTP response code to prevent search bots from indexing this message
//header('HTTP/1.1 503 Service Temporarily Unavailable');
kleeja_info($lang['SITE_FOR_MEMBER_ONLY'], $lang['HOME']);
}
$action = $config['siteurl'];
/** @var KleejaUploader $uploader */
$uploadingMethodClassBaseName = basename($uploadingMethodClass, '.php');
$uploader = new $uploadingMethodClassBaseName;
$uploader->setAllowedFileExtensions($d_groups[$userinfo['group_id']]['exts']);
$uploader->setUploadFieldsLimit($config['filesnum']);
if (ip('submitr'))
{
$uploader->upload();
}
//file input fields
$FILES_NUM_LOOP = [];
if ($config['filesnum'] > 0)
{
foreach (range(1, $config['filesnum']) as $i)
{
$FILES_NUM_LOOP[] = ['i' => $i, 'show'=>($i == 1 || (! empty($config['filesnum_show']) && (int) $config['filesnum_show'] == 1) ? '' : 'display: none')];
}
}
else
{
$text = $lang['PLACE_NO_YOU'];
}
//show errors and info
$info = [];
foreach ($uploader->getMessages() as $t => $s)
{
$info[] = [
't' => $s[1] == 'error' ? 'index_err' : 'index_info', //for old Kleeja versions
'i' => $s[0], //#for old Kleeja versions
'message_content' => $s[0],
'message_type' => $s[1],
];
}
//some words for template
$welcome_msg = $config['welcome_msg'];
$filecp_link = $usrcp->id() ? $config['siteurl'] . ($config['mod_writer'] ? 'filecp.html' : 'ucp.php?go=filecp') : false;
$terms_msg = sprintf($lang['AGREE_RULES'], '<a href="' . ($config['mod_writer'] ? 'rules.html' : 'go.php?go=rules') . '">', '</a>');
$link_avater = sprintf($lang['EDIT_U_AVATER_LINK'], '<a href="https://www.gravatar.com/" target="_blank">', '</a>');
$js_allowed_extensions_types = "['" . implode("', '", array_keys($d_groups[$userinfo['group_id']]['exts'])) . "']";
$js_allowed_extensions_sizes = '[' . implode(', ', array_values($d_groups[$userinfo['group_id']]['exts'])) . ']';
//
//who's online right now..
//I don't like this feature and I prefer that you disable it
//
$show_online = $config['allow_online'] == 1 ? true : false;
if ($show_online)
{
$current_online_users = 0;
$online_names = [];
$timeout = 60; //30 second
$timeout2 = time()-$timeout;
//put another bot name
is_array($plugin_run_result = Plugins::getInstance()->run('anotherbots_online_index_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$query = [
'SELECT' => 'u.name',
'FROM' => "{$dbprefix}users u",
'WHERE' => "u.last_visit > $timeout2"
];
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_online_index_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$result = $SQL->build($query);
while ($row=$SQL->fetch_array($result))
{
is_array($plugin_run_result = Plugins::getInstance()->run('while_qr_select_online_index_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$current_online_users++;
$online_names[$row['name']] = $row['name'];
}//while
$SQL->freeresult($result);
//make names as array to print them in template
$show_names = [];
$show_names_sizeof = sizeof($online_names);
foreach ($online_names as $k)
{
$show_names[] = ['name' => $k, 'separator' => $show_names_sizeof ? ',' : ''];
}
//some variables must be destroyed here
unset($online_names, $timeout, $timeout2);
//check & update most ever users and visitors were online
if (empty($config['most_user_online_ever']) || trim($config['most_user_online_ever']) == '')
{
$most_online = $current_online_users;
$online_time = time();
}
else
{
list($most_online, $online_time) = @explode(':', $config['most_user_online_ever']);
}
if ($most_online < $current_online_users || empty($config['most_user_online_ever']))
{
update_config('most_user_online_ever', $current_online_users . ':' . time());
}
$online_time = kleeja_date($online_time, true, 'd-m-Y h:i a');
//before 1.8, styles computability
$usersnum = $current_online_users;
$shownames = $show_names;
is_array($plugin_run_result = Plugins::getInstance()->run('if_online_index_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
}//allow_online
$show_style = true;
is_array($plugin_run_result = Plugins::getInstance()->run('end_index_page', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
//is ajax
if (ip('ajax'))
{
if (! empty($info))
{
header('Content-Type: text/plain; charset=utf-8');
echo json_encode($info);
}
exit;
}
//show style
if ($show_style)
{
Saaheader();
echo $tpl->display(($config['filesnum'] > 0 ? 'index_body' : 'info'));
Saafooter();
}