cvs: /php4/ext/standard url_scanner.c url_scanner.h url_scanner.re /php4 output.c /php4/ext/session config.h.stub config.m4 php_session.h session.c
/php4/ext/standard Makefile.am
| From: | Sascha Schumann | Date: | Sat, 11 Sep 1999 23:47:16 +0000 |
| Subject: | cvs: /php4/ext/standard url_scanner.c url_scanner.h url_scanner.re /php4 output.c /php4/ext/session config.h.stub config.m4 php_session.h session.c /php4/ext/standard Makefile.am |
||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-4335@lists.php.net to get a copy of this message | ||
sas Sat Sep 11 19:47:16 1999 EDT
Added files:
/php4/ext/standard url_scanner.c url_scanner.h url_scanner.re
Modified files:
/php4 output.c
/php4/ext/session config.h.stub config.m4 php_session.h session.c
/php4/ext/standard Makefile.am
Log:
add transparent session id propagation
this uses a custom scanner which detects relative URIs and changes
them appropiately.
must be explicitly enabled with --enable-trans-sid
(normal case is not affected, since session_adapt_uris defaults to
void statement. Compiler should eliminate dead code in output.c then.)
Index: php4/output.c
diff -u php4/output.c:1.13 php4/output.c:1.14
--- php4/output.c:1.13 Sat Sep 4 15:08:19 1999
+++ php4/output.c Sat Sep 11 19:47:16 1999
@@ -20,6 +20,7 @@
#include "php.h"
#include "ext/standard/head.h"
+#include "ext/session/php_session.h"
#include "SAPI.h"
/* output functions */
@@ -189,17 +190,31 @@
static int zend_ub_body_write(const char *str, uint str_length)
{
+ char *newstr = NULL;
+ uint new_length;
+ int result = 0;
SLS_FETCH();
if (SG(request_info).headers_only) {
zend_bailout();
}
if (php3_header()) {
+ session_adapt_uris(str, str_length, &newstr, &new_length);
+
+ if (newstr) {
+ str = newstr;
+ str_length = new_length;
+ }
+
zend_body_write = zend_ub_body_write_no_header;
- return zend_header_write(str, str_length);
- } else {
- return 0;
+ result = zend_header_write(str, str_length);
+
+ if (newstr) {
+ free(newstr);
+ }
}
+
+ return result;
}
Index: php4/ext/session/config.h.stub
diff -u php4/ext/session/config.h.stub:1.2 php4/ext/session/config.h.stub:1.3
--- php4/ext/session/config.h.stub:1.2 Fri Aug 27 17:03:22 1999
+++ php4/ext/session/config.h.stub Sat Sep 11 19:47:16 1999
@@ -1,3 +1,4 @@
/* define if you want to use the session extension */
+#undef TRANS_SID
#undef HAVE_LIBMM
Index: php4/ext/session/config.m4
diff -u php4/ext/session/config.m4:1.3 php4/ext/session/config.m4:1.4
--- php4/ext/session/config.m4:1.3 Fri Sep 3 13:46:39 1999
+++ php4/ext/session/config.m4 Sat Sep 11 19:47:16 1999
@@ -1,9 +1,8 @@
-dnl $Id: config.m4,v 1.3 1999/09/03 17:46:39 sas Exp $
+dnl $Id: config.m4,v 1.4 1999/09/11 23:47:16 sas Exp $
dnl config.m4 for extension session
dnl don't forget to call PHP_EXTENSION(session)
-
-MM_RESULT=no
+RESULT=no
AC_MSG_CHECKING(for mm support)
AC_ARG_WITH(mm,
[ --with-mm[=DIR] Include mm support],
@@ -22,10 +21,22 @@
AC_ADD_LIBRARY_WITH_PATH(mm, $MM_DIR/lib)
AC_ADD_INCLUDE($MM_DIR/include)
AC_DEFINE(HAVE_LIBMM, 1)
- MM_RESULT=yes
+ RESULT=yes
PHP_EXTENSION(ps_mm)
fi
+])
+AC_MSG_RESULT($RESULT)
+
+RESULT=no
+AC_MSG_CHECKING(whether to enable transparent session id propagation)
+AC_ARG_ENABLE(trans-sid,
+[ --enable-trans-sid Enable transparent session id propagation],
+[
+ if test "$enableval" = "yes" ; then
+ AC_DEFINE(TRANS_SID, 1)
+ RESULT=yes
+ fi
])
-AC_MSG_RESULT($MM_RESULT)
+AC_MSG_RESULT($RESULT)
PHP_EXTENSION(session)
Index: php4/ext/session/php_session.h
diff -u php4/ext/session/php_session.h:1.14 php4/ext/session/php_session.h:1.15
--- php4/ext/session/php_session.h:1.14 Sat Sep 11 18:31:04 1999
+++ php4/ext/session/php_session.h Sat Sep 11 19:47:16 1999
@@ -78,6 +78,7 @@
char *entropy_file;
int entropy_length;
int lifetime;
+ zend_bool define_sid;
ps_module *mod;
void *mod_data;
HashTable vars;
@@ -141,4 +142,10 @@
#define PS_SERIALIZER_ENTRY(x) \
{ #x, _ps_srlzr_encode_##x, _ps_srlzr_decode_##x }
+#ifdef TRANS_SID
+void session_adapt_uris(const char *, uint, char **, uint *);
+#else
+#define session_adapt_uris(a,b) do { } while(0)
+#endif
+
#endif
Index: php4/ext/session/session.c
diff -u php4/ext/session/session.c:1.42 php4/ext/session/session.c:1.43
--- php4/ext/session/session.c:1.42 Sat Sep 11 18:31:04 1999
+++ php4/ext/session/session.c Sat Sep 11 19:47:16 1999
@@ -39,6 +39,7 @@
#include "ext/standard/php3_var.h"
#include "ext/standard/datetime.h"
#include "ext/standard/php_lcg.h"
+#include "ext/standard/url_scanner.h"
#ifdef ZTS
int ps_globals_id;
@@ -504,6 +505,7 @@
} else {
REGISTER_STRING_CONSTANT("SID", empty_string, 0);
}
+ PS(define_sid) = define_sid;
PS(nr_open_sessions)++;
@@ -528,7 +530,6 @@
PS(mod)->destroy(&PS(mod_data), PS(id));
php_rshutdown_session_globals(PSLS_C);
php_rinit_session_globals(PSLS_C);
- PS(nr_open_sessions)--;
}
/* {{{ proto string session_name([string newname])
@@ -756,6 +757,22 @@
}
/* }}} */
+#ifdef TRANS_SID
+void session_adapt_uris(const char *src, uint srclen, char **new, uint *newlen)
+{
+ char *data;
+ size_t len;
+ char buf[512];
+ PSLS_FETCH();
+
+ if(PS(define_sid) && PS(nr_open_sessions) > 0) {
+ snprintf(buf, sizeof(buf), "%s=%s", PS(session_name), PS(id));
+ data = url_adapt(src, srclen, buf, &len);
+ *new = data;
+ *newlen = len;
+ }
+}
+#endif
/* {{{ proto session_unset()
Unset all registered variables */
@@ -784,6 +801,7 @@
_php_find_ps_serializer(INI_STR("session.serialize_handler") PSLS_CC);
zend_hash_init(&PS(vars), 0, NULL, NULL, 0);
+ PS(define_sid) = 0;
PS(save_path) = estrdup(INI_STR("session.save_path"));
PS(session_name) = estrdup(INI_STR("session.name"));
PS(entropy_file) = estrdup(INI_STR("session.entropy_file"));
Index: php4/ext/standard/Makefile.am
diff -u php4/ext/standard/Makefile.am:1.8 php4/ext/standard/Makefile.am:1.9
--- php4/ext/standard/Makefile.am:1.8 Sun Aug 29 16:11:54 1999
+++ php4/ext/standard/Makefile.am Sat Sep 11 19:47:16 1999
@@ -8,7 +8,7 @@
pack.c pageinfo.c rand.c reg.c soundex.c string.c \
syslog.c type.c uniqid.c url.c iptc.c var.c quot_print.c \
cyr_convert.c flock_compat.c crypt.c dl.c head.c post.c \
- parsedate.y lcg.c
+ parsedate.y lcg.c url_scanner.c
#number.o: number.c
# $(CC) $(CFLAGS) -w@WARNING_LEVEL@ -c $< -o $@