| Новости | FAQ | Авторы | Документация | В действии | Библиотека |
| Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
AK666 19.11.2013 19:28
Далее, нам нужно получить авторизационные данные. Но сами они в парсер не попадут,Прекрасно попадают
...
$http_auth[$env:HTTP_AUTHORIZATION]
^if(^http_auth.length[] == 0){ ^throw[auth.401] }
^if(^http_auth.pos[Basic ] != 0){ ^throw[auth.403] }
$m[^http_auth.match[Basic ([a-zA-Z0-9=]+)]]
^if(^m.count[] == 0){ ^throw[auth.403] }
$http_auth[^string:base64[$m.1]]
$auth[^http_auth.match[(\w+):(\S+)]]
^if(^auth.count[] == 0){ ^throw[auth.403] }
$UIN[$auth.1]
$PWD[$auth.2]
^if(^UIN.length[] != 7){ ^throw[auth.401] }
^if(^PWD.length[] == 0){ ^throw[auth.401] }
...
получение userData c mySQL
...
^if(^math:crypt[$PWD;$userData.$UIN.passwd] ne $userData.$UIN.passwd){^throw[auth.401]}
$response:x-auth-uin[$UIN]
$response:x-auth-id[$userData.$UIN.ID] @unhandled_exception[exception;stack]
^switch[$exception.type]{
^case[auth.401]{ $response:status(401) $response:WWW-Authenticate[Basic realm="$REALM"] }
^case[auth.403]{ $response:status(403) }
^case[DEFAULT]{
$response:status(500)
$response:content-type[
$.value[text/html]
$.charset[$response:charset]
]
<p>The server encountered an unhandled exception and was unable to complete your request.</p>
<p>Please contact the server administrator: <a href="mailto:$env:SERVER_ADMIN?Subject=[Error:$env:SERVER_NAME]">$env:SERVER_ADMIN</a>
and inform them of the time the error occurred, and anything you might have done that may have caused the error.</p>
}
}у меня нет проблем с авторизацией, у меня проблема с обратной передачей данных. не получается установить мои header.