-
-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathconnect.php
2464 lines (2222 loc) · 89.9 KB
/
connect.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
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
require_once dirname(__FILE__).'/inc/userlib.php';
include_once dirname(__FILE__).'/inc/maillib.php';
include_once dirname(__FILE__).'/inc/php_compat.php';
// set some variables
if (!isset($_GET['pi'])) {
$_GET['pi'] = '';
}
$GLOBALS['mail_error'] = '';
$GLOBALS['mail_error_count'] = 0;
$organisation_name = getConfig('organisation_name');
$domain = getConfig('domain');
$website = getConfig('website');
if (empty($domain)) {
$domain = $_SERVER['SERVER_NAME'];
}
if (empty($website)) {
$website = $_SERVER['SERVER_NAME'];
}
if (empty($organisation_name)) {
$organisation_name = $_SERVER['SERVER_NAME'];
}
$xormask = getConfig('xormask');
if (empty($xormask)) {
$xormask = md5(uniqid(rand(), true));
SaveConfig('xormask', $xormask, 0, 1);
}
define('XORmask', str_repeat($xormask, 20));
$hmackey = getConfig('hmackey');
if (empty($hmackey)) {
$hmackey = bin2hex(random_bytes(256));
SaveConfig('hmackey', $hmackey, 0, 1);
}
define('HMACKEY', $hmackey);
if (empty($_SESSION[$GLOBALS['installation_name'].'_csrf_token'])) {
$_SESSION[$GLOBALS['installation_name'].'_csrf_token'] = bin2hex(random_bytes(16));
}
if (isset($_SESSION['lastactivity'])) {
$_SESSION['session_age'] = time() - $_SESSION['lastactivity'];
}
$_SESSION['lastactivity'] = time();
$GLOBALS['img_tick'] = '<span class="yes">Yes</span>';
$GLOBALS['img_cross'] = '<span class="no">No</span>';
$GLOBALS['img_view'] = '<span class="view">View</span>';
$GLOBALS['img_busy'] = '<img src="images/busy.gif" with="34" height="34" border="0" alt="Please wait" id="busyimage" />';
// if keys need expanding with 0-s
$checkboxgroup_storesize = 1; // this will allow 10000 options for checkboxes
// identify pages that can be run on commandline
$commandline_pages = array(
'initialise',
'dbcheck',
'send',
'processqueue',
'processbounces',
'import',
'upgrade',
'convertstats',
'reindex',
'blacklistemail',
'systemstats',
'converttoutf8',
'initlanguages',
'cron',
'updatetlds',
'export',
'runcommand',
);
if (isset($message_envelope)) {
$envelope = "-f$message_envelope";
}
include_once dirname(__FILE__).'/pluginlib.php';
//# this needs more testing, and docs on how to set the Timezones in the DB
if (defined('SYSTEM_TIMEZONE')) {
// print('set time_zone = "'.SYSTEM_TIMEZONE.'"<br/>');
Sql_Query('set time_zone = "'.SYSTEM_TIMEZONE.'"');
//# verify that it applied correctly
$tz = Sql_Fetch_Row_Query('select @@session.time_zone');
if ($tz[0] != SYSTEM_TIMEZONE) {
//# I18N doesn't exist yet, @@TODO need better error catching here
echo 'Error setting timezone in Sql Database'.'<br/>';
} else {
// print "Mysql timezone set to $tz[0]<br/>";
}
$phptz_set = date_default_timezone_set(SYSTEM_TIMEZONE);
$phptz = date_default_timezone_get();
if (!$phptz_set || $phptz != SYSTEM_TIMEZONE) {
//# I18N doesn't exist yet, @@TODO need better error catching here
echo 'Error setting timezone in PHP'.'<br/>';
} else {
// print "PHP system timezone set to $phptz<br/>";
}
// print "Time now: ".date('Y-m-d H:i:s').'<br/>';
}
//# build a list of themes that are available
$themedir = dirname(__FILE__).'/ui';
$themeNames = array(); // avoid duplicate theme names
$d = opendir($themedir);
while (false !== ($th = readdir($d))) {
if (is_dir($themedir.'/'.$th) && is_file($themedir.'/'.$th.'/theme_info')) {
$themeData = parse_ini_file($themedir.'/'.$th.'/theme_info');
if (false === $themeData || null === $themeData) {
// unable to parse the theme info file so choose the first theme found
$THEMES[$th] = array(
'name' => 'unknown',
'dir' => $th,
);
break;
}
if (!empty($themeData['name']) && !empty($themeData['dir']) && !isset($themeNames[$themeData['name']])) {
$THEMES[$th] = $themeData;
$themeNames[$themeData['name']] = $th;
}
}
}
if (count($THEMES) > 1 && THEME_SWITCH) {
unset($THEMES['default']); // the default theme can be hidden if others are available
unset($themeNames['phpList Default']);
$default_config['UITheme'] = array(
'value' => isset($_SESSION['ui']) ? $_SESSION['ui'] : '',
'values' => array_flip($themeNames),
'description' => s('Theme for phpList'),
'type' => 'select',
'allowempty' => false,
'category' => 'general',
'hidden' => false,
);
}
unset($themeNames);
if (!empty($GLOBALS['SessionTableName'])) { // rather undocumented feature, but seems to be used by some
include_once dirname(__FILE__).'/sessionlib.php';
}
if (!isset($table_prefix)) {
$table_prefix = '';
}
if (!isset($usertable_prefix)) {
$usertable_prefix = $table_prefix;
}
/* set session name, without revealing version
* but with version included, so that upgrading works more smoothly
*/
/* hmm, won't work, going around in circles. Session is started in languages, where the DB
* is not known yet, so we can't read xormask from the DB yet*/
//ini_set('session.name','phpList-'.$GLOBALS['installation_name'].VERSION | $xormask);
$redfont = '';
$efont = '';
$GLOBALS['coderoot'] = dirname(__FILE__).'/';
$GLOBALS['mail_error'] = '';
$GLOBALS['mail_error_count'] = 0;
function SaveConfig($item, $value, $editable = 1, $ignore_errors = 0)
{
global $tables;
//# in case DB hasn't been initialised
if (empty($_SESSION['hasconf'])) {
$_SESSION['hasconf'] = Sql_Table_Exists($tables['config']);
}
if (empty($_SESSION['hasconf'])) {
return;
}
if (isset($GLOBALS['default_config'][$item])) {
$configInfo = $GLOBALS['default_config'][$item];
} else {
$configInfo = array(
'type' => 'unknown',
'allowempty' => true,
'value' => '',
);
}
//# to validate we need the actual values
$value = str_ireplace('[domain]', $GLOBALS['domain'], $value);
$value = str_ireplace('[website]', $GLOBALS['website'], $value);
switch ($configInfo['type']) {
case 'boolean':
if ($value == 'false' || $value == 'no') {
$value = 0;
} elseif ($value == 'true' || $value == 'yes') {
$value = 1;
}
break;
case 'integer':
$value = sprintf('%d', $value);
if ($value < $configInfo['min']) {
$value = $configInfo['min'];
}
if ($value > $configInfo['max']) {
$value = $configInfo['max'];
}
break;
case 'email':
if (!empty($value) && !is_email($value)) {
//# hmm, this is displayed only later
// $_SESSION['action_result'] = s('Invalid value for email address');
return $configInfo['description'].': '.s('Invalid value for email address');
$value = '';
}
break;
case 'emaillist':
if (!empty($value)) {
$valid = array();
$hasError = false;
$emails = explode(',', $value);
foreach ($emails as $email) {
if (is_email($email)) {
$valid[] = $email;
} else {
$hasError = true;
}
}
$value = implode(',', $valid);
/*
* hmm, not sure this is good or bad for UX
*
*/
if ($hasError) {
return $configInfo['description'].': '.s('Invalid value for email address');
}
}
break;
case 'image':
include 'class.image.inc';
$image = new imageUpload();
$imageId = $image->uploadImage($item, 0);
# if ($imageId) {
$value = $imageId;
# }
//# we only use the image type for the logo
flushLogoCache();
break;
default:
if (isset($configInfo['allowtags'])) { ## allowtags can be set but empty
$value = strip_tags($value,$configInfo['allowtags']);
}
if (isset($configInfo['allowJS']) && !$configInfo['allowJS']) { ## it needs to be set and false
$value = disableJavascript($value);
}
}
//# reset to default if not set, and required
if (empty($configInfo['allowempty']) && empty($value)) {
$value = $configInfo['value'];
}
if (!empty($configInfo['hidden'])) {
$editable = 0;
}
//# force reloading config values in session
unset($_SESSION['config']);
//# and refresh the config immediately https://mantis.phplist.com/view.php?id=16693
unset($GLOBALS['config']);
Sql_Query(sprintf('replace into %s set item = "%s", value = "%s", editable = %d', $tables['config'],
sql_escape($item), sql_escape($value), $editable));
return false; //# true indicates error, and which one
}
/*
We request you retain the $PoweredBy variable including the links.
This not only gives respect to the large amount of time given freely
by the developers but also helps build interest, traffic and use of
PHPlist, which is beneficial to it's future development.
You can configure your PoweredBy options in your config file
Michiel Dethmers, phpList Ltd 2001-2015
*/
if (DEVVERSION) {
$v = 'dev';
} else {
$v = VERSION;
}
if (REGISTER) {
$PoweredByImage = '<p class="poweredby" style="text-align:center"><a href="https://www.phplist.com/poweredby?utm_source=pl'.$v.'&utm_medium=poweredhostedimg&utm_campaign=phpList" title="visit the phpList website" ><img src="'.PHPLIST_POWEREDBY_URLROOT.'/'.$v.'/power-phplist.png" title="powered by phpList version '.$v.', © phpList ltd" alt="powered by phpList '.$v.', © phpList ltd" border="0" /></a></p>';
} else {
$PoweredByImage = '<p class="poweredby" style="text-align:center"><a href="https://www.phplist.com/poweredby?utm_source=pl'.$v.'&utm_medium=poweredlocalimg&utm_campaign=phpList" title="visit the phpList website"><img src="images/power-phplist.png" title="powered by phpList version '.$v.', © phpList ltd" alt="powered by phpList '.$v.', © phpList ltd" border="0"/></a></p>';
}
$PoweredByText = '<div style="clear: both; font-family: arial, verdana, sans-serif; font-size: 8px; font-variant: small-caps; font-weight: normal; padding: 2px; padding-left:10px;padding-top:20px;">powered by <a href="https://www.phplist.com/poweredby?utm_source=download'.$v.'&utm_medium=poweredtxt&utm_campaign=phpList" target="_blank" title="powered by phpList version '.$v.', © phpList ltd">phpList</a></div>';
if (!TEST && REGISTER) {
if (!PAGETEXTCREDITS) {
$PoweredBy = $PoweredByImage;
} else {
$PoweredBy = $PoweredByText;
}
} else {
if (!PAGETEXTCREDITS) {
$PoweredBy = $PoweredByImage;
} else {
$PoweredBy = $PoweredByText;
}
}
// some other configuration variables, which need less tweaking
// number of users to show per page if there are more
if (!defined('MAX_USER_PP')) {
define('MAX_USER_PP', 50);
}
if (!defined('MAX_MSG_PP')) {
define('MAX_MSG_PP', 5);
}
// Used by e.g. mviews.php
if (!defined('MAX_OPENS_PP')) {
define('MAX_OPENS_PP', 20);
}
function formStart($additional = '')
{
global $form_action, $page, $p;
// depending on server software we can post to the directory, or need to pass on the page
if ($form_action) {
$html = sprintf('<form method="post" action="%s" %s>', $form_action, $additional);
// retain all get variables as hidden ones
foreach (array(
'p',
'page',
) as $key) {
$val = $_REQUEST[$key];
if ($val) {
$html .= sprintf('<input type="hidden" name="%s" value="%s" />', $key, htmlspecialchars($val));
}
}
} else {
$html = sprintf('<form method="post" action="" %s>', $additional);
}
if (!empty($_SESSION['logindetails']['id'])) {
//# create the token table, if necessary
if (!Sql_Check_For_Table('admintoken')) {
createTable('admintoken');
}
$key = bin2hex(random_bytes(16));
Sql_Query(sprintf('insert into %s (adminid,value,entered,expires) values(%d,"%s",%d,date_add(now(),interval 1 hour))',
$GLOBALS['tables']['admintoken'], $_SESSION['logindetails']['id'], $key, time()), 1);
$html .= sprintf('<input type="hidden" name="formtoken" value="%s" />', $key);
//# keep the token table empty
Sql_Query(sprintf('delete from %s where expires < now()',
$GLOBALS['tables']['admintoken']), 1);
}
return $html;
}
function checkAccess($page, $pluginName = '')
{
if (empty($pluginName)) {
if (!$GLOBALS['commandline'] && isset($GLOBALS['disallowpages']) && in_array($page,
$GLOBALS['disallowpages'])
) {
return 0;
}
} else {
if (!$GLOBALS['commandline'] && isset($GLOBALS['disallowpages']) && in_array($page.'&pi='.$pluginName,
$GLOBALS['disallowpages'])
) {
return 0;
}
}
/*
if (isSuperUser())
return 1;
*/
//# we allow all that haven't been disallowed
//# might be necessary to turn that around
return 1;
}
function isSuperUser()
{
//# for now mark webbler admins superuser
if (defined('WEBBLER') || defined('IN_WEBBLER')) {
return true;
}
if (!empty($GLOBALS['firsttime'])) {
return true;
}
if (!empty($GLOBALS['commandline'])) {
return true;
}
global $tables;
$issuperuser = 0;
// if (!isset($_SESSION["adminloggedin"])) return 0;
// if (!is_array($_SESSION["logindetails"])) return 0;
if (isset($_SESSION['logindetails']['superuser'])) {
return $_SESSION['logindetails']['superuser'];
}
if (isset($_SESSION['logindetails']['id'])) {
if (is_object($GLOBALS['admin_auth'])) {
$issuperuser = $GLOBALS['admin_auth']->isSuperUser($_SESSION['logindetails']['id']);
} else {
$req = Sql_Fetch_Row_Query(sprintf('select superuser from %s where id = %d', $tables['admin'],
$_SESSION['logindetails']['id']));
$issuperuser = $req[0];
}
$_SESSION['logindetails']['superuser'] = $issuperuser;
}
return !empty($issuperuser);
}
//@@TODO centralise the reporting and who gets what
function sendReport($subject, $message)
{
$report_addresses = getConfig('report_address');
if ($report_addresses) {
foreach (explode(',', $report_addresses) as $address) {
sendMail($address, $GLOBALS['installation_name'].' '.$subject, $message);
}
}
foreach ($GLOBALS['plugins'] as $pluginname => $plugin) {
$plugin->sendReport($GLOBALS['installation_name'].' '.$subject, $message);
}
}
function sendError($message, $to, $subject)
{
foreach ($GLOBALS['plugins'] as $pluginname => $plugin) {
$plugin->sendError($GLOBALS['installation_name'].' Error: '.$subject, $message);
}
// Error($msg);
}
function sendMessageStats($msgid)
{
global $stats_collection_address, $tables;
$msg = '';
if (defined('NOSTATSCOLLECTION') && NOSTATSCOLLECTION) {
return;
}
if (!isset($stats_collection_address)) {
$stats_collection_address = 'phplist-stats@phplist.com';
}
$data = Sql_Fetch_Array_Query(sprintf('select * from %s where id = %d', $tables['message'], $msgid));
$msg .= 'phpList version '.VERSION."\n";
$msg .= 'phpList url '.getConfig("website")."\n";
$diff = timeDiff($data['sendstart'], $data['sent']);
if ($data['id'] && $data['processed'] > 10 && $diff != 'very little time') {
$msg .= "\n".'Time taken: '.$diff;
foreach (array(
'entered',
'processed',
'sendstart',
'sent',
'htmlformatted',
'sendformat',
'template',
'astext',
'ashtml',
'astextandhtml',
'aspdf',
'astextandpdf',
) as $item) {
$msg .= "\n".$item.' => '.$data[$item];
}
sendMail($stats_collection_address, 'phpList stats', $msg, '', '', true);
}
}
function normalize($var)
{
$var = str_replace(' ', '_', $var);
$var = str_replace(';', '', $var);
return $var;
}
function ClineSignature()
{
return 'phpList version '.VERSION.' (c) 2000-'.date('Y')." phpList Ltd, https://www.phplist.com";
}
function ClineError($msg, $documentationURL = '')
{
ob_end_clean();
echo PHP_EOL."Error: $msg\n";
if (!empty($documentationURL)) {
echo PHP_EOL.s("For more information: "). $documentationURL;
}
exit;
}
function clineUsage($line = '')
{
cl_output( 'Usage: '.$_SERVER['SCRIPT_FILENAME']." -p page $line".PHP_EOL);
}
function Error($msg, $documentationURL = '')
{
if ($GLOBALS['commandline']) {
clineError($msg, $documentationURL);
return;
}
echo '<div class="error">'.s('error').": $msg ";
if (!empty($documentationURL)) {
echo resourceLink($documentationURL);
}
echo '</div>';
$GLOBALS['mail_error'] .= 'Error: '.$msg."\n";
++$GLOBALS['mail_error_count'];
if (is_array($_POST) && count($_POST)) {
$GLOBALS['mail_error'] .= "\nPost vars:\n";
foreach ($_POST as $key => $val) {
if ($key != 'password') {
if (is_array($val)) {
$GLOBALS['mail_error'] .= $key.'='.serialize($val)."\n";
} else {
$GLOBALS['mail_error'] .= $key.'='.$val."\n";
}
} else {
$GLOBALS['mail_error'] .= "password=********\n";
}
}
}
}
function clean($value)
{
$value = trim($value);
$value = preg_replace("/\r/", '', $value);
$value = preg_replace("/\n/", '', $value);
$value = str_replace('"', '"', $value);
$value = str_replace("'", '’', $value);
$value = str_replace('`', '‘', $value);
$value = stripslashes($value);
return $value;
}
function join_clean($sep, $array)
{
// join values without leaving a , at the end
$arr2 = array();
foreach ($array as $key => $val) {
if ($val) {
$arr2[$key] = $val;
}
}
return implode($sep, $arr2);
}
function Fatal_Error($msg, $documentationURL = '')
{
if (empty($_SESSION['fatalerror'])) {
$_SESSION['fatalerror'] = 0;
}
++$_SESSION['fatalerror'];
header('HTTP/1.0 500 Fatal error');
if ($_SESSION['fatalerror'] > 5) {
$_SESSION['logout_error'] = s('Too many errors, please login again');
$_SESSION['adminloggedin'] = '';
$_SESSION['logindetails'] = '';
session_destroy();
Redirect('logout&err=2');
exit;
}
if ($GLOBALS['commandline']) {
@ob_end_clean();
echo "\n".$GLOBALS['I18N']->get('fatalerror').': '.strip_tags($msg)."\n";
@ob_start();
} else {
@ob_end_clean();
if (isset($GLOBALS['I18N']) && is_object($GLOBALS['I18N'])) {
echo '<div align="center" class="error">'.$GLOBALS['I18N']->get('fatalerror').": $msg ";
} else {
echo '<div align="center" class="error">'."Fatal Error: $msg ";
}
if (!empty($documentationURL)) {
echo resourceLink($documentationURL);
}
echo '</div>';
foreach ($GLOBALS['plugins'] as $pluginname => $plugin) {
$plugin->processError($msg);
}
}
// include "footer.inc";
// exit;
return 0;
}
function resourceLink($url, $title = '')
{
if (empty($title)) {
$title = s('Documentation about this error');
}
return ' <span class="resourcelink"><a href="'.$url.'" title="'.htmlspecialchars($title).'" target="_blank" class="resourcelink">'.snbr('More information').'</a></span>';
}
function Warn($msg)
{
if ($GLOBALS['commandline']) {
@ob_end_clean();
echo "\n".strip_tags($GLOBALS['I18N']->get('warning').': '.$msg)."\n";
@ob_start();
} else {
echo '<div align=center class="error">'."$msg </div>";
$message = '
An warning has occurred in the Mailinglist System
' .$msg;
}
// sendMail(getConfig("report_address"),"Mail list warning",$message,"");
}
function Info($msg, $noClose = false)
{
if (!empty($GLOBALS['commandline'])) {
@ob_end_clean();
echo "\n".strip_tags($msg)."\n";
@ob_start();
} else {
//# generate some ID for the info div
$id = substr(md5($msg), 0, 15);
$pageinfo = new pageInfo($id);
$pageinfo->setContent('<p>'.$msg.'</p>');
if ($noClose && method_exists($pageinfo, 'suppressHide')) {
$pageinfo->suppressHide();
}
echo $pageinfo->show();
}
}
function ActionResult($msg)
{
if ($GLOBALS['commandline']) {
@ob_end_clean();
echo "\n".strip_tags($msg)."\n";
@ob_start();
} else {
return '<div class="actionresult">'.$msg.'</div>';
}
}
function pageTitle($page)
{
return $GLOBALS['I18N']->pageTitle($page);
}
$GLOBALS['pagecategories'] = array(
//# category title => array(
// toplink => page to link top menu to
// pages => pages in this category
'dashboard' => array(
'toplink'=> 'home',
'pages' => array(),
'menulinks' => array(),
),
'subscribers' => array(
'toplink' => 'list',
'pages' => array(
'users',
'usermgt',
'members',
'import',
'import1',
'import2',
'import3',
'import4',
'importsimple',
'dlusers',
'export',
'listbounces',
'massremove',
'suppressionlist',
'reconcileusers',
'usercheck',
'user',
'adduser',
'attributes',
),
'menulinks' => array(
'users',
'usermgt',
'attributes',
'list',
'import',
'export',
'listbounces',
'suppressionlist',
'reconcileusers',
),
),
'campaigns' => array(
'toplink' => 'messages',
'pages' => array(
'send',
'sendprepared',
'message',
'messages',
'viewmessage',
'templates',
'template',
'viewtemplate',
),
'menulinks' => array(
'send',
'messages',
'templates',
),
),
'statistics' => array(
'toplink' => 'statsmgt',
'pages' => array(
'mviews',
'mclicks',
'uclicks',
'userclicks',
'statsmgt',
'statsoverview',
'domainstats',
'msgbounces',
),
'menulinks' => array(
'statsoverview',
'mviews',
'mclicks',
'uclicks',
'domainstats',
'msgbounces',
),
),
'system' => array(
'toplink' => 'system',
'pages' => array(
'bounce',
'bounces',
'convertstats',
'dbcheck',
'eventlog',
'bouncemgt',
'generatebouncerules',
'initialise',
'upgrade',
'processqueue',
'processbounces',
'reindex',
'resetstats',
'updatetranslation',
),
'menulinks' => array(
// 'bounces',
'updatetranslation',
'dbcheck',
'eventlog',
'initialise',
'upgrade',
'bouncemgt',
'processqueue',
// 'processbounces',
'reindex',
),
),
'config' => array(
'toplink' => 'setup',
'pages' => array(
'setup',
'configure',
'plugins',
'catlists',
'spage',
'spageedit',
'editattributes',
'defaults',
'bouncerules',
'bouncerule',
'checkbouncerules',
),
'menulinks' => array(
'setup',
'configure',
'plugins',
'spage',
'bouncerules',
'checkbouncerules',
'catlists',
),
),
//'info' => array(
//'toplink' => 'about',
//'pages' => array(
//'about',
//'community',
//'home',
// 'translate',
//'vote',
//),
//'menulinks' => array(
// 'about',
//'community',
// 'translate',
//'home',
//),
//),
//'plugins' => array(
//'toplink' => 'plugins',
//'pages' => array(),
//'menulinks' => array(),
//),
);
if (DEVVERSION) {
$GLOBALS['pagecategories']['develop'] = array(
'toplink' => 'develop',
'pages' => array(
// 'checki18n',
'stresstest',
'subscriberstats',
'tests',
),
'menulinks' => array(
// 'checki18n',
'stresstest',
'subscriberstats',
'tests',
),
);
}
function pageCategory($page)
{
foreach ($GLOBALS['pagecategories'] as $category => $cat_details) {
if (in_array($page, $cat_details['pages'])) {
return $category;
}
}
return '';
}
/*
$main_menu = array(
"configure" => "Configure",
"community" => "Help",
"about" => "About",
"div1" => "<hr />",
"list" => "Lists",
"send"=>"Send a message",
"users" => "Users",
"usermgt" => "Manage Users",
"spage" => "Subscribe Pages",
"messages" => "Messages",
'statsmgt' => 'Statistics',
"div2" => "<hr />",
"templates" => "Templates",
"preparesend"=>"Prepare a message",
"sendprepared"=>"Send a prepared message",
"processqueue"=>"Process Queue",
"processbounces"=>"Process Bounces",
"bouncemgt" => 'Manage Bounces',
"bounces"=>"View Bounces",
"eventlog"=>"Eventlog"
);
*/
$GLOBALS['context_menu'] = array(
'home' => 'home',
'community' => 'help',
'about' => 'about',
'logout' => 'logout',
);
function contextMenu()
{
if (isset($GLOBALS['firsttime']) || (isset($_GET['page']) && $_GET['page'] == 'initialise')) {
return;
}
if (!CLICKTRACK) {
unset($GLOBALS['context_menu']['statsmgt']);
}
$shade = 1;
$spb = '<li class="shade0">';
// $spb = '<li class="shade2">';
$spe = '</li>';
$nm = mb_strtolower(NAME);
if ($nm != 'phplist') {
$GLOBALS['context_menu']['community'] = '';
}
// if (USE_ADVANCED_BOUNCEHANDLING) {
$GLOBALS['context_menu']['bounces'] = '';
$GLOBALS['context_menu']['processbounces'] = '';
// } else {
// $GLOBALS["context_menu"]["bouncemgt"] = '';
// }
if (!isset($_SESSION['adminloggedin']) || !$_SESSION['adminloggedin']) {
return '<ul class="contextmenu">'.$spb.PageLink2('home',
$GLOBALS['I18N']->get('Main Page')).'<br />'.$spe.$spb.PageLink2('about',
$GLOBALS['I18N']->get('about').' phplist').'<br />'.$spe.'</ul>';
}
$access = accessLevel('spage');
switch ($access) {
case 'owner':
$subselect = sprintf(' where owner = %d', $_SESSION['logindetails']['id']);
break;
case 'all':
case 'view':
$subselect = '';
break;
case 'none':
default:
$subselect = ' where id = 0';
break;
}
if (TEST && REGISTER) {
$pixel = '<img src="https://d3u7tsw7cvar0t.cloudfront.net/images/pixel.gif" width="1" height="1" alt="" />';
} else {
$pixel = '';
}
global $tables;
$html = '';
if (isset($_GET['page'])) {
$thispage = $_GET['page'];
} else {
$thispage = 'home';
}
$thispage_category = pageCategory($thispage);
if (empty($thispage_category) && empty($_GET['pi'])) {
$thispage_category = '';
} elseif (!empty($_GET['pi'])) {
$thispage_category = 'plugins';
}
if (!empty($thispage_category) && !empty($GLOBALS['pagecategories'][$thispage_category]['menulinks'])) {
if (count($GLOBALS['pagecategories'][$thispage_category]['menulinks'])) {
foreach ($GLOBALS['pagecategories'][$thispage_category]['menulinks'] as $category_page) {
$GLOBALS['context_menu'][$category_page] = $category_page;
}
} else {
unset($GLOBALS['context_menu']['categoryheader']);
}
} elseif (!empty($_GET['pi'])) {
if (isset($GLOBALS['plugins'][$_GET['pi']]) && method_exists($GLOBALS['plugins'][$_GET['pi']], 'adminmenu')) {
$GLOBALS['context_menu']['categoryheader'] = $GLOBALS['plugins'][$_GET['pi']]->name;
$GLOBALS['context_menu'] = $GLOBALS['plugins'][$_GET['pi']]->adminMenu();
}
}
foreach ($GLOBALS['context_menu'] as $page => $desc) {
if (!$desc) {
continue;
}
$link = PageLink2($page, $GLOBALS['I18N']->pageTitle($desc));
if ($link) {
if ($page == 'preparesend' || $page == 'sendprepared') {
if (USE_PREPARE) {
$html .= $spb.$link.$spe;
}
} // don't use the link for a rule
elseif ($desc == '<hr />') {
$html .= '<li>'.$desc.'</li>';
} elseif ($page == 'categoryheader') {
// $html .= '<li><h3>'.$GLOBALS['I18N']->get($thispage_category).'</h3></li>';
$html .= '<li><h3>'.$GLOBALS['I18N']->get('In this section').'</h3></li>';
} else {
$html .= $spb.$link.$spe;
}
}
}
/*
if (sizeof($GLOBALS["plugins"])) {
$html .= $spb."<hr/>".$spe;
foreach ($GLOBALS["plugins"] as $pluginName => $plugin) {
$html .= $spb.PageLink2("main&pi=$pluginName",$pluginName).$spe;
}
}
*/