-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_chatbox.php
158 lines (126 loc) · 4.2 KB
/
admin_chatbox.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
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Plugin - Chatbox
*
*/
require_once(__DIR__.'/../../class2.php');
if (!e107::isInstalled('chatbox_menu') || !getperms("P"))
{
e107::redirect('admin');
exit;
}
// include_lXXXan( e_PLUGIN."chatbox_menu/languages/".e_LANGUAGE."/admin_chatbox_menu.php");
e107::lan('chatbox_menu','admin_chatbox_menu');
require_once(e_ADMIN."auth.php");
require_once(e_HANDLER."userclass_class.php");
$mes = e107::getMessage();
$frm = e107::getForm();
if (isset($_POST['updatesettings']))
{
$temp = array();
$temp['chatbox_posts'] = vartrue($_POST['chatbox_posts'], 5);
$temp['cb_layer'] = intval($_POST['cb_layer']);
$temp['cb_layer_height'] = max(varset($_POST['cb_layer_height'], 200), 150);
$temp['cb_emote'] = intval($_POST['cb_emote']);
$temp['cb_mod'] = intval($_POST['cb_mod']);
$temp['cb_user_addon'] = intval($_POST['cb_user_addon']);
e107::getConfig('core')->setPref($temp)->save(false);
e107::getCache()->clear("nq_chatbox");
}
if (isset($_POST['prune']))
{
$chatbox_prune = intval($_POST['chatbox_prune']);
$prunetime = time() - $chatbox_prune;
$sql->delete("chatbox", "cb_datestamp < '{$prunetime}' ");
e107::getLog()->add('CHBLAN_02', $chatbox_prune.', '.$prunetime, E_LOG_INFORMATIVE, '');
e107::getCache()->clear("nq_chatbox");
$mes->addSuccess(LAN_AL_CHBLAN_02);
}
if (isset($_POST['recalculate']))
{
$sql->update("user", "user_chats = 0");
$qry = "SELECT u.user_id AS uid, count(c.cb_nick) AS count FROM #chatbox AS c
LEFT JOIN #user AS u ON SUBSTRING_INDEX(c.cb_nick,'.',1) = u.user_id
WHERE u.user_id > 0
GROUP BY uid";
if ($sql->gen($qry))
{
$ret = array();
while($row = $sql -> fetch())
{
$list[$row['uid']] = $row['count'];
}
}
foreach($list as $uid => $cnt)
{
$sql->update("user", "user_chats = '{$cnt}' WHERE user_id = '{$uid}'");
}
e107::getLog()->add('CHBLAN_03','', E_LOG_INFORMATIVE, '');
$mes->addSuccess(CHBLAN_33);
}
if(!isset($pref['cb_mod']))
{
$pref['cb_mod'] = e_UC_ADMIN;
}
$text = "
<form method='post' action='".e_SELF."' id='cbform' >
<table class='table adminform'>
<colgroup>
<col class='col-label' />
<col class='col-control' />
</colgroup>
<tr>
<td>".CHBLAN_11.":</td>
<td>".$frm->select('chatbox_posts', array(5, 10, 15, 20, 25), varset($pref['chatbox_posts']),'useValues=1')."<span class='field-help'>".CHBLAN_12."</span></td>
</tr>
<tr>
<td>".CHBLAN_32.": </td>
<td>". r_userclass("cb_mod", varset($pref['cb_mod']), 'off', "nobody,main,admin, classes")."</td>
</tr>
<tr>
<td>".CHBLAN_36."</td>
<td>".$frm->radio('cb_layer', array(0 => CHBLAN_37, 1 => str_replace("[x]", $frm->number('cb_layer_height', varset($pref['cb_layer_height']), 3), CHBLAN_29), 2 => CHBLAN_38), varset($pref['cb_layer']), array('sep' => '<br />'))."</td>
</tr>
";
if(!empty($pref['smiley_activate']))
{
$text .= "<tr>
<td>".CHBLAN_31."?: </td>
<td>".$frm->radio_switch('cb_emote', varset($pref['cb_emote']))."</td>
</tr>";
}
$text .= "
<tr>
<td>".CHBLAN_42."</td>
<td>".$frm->radio_switch('cb_user_addon', varset($pref['cb_user_addon']))."</td>
</tr>
<tr>
<td>".LAN_PRUNE.":</td>
<td class='form-inline'>".CHBLAN_23.$frm->select('chatbox_prune', array(86400 => CHBLAN_24, 604800 => CHBLAN_25, 2592000 => CHBLAN_26, 1 => CHBLAN_27), '', '', true).$frm->admin_button('prune', LAN_PRUNE, 'other')."<span class='field-help'>".CHBLAN_22."</span></td>
</tr>
<tr>
<td>".CHBLAN_34.":</td>
<td>".$frm->admin_button('recalculate', CHBLAN_35, 'other')."</td>
</tr>
</table>
<div class='buttons-bar center'>
".$frm->admin_button('updatesettings', LAN_UPDATE, 'update')."
</div>
</form>";
$ns->tablerender(CHBLAN_20, $mes->render().$text);
require_once(e_ADMIN."footer.php");
function admin_chatbox_adminmenu()
{
$mode = varset($_GET['mode'],'main');
$var['main']['text'] = LAN_PREFS;
$var['main']['link'] = e_SELF;
$caption = "<span>".LAN_PLUGIN_CHATBOX_MENU_NAME."</span>";
$var['_extras_']['icon'] = e107::getParser()->toIcon(e_PLUGIN."chatbox_menu/images/chatbox_32.png");
e107::getNav()->admin($caption, $mode, $var);
}