summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2000-10-27 10:16:54 +0000
committerSascha Schumann <sas@php.net>2000-10-27 10:16:54 +0000
commit85b52234e43210f45742e41f822b3d1929a42f3b (patch)
treea725f8d677447283291f79628ff60925492a2994 /main
parent01b4c077476ffa31d38a380046e0c0f525c2f2b9 (diff)
downloadphp-git-85b52234e43210f45742e41f822b3d1929a42f3b.tar.gz
Utility function for sapi modules (it is not in SAPI.c, because it
relies on php_base64_encode).
Diffstat (limited to 'main')
-rw-r--r--main/main.c25
-rw-r--r--main/php_main.h1
2 files changed, 26 insertions, 0 deletions
diff --git a/main/main.c b/main/main.c
index 79ed8812c2..d06b5731ca 100644
--- a/main/main.c
+++ b/main/main.c
@@ -1214,6 +1214,31 @@ PHPAPI void php_execute_script(zend_file_handle *primary_file CLS_DC ELS_DC PLS_
free_alloca(old_cwd);
}
+PHPAPI int php_handle_auth_data(const char *auth SLS_DC)
+{
+ int ret = -1;
+
+ if (auth && auth[0] != '\0'
+ && strncmp(auth, "Basic ", 6) == 0) {
+ char *pass;
+ char *user;
+
+ user = php_base64_decode(auth + 6, strlen(auth) - 6, NULL);
+ if (user) {
+ pass = strchr(user, ':');
+ if (pass) {
+ *pass++ = '\0';
+ SG(request_info).auth_user = user;
+ SG(request_info).auth_password = estrdup(pass);
+ ret = 0;
+ } else {
+ efree(user);
+ }
+ }
+ }
+ return ret;
+}
+
PHPAPI int php_lint_script(zend_file_handle *file CLS_DC ELS_DC PLS_DC)
{
zend_op_array *op_array;
diff --git a/main/php_main.h b/main/php_main.h
index e0ad78b915..390002d319 100644
--- a/main/php_main.h
+++ b/main/php_main.h
@@ -44,6 +44,7 @@ PHPAPI void php_execute_script(zend_file_handle *primary_file CLS_DC ELS_DC PLS_
PHPAPI int php_handle_special_queries(SLS_D PLS_DC);
PHPAPI int php_lint_script(zend_file_handle *file CLS_DC ELS_DC PLS_DC);
+PHPAPI int php_handle_auth_data(const char *auth SLS_DC);
extern void php_call_shutdown_functions(void);