/usr/share/squirrelmail/plugins/lockout/functions.php is in squirrelmail-lockout 1.7-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 | <?php
/**
* SquirrelMail Lockout Plugin
* Copyright (c) 2003-2010 Paul Lesniewski <paul@squirrelmail.org>
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* @package plugins
* @subpackage lockout
*
*/
/**
* Initialize this plugin (load config values)
*
* @return boolean FALSE if no configuration file could be loaded, TRUE otherwise
*
*/
function lockout_init()
{
if (!@include_once (SM_PATH . 'plugins/lockout/data/config.php'))
return FALSE;
return TRUE;
}
/**
* Validate that this plugin is configured correctly
*
* @return boolean Whether or not there was a
* configuration error for this plugin.
*
*/
function lockout_configtest_do()
{
// make sure base config is available
//
if (!lockout_init())
{
do_err('Lockout plugin is missing its main configuration file', FALSE);
return TRUE;
}
// make sure the lockout rules configuration is in place if necessary
//
global $use_lockout_rules;
if ($use_lockout_rules)
{
if (!file_exists(SM_PATH . 'plugins/lockout/data/lockout_table.php')
|| !is_readable(SM_PATH . 'plugins/lockout/data/lockout_table.php'))
{
do_err('Lockout plugin lockout rules file is missing (data/lockout_table.php)', FALSE);
return TRUE;
}
}
// make sure config settings are in correct format
//
global $max_login_attempts;
if (!empty($max_login_attempts)
&& !preg_match('/^\d+:\d+:\d+$/', $max_login_attempts))
{
do_err('Lockout plugin is misconfigured: $max_login_attempts must be in the form "n:n:n", where each "n" must be a number', FALSE);
return TRUE;
}
global $max_login_attempts_per_IP;
if (!empty($max_login_attempts_per_IP)
&& !preg_match('/^\d+:\d+:\d+$/', $max_login_attempts_per_IP))
{
do_err('Lockout plugin is misconfigured: $max_login_attempts_per_IP must be in the form "n:n:n", where each "n" must be a number', FALSE);
return TRUE;
}
global $activate_CAPTCHA_after_failed_attempts;
if (!empty($activate_CAPTCHA_after_failed_attempts)
&& !preg_match('/^\d+:\d+:\d+(:\d+|)$/', $activate_CAPTCHA_after_failed_attempts))
{
do_err('Lockout plugin is misconfigured: $activate_CAPTCHA_after_failed_attempts must be in the form "n:n:n:n", where each "n" must be a number', FALSE);
return TRUE;
}
// make sure the CAPTCHA plugin is available when needed
//
if ($activate_CAPTCHA_after_failed_attempts
&& !check_plugin_version('captcha', 1, 0, 0, TRUE))
{
do_err('Lockout plugin is configured to use the CAPTCHA plugin, but the CAPTCHA plugin was not found', FALSE);
return TRUE;
}
// only need to do this pre-1.5.2, as 1.5.2 will make this
// check for us automatically
//
if (!check_sm_version(1, 5, 2))
{
// try to find Compatibility, and then that it is v2.0.7+
//
if (function_exists('check_plugin_version')
&& check_plugin_version('compatibility', 2, 0, 7, TRUE))
return FALSE;
// something went wrong
//
do_err('Lockou plugin requires the Compatibility plugin version 2.0.7+', FALSE);
return TRUE;
}
return FALSE;
}
/**
* Make sure this plugin fires the LAST on the login_before
* hook, but before any plugins that might show different
* logout error (captcha, <others?>)
*
*/
function move_lockout_to_end_of_login_before_hook_do()
{
global $PHP_SELF;
if (stristr($PHP_SELF, '/redirect.php'))
{
reposition_plugin_on_hook('lockout', 'login_before', FALSE);
reposition_plugin_on_hook('captcha', 'login_before', FALSE);
}
}
/**
* Activate the CAPTCHA plugin if need be
*
*/
function activate_captcha_plugin_do($args)
{
global $data_dir, $activate_CAPTCHA_after_failed_attempts,
$prefs_dsn, $prefs_are_cached, $prefs_cache, $null;
lockout_init();
if (!$activate_CAPTCHA_after_failed_attempts
|| !sqGetGlobalVar('REMOTE_ADDR', $remote_addr, SQ_SERVER))
return;
// eiw - a bit messy, but we need to have prefs
// functions here on the login page where they
// are not usually needed - borrowed from init.php
// and NOT tested with custom pref backends
//
if (check_sm_version(1, 5, 2))
{
/* more recently, 1.5.2 fixed this issue......
include_once(SM_PATH . 'functions/strings.php');
include_once(SM_PATH . 'functions/prefs.php');
$prefs_backend = do_hook('prefs_backend', $null);
if (isset($prefs_backend) && !empty($prefs_backend) && file_exists(SM_PATH . $prefs_backend)) {
include_once(SM_PATH . $prefs_backend);
} elseif (isset($prefs_dsn) && !empty($prefs_dsn)) {
include_once(SM_PATH . 'functions/db_prefs.php');
} else {
include_once(SM_PATH . 'functions/file_prefs.php');
}
*/
}
else
include_once(SM_PATH . 'functions/prefs.php');
// check if IP addr has been locked out
// because of too many login failures
//
// note how we unset the prefs cache flag before/after this
// code so as not to corrupt any prefs for the user who is
// currently logging in
//
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
$enable_captcha = getPref($data_dir, 'lockout_plugin_login_failure_information', $remote_addr . '_CAPTCHA_TOO_MANY_FAILED_LOGIN_ATTEMPTS', '');
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
if ($enable_captcha)
{
// is the lockout window over? if so, clear all
// lockout preference settings, otherwise turn on CAPTCHA
//
if (is_numeric($enable_captcha) && time() > $enable_captcha)
{
setPref($data_dir, 'lockout_plugin_login_failure_information', $remote_addr . '_CAPTCHA_TOO_MANY_FAILED_LOGIN_ATTEMPTS', '');
setPref($data_dir, 'lockout_plugin_login_failure_information', $remote_addr . '_CAPTCHA_login_failure_times', '');
// clear prefs cache again
//
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
$enable_captcha = '';
}
else
{
add_plugin('captcha', $args);
}
}
}
/**
* Activate the CAPTCHA plugin (receiving end) if need be
*
*/
function activate_captcha_plugin_check_code_do($args)
{
global $data_dir, $activate_CAPTCHA_after_failed_attempts,
$prefs_are_cached, $prefs_cache;
lockout_init();
if (!$activate_CAPTCHA_after_failed_attempts
|| !sqGetGlobalVar('REMOTE_ADDR', $remote_addr, SQ_SERVER))
return;
// check if IP addr has been locked out
// because of too many login failures
//
// note how we unset the prefs cache flag before/after this
// code so as not to corrupt any prefs for the user who is
// currently logging in
//
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
$enable_captcha = getPref($data_dir, 'lockout_plugin_login_failure_information', $remote_addr . '_CAPTCHA_TOO_MANY_FAILED_LOGIN_ATTEMPTS', '');
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
if ($enable_captcha)
{
add_plugin('captcha', $args);
}
}
/**
* Checks for prior violations of maximum failed login attempts
* as well as the rules for what users can and can't log in.
*
*/
function check_lockout_do($args)
{
global $data_dir, $login_username, $at, $reverseLockout,
$use_lockout_rules, $prefs_are_cached, $prefs_cache,
$max_login_attempts, $max_login_attempts_per_IP,
$obey_x_forwarded_headers;
lockout_init();
if ($max_login_attempts)
{
// first, check if user has already been locked out
// because they had too many login failures
//
// note how we unset the prefs cache flag before/after this
// code so as not to corrupt any prefs for the user who is
// currently logging in
//
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
$locked_out = getPref($data_dir, 'lockout_plugin_login_failure_information', $login_username . '_TOO_MANY_FAILED_LOGIN_ATTEMPTS', '');
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
if ($locked_out)
{
// is the lockout window over? if so, clear all
// lockout preference settings, otherwise error out
//
if (is_numeric($locked_out) && time() > $locked_out)
{
setPref($data_dir, 'lockout_plugin_login_failure_information', $login_username . '_TOO_MANY_FAILED_LOGIN_ATTEMPTS', '');
setPref($data_dir, 'lockout_plugin_login_failure_information', $login_username . '_login_failure_times', '');
// clear prefs cache again
//
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
$locked_out = '';
}
else
{
sq_change_text_domain('lockout');
logout_error(_("Access denied. Please contact your system administrator."));
exit;
}
}
}
if ($max_login_attempts_per_IP
&& sqGetGlobalVar('REMOTE_ADDR', $remote_addr, SQ_SERVER))
{
// first, check if IP addr has already been locked out
// because of too many login failures
//
// note how we unset the prefs cache flag before/after this
// code so as not to corrupt any prefs for the user who is
// currently logging in
//
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
$locked_out = getPref($data_dir, 'lockout_plugin_login_failure_information', $remote_addr . '_TOO_MANY_FAILED_LOGIN_ATTEMPTS', '');
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
if ($locked_out)
{
// is the lockout window over? if so, clear all
// lockout preference settings, otherwise error out
//
if (is_numeric($locked_out) && time() > $locked_out)
{
setPref($data_dir, 'lockout_plugin_login_failure_information', $remote_addr . '_TOO_MANY_FAILED_LOGIN_ATTEMPTS', '');
setPref($data_dir, 'lockout_plugin_login_failure_information', $remote_addr . '_login_failure_times', '');
// clear prefs cache again
//
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
$locked_out = '';
}
else
{
sq_change_text_domain('lockout');
logout_error(_("Access denied. Please contact your system administrator."));
exit;
}
}
}
// now, proceed with checking lockout rules if necessary
//
if (!$use_lockout_rules)
{
activate_captcha_plugin_check_code_do($args);
return;
}
$user = $login_username;
// grab hostname into local var
//
$host = '';
if (!$obey_x_forwarded_headers
|| !sqGetGlobalVar('HTTP_X_FORWARDED_HOST', $host, SQ_SERVER))
sqGetGlobalVar('HTTP_HOST', $host, SQ_SERVER);
// get the domain from the username, since it might
// be different than the domain being used to log in
//
if (strpos($user, $at) !== FALSE)
$usersDomain = substr($user, strpos($user, $at) + 1);
else
$usersDomain = '';
if ($LOCKOUTTABLE = @fopen (SM_PATH . 'plugins/lockout/data/lockout_table.php', 'r'))
{
while (!feof($LOCKOUTTABLE))
{
$line = fgets($LOCKOUTTABLE, 4096);
$line = trim($line);
// skip blank lines and comment lines and php
// open/close tag lines
//
if (strpos($line, '#') === 0 || strlen($line) < 3
|| strpos($line, '<?php') === 0 || strpos($line, '*/ ?>') === 0)
continue;
// if we have a hostname from the username, see if this is
// a domain lockout line
//
if (!empty($usersDomain) && preg_match('/^\s*domain:\s*(\S+)\s+(.+)\s*$/', $line, $matches))
{
// check for match with hostname, redirect if found
//
if (preg_match('/^' . str_replace(array('?', '*'), array('\w{1}', '.*?'),
strtoupper($matches[1])) . '$/', strtoupper($usersDomain)))
{
fclose($LOCKOUTTABLE);
if ($reverseLockout)
{
activate_captcha_plugin_check_code_do($args);
return;
}
lockout_redirect($matches[2]);
}
}
// if we were given a hostname, see if this is
// a domain lockout line
//
if (!empty($host) && preg_match('/^\s*domain:\s*(\S+)\s+(.+)\s*$/', $line, $matches))
{
// check for match with hostname, redirect if found
//
if (preg_match('/^' . str_replace(array('?', '*'), array('\w{1}', '.*?'),
strtoupper($matches[1])) . '$/', strtoupper($host)))
{
fclose($LOCKOUTTABLE);
if ($reverseLockout)
{
activate_captcha_plugin_check_code_do($args);
return;
}
lockout_redirect($matches[2]);
}
}
// if we were given a username, see if this is
// a user lockout line
//
if (!empty($user) && preg_match('/^\s*user:\s*(\S+)\s+(.+)\s*$/', $line, $matches))
{
// check for match with username, redirect if found
//
if (preg_match('/^' . str_replace(array('?', '*'), array('\w{1}', '.*?'),
strtoupper($matches[1])) . '$/', strtoupper($user)))
{
fclose($LOCKOUTTABLE);
if ($reverseLockout)
{
activate_captcha_plugin_check_code_do($args);
return;
}
lockout_redirect($matches[2]);
}
}
}
fclose($LOCKOUTTABLE);
// if we are reversing functionality, lockout anyone
// not found in the lockout file
//
if ($reverseLockout)
lockout_redirect($reverseLockout);
}
activate_captcha_plugin_check_code_do($args);
}
/**
* Redirect current page request to another page,
* or the built in (fake) login error page.
*
* We also log lockout rules violation events here.
*
*/
function lockout_redirect($uri)
{
// log this event - note that to use this,
// you'll need to have the Squirrel Logger plugin
// installed and activated and you'll have to add
// a "LOCKOUT" event type to its configuration
//
global $log_violated_lockout_rules, $login_username;
if ($log_violated_lockout_rules && is_plugin_enabled('squirrel_logger'))
{
include_once(SM_PATH . 'plugins/squirrel_logger/functions.php');
sl_logit('LOCKOUT', sprintf('User "%s" has tripped lockout rules; login disallowed', $login_username));
}
sqsession_destroy();
if (strpos($uri, 'http') === 0)
{
header('Location: ' . $uri);
}
else if ($uri == '##BAD_LOGIN_PAGE##')
{
include_once (SM_PATH . 'functions/display_messages.php');
// simulate delay
sleep(5);
global $locked_out_per_lockout_rules;
$locked_out_per_lockout_rules = TRUE;
logout_error( _("Unknown user or password incorrect.") );
// Why did I choose this string before? The above is better, right?
//logout_error( _("You must be logged in to access this page.") );
}
else
{
$location = get_location();
// need to trim off the last directory off the location path
//
$location = substr($location, 0, strrpos($location, '/'));
header('Location: ' . $location . '/plugins/lockout/' . $uri);
}
exit;
}
/**
* Valid login - reset failure count
*
*/
function reset_failed_login_count_do()
{
global $prefs_are_cached, $prefs_cache, $username, $data_dir,
$max_login_attempts, $max_login_attempts_per_IP,
$activate_CAPTCHA_after_failed_attempts;
lockout_init();
if ($max_login_attempts)
{
// note how we unset the prefs cache flag before/after this code so as not
// to corrupt any prefs for the user who is currently logging in
//
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
setPref($data_dir, 'lockout_plugin_login_failure_information', $username . '_login_failure_times', '');
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
}
if (!sqGetGlobalVar('REMOTE_ADDR', $remote_addr, SQ_SERVER))
return;
if ($max_login_attempts_per_IP)
{
// note how we unset the prefs cache flag before/after this code so as not
// to corrupt any prefs for the user who is currently logging in
//
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
setPref($data_dir, 'lockout_plugin_login_failure_information', $remote_addr . '_login_failure_times', '');
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
}
if ($activate_CAPTCHA_after_failed_attempts)
{
// note how we unset the prefs cache flag before/after this code so as not
// to corrupt any prefs for the user who is currently logging in
//
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
setPref($data_dir, 'lockout_plugin_login_failure_information', $remote_addr . '_CAPTCHA_login_failure_times', '');
// immediately deactivate CAPTCHA validation if configured
//
$activate_CAPTCHA_config = explode(':', $activate_CAPTCHA_after_failed_attempts);
if (!empty($activate_CAPTCHA_config[3]))
setPref($data_dir, 'lockout_plugin_login_failure_information', $remote_addr . '_CAPTCHA_TOO_MANY_FAILED_LOGIN_ATTEMPTS', '');
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
}
}
/**
* Check number of successive failed login attempts
* and block user or IP permanently if necessary
* (or turn on CAPTCHA plugin)
*
*/
function check_failed_login_count_do($args)
{
global $data_dir, $login_username, $max_login_attempts,
$locked_out_per_lockout_rules, $prefs_are_cached,
$prefs_cache, $max_login_attempts_per_IP,
$activate_CAPTCHA_after_failed_attempts;
lockout_init();
// skip the below if our own lockout rules
// were the cause of this failed login
//
if ($locked_out_per_lockout_rules) return;
$now = time();
if (check_sm_version(1, 5, 2))
$logout_message = $args[0];
else
$logout_message = $args[1];
// this is a bit precarious - we determine if the user failed
// login based on the error string...
//
$valid_messages = array(_("Unknown user or password incorrect."));
if (is_plugin_enabled('captcha') || $activate_CAPTCHA_after_failed_attempts)
{
sq_change_text_domain('captcha');
$valid_messages[] = _("Sorry, you did not provide the correct challenge response.");
sq_change_text_domain('squirrelmail');
}
if (!in_array($logout_message, $valid_messages))
return;
if ($max_login_attempts)
{
list($max_failures, $number_minutes, $lockout_window)
= explode(':', $max_login_attempts);
// get and parse previous login failure stats and add current time to list
//
// note how we unset the prefs cache flag before/after this code so as not
// to corrupt any prefs for the user who is currently logging in
//
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
$failure_times = getPref($data_dir, 'lockout_plugin_login_failure_information', $login_username . '_login_failure_times', '');
if ($failure_times)
$failure_times = explode(':', $failure_times);
else
$failure_times = array();
$new_times = array();
foreach ($failure_times as $time)
if ($number_minutes == 0 || $time >= $now - ($number_minutes * 60))
$new_times[] = $time;
$new_times[] = $now;
setPref($data_dir, 'lockout_plugin_login_failure_information', $login_username . '_login_failure_times', implode(':', $new_times));
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
// now check for and ban abusive users
//
if (sizeof($new_times) >= $max_failures)
{
if (!$lockout_window) $lockout_end_time = 'PERMANENT';
else $lockout_end_time = $now + ($lockout_window * 60);
setPref($data_dir, 'lockout_plugin_login_failure_information', $login_username . '_TOO_MANY_FAILED_LOGIN_ATTEMPTS', $lockout_end_time);
// clear prefs cache again
//
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
$failed_times = '';
foreach ($new_times as $time)
$failed_times .= date('H:i:s Y-m-d', $time) . "\n";
// send alert to admin if necessary
//
global $domain, $log_violated_max_user_logins;
sq_change_text_domain('lockout');
if ($number_minutes > 0)
{
if (!$lockout_window)
{
// log this event - note that to use this, you'll need to have
// the Squirrel Logger plugin installed and activated and you'll
// have to add a "LOCKOUT" event type to its configuration
//
if ($log_violated_max_user_logins && is_plugin_enabled('squirrel_logger'))
{
include_once(SM_PATH . 'plugins/squirrel_logger/functions.php');
sl_logit('LOCKOUT', sprintf('User "%s" (domain "%s") has attempted (and failed) to log in %d times in the last %d minutes; %s has been LOCKED OUT PERMANENTLY', $login_username, $domain, sizeof($new_times), $number_minutes, $login_username));
}
l_report_abuse(sprintf(_("NOTICE: User \"%s\" (domain \"%s\") has attempted (and failed) to log in %d times in the last %d minutes.\n\nTimes:\n%s\n\n%s has been LOCKED OUT PERMANENTLY.\n\nTo unlock this user, remove the \"%s_TOO_MANY_FAILED_LOGIN_ATTEMPTS\" setting from the \"lockout_plugin_login_failure_information\" preference set."), $login_username, $domain, sizeof($new_times), $number_minutes, $failed_times, $login_username, $login_username), sprintf(_(" --- LOCKED OUT - %s"), $login_username));
}
else
{
// log this event - note that to use this, you'll need to have
// the Squirrel Logger plugin installed and activated and you'll
// have to add a "LOCKOUT" event type to its configuration
//
if ($log_violated_max_user_logins && is_plugin_enabled('squirrel_logger'))
{
include_once(SM_PATH . 'plugins/squirrel_logger/functions.php');
sl_logit('LOCKOUT', sprintf('User "%s" (domain "%s") has attempted (and failed) to log in %d times in the last %d minutes; %s has been LOCKED OUT for %d minutes', $login_username, $domain, sizeof($new_times), $number_minutes, $login_username, $lockout_window));
}
l_report_abuse(sprintf(_("NOTICE: User \"%s\" (domain \"%s\") has attempted (and failed) to log in %d times in the last %d minutes.\n\nTimes:\n%s\n\n%s has been LOCKED OUT for %d minutes.\n\nTo unlock this user before then, remove the \"%s_TOO_MANY_FAILED_LOGIN_ATTEMPTS\" setting from the \"lockout_plugin_login_failure_information\" preference set."), $login_username, $domain, sizeof($new_times), $number_minutes, $failed_times, $login_username, $lockout_window, $login_username), sprintf(_(" --- LOCKED OUT - %s"), $login_username));
}
}
else
{
if (!$lockout_window)
{
// log this event - note that to use this, you'll need to have
// the Squirrel Logger plugin installed and activated and you'll
// have to add a "LOCKOUT" event type to its configuration
//
if ($log_violated_max_user_logins && is_plugin_enabled('squirrel_logger'))
{
include_once(SM_PATH . 'plugins/squirrel_logger/functions.php');
sl_logit('LOCKOUT', sprintf('User "%s" (domain "%s") has attempted (and failed) to log in %d times; %s has been LOCKED OUT PERMANENTLY', $login_username, $domain, sizeof($new_times), $login_username));
}
l_report_abuse(sprintf(_("NOTICE: User \"%s\" (domain \"%s\") has attempted (and failed) to log in %d times.\n\nTimes:\n%s\n\n%s has been LOCKED OUT PERMANENTLY.\n\nTo unlock this user, remove the \"%s_TOO_MANY_FAILED_LOGIN_ATTEMPTS\" setting from the \"lockout_plugin_login_failure_information\" preference set."), $login_username, $domain, sizeof($new_times), $failed_times, $login_username, $login_username), sprintf(_(" --- LOCKED OUT - %s"), $login_username));
}
else
{
// log this event - note that to use this, you'll need to have
// the Squirrel Logger plugin installed and activated and you'll
// have to add a "LOCKOUT" event type to its configuration
//
if ($log_violated_max_user_logins && is_plugin_enabled('squirrel_logger'))
{
include_once(SM_PATH . 'plugins/squirrel_logger/functions.php');
sl_logit('LOCKOUT', sprintf('User "%s" (domain "%s") has attempted (and failed) to log in %d times; %s has been LOCKED OUT for %d minutes', $login_username, $domain, sizeof($new_times), $login_username, $lockout_window));
}
l_report_abuse(sprintf(_("NOTICE: User \"%s\" (domain \"%s\") has attempted (and failed) to log in %d times.\n\nTimes:\n%s\n\n%s has been LOCKED OUT for %d minutes.\n\nTo unlock this user before then, remove the \"%s_TOO_MANY_FAILED_LOGIN_ATTEMPTS\" setting from the \"lockout_plugin_login_failure_information\" preference set."), $login_username, $domain, sizeof($new_times), $failed_times, $login_username, $lockout_window, $login_username), sprintf(_(" --- LOCKED OUT - %s"), $login_username));
}
}
sq_change_text_domain('squirrelmail');
}
}
if (!sqGetGlobalVar('REMOTE_ADDR', $remote_addr, SQ_SERVER))
return;
if ($max_login_attempts_per_IP)
{
list($max_failures, $number_minutes, $lockout_window)
= explode(':', $max_login_attempts_per_IP);
// get and parse previous login failure stats and add current time to list
//
// note how we unset the prefs cache flag before/after this code so as not
// to corrupt any prefs for the user who is currently logging in
//
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
$failure_times = getPref($data_dir, 'lockout_plugin_login_failure_information', $remote_addr . '_login_failure_times', '');
if ($failure_times)
$failure_times = explode(':', $failure_times);
else
$failure_times = array();
$new_times = array();
foreach ($failure_times as $time)
if ($number_minutes == 0 || $time >= $now - ($number_minutes * 60))
$new_times[] = $time;
$new_times[] = $now;
setPref($data_dir, 'lockout_plugin_login_failure_information', $remote_addr . '_login_failure_times', implode(':', $new_times));
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
// now check for and ban abusive users
//
if (sizeof($new_times) >= $max_failures)
{
if (!$lockout_window) $lockout_end_time = 'PERMANENT';
else $lockout_end_time = $now + ($lockout_window * 60);
setPref($data_dir, 'lockout_plugin_login_failure_information', $remote_addr . '_TOO_MANY_FAILED_LOGIN_ATTEMPTS', $lockout_end_time);
// clear prefs cache again
//
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
$failed_times = '';
foreach ($new_times as $time)
$failed_times .= date('H:i:s Y-m-d', $time) . "\n";
// send alert to admin if necessary
//
global $domain, $log_violated_max_IP_logins;
sq_change_text_domain('lockout');
if ($number_minutes > 0)
{
if (!$lockout_window)
{
// log this event - note that to use this, you'll need to have
// the Squirrel Logger plugin installed and activated and you'll
// have to add a "LOCKOUT" event type to its configuration
//
if ($log_violated_max_IP_logins && is_plugin_enabled('squirrel_logger'))
{
include_once(SM_PATH . 'plugins/squirrel_logger/functions.php');
sl_logit('LOCKOUT', sprintf('Someone at %s has attempted (and failed) to log in %d times in the last %d minutes; %s has been LOCKED OUT PERMANENTLY', $remote_addr, sizeof($new_times), $number_minutes, $remote_addr));
}
l_report_abuse(sprintf(_("NOTICE: Someone at %s has attempted (and failed) to log in %d times in the last %d minutes.\n\nTimes:\n%s\n\n%s has been LOCKED OUT PERMANENTLY.\n\nTo unlock this client address, remove the \"%s_TOO_MANY_FAILED_LOGIN_ATTEMPTS\" setting from the \"lockout_plugin_login_failure_information\" preference set."), $remote_addr, sizeof($new_times), $number_minutes, $failed_times, $remote_addr, $remote_addr), sprintf(_(" --- LOCKED OUT - %s"), $remote_addr));
}
else
{
// log this event - note that to use this, you'll need to have
// the Squirrel Logger plugin installed and activated and you'll
// have to add a "LOCKOUT" event type to its configuration
//
if ($log_violated_max_IP_logins && is_plugin_enabled('squirrel_logger'))
{
include_once(SM_PATH . 'plugins/squirrel_logger/functions.php');
sl_logit('LOCKOUT', sprintf('Someone at %s has attempted (and failed) to log in %d times in the last %d minutes; %s has been LOCKED OUT for %d minutes', $remote_addr, sizeof($new_times), $number_minutes, $remote_addr, $lockout_window));
}
l_report_abuse(sprintf(_("NOTICE: Someone at %s has attempted (and failed) to log in %d times in the last %d minutes.\n\nTimes:\n%s\n\n%s has been LOCKED OUT for %d minutes.\n\nTo unlock this client address, remove the \"%s_TOO_MANY_FAILED_LOGIN_ATTEMPTS\" setting from the \"lockout_plugin_login_failure_information\" preference set."), $remote_addr, sizeof($new_times), $number_minutes, $failed_times, $remote_addr, $lockout_window, $remote_addr), sprintf(_(" --- LOCKED OUT - %s"), $remote_addr));
}
}
else
{
if (!$lockout_window)
{
// log this event - note that to use this, you'll need to have
// the Squirrel Logger plugin installed and activated and you'll
// have to add a "LOCKOUT" event type to its configuration
//
if ($log_violated_max_IP_logins && is_plugin_enabled('squirrel_logger'))
{
include_once(SM_PATH . 'plugins/squirrel_logger/functions.php');
sl_logit('LOCKOUT', sprintf('Someone at %s has attempted (and failed) to log in %d times; %s has been LOCKED OUT PERMANENTLY', $remote_addr, sizeof($new_times), $remote_addr));
}
l_report_abuse(sprintf(_("NOTICE: Someone at %s has attempted (and failed) to log in %d times.\n\nTimes:\n%s\n\n%s has been LOCKED OUT PERMANENTLY.\n\nTo unlock this client address, remove the \"%s_TOO_MANY_FAILED_LOGIN_ATTEMPTS\" setting from the \"lockout_plugin_login_failure_information\" preference set."), $remote_addr, sizeof($new_times), $failed_times, $remote_addr, $remote_addr), sprintf(_(" --- LOCKED OUT - %s"), $remote_addr));
}
else
{
// log this event - note that to use this, you'll need to have
// the Squirrel Logger plugin installed and activated and you'll
// have to add a "LOCKOUT" event type to its configuration
//
if ($log_violated_max_IP_logins && is_plugin_enabled('squirrel_logger'))
{
include_once(SM_PATH . 'plugins/squirrel_logger/functions.php');
sl_logit('LOCKOUT', sprintf('Someone at %s has attempted (and failed) to log in %d times; %s has been LOCKED OUT for %d minutes', $remote_addr, sizeof($new_times), $remote_addr, $lockout_window));
}
l_report_abuse(sprintf(_("NOTICE: Someone at %s has attempted (and failed) to log in %d times.\n\nTimes:\n%s\n\n%s has been LOCKED OUT for %d minutes.\n\nTo unlock this client address before then, remove the \"%s_TOO_MANY_FAILED_LOGIN_ATTEMPTS\" setting from the \"lockout_plugin_login_failure_information\" preference set."), $remote_addr, sizeof($new_times), $failed_times, $remote_addr, $lockout_window, $remote_addr), sprintf(_(" --- LOCKED OUT - %s"), $remote_addr));
}
}
sq_change_text_domain('squirrelmail');
}
}
if ($activate_CAPTCHA_after_failed_attempts)
{
list($max_failures, $number_minutes, $lockout_window)
= explode(':', $activate_CAPTCHA_after_failed_attempts);
// get and parse previous login failure stats and add current time to list
//
// note how we unset the prefs cache flag before/after this code so as not
// to corrupt any prefs for the user who is currently logging in
//
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
$failure_times = getPref($data_dir, 'lockout_plugin_login_failure_information', $remote_addr . '_CAPTCHA_login_failure_times', '');
if ($failure_times)
$failure_times = explode(':', $failure_times);
else
$failure_times = array();
$new_times = array();
foreach ($failure_times as $time)
if ($number_minutes == 0 || $time >= $now - ($number_minutes * 60))
$new_times[] = $time;
$new_times[] = $now;
setPref($data_dir, 'lockout_plugin_login_failure_information', $remote_addr . '_CAPTCHA_login_failure_times', implode(':', $new_times));
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
// now check for and ban abusive users
//
if (sizeof($new_times) >= $max_failures)
{
if (!$lockout_window) $lockout_end_time = 'PERMANENT';
else $lockout_end_time = $now + ($lockout_window * 60);
setPref($data_dir, 'lockout_plugin_login_failure_information', $remote_addr . '_CAPTCHA_TOO_MANY_FAILED_LOGIN_ATTEMPTS', $lockout_end_time);
// clear prefs cache again
//
$prefs_are_cached = FALSE;
$prefs_cache = FALSE;
sqsession_unregister('prefs_are_cached');
sqsession_unregister('prefs_cache');
$failed_times = '';
foreach ($new_times as $time)
$failed_times .= date('H:i:s Y-m-d', $time) . "\n";
// log event and send alert to admin if necessary
//
global $domain, $log_CAPTCHA_enabled;
sq_change_text_domain('lockout');
if ($number_minutes > 0)
{
if (!$lockout_window)
{
// log this event - note that to use this, you'll need to have
// the Squirrel Logger plugin installed and activated and you'll
// have to add a "LOCKOUT" event type to its configuration
//
if ($log_CAPTCHA_enabled && is_plugin_enabled('squirrel_logger'))
{
include_once(SM_PATH . 'plugins/squirrel_logger/functions.php');
sl_logit('LOCKOUT', sprintf('Someone at %s has attempted (and failed) to log in %d times in the last %d minutes; users attempting to log in from %s are PERMANENTLY required to enter a CAPTCHA code when logging in', $remote_addr, sizeof($new_times), $number_minutes, $remote_addr));
}
l_report_abuse(sprintf(_("NOTICE: Someone at %s has attempted (and failed) to log in %d times in the last %d minutes.\n\nTimes:\n%s\n\nUsers attempting to log in from %s are PERMANENTLY required to enter a CAPTCHA code when logging in.\n\nTo remove the CAPTCHA requirement, remove the \"%s_CAPTCHA_TOO_MANY_FAILED_LOGIN_ATTEMPTS\" setting from the \"lockout_plugin_login_failure_information\" preference set."), $remote_addr, sizeof($new_times), $number_minutes, $failed_times, $remote_addr, $remote_addr), sprintf(_(" --- LOCKED OUT - %s"), $remote_addr));
}
else
{
// log this event - note that to use this, you'll need to have
// the Squirrel Logger plugin installed and activated and you'll
// have to add a "LOCKOUT" event type to its configuration
//
if ($log_CAPTCHA_enabled && is_plugin_enabled('squirrel_logger'))
{
include_once(SM_PATH . 'plugins/squirrel_logger/functions.php');
sl_logit('LOCKOUT', sprintf('Someone at %s has attempted (and failed) to log in %d times in the last %d minutes; users attempting to log in from %s will be required to enter a CAPTCHA code when logging in for the next %d minutes', $remote_addr, sizeof($new_times), $number_minutes, $remote_addr, $lockout_window));
}
l_report_abuse(sprintf(_("NOTICE: Someone at %s has attempted (and failed) to log in %d times in the last %d minutes.\n\nTimes:\n%s\n\nUsers attempting to log in from %s will be required to enter a CAPTCHA code when logging in for the next %d minutes.\n\nTo remove the CAPTCHA requirement, remove the \"%s_CAPTCHA_TOO_MANY_FAILED_LOGIN_ATTEMPTS\" setting from the \"lockout_plugin_login_failure_information\" preference set."), $remote_addr, sizeof($new_times), $number_minutes, $failed_times, $remote_addr, $lockout_window, $remote_addr), sprintf(_(" --- LOCKED OUT - %s"), $remote_addr));
}
}
else
{
if (!$lockout_window)
{
// log this event - note that to use this, you'll need to have
// the Squirrel Logger plugin installed and activated and you'll
// have to add a "LOCKOUT" event type to its configuration
//
if ($log_CAPTCHA_enabled && is_plugin_enabled('squirrel_logger'))
{
include_once(SM_PATH . 'plugins/squirrel_logger/functions.php');
sl_logit('LOCKOUT', sprintf('Someone at %s has attempted (and failed) to log in %d times; users attempting to log in from %s are PERMANENTLY required to enter a CAPTCHA code when logging in', $remote_addr, sizeof($new_times), $remote_addr));
}
l_report_abuse(sprintf(_("NOTICE: Someone at %s has attempted (and failed) to log in %d times.\n\nTimes:\n%s\n\nUsers attempting to log in from %s are PERMANENTLY required to enter a CAPTCHA code when logging in.\n\nTo remove the CAPTCHA requirement, remove the \"%s_CAPTCHA_TOO_MANY_FAILED_LOGIN_ATTEMPTS\" setting from the \"lockout_plugin_login_failure_information\" preference set."), $remote_addr, sizeof($new_times), $failed_times, $remote_addr, $remote_addr), sprintf(_(" --- LOCKED OUT - %s"), $remote_addr));
}
else
{
// log this event - note that to use this, you'll need to have
// the Squirrel Logger plugin installed and activated and you'll
// have to add a "LOCKOUT" event type to its configuration
//
if ($log_CAPTCHA_enabled && is_plugin_enabled('squirrel_logger'))
{
include_once(SM_PATH . 'plugins/squirrel_logger/functions.php');
sl_logit('LOCKOUT', sprintf('Someone at %s has attempted (and failed) to log in %d times; users attempting to log in from %s will be required to enter a CAPTCHA code when logging in for the next %d minutes', $remote_addr, sizeof($new_times), $remote_addr, $lockout_window));
}
l_report_abuse(sprintf(_("NOTICE: Someone at %s has attempted (and failed) to log in %d times.\n\nTimes:\n%s\n\nUsers attempting to log in from %s will be required to enter a CAPTCHA code when logging in for the next %d minutes.\n\nTo remove the CAPTCHA requirement before then, remove the \"%s_CAPTCHA_TOO_MANY_FAILED_LOGIN_ATTEMPTS\" setting from the \"lockout_plugin_login_failure_information\" preference set."), $remote_addr, sizeof($new_times), $failed_times, $remote_addr, $lockout_window, $remote_addr), sprintf(_(" --- LOCKED OUT - %s"), $remote_addr));
}
}
sq_change_text_domain('squirrelmail');
}
}
}
/**
* Reports abuse to administrator
*
* @param $error string Error text indicating what the abuse problem is
* @param $title string Short text for inclusion in email subject line
*
*/
function l_report_abuse($error, $title='')
{
global $lockout_notification_addresses, $at, $domain,
$login_username, $lockout_useSendmail, $lockout_smtpServerAddress,
$lockout_smtpPort, $lockout_sendmail_path, $lockout_sendmail_args,
$lockout_pop_before_smtp, $lockout_encode_header_key,
$lockout_smtp_auth_mech, $lockout_smtp_sitewide_user,
$lockout_smtp_sitewide_pass, $useSendmail, $smtpServerAddress,
$smtpPort, $sendmail_path, $sendmail_args, $pop_before_smtp,
$encode_header_key, $smtp_auth_mech, $smtp_sitewide_user,
$smtp_sitewide_pass;
lockout_init();
if (empty($lockout_notification_addresses))
return;
sq_change_text_domain('lockout');
$user = substr($login_username, 0, strpos($login_username, $at));
$body = $error . "\n\n" . _("User account:") . ' ' . $login_username
. "\n" . _("Domain:") . ' ' . $domain
. "\n" . _("Timestamp: ") . date('Y-m-d H:i:s');
$subject = _("[POSSIBLE BRUTEFORCE ABUSE]")
. (empty($title) ? '' : ': ' . $title)
. ' (' . $login_username . ')';
sq_change_text_domain('squirrelmail');
// override any SMTP/Sendmail settings...
//
$orig_useSendmail = $useSendmail;
if (!is_null($lockout_useSendmail))
$useSendmail = $lockout_useSendmail;
$orig_smtpServerAddress = $smtpServerAddress;
if (!is_null($lockout_smtpServerAddress))
$smtpServerAddress = $lockout_smtpServerAddress;
$orig_smtpPort = $smtpPort;
if (!is_null($lockout_smtpPort))
$smtpPort = $lockout_smtpPort;
$orig_sendmail_path = $sendmail_path;
if (!is_null($lockout_sendmail_path))
$sendmail_path = $lockout_sendmail_path;
$orig_sendmail_args = $sendmail_args;
if (!is_null($lockout_sendmail_args))
$sendmail_args = $lockout_sendmail_args;
$orig_pop_before_smtp = $pop_before_smtp;
if (!is_null($lockout_pop_before_smtp))
$pop_before_smtp = $lockout_pop_before_smtp;
$orig_encode_header_key = $encode_header_key;
if (!is_null($lockout_encode_header_key))
$encode_header_key = $lockout_encode_header_key;
$orig_smtp_auth_mech = $smtp_auth_mech;
if (!is_null($lockout_smtp_auth_mech))
$smtp_auth_mech = $lockout_smtp_auth_mech;
$orig_smtp_sitewide_user = $smtp_sitewide_user;
if (!is_null($lockout_smtp_sitewide_user))
$smtp_sitewide_user = $lockout_smtp_sitewide_user;
$orig_smtp_sitewide_pass = $smtp_sitewide_pass;
if (!is_null($lockout_smtp_sitewide_pass))
$smtp_sitewide_pass = $lockout_smtp_sitewide_pass;
// function found in SM core 1.5.2+ and Compatibility plugin 2.0.11+
// (suppress include error, since file is only needed for 1.5.2+,
// otherwise Compatibility has us covered)
//
@include_once(SM_PATH . 'functions/compose.php');
$success = sq_send_mail($lockout_notification_addresses, $subject, $body, 'noreply@' . $domain);
// return SMTP/Sendmail settings to what they were
//
$useSendmail = $orig_useSendmail;
$smtpServerAddress = $orig_smtpServerAddress;
$smtpPort = $orig_smtpPort;
$sendmail_path = $orig_sendmail_path;
$sendmail_args = $orig_sendmail_args;
$pop_before_smtp = $orig_pop_before_smtp;
$encode_header_key = $orig_encode_header_key;
$smtp_auth_mech = $orig_smtp_auth_mech;
$smtp_sitewide_user = $orig_smtp_sitewide_user;
$smtp_sitewide_pass = $orig_smtp_sitewide_pass;
}
|