| 23 | | // not logged in, and have provided a user/pass |
|---|
| 24 | | $_SESSION['AMP_user'] = new ampuser($_SERVER['PHP_AUTH_USER']); |
|---|
| 25 | | |
|---|
| 26 | | if (!$_SESSION['AMP_user']->checkPassword($_SERVER['PHP_AUTH_PW'])) { |
|---|
| 27 | | // failed, one last chance -- fallback to amportal.conf db admin user |
|---|
| 28 | | if ( (count(getAmpAdminUsers()) == 0) && ($_SERVER['PHP_AUTH_USER'] == $amp_conf['AMPDBUSER']) |
|---|
| 29 | | && ($_SERVER['PHP_AUTH_PW'] == $amp_conf['AMPDBPASS'])) { |
|---|
| 30 | | |
|---|
| 31 | | // password succesfully matched amportal.conf db admin user |
|---|
| 32 | | |
|---|
| 33 | | // set admin access |
|---|
| 34 | | $_SESSION['AMP_user']->setAdmin(); |
|---|
| 35 | | } else { |
|---|
| 36 | | // password failed and admin user fall-back failed |
|---|
| 37 | | unset($_SESSION['AMP_user']); |
|---|
| 38 | | } |
|---|
| 39 | | } // else, succesfully logged in |
|---|
| 40 | | } |
|---|
| | 22 | if (isset($_SESSION['logout']) && $_SESSION['logout']) { |
|---|
| | 23 | // workaround for HTTP-auth - just tried to logout, don't allow a log in (with the same credentials) |
|---|
| | 24 | unset($_SESSION['logout']); |
|---|
| | 25 | // afterwards, this falls through to the !AMP_user check below, and sends 401 header, which causes the browser to re-prompt the user |
|---|
| | 26 | } else { |
|---|
| | 27 | // not logged in, and have provided a user/pass |
|---|
| | 28 | $_SESSION['AMP_user'] = new ampuser($_SERVER['PHP_AUTH_USER']); |
|---|
| | 29 | |
|---|
| | 30 | if (!$_SESSION['AMP_user']->checkPassword($_SERVER['PHP_AUTH_PW'])) { |
|---|
| | 31 | // failed, one last chance -- fallback to amportal.conf db admin user |
|---|
| | 32 | if ( (count(getAmpAdminUsers()) == 0) && ($_SERVER['PHP_AUTH_USER'] == $amp_conf['AMPDBUSER']) |
|---|
| | 33 | && ($_SERVER['PHP_AUTH_PW'] == $amp_conf['AMPDBPASS'])) { |
|---|
| | 34 | |
|---|
| | 35 | // password succesfully matched amportal.conf db admin user |
|---|
| | 36 | |
|---|
| | 37 | // set admin access |
|---|
| | 38 | $_SESSION['AMP_user']->setAdmin(); |
|---|
| | 39 | } else { |
|---|
| | 40 | // password failed and admin user fall-back failed |
|---|
| | 41 | unset($_SESSION['AMP_user']); |
|---|
| | 42 | } |
|---|
| | 43 | } // else, succesfully logged in |
|---|
| | 44 | } |
|---|
| | 45 | } |
|---|