-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathindex.php
executable file
·172 lines (156 loc) · 5.25 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
<?php
/*
* Osclass - software for creating and publishing online classified advertising platforms
* Maintained and supported by Mindstellar Community
* https://github.com/mindstellar/Osclass
* Copyright (c) 2021. Mindstellar
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* GNU GENERAL PUBLIC LICENSE
* Version 3, 29 June 2007
*
* Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*
* You should have received a copy of the GNU Affero General Public
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
if (PHP_SAPI === 'cli') {
define('CLI', true);
} else {
define('CLI', false);
}
require_once __DIR__ . '/oc-load.php';
if (CLI) {
//Example: php index.php -p cron -t hourly
$cli_params = getopt('p:t:');
if ($cli_params) {
Params::setParam('page', $cli_params['p']);
Params::setParam('cron-type', $cli_params['t']);
}
if (Params::getParam('page') === 'upgrade') {
echo \mindstellar\upgrade\Osclass::upgradeDB();
exit(1);
}
if (Params::getParam('page') !== 'cron'
&& !in_array(Params::getParam('cron-type'), array('hourly', 'daily', 'weekly'))
) {
exit(1);
}
}
if (file_exists(ABS_PATH . '.maintenance')) {
if (osc_is_admin_user_logged_in()) {
define('__OSC_MAINTENANCE__', true);
} else {
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 900');
if (file_exists(WebThemes::newInstance()->getCurrentThemePath() . 'maintenance.php')) {
osc_current_web_theme_path('maintenance.php');
die();
}
require_once LIB_PATH . 'osclass/helpers/hErrors.php';
$title = sprintf(__('Maintenance » %s'), osc_page_title());
$message = sprintf(
__('We are sorry for any inconvenience. %s is undergoing maintenance.') . '.',
osc_page_title()
);
osc_die($title, $message);
}
}
if (!osc_users_enabled() && osc_is_web_user_logged_in()) {
Session::newInstance()->_drop('userId');
Session::newInstance()->_drop('userName');
Session::newInstance()->_drop('userEmail');
Session::newInstance()->_drop('userPhone');
Cookie::newInstance()->pop('oc_userId');
Cookie::newInstance()->pop('oc_userSecret');
Cookie::newInstance()->set();
}
if (osc_is_web_user_logged_in()) {
User::newInstance()->lastAccess(
osc_logged_user_id(),
date('Y-m-d H:i:s'),
Params::getServerParam('REMOTE_ADDR'),
3600
);
}
switch (Params::getParam('page')) {
case ('cron'): // cron system
define('__FROM_CRON__', true);
require_once(LIB_PATH . 'osclass/cron.php');
break;
case ('user'): // user pages (with security)
$osclass_action = Params::getParam('action');
if ($osclass_action === 'change_email_confirm'
|| $osclass_action === 'activate_alert'
|| $osclass_action === 'contact_post'
|| $osclass_action === 'pub_profile'
|| ($osclass_action === 'unsub_alert' && !osc_is_web_user_logged_in())
) {
$do = new CWebUserNonSecure();
} else {
$do = new CWebUser();
}
$do->doModel();
break;
case ('item'): // item pages
$do = new CWebItem();
$do->doModel();
break;
case ('search'): // search pages
$do = new CWebSearch();
$do->doModel();
break;
case ('page'): // static pages
$do = new CWebPage();
$do->doModel();
break;
case ('register'): // register page
$do = new CWebRegister();
$do->doModel();
break;
case ('ajax'): // ajax
$do = new CWebAjax();
$do->doModel();
break;
case ('login'): // login page
$do = new CWebLogin();
$do->doModel();
break;
case ('language'): // set language
$do = new CWebLanguage();
$do->doModel();
break;
case ('contact'): //contact
$do = new CWebContact();
$do->doModel();
break;
case ('custom'): //custom
$do = new CWebCustom();
$do->doModel();
break;
case ('route'):
if (Params::getParam('route')) {
osc_run_hook(Params::getParam('route'));
}
break;
default: // home and static pages that are mandatory...
$do = new CWebMain();
$do->doModel();
break;
}
if (!defined('__FROM_CRON__') && osc_auto_cron()) {
\mindstellar\utility\Utils::doRequest(osc_base_url(), array('page' => 'cron'));
}
/* file end: ./index.php */