|
49 | 49 | $to = $data[$user]["CONTACT"]; |
50 | 50 | $subject = sprintf(_("MAIL_RESET_SUBJECT"), date("Y-m-d H:i:s")); |
51 | 51 | $hostname = get_hostname(); |
52 | | - if ($hostname . ":" . $_SERVER["SERVER_PORT"] == $_SERVER["HTTP_HOST"]) { |
53 | | - $check = true; |
54 | | - $hostname_email = $hostname; |
55 | | - } elseif ($hostname_full . ":" . $_SERVER["SERVER_PORT"] == $_SERVER["HTTP_HOST"]) { |
56 | | - $check = true; |
57 | | - $hostname_email = $hostname_full; |
58 | | - } else { |
59 | | - $check = false; |
60 | | - $ERROR = "<p class=\"error\">" . _("Invalid host domain") . "</p>"; |
61 | | - } |
62 | | - if ($check == true) { |
| 52 | + if ($hostname) { |
| 53 | + $host = preg_replace( |
| 54 | + "/(\[?[^]]*\]?):([0-9]{1,5})$/", |
| 55 | + "$1", |
| 56 | + $_SERVER["HTTP_HOST"], |
| 57 | + ); |
| 58 | + if ($host == $hostname) { |
| 59 | + $port_is_defined = preg_match( |
| 60 | + "/\[?[^]]*\]?:[0-9]{1,5}$/", |
| 61 | + $_SERVER["HTTP_HOST"], |
| 62 | + ); |
| 63 | + if ($port_is_defined) { |
| 64 | + $port = preg_replace( |
| 65 | + "/(\[?[^]]*\]?):([0-9]{1,5})$/", |
| 66 | + "$2", |
| 67 | + $_SERVER["HTTP_HOST"], |
| 68 | + ); |
| 69 | + } else { |
| 70 | + $port = ""; |
| 71 | + } |
| 72 | + } else { |
| 73 | + $port = ":" . $_SERVER["SERVER_PORT"]; |
| 74 | + } |
63 | 75 | $from = "noreply@" . $hostname; |
64 | 76 | $from_name = _("Hestia Control Panel"); |
65 | 77 | if (!empty($name)) { |
|
69 | 81 | } |
70 | 82 | $mailtext .= sprintf( |
71 | 83 | _("PASSWORD_RESET_REQUEST"), |
72 | | - $_SERVER["HTTP_HOST"], |
| 84 | + $hostname . $port, |
73 | 85 | $user, |
74 | 86 | $rkey, |
75 | | - $_SERVER["HTTP_HOST"], |
| 87 | + $hostname . $port, |
76 | 88 | $user, |
77 | 89 | $rkey, |
78 | 90 | ); |
|
86 | 98 | $data[$user]["NAME"], |
87 | 99 | ); |
88 | 100 | } |
89 | | - $ERROR = |
90 | | - "<p class=\"error\">" . |
91 | | - _( |
92 | | - "Password reset instructions have been sent to the email address associated with this account.", |
93 | | - ) . |
94 | | - "</p>"; |
95 | 101 | } |
| 102 | + $ERROR = |
| 103 | + "<p class=\"error\">" . |
| 104 | + _( |
| 105 | + "Password reset instructions have been sent to the email address associated with this account.", |
| 106 | + ) . |
| 107 | + "</p>"; |
96 | 108 | } else { |
97 | 109 | # Prevent user enumeration and let hackers guess username and working email |
98 | 110 | $ERROR = |
|
0 commit comments