]> granicus.if.org Git - php/commitdiff
Utility function for sapi modules (it is not in SAPI.c, because it
authorSascha Schumann <sas@php.net>
Fri, 27 Oct 2000 10:16:54 +0000 (10:16 +0000)
committerSascha Schumann <sas@php.net>
Fri, 27 Oct 2000 10:16:54 +0000 (10:16 +0000)
relies on php_base64_encode).

main/main.c
main/php_main.h

index 79ed8812c298f2478d7738b4bc5adc9b8e9da12f..d06b5731cad17c4ec668018e2af27eda375cd89e 100644 (file)
@@ -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;
index e0ad78b9152a546b111d741a8146d729771f718f..390002d319707e5c0f137c92c6fbd393ed5ec40b 100644 (file)
@@ -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);