-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
squirrelmail_check_quota.patch
458 lines (454 loc) · 12.9 KB
/
squirrelmail_check_quota.patch
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
diff -ruN check_quota_old/config.php check_quota/config.php
--- check_quota_old/config.php 1970-01-01 01:00:00.000000000 +0100
+++ check_quota/config.php 2023-05-22 08:47:49.000000000 +0200
@@ -0,0 +1,409 @@
+<?php
+
+/*
+ * This is the configuration file for Check Quota Plugin.
+ * You can edit the options here to suit your needs.
+ * Please make sure you read the INSTALL file before configuring
+ * these options.
+*/
+
+global $settings;
+$settings = array();
+
+
+/*******************************
+ * Quota Configuration Options *
+ *******************************/
+
+/*
+ * Use UNIX (filesystem), IMAP-based or cPanel (experimental) quotas?
+ * If you use UNIX (filesystem) quotas, you should set this to 0.
+ * If you use IMAP-based quotas, you should set this to 1.
+ * If you use cPanel quotas, you should set this to 2.
+ *
+ * Default: UNIX (filesystem) quotas
+ * 0: UNIX / 1: IMAP / 2: cPanel
+*/
+
+$settings['quota_type'] = 1;
+
+
+/*
+ * If you are using UNIX (filesystem) quotas, set the path
+ * to the "sudo" binary here. See INSTALL for instructions.
+*/
+
+$settings['sudo_binary'] = '/usr/bin/sudo';
+
+
+/*
+ * If you are using UNIX quotas, set the path to the "quota"
+ * binary here. See INSTALL for instructions.
+*/
+
+$settings['quota_binary'] = '/usr/bin/quota';
+
+
+/*
+ * If you are using UNIX quotas and your IMAP server and web server
+ * are on different physical machines (i.e. you want to check UNIX
+ * quotas remotely) set this to 1. See INSTALL for instructions.
+ *
+ * This setting is only used for UNIX quotas.
+ *
+ * Default: Check on local server
+ * 0: Check on local server / 1: Check on remote server
+*/
+
+$settings['check_unix_on_remote_server'] = 0;
+
+
+/*
+ * If you are using UNIX quotas and your IMAP server and web server
+ * are on different physical machines (i.e. you want to check UNIX
+ * quotas remotely) set the path to the "ssh" binary here. See INSTALL
+ * for instructions.
+ *
+ * This setting is only used for remote UNIX quotas.
+*/
+
+$settings['ssh_binary'] = '/usr/bin/ssh';
+
+
+/*
+ * If you are using UNIX quotas and your IMAP server and web server
+ * are on different physical machines (i.e. you want to check UNIX
+ * quotas remotely) set the username that will check quotas on your
+ * IMAP server here. See INSTALL for instructions.
+ *
+ * This setting is only used for remote UNIX quotas.
+*/
+
+$settings['remote_unix_user'] = 'cquotauser';
+
+
+/*
+ * If you are using UNIX quotas and your IMAP server and web server
+ * are on different physical machines (i.e. you want to check UNIX
+ * quotas remotely) set the IP address or hostname of your IMAP
+ * server here. See INSTALL for instructions.
+ *
+ * This setting is only used for remote UNIX quotas.
+*/
+
+$settings['remote_unix_server'] = '192.168.1.1';
+
+
+/*
+ * If you are using cPanel quotas, set the path to the "du" binary
+ * here. See INSTALL for instructions.
+*/
+
+$settings['du_binary'] = '/usr/bin/du';
+
+
+/*
+ * If you are using cPanel quotas, set the cPanel root path here.
+ * See INSTALL for instructions.
+*/
+
+$settings['cpanel_root'] = '/path/to/cpanel/root';
+
+
+/*
+ * If you want to use a separate IMAP connection when checking your
+ * quota, set this variable to 1, else, set it to 0
+ *
+ * This will be a waste of resources if there already is an open
+ * IMAP connection to your server. So, most probably you will not need
+ * to adjust this variable in most occasions.
+ *
+ * Default: Do not use separate IMAP connection
+ * 0: Do not use separate connection / 1: Use separate connection
+*/
+
+$settings['use_separate_imap_connection'] = 0;
+
+/***************************
+ * General Display Options *
+ ***************************/
+
+/*
+ * Which graph type do you prefer?
+ *
+ * You have three options here. You can use HTML tables, GD images,
+ * or Flash graphics.
+ *
+ * GD images can only be generated if you have GD support built into
+ * PHP (--with-gd). For more information on how to install GD support
+ * in PHP, see:
+ *
+ * http://www.php.net/manual/ref.image.php
+ *
+ * If your server doesn't have GD png, gif or jpg support but you enable GD
+ * graphics, the plugin will revert to HTML tables.
+ *
+ * As SquirrelMail is a pure PHP-driven webmail program, and some people do
+ * not have GD support in PHP, default is HTML tables.
+ *
+ * You will get the most satisfying graph output with GD or Flash graphs.
+ *
+ * Default: Use HTML
+ * 0: Use HTML / 1: Use GD / 2: Use Flash
+*/
+
+$settings['graph_type'] = 0;
+
+
+/*
+ * Will the quota information be shown above or below the folders list?
+ *
+ * Default: Above
+ * 0: Below / 1: Above
+*/
+
+$settings['info_above_folders_list'] = 1;
+
+
+/*
+ * Font size for quota information displayed on the folder pane.
+ * Must be a positive or negative integer value.
+ *
+ * Default: -2
+*/
+
+$settings['font_size'] = -2;
+
+
+/*
+ * Alignment for the graph and text information on the folder pane.
+ * This can be "left", "center" or "right".
+ *
+ * Default: "left"
+*/
+
+$settings['graph_alignment'] = 'left';
+
+
+/*
+ * Whether or not to use horizontal rules to seperate quota information
+ * from other information on the folder pane.
+ *
+ * Default: No
+ * 0: No / 1: Yes
+*/
+
+$settings['use_hr'] = 0;
+
+
+/*
+ * Whether or not to show the introductory "Quota Usage" text for
+ * size-based quotas and the "File Usage" text for count-based quotas
+ * displayed on the folder pane.
+ *
+ * Default: On
+ * 0: Off / 1: On
+*/
+
+$settings['show_intro_texts'] = 1;
+
+
+/*
+ * Show the quota details above or below the quota graph?
+ *
+ * Default: Below
+ * 0: Below / 1: Above
+*/
+
+$settings['details_above_graph'] = 0;
+
+
+/*
+ * Whether to show used space (in KB, MB or GB depending on usage) for
+ * size-based quotas and file count for count-based quotas instead of
+ * percent usage in the information displayed on the folder pane.
+ *
+ * Default: Show percent
+ * 0: Show percent / 1: Show size/count
+*/
+
+$settings['show_quantity_instead_of_percent'] = 0;
+
+
+/*
+ * Quota percent thresholds. If the user's usage is more than one
+ * of these, the graph will use a different color and you also have
+ * the option to show a warning in the SquirrelMail "MOTD" display
+ * area when the user logs in.
+ *
+ * These must be positive integers.
+ *
+ * Defaults: Yellow: 70% / Red: 90%
+*/
+
+$settings['yellow_alert_limit'] = 70;
+$settings['red_alert_limit'] = 90;
+
+
+/*
+ * Yellow alert login warning option. When turned on and when the
+ * user's usage exceeds the yellow alert threshold (see above), a
+ * warning message will be displayed in the SquirrelMail "MOTD" area
+ * when he/she logs on.
+ *
+ * Default: On
+ * 0: Off / 1: On
+*/
+
+$settings['show_yellow_alert_motd'] = 1;
+
+
+/*
+ * Red alert login warning option. When turned on and when the
+ * user's usage exceeds the red alert threshold (see above), a
+ * warning message will be displayed in the SquirrelMail "MOTD" area
+ * when he/she logs on.
+ *
+ * Default: On
+ * 0: Off / 1: On
+*/
+
+$settings['show_red_alert_motd'] = 1;
+
+
+/*
+ * If your quotas are set based on 1 MB = 1000 KB, you may want to
+ * turn this option on. Otherwise, 1 MB = 1024 KB will be used for
+ * all quota calculations, which is the generally accepted convention.
+ *
+ * Default: Off
+ * 0: Off (1MB = 1024KB) / 1: On (1MB = 1000KB)
+*/
+
+$settings['use_1000KB_per_MB'] = 0;
+
+
+/*
+ * Whether or not to show filesystem names. This setting
+ * is only used for UNIX (filesystem) quotas.
+ *
+ * This is useful when you have more than one filesystem
+ * which have quotas for your users.
+ *
+ * When set to "1" filesystem aliases override filesystem names.
+ *
+ * Default: Off
+ * 0: Off
+ * 1: Show filesystem name or alias if an alias is set for that filesystem
+*/
+
+$settings['show_filesystems'] = 0;
+
+
+/********************
+ * Override Options *
+ ********************/
+
+/*
+ * You can use this list to map different names to your filesystems. For
+ * example, you can display "Mail Folder" instead of the filesystem name
+ * "/dev/hda4". Leave this empty if you don't want to set up any such
+ * aliases. If "show_filesystems" is set to "0" this list will have no
+ * meaning.
+ *
+ * This setting is only used for UNIX quotas.
+ *
+ * If you use this setting, make sure to replace "/dev/hda8" and "/dev/sda1"
+ * below with the filesystems that are appropriate on your system.
+*/
+
+$settings['fs_alias'] = array (
+ '/dev/hda8' => 'Mail',
+ '/dev/sda6' => 'Data',
+ );
+
+
+/*
+ * You can use this list to exclude some filesystems in your quota output.
+ * This allows you to only show quota information for the filesystem that
+ * your mail accounts reside on, to avoid confusion.
+ *
+ * You don't need to add filesystems which do not have any
+ * quota support here.
+ *
+ * You will need to write the exact filesystem name and, if you want to
+ * hide that filesystem, you will need to set its value to 1. If you want
+ * to show that filesystem, you can remove its entry from this list, or
+ * you can set its value to 0.
+ *
+ * This setting is only used for UNIX quotas.
+ *
+ * If you use this setting, make sure to replace "/dev/hda8" and "/dev/sda1"
+ * below with the filesystems that are appropriate on your system.
+*/
+
+$settings['exclude_fs'] = array (
+ '/dev/hda8' => 1,
+ '/dev/sda6' => 0,
+ );
+
+
+/*
+ * Some IMAP servers use dynamic quotas, so the users may not be able to
+ * see their true quotas. In this situation you can override the max quota
+ * information returned by the plugin with these variables. For size-based
+ * quotas, change "imap_size_quota", for count-based quotas, change
+ * "imap_count_quota".
+ *
+ * Leave blank for server returned quota information to be displayed.
+ *
+ * This setting is only used for IMAP quotas.
+ *
+ * NOTE: Values must be entered in Kilobytes.
+*/
+
+$settings['imap_size_quota'] = '';
+$settings['imap_count_quota'] = '';
+
+
+/*
+ * As cPanel quotas work differently from UNIX or IMAP quotas, we have to
+ * use "du" to calculate these type of quotas. Using "du" can be very
+ * exhaustive for a slow or loaded server. So as a default, we calculate
+ * cPanel quotas only once for a logged in user. To refresh the quota
+ * information the user has to log out and log in again. This option
+ * overrides this behavior and refreshes cPanel quota information on every
+ * refresh of the folders list.
+ *
+ * CAUTION: enabling this may place unnecessarily high load on your server.
+ *
+ * cPanel quota information is always refreshed on the troubleshooting page,
+ * regardless of this option.
+ *
+ * This setting is only used for cPanel quotas.
+ *
+ * Default: Off
+ * 0: Off; calculate quota once at time of login
+ * 1: Always refresh cPanel information
+*/
+
+$settings['always_refresh_cpanel'] = 0;
+
+
+/********************
+ * Troubleshooting *
+ ********************/
+
+/*
+ * Turn this on to see troubleshooting output from server for help
+ * debugging your Check Quota settings. This will add a link to
+ * the "Options" page with the name "Check Quota Troubleshooting".
+ * You should always turn this off when Check Quota is working as
+ * intended.
+ *
+ * Default: Off
+ * 0: Off / 1: On
+*/
+
+$settings['troubleshoot'] = 1;
+
diff -ruN check_quota_old/functions.php check_quota/functions.php
--- check_quota_old/functions.php 2007-08-04 16:58:53.000000000 +0200
+++ check_quota/functions.php 2023-05-22 08:14:04.000000000 +0200
@@ -143,10 +143,11 @@
*/
function check_quota_motd($args)
{
+ global $currentHookName;
if ( !sqgetGlobalVar('just_logged_in', $just_logged_in, SQ_SESSION) || empty($just_logged_in) )
return FALSE;
- if ( get_current_hook_name($args) != 'right_main_after_header' || !sqGetGlobalVar('check_quota_motd_displayed', $check_quota_motd_displayed, SQ_SESSION) || empty($check_quota_motd_displayed) )
+ if ( $currentHookName !== 'right_main_after_header' || !sqGetGlobalVar('check_quota_motd_displayed', $check_quota_motd_displayed, SQ_SESSION) || empty($check_quota_motd_displayed) )
{
global $check_quota;
@@ -214,7 +215,7 @@
* settings and checks the user's quota.
*
*/
- function CheckQuota()
+ function __construct()
{
$this->reset_debug();
$this->load_settings();
@@ -230,7 +231,6 @@
global $settings;
include_once(SM_PATH . 'plugins/check_quota/config.php');
-
$this->settings = $settings;
unset ($settings);
}
diff -ruN check_quota_old/troubleshoot.php check_quota/troubleshoot.php
--- check_quota_old/troubleshoot.php 2007-08-06 11:16:29.000000000 +0200
+++ check_quota/troubleshoot.php 2023-05-22 07:55:31.000000000 +0200
@@ -42,7 +42,7 @@
if ( empty($check_quota->settings['troubleshoot']) )
{
unset($check_quota);
- exit();
+// exit();
}
$cq_to = '<tr><td colspan="2" bgcolor="' . $color[4] . '" align="center"><font color="' . $color[8] . '"><b>';