|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* @package sitemaker |
|
5
|
|
|
* @copyright (c) 2013 Daniel A. (blitze) |
|
6
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
|
7
|
|
|
* |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace blitze\sitemaker\blocks; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Whois Block |
|
14
|
|
|
*/ |
|
15
|
|
|
class whois extends \blitze\sitemaker\services\blocks\driver\block |
|
16
|
|
|
{ |
|
17
|
|
|
/** @var \phpbb\auth\auth */ |
|
18
|
|
|
protected $auth; |
|
19
|
|
|
|
|
20
|
|
|
/** @var \phpbb\config\config */ |
|
21
|
|
|
protected $config; |
|
22
|
|
|
|
|
23
|
|
|
/** @var \phpbb\template\context */ |
|
24
|
|
|
protected $context; |
|
25
|
|
|
|
|
26
|
|
|
/** @var \phpbb\user */ |
|
27
|
|
|
protected $user; |
|
28
|
|
|
|
|
29
|
|
|
/** @var string */ |
|
30
|
|
|
protected $phpbb_root_path; |
|
31
|
|
|
|
|
32
|
|
|
/** @var string */ |
|
33
|
|
|
protected $php_ext; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Constructor |
|
37
|
|
|
* |
|
38
|
|
|
* @param \phpbb\auth\auth $auth Permission object |
|
39
|
|
|
* @param \phpbb\config\config $config phpBB configuration |
|
40
|
|
|
* @param \phpbb\template\context $context Template context |
|
41
|
|
|
* @param \phpbb\user $user User object |
|
42
|
|
|
* @param string $phpbb_root_path Path to the phpbb includes directory. |
|
43
|
|
|
* @param string $php_ext php file extension |
|
44
|
|
|
*/ |
|
45
|
3 |
|
public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\template\context $context, \phpbb\user $user, $phpbb_root_path, $php_ext) |
|
46
|
|
|
{ |
|
47
|
3 |
|
$this->auth = $auth; |
|
48
|
3 |
|
$this->config = $config; |
|
49
|
3 |
|
$this->context = $context; |
|
50
|
3 |
|
$this->user = $user; |
|
51
|
3 |
|
$this->phpbb_root_path = $phpbb_root_path; |
|
52
|
3 |
|
$this->php_ext = $php_ext; |
|
53
|
3 |
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* {@inheritdoc} |
|
57
|
|
|
*/ |
|
58
|
2 |
|
public function display(array $settings, $edit_mode = false) |
|
59
|
|
|
{ |
|
60
|
2 |
|
$data = $this->context->get_data_ref(); |
|
61
|
|
|
|
|
62
|
2 |
|
if (!empty($data['.'][0]['TOTAL_USERS_ONLINE'])) |
|
63
|
2 |
|
{ |
|
64
|
1 |
|
$l_online_users = $data['.'][0]['TOTAL_USERS_ONLINE']; |
|
65
|
1 |
|
$online_userlist = $data['.'][0]['LOGGED_IN_USER_LIST']; |
|
66
|
1 |
|
$l_online_record = $data['.'][0]['RECORD_USERS']; |
|
67
|
1 |
|
} |
|
68
|
|
|
else |
|
69
|
|
|
{ |
|
70
|
1 |
|
$item_id = 0; |
|
71
|
1 |
|
$item = 'forum'; |
|
72
|
|
|
|
|
73
|
1 |
|
$online_users = obtain_users_online($item_id, $item); |
|
74
|
1 |
|
$user_online_strings = obtain_users_online_string($online_users, $item_id, $item); |
|
75
|
|
|
|
|
76
|
1 |
|
$l_online_users = $user_online_strings['l_online_users']; |
|
77
|
1 |
|
$online_userlist = $user_online_strings['online_userlist']; |
|
78
|
|
|
|
|
79
|
1 |
|
$l_online_record = $this->user->lang('RECORD_ONLINE_USERS', (int) $this->config['record_online_users'], $this->user->format_date($this->config['record_online_date'], false, true)); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
2 |
|
$this->ptemplate->assign_vars(array( |
|
83
|
2 |
|
'TOTAL_USERS_ONLINE' => $l_online_users, |
|
84
|
2 |
|
'LOGGED_IN_USER_LIST' => $online_userlist, |
|
85
|
2 |
|
'RECORD_USERS' => $l_online_record, |
|
86
|
2 |
|
'U_VIEWONLINE' => $this->_get_viewonline_url(), |
|
87
|
2 |
|
)); |
|
88
|
2 |
|
unset($data); |
|
89
|
|
|
|
|
90
|
|
|
return array( |
|
91
|
2 |
|
'title' => 'WHO_IS_ONLINE', |
|
92
|
2 |
|
'content' => $this->ptemplate->render_view('blitze/sitemaker', 'blocks/whois.html', 'whois_block') |
|
93
|
2 |
|
); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @return string |
|
98
|
|
|
*/ |
|
99
|
2 |
|
private function _get_viewonline_url() |
|
100
|
|
|
{ |
|
101
|
2 |
|
return ($this->auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) ? append_sid("{$this->phpbb_root_path}viewonline." . $this->php_ext) : ''; |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|