@@ -31,9 +31,9 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | public function forgotPassword($data) |
| 33 | 33 | { |
| 34 | - if($data['Email']) { |
|
| 34 | + if ($data['Email']) { |
|
| 35 | 35 | /* @var $member Member */ |
| 36 | - if ($member = Member::get()->where("Email = '".Convert::raw2sql($data['Email'])."'")->first()) { |
|
| 36 | + if ($member = Member::get()->where("Email = '" . Convert::raw2sql($data['Email']) . "'")->first()) { |
|
| 37 | 37 | $token = $member->generateAutologinTokenAndStoreHash(); |
| 38 | 38 | $this->sendPasswordResetLinkEmail($member, $token); |
| 39 | 39 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | Deprecation::notice('1.1', 'Use the "IpAccess.allowed_ips" config setting instead'); |
| 61 | 61 | self::config()->allowed_ips = $this->allowedIps; |
| 62 | 62 | } |
| 63 | - return (array)self::config()->allowed_ips; |
|
| 63 | + return (array) self::config()->allowed_ips; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function isEnabled() |
| 70 | 70 | { |
| 71 | - return (bool)Config::inst()->get('IpAccess', 'enabled'); |
|
| 71 | + return (bool) Config::inst()->get('IpAccess', 'enabled'); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | public function matchRange() |
| 114 | 114 | { |
| 115 | - $ranges = array_filter($this->getAllowedIps(), function ($ip) { |
|
| 115 | + $ranges = array_filter($this->getAllowedIps(), function($ip) { |
|
| 116 | 116 | return strstr($ip, '-'); |
| 117 | 117 | }); |
| 118 | 118 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | public function matchCIDR() |
| 139 | 139 | { |
| 140 | - $ranges = array_filter($this->getAllowedIps(), function ($ip) { |
|
| 140 | + $ranges = array_filter($this->getAllowedIps(), function($ip) { |
|
| 141 | 141 | return strstr($ip, '/'); |
| 142 | 142 | }); |
| 143 | 143 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public function matchWildCard() |
| 161 | 161 | { |
| 162 | - $ranges = array_filter($this->getAllowedIps(), function ($ip) { |
|
| 162 | + $ranges = array_filter($this->getAllowedIps(), function($ip) { |
|
| 163 | 163 | return substr($ip, -1) === '*'; |
| 164 | 164 | }); |
| 165 | 165 | |
@@ -119,8 +119,10 @@ discard block |
||
| 119 | 119 | $ipFirstPart = substr($this->ip, 0, strrpos($this->ip, '.') + 1); |
| 120 | 120 | $ipLastpart = substr(strrchr($this->ip, '.'), 1); |
| 121 | 121 | |
| 122 | - if (!empty($ranges)) foreach ($ranges as $range) { |
|
| 122 | + if (!empty($ranges)) { |
|
| 123 | + foreach ($ranges as $range) { |
|
| 123 | 124 | $rangeFirstPart = substr($range, 0, strrpos($range, '.') + 1); |
| 125 | + } |
|
| 124 | 126 | list ($start, $end) = explode('-', substr(strrchr($range, '.'), 1)); |
| 125 | 127 | if ($ipFirstPart === $rangeFirstPart && $ipLastpart >= $start && $ipLastpart <= $end) { |
| 126 | 128 | return $range; |
@@ -141,8 +143,10 @@ discard block |
||
| 141 | 143 | return strstr($ip, '/'); |
| 142 | 144 | }); |
| 143 | 145 | |
| 144 | - if (!empty($ranges)) foreach ($ranges as $range) { |
|
| 146 | + if (!empty($ranges)) { |
|
| 147 | + foreach ($ranges as $range) { |
|
| 145 | 148 | list ($net, $mask) = explode('/', $cidr); |
| 149 | + } |
|
| 146 | 150 | if ((ip2long($this->ip) & ~((1 << (32 - $mask)) - 1)) == ip2long($net)) { |
| 147 | 151 | return $cidr; |
| 148 | 152 | } |
@@ -163,9 +167,11 @@ discard block |
||
| 163 | 167 | return substr($ip, -1) === '*'; |
| 164 | 168 | }); |
| 165 | 169 | |
| 166 | - if (!empty($ranges)) foreach ($ranges as $range) { |
|
| 170 | + if (!empty($ranges)) { |
|
| 171 | + foreach ($ranges as $range) { |
|
| 167 | 172 | if (substr($this->ip, 0, strlen(substr($range, 0, -1))) === substr($range, 0, -1)) { |
| 168 | 173 | return $range; |
| 174 | + } |
|
| 169 | 175 | } |
| 170 | 176 | } |
| 171 | 177 | return ''; |