-
Notifications
You must be signed in to change notification settings - Fork 0
/
login_menu_shortcodes.php
552 lines (446 loc) · 15.5 KB
/
login_menu_shortcodes.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
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright (C) 2008-2009 e107 Inc
| http://e107.org
|
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
+----------------------------------------------------------------------------+
*/
if (!defined('e107_INIT')) { exit(); }
global $tp;
e107::plugLan('login_menu', null);
// BC LAN Fix.
$bcDefs = array(
'LOGIN_MENU_L1' => 'LAN_LOGINMENU_1',
'LOGIN_MENU_L2' => 'LAN_LOGINMENU_2',
'LOGIN_MENU_L3' => 'LAN_LOGINMENU_3',
'LOGIN_MENU_L4' => 'LAN_LOGINMENU_4',
'LOGIN_MENU_L6' => 'LAN_LOGINMENU_6',
'LOGIN_MENU_L40' => 'LAN_LOGINMENU_40',
'LOGIN_MENU_L51' => 'LAN_LOGINMENU_51'
);
e107::getLanguage()->bcDefs($bcDefs);
//$login_menu_shortcodes = $tp -> e_sc -> parse_scbatch(__FILE__);
if(!class_exists('login_menu_shortcodes'))
{
class login_menu_shortcodes extends e_shortcode
{
private $use_imagecode =0;
private $sec;
private $usernameLabel = LAN_LOGINMENU_1;
private $allowEmailLogin;
function __construct()
{
$pref = e107::getPref();
$this->use_imagecode = e107::getConfig()->get('logcode');
$this->sec = e107::getSecureImg();
$this->usernameLabel = '';
$this->allowEmailLogin = $pref['allowEmailLogin'];
if($pref['allowEmailLogin']==1)
{
$this->usernameLabel = LAN_LOGINMENU_49;
}
if($pref['allowEmailLogin']==2)
{
$this->usernameLabel = LAN_LOGINMENU_50;
}
}
/**
*
* @param array $parm
* @return null|string
*/
function sc_lm_active($parm=array())
{
// $request = e_REQUEST_URI;
$ret = null;
$mode = varset($parm['mode']);
if($mode === 'usersettings' && defset('e_PAGE') === 'usersettings.php')
{
return 'active';
}
elseif($mode === 'profile' && defset('e_PAGE') === 'user.php')
{
return 'active';
}
return null;
}
function sc_lm_username_input($parm=null)
{
$pref = e107::getPref();
// If logging in with email address - ignore pref and increase to 100 chars.
$maxLength = ($this->allowEmailLogin == 1 || $this->allowEmailLogin) ? 100 : varset($pref['loginname_maxlength'],30);
return "
<label class='sr-only' for='".vartrue( $parm['idprefix'] )."username'>".$this->usernameLabel."</label>
<input class='form-control tbox login user' type='text' name='username' placeholder='".$this->usernameLabel."' required='required' id='".vartrue( $parm['idprefix'] )."username' size='15' value='' maxlength='".$maxLength."' />\n";
}
function sc_lm_username_label($parm='')
{
return $this->usernameLabel;
}
function sc_lm_password_input($parm=null)
{
$pref = e107::getPref();
$t_password = "
<label class='sr-only' for='".vartrue( $parm['idprefix'] )."userpass'>".LAN_PASSWORD."</label>
<input class='form-control tbox login pass' type='password' placeholder='".LAN_PASSWORD."' required='required' name='userpass' id='".vartrue( $parm['idprefix'] )."userpass' size='15' value='' maxlength='30' />\n";
if (!USER && e107::getSession()->is('challenge') && varset($pref['password_CHAP'],0))
$t_password .= "<input type='hidden' name='hashchallenge' id='hashchallenge' value='".e107::getSession()->get('challenge')."' />\n\n";
return $t_password;
}
function sc_lm_password_label($parm='')
{
return LAN_LOGINMENU_2;
}
/**
* @deprecated use {LM_IMAGECODE_NUMBER}, {LM_IMAGECODE_BOX} instead
* @param string $parm
* @return string
*/
function sc_lm_imagecode($parm='')
{
trigger_error('<b>{LM_IMAGECODE} is deprecated.</b> Use {LM_IMAGECODE_NUMBER}, {LM_IMAGECODE_BOX} instead.', E_USER_DEPRECATED); // NO LAN
//DEPRECATED - use LM_IMAGECODE_NUMBER, LM_IMAGECODE_BOX instead
if($this->use_imagecode)
{
return $this->sc_lm_imagecode_number()."<br />".$this->sc_lm_imagecode_box();
/*return '<input type="hidden" name="rand_num" id="rand_num" value="'.$this->sec->random_number.'" />
'.$this->sec->r_image().'
<br /><input class="tbox login verify" type="text" name="code_verify" id="code_verify" size="15" maxlength="20" /><br />';
*/
}
return '';
}
function sc_lm_imagecode_number($parm='')
{
if($this->use_imagecode)
{
return e107::getSecureImg()->renderImage();
/* return '<input type="hidden" name="rand_num" id="rand_num" value="'.$this->sec->random_number.'" />
'.$this->sec->r_image();*/
}
return '';
}
function sc_lm_imagecode_box($parm='')
{
if($this->use_imagecode)
{
return e107::getSecureImg()->renderInput();
// $placeholder = LAN_ENTER_CODE;
// return '<input class="form-control tbox login verify" type="text" name="code_verify" id="code_verify" size="15" maxlength="20" placeholder="'.$placeholder.'" />';
}
return '';
}
function sc_lm_loginbutton($parm='')
{
return "<input class='button btn btn-default btn-secondary login' type='submit' name='userlogin' id='userlogin' value='".LAN_LOGIN."' />";
}
function sc_lm_rememberme($parm='')
{
$pref = e107::getPref();
if($parm == "hidden"){
return "<input type='hidden' name='autologin' id='autologin' value='1' />";
}
if(varset($pref['user_tracking']) !== "session")
{
return "<label for='autologin'><input type='checkbox' name='autologin' id='autologin' value='1' checked='checked' />".($parm ? $parm : "".LAN_LOGINMENU_6."</label>");
}
return '';
}
function sc_lm_signup_link($parm='')
{
$pref = e107::getPref();
if (intval($pref['user_reg'])===1)
{
if (!$pref['auth_method'] || $pref['auth_method'] == 'e107')
{
return $parm == 'href' ? e_SIGNUP : "<a class='login_menu_link signup' id='login_menu_link_signup' href='".e_SIGNUP."' title=\"".LAN_LOGINMENU_3."\">".LAN_LOGINMENU_3."</a>";
}
}
return '';
}
function sc_lm_fpw_link($parm='')
{
$pref = e107::getPref();
if (!$pref['auth_method'] || $pref['auth_method'] == 'e107')
{
return $parm == 'href' ? SITEURL.'fpw.php' : "<a class='login_menu_link fpw' id='login_menu_link_fpw' href='".SITEURL."fpw.php' title=\"".LAN_LOGINMENU_4."\">".LAN_LOGINMENU_4."</a>";
}
return '';
}
function sc_lm_resend_link($parm='')
{
$pref = e107::getPref();
if (intval($pref['user_reg'])===1)
{
if(isset($pref['user_reg_veri']) && $pref['user_reg_veri'] == 1)
{
if (!$pref['auth_method'] || $pref['auth_method'] == 'e107' )
{
return $parm == 'href' ? e_SIGNUP.'?resend' : "<a class='login_menu_link resend' id='login_menu_link_resend' href='".e_SIGNUP."?resend' title=\"".LAN_LOGINMENU_40."\">".LAN_LOGINMENU_40."</a>";
}
}
}
return '';
}
function sc_lm_maintenance($parm='')
{
$pref = e107::getPref();
if(ADMIN && varset($pref['maintainance_flag']))
{
return LAN_LOGINMENU_10;
}
return '';
}
function sc_lm_adminlink_bullet($parm='')
{
if(ADMIN)
{
if($data = e107::getRegistry('login_menu_data'))
{
return $parm == 'src' ? $data['link_bullet_src'] : $data['link_bullet'];
}
}
return '';
}
function sc_lm_adminlink($parm='')
{
if(ADMIN == TRUE) {
return $parm == 'href' ? e_ADMIN_ABS.'admin.php' : '<a class="login_menu_link admin" id="login_menu_link_admin" href="'.e_ADMIN_ABS.'admin.php">'.LAN_LOGINMENU_11.'</a>';
}
return '';
}
function sc_lm_admin_configure($parm='')
{
if(ADMIN == TRUE) {
return $parm == 'href' ? e_PLUGIN_ABS.'login_menu/config.php' : '<a class="login_menu_link config" id="login_menu_link_config" href="'.e_PLUGIN_ABS.'login_menu/config.php">'.LAN_LOGINMENU_48.'</a>';
}
return '';
}
function sc_lm_bullet($parm='')
{
if(!$data = e107::getRegistry('login_menu_data'))
{
return null;
}
return $parm == 'src' ? $data['link_bullet_src'] : $data['link_bullet'];
}
function sc_lm_usersettings($parm='')
{
$text = ($parm) ? $parm : LAN_SETTINGS;
$url = $this->sc_lm_usersettings_href();
return '<a class="login_menu_link usersettings" id="login_menu_link_usersettings" href="'.$url.'">'.$text.'</a>';
}
function sc_lm_usersettings_href($parm='')
{
return e107::getUrl()->create('user/myprofile/edit',array('id'=>USERID));
// return e_HTTP.'usersettings.php';
}
function sc_lm_profile($parm='')
{
$text = ($parm) ? $parm : LAN_LOGINMENU_13;
$url = $this->sc_lm_profile_href();
return '<a class="login_menu_link profile" id="login_menu_link_profile" href="'.$url.'">'.$text.'</a>';
}
function sc_lm_profile_href($parm='')
{
return e107::getUrl()->create('user/profile/view',array('user_id'=>USERID, 'user_name'=>USERNAME));
// return e_HTTP.'user.php?id.'.USERID;
}
function sc_lm_logout($parm='')
{
$text = ($parm) ? $parm : LAN_LOGOUT;
return '<a class="login_menu_link logout" id="login_menu_link_logout" href="'.e_HTTP.'index.php?logout">'.$text.'</a>';
}
function sc_lm_logout_href($parm='')
{
return e_HTTP.'index.php?logout';
}
function sc_lm_external_links($parm='')
{
global $LOGIN_MENU_EXTERNAL_LINK;
$menu_pref = e107::getConfig('menu')->getPref();
$tp = e107::getParser();
require_once(e_PLUGIN."login_menu/login_menu_class.php");
$lmc = new login_menu_class;
if(!vartrue($menu_pref['login_menu']['external_links']))
{
return '';
}
$lbox_infos = $lmc->parse_external_list(true, false);
$lbox_active = $menu_pref['login_menu']['external_links'] ? explode(',', $menu_pref['login_menu']['external_links']) : array();
if(!vartrue($lbox_infos['links']))
{
return '';
}
$ret = '';
foreach($lbox_active as $stackid)
{
$lbox_items = $lmc->clean_links(varset($lbox_infos['links'][$stackid]));
if(!$lbox_items)
{
continue;
}
foreach($lbox_items as $num => $lbox_item)
{
$lbox_item['link_id'] = $stackid . '_' . $num;
e107::setRegistry('login_menu_linkdata', $lbox_item);
$ret .= $tp->parseTemplate($LOGIN_MENU_EXTERNAL_LINK, false, $this);
}
}
return $ret;
}
function sc_lm_external_link($parm='')
{
$lbox_item = e107::getRegistry('login_menu_linkdata');
if(empty($lbox_item['link_url']))
{
return null;
}
return $parm == 'href' ? $lbox_item['link_url'] : '<a href="'.$lbox_item['link_url'].'" class="login_menu_link external" id="login_menu_link_external_'.$lbox_item['link_id'].'">'.vartrue($lbox_item['link_label'], '['.LAN_LOGINMENU_44.']').'</a>';
}
function sc_lm_external_link_label($parm='')
{
$lbox_item = e107::getRegistry('login_menu_linkdata');
return vartrue($lbox_item['link_label'], '['.LAN_LOGINMENU_44.']');
}
function sc_lm_stats($parm='')
{
$tp = e107::getParser();
global $LOGIN_MENU_STATS;
$data = e107::getRegistry('login_menu_data');
if(empty($data['enable_stats']) || empty($LOGIN_MENU_STATS))
{
return '';
}
return $tp->parseTemplate($LOGIN_MENU_STATS, true, $this);
}
function sc_lm_new_news($parm='')
{
$tp = e107::getParser();
global $LOGIN_MENU_STATITEM;
$data = e107::getRegistry('login_menu_data');
if(!isset($data['new_news'])) return '';
$tmp = array();
if($data['new_news']){
$tmp['LM_STAT_NEW'] = $data['new_news'];
$tmp['LM_STAT_LABEL'] = $data['new_news'] == 1 ? LAN_LOGINMENU_14 : LAN_LOGINMENU_15;
$tmp['LM_STAT_EMPTY'] = '';
} else {
$tmp['LM_STAT_NEW'] = '';
$tmp['LM_STAT_LABEL'] = '';
$tmp['LM_STAT_EMPTY'] = LAN_LOGINMENU_26." ".LAN_LOGINMENU_15;
}
return $tp -> parseTemplate($LOGIN_MENU_STATITEM, false, $tmp);
}
function sc_lm_new_comments($parm='')
{
global $LOGIN_MENU_STATITEM, $tp;
$data = e107::getRegistry('login_menu_data');
if(!isset($data['new_comments'])) return '';
$tmp = array();
if($data['new_comments']){
$tmp['LM_STAT_NEW'] = $data['new_comments'];
$tmp['LM_STAT_LABEL'] = $data['new_comments'] == 1 ? LAN_LOGINMENU_18 : LAN_LOGINMENU_19;
$tmp['LM_STAT_EMPTY'] = '';
} else {
$tmp['LM_STAT_NEW'] = '';
$tmp['LM_STAT_LABEL'] = '';
$tmp['LM_STAT_EMPTY'] = LAN_LOGINMENU_26." ".LAN_LOGINMENU_19;
}
return $tp -> parseTemplate($LOGIN_MENU_STATITEM, false, $tmp);
}
function sc_lm_new_users($parm='')
{
global $LOGIN_MENU_STATITEM, $tp;
$data = e107::getRegistry('login_menu_data');
if(!isset($data['new_users'])) return '';
$tmp = array();
if($data['new_users']){
$tmp['LM_STAT_NEW'] = $data['new_users'];
$tmp['LM_STAT_LABEL'] = $data['new_users'] == 1 ? LAN_LOGINMENU_22 : LAN_LOGINMENU_23;
$tmp['LM_STAT_EMPTY'] = '';
} else {
$tmp['LM_STAT_NEW'] = '';
$tmp['LM_STAT_LABEL'] = '';
$tmp['LM_STAT_EMPTY'] = LAN_LOGINMENU_26." ".LAN_LOGINMENU_23;
}
return $tp -> parseTemplate($LOGIN_MENU_STATITEM, false, $tmp);
}
function sc_lm_plugin_stats($parm='')
{
global $tp, $menu_pref, $new_total, $LOGIN_MENU_STATITEM, $LM_STATITEM_SEPARATOR;
if(!vartrue($menu_pref['login_menu']['external_stats'])) return '';
require_once(e_PLUGIN."login_menu/login_menu_class.php");
$lm = new login_menu_class;
$lbox_infos = $lm->parse_external_list(true, false);
if(!vartrue($lbox_infos['stats'])) return '';
$lbox_active_sorted = $menu_pref['login_menu']['external_stats'] ? explode(',', $menu_pref['login_menu']['external_stats']) : array();
$ret = array();
$sep = varset($LM_STATITEM_SEPARATOR, '<br />');
foreach ($lbox_active_sorted as $stackid)
{
if(!varset($lbox_infos['stats'][$stackid])) continue;
foreach ($lbox_infos['stats'][$stackid] as $lbox_item)
{
$tmp = array();
if($lbox_item['stat_new'])
{
$tmp['LM_STAT_NEW'] = $lbox_item['stat_new'];
$tmp['LM_STAT_LABEL'] = $lbox_item["stat_new"] == 1 ? $lbox_item['stat_item'] : $lbox_item['stat_items'];
$tmp['LM_STAT_EMPTY'] = '';
$new_total += $lbox_item['stat_new'];
}
else
{
//if(empty($lbox_item['stat_nonew'])) continue;
$tmp['LM_STAT_NEW'] = '';
$tmp['LM_STAT_LABEL'] = '';
$tmp['LM_STAT_EMPTY'] = $lbox_item['stat_nonew'];
}
$ret[] = $tp->parseTemplate($LOGIN_MENU_STATITEM, false, $tmp);
}
}
return $ret ? implode($sep, $ret) : '';
}
function sc_lm_listnew_link($parm = '')
{
if(!$data = e107::getRegistry('login_menu_data'))
{
return null;
}
if($parm === 'href')
{
return $data['listnew_link'];
}
return $data['listnew_link'] ? '<a href="' . $data['listnew_link'] . '" class="login_menu_link listnew" id="login_menu_link_listnew">' . LAN_LOGINMENU_24 . '</a>' : '';
}
function sc_lm_message($parm='')
{
global $tp, $LOGIN_MENU_MESSAGE;
if(!deftrue('LOGINMESSAGE')) return '';
if($parm == "popup"){
$srch = array("<br />","'");
$rep = array("\\n","\'");
return "<script>
alert(".$tp->toJSON(LOGINMESSAGE).");
</script>";
}
else
{
return e107::getParser()->parseTemplate($LOGIN_MENU_MESSAGE, true, $this);
}
}
function sc_lm_message_text($parm='')
{
return deftrue('LOGINMESSAGE', '');
}
}
}
$login_menu_shortcodes = e107::getScBatch('login_menu',TRUE);