/** * @return bool */ private function getAuth() : bool { // Auth is already done if (sizeof($this->services) > 0) { return true; } $auth = $this->getUserPassword(); if (!$auth) { return false; } list($user, $password) = $auth; $usersList = $this->module->users; if (!isset($usersList[$user])) { return false; } // password check if (md5(strtolower($user) . $password) != $usersList[$user]['password']) { return false; } // ip check if (isset($usersList[$user]['ip']) && sizeof($usersList[$user]['ip']) > 0) { $ipSuccess = false; $currentIp = Ip::get(); foreach ($usersList[$user]['ip'] as $currentRestriction) { $isRange = stripos($currentRestriction, '/') !== false; if ($isRange && Ip::isInRange($currentRestriction, $currentIp) || $currentIp == $currentRestriction) { $ipSuccess = true; break; } } if (!$ipSuccess) { return false; } } $this->services = $usersList[$user]['services']; $this->user = $user; return true; }