forked from e107inc/e107
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
339 lines (259 loc) · 8.38 KB
/
Copy pathindex.php
File metadata and controls
339 lines (259 loc) · 8.38 KB
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2011 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* News frontend
*
* $URL$
* $Id$
*/
/*! \mainpage e107 Content Management System (CMS) - v2
*
* \section intro_sec What is e107?
*
* e107 is a free (open-source) content management system which allows you to easily manage and publish your content online. Developers can save time in building websites and powerful online applications. Users can avoid programming completely! Blogs, Websites, Intranets - e107 does it all.
*
* \section requirements_sec Requirements
*
* - PHP v5.3 or higher
* - MySQL 4.x or higher
*
* \section install_sec Installation
*
* - Point your browser to the http://localhost/YOUR FOLDER/install.php (depending on your webserver setup)
* - Follow the installation wizard
*
* \section reporting_bugs_sec Reporting Bugs
*
* Be sure you are using the most recent version prior to reporting an issue. You may report any bugs or feature requests on GitHub (https://github.com/e107inc/e107/issues)
*
* \section pull_requests_sec Pull-Requests
*
* - Please submit 1 pull-request for each Github #issue you may work on.
* - Make sure that only the lines you have changed actually show up in a file-comparison (diff) ie. some text-editors alter every line so this should be avoided.
*
* \section license_sec License
*
* e107 is released under the terms and conditions of the GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
// BOOTSTRAP START
define('e_SINGLE_ENTRY', TRUE);
$_E107['single_entry'] = true; // TODO - notify class2.php
define('ROOT', dirname(__FILE__));
set_include_path(ROOT.PATH_SEPARATOR.get_include_path());
require_once("class2.php");
// ----------------------------
/**
* Simple URL ReWrite (experimental) //TODO test, discuss, benchmark, enhance and include in eFront etc. if all goes well.
* Why?:
* - To make simple url rewrites as quick and easy for plugin developers to implement as it currently is to do the same with .htaccess
* - To use the same familiar standard as used by e_cron, e_status, e_rss etc. etc. so even a novice developer can understand it.
*
* @example (.httaccess):
* RewriteRule ^ref-(.*)/?$ e107_plugins/myplugin/myplugin.php?ref=$1 [NC,L]
*
* @example (e_url.php file - in the 'myplugin' folder)
*
* class myplugin_url // plugin-folder + '_url'
{
function config()
{
$config = array();
$config[] = array(
'regex' => '^ref-(.*)/?$',
'redirect' => '{e_PLUGIN}myplugin/myplugin.php?ref=$1',
);
return $config;
}
}
*/
$sql->db_Mark_Time("Start Simple URL-ReWrite Routine");
// XXX Cache didn't bring much benefit.
/*if($cached = e107::getCache()->retrieve('Addon_url',5,true,true))
{
$tmp = e107::unserialize($cached);
}
else*/
{
// $tmp = e107::getAddonConfig('e_url');
$tmp = e107::getUrlConfig();
// e107::getCache()->set('Addon_url',e107::serialize($tmp,'json'),true,true,true);
}
$req = (e_HTTP === '/') ? ltrim(e_REQUEST_URI,'/') : str_replace(e_HTTP,'', e_REQUEST_URI) ;
if(count($tmp) && !empty($req) && $req !== 'index.php')
{
$rootNamespace = e107::getPref('url_main_module');
$replaceAlias = array('{alias}\/?','{alias}/?','{alias}\/','{alias}/',);
$plugs = array_keys($tmp);
if(in_array($rootNamespace,$plugs)) // Move rootnamespace check to the end of the list.
{
$v = $tmp[$rootNamespace];
unset($tmp[$rootNamespace]);
$tmp[$rootNamespace] = $v;
}
foreach($tmp as $plug=>$cfg)
{
if(empty($pref['e_url_list'][$plug])) // disabled.
{
e107::getDebug()->log('e_URL for <b>'.$plug.'</b> is disabled.');
continue;
}
foreach($cfg as $k=>$v)
{
if(empty($v['regex']))
{
// e107::getMessage()->addDebug("Skipping empty regex: <b>".$k."</b>");
continue;
}
if(!empty($v['alias']))
{
$alias = (!empty($pref['e_url_alias'][e_LAN][$plug][$k])) ? $pref['e_url_alias'][e_LAN][$plug][$k] : $v['alias'];
// e107::getMessage()->addDebug("e_url alias found: <b>".$alias."</b>");
if(!empty($rootNamespace) && $rootNamespace === $plug)
{
$v['regex'] = str_replace($replaceAlias, '', $v['regex']);
}
else
{
$v['regex'] = str_replace('{alias}', $alias, $v['regex']);
}
}
$regex = '#'.$v['regex'].'#';
if(empty($v['redirect']))
{
continue;
}
$newLocation = preg_replace($regex, $v['redirect'], $req);
if($newLocation != $req)
{
$redirect = e107::getParser()->replaceConstants($newLocation);
list($file,$query) = explode("?",$redirect,2);
$get = array();
if(!empty($query))
{
parse_str($query,$get);
}
foreach($get as $gk=>$gv)
{
$_GET[$gk] = $gv;
}
e107::getDebug()->log('e_URL in <b>'.$plug.'</b> with key: <b>'.$k.'</b> matched <b>'.$v['regex'].'</b> and included: <b>'.$file.'</b> with $_GET: '.print_a($_GET,true),1);
if(file_exists($file))
{
define('e_CURRENT_PLUGIN', $plug);
define('e_QUERY', $query); // do not add to e107_class.php
define('e_URL_LEGACY', $redirect);
include_once($file);
exit;
}
elseif(getperms('0'))
{
require_once(HEADERF);
echo "<div class='alert alert-warning'>";
echo "<h3>SEF Debug Info</h3>";
echo "File missing: ".$file;
echo "<br />Matched key: <b>".$k."</b>";
print_a($v);
echo "</div>";
require_once(FOOTERF);
exit;
}
}
}
}
unset($tmp,$redirect,$regex);
}
// -----------------------------------------
$sql->db_Mark_Time("Start regular eFront Class");
$front = eFront::instance();
$front->init()
->run();
$request = $front->getRequest();
// If not already done - define legacy constants
$request->setLegacyQstring();
$request->setLegacyPage();
$inc = $front->isLegacy();
if($inc)
{
// last chance to set legacy env
$request->populateRequestParams();
if(!is_file($inc) || !is_readable($inc))
{
echo 'Bad request - destination unreachable - '.$inc;
}
include($inc);
exit;
}
$response = $front->getResponse();
if(e_AJAX_REQUEST)
{
$response->setParam('meta', false)
->setParam('render', false)
->send('default', false, true);
exit;
}
$response->sendMeta();
// -------------- Experimental -----------------
// unset($_SESSION['E:SOCIAL']);
if(vartrue($_GET['provider']) && !isset($_SESSION['E:SOCIAL']) && e107::getPref('social_login_active', false) && (e_ADMIN_AREA !== true))
{
require_once(e_HANDLER."hybridauth/Hybrid/Auth.php");
$config = array(
"base_url" => SITEURL.$HANDLERS_DIRECTORY."hybridauth/",
"providers" => e107::getPref('social_login', array())
);
// print_a($config);
// $params = array("hauth_return_to" => e_SELF);
$hybridauth = new Hybrid_Auth($config);
$prov = (!isset($config['providers'][$_GET['provider']])) ? "Facebook" : $_GET['provider'];
$adapter = $hybridauth->authenticate( $prov);
$user_profile = $adapter->getUserProfile();
$prov_id = $prov."_".$user_profile->identifier;
if($user_profile->identifier >0)
{
if (!$sql->select("user", "*", "user_xup = '".$prov_id."' ")) // New User
{
$user_join = time();
$user_pass = md5($user_profile->identifier.$user_join);
$user_loginname = "xup_".$user_profile->identifier;
$insert = array(
'user_name' => $user_profile->displayName,
'user_email' => $user_profile->email,
'user_loginname' => $user_loginname,
'user_password' => $user_pass,
'user_login' => $user_profile->displayName,
'user_join' => $user_join,
'user_xup' => $prov_id
);
if($newid = $sql->insert('user',$insert,true))
{
e107::getEvent()->trigger('usersup', $insert);
if(!USERID)
{
require_once(e_HANDLER.'login.php');
$usr = new userlogin($user_loginname, $user_pass, 'signup', '');
}
}
}
else // Existing User.
{
}
}
// echo "CHECKING";
$_SESSION['E:SOCIAL'] = (array) $user_profile;
echo "USERNAME=".USERNAME;
echo "<br />USEREMAIL=".USEREMAIL;
echo "<br />USERIMAGE=".USERIMAGE;
// print_a($_SESSION['E:SOCIAL']);
}
// -------------------------------------------
include_once(HEADERF);
eFront::instance()->getResponse()->send('default', false, true);
include_once(FOOTERF);
exit;
// BOOTSTRAP END