2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2006, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
15 #define HTTP_WANT_SAPI
20 #include "php_variables.h"
21 #include "zend_interfaces.h"
25 # include "ext/iconv/php_iconv.h"
26 # include "ext/standard/url.h"
29 #include "php_http_api.h"
30 #include "php_http_url_api.h"
31 #include "php_http_querystring_object.h"
32 #include "php_http_exception_object.h"
34 #define HTTP_BEGIN_ARGS(method, req_args) HTTP_BEGIN_ARGS_EX(HttpQueryString, method, 0, req_args)
35 #define HTTP_EMPTY_ARGS(method) HTTP_EMPTY_ARGS_EX(HttpQueryString, method, 0)
36 #define HTTP_QUERYSTRING_ME(method, visibility) PHP_ME(HttpQueryString, method, HTTP_ARGS(HttpQueryString, method), visibility)
37 #define HTTP_QUERYSTRING_GME(method, visibility) PHP_ME(HttpQueryString, method, HTTP_ARGS(HttpQueryString, __getter), visibility)
39 HTTP_BEGIN_ARGS(__construct
, 0)
40 HTTP_ARG_VAL(global
, 0)
41 HTTP_ARG_VAL(params
, 0)
45 HTTP_BEGIN_ARGS(singleton
, 0)
46 HTTP_ARG_VAL(global
, 0)
50 HTTP_EMPTY_ARGS(toArray
);
51 HTTP_EMPTY_ARGS(toString
);
53 HTTP_BEGIN_ARGS(get
, 0)
56 HTTP_ARG_VAL(defval
, 0)
57 HTTP_ARG_VAL(delete, 0)
60 HTTP_BEGIN_ARGS(set
, 1)
61 HTTP_ARG_VAL(params
, 0)
64 HTTP_BEGIN_ARGS(__getter
, 1)
66 HTTP_ARG_VAL(defval
, 0)
67 HTTP_ARG_VAL(delete, 0)
71 HTTP_BEGIN_ARGS(xlate
, 2)
72 HTTP_ARG_VAL(from_encoding
, 0)
73 HTTP_ARG_VAL(to_encoding
, 0)
77 HTTP_EMPTY_ARGS(serialize
);
78 HTTP_BEGIN_ARGS(unserialize
, 1)
79 HTTP_ARG_VAL(serialized
, 0)
82 #define OBJ_PROP_CE http_querystring_object_ce
83 zend_class_entry
*http_querystring_object_ce
;
84 zend_function_entry http_querystring_object_fe
[] = {
85 HTTP_QUERYSTRING_ME(__construct
, ZEND_ACC_PUBLIC
|ZEND_ACC_CTOR
|ZEND_ACC_FINAL
)
87 HTTP_QUERYSTRING_ME(toArray
, ZEND_ACC_PUBLIC
)
88 HTTP_QUERYSTRING_ME(toString
, ZEND_ACC_PUBLIC
)
89 ZEND_MALIAS(HttpQueryString
, __toString
, toString
, HTTP_ARGS(HttpQueryString
, toString
), ZEND_ACC_PUBLIC
)
91 HTTP_QUERYSTRING_ME(get
, ZEND_ACC_PUBLIC
)
92 HTTP_QUERYSTRING_ME(set
, ZEND_ACC_PUBLIC
)
94 HTTP_QUERYSTRING_GME(getBool
, ZEND_ACC_PUBLIC
)
95 HTTP_QUERYSTRING_GME(getInt
, ZEND_ACC_PUBLIC
)
96 HTTP_QUERYSTRING_GME(getFloat
, ZEND_ACC_PUBLIC
)
97 HTTP_QUERYSTRING_GME(getString
, ZEND_ACC_PUBLIC
)
98 HTTP_QUERYSTRING_GME(getArray
, ZEND_ACC_PUBLIC
)
99 HTTP_QUERYSTRING_GME(getObject
, ZEND_ACC_PUBLIC
)
102 HTTP_QUERYSTRING_ME(singleton
, ZEND_ACC_PUBLIC
|ZEND_ACC_STATIC
)
105 HTTP_QUERYSTRING_ME(xlate
, ZEND_ACC_PUBLIC
)
108 /* Implements Serializable */
109 HTTP_QUERYSTRING_ME(serialize
, ZEND_ACC_PUBLIC
)
110 HTTP_QUERYSTRING_ME(unserialize
, ZEND_ACC_PUBLIC
)
114 static zend_object_handlers http_querystring_object_handlers
;
116 PHP_MINIT_FUNCTION(http_querystring_object
)
118 HTTP_REGISTER_CLASS_EX(HttpQueryString
, http_querystring_object
, NULL
, 0);
121 zend_class_implements(http_querystring_object_ce TSRMLS_CC
, 1, zend_ce_serializable
);
124 DCL_STATIC_PROP_N(PRIVATE
, instance
);
125 DCL_PROP_N(PRIVATE
, queryArray
);
126 DCL_PROP(PRIVATE
, string
, queryString
, "");
129 DCL_CONST(long, "TYPE_BOOL", HTTP_QUERYSTRING_TYPE_BOOL
);
130 DCL_CONST(long, "TYPE_INT", HTTP_QUERYSTRING_TYPE_INT
);
131 DCL_CONST(long, "TYPE_FLOAT", HTTP_QUERYSTRING_TYPE_FLOAT
);
132 DCL_CONST(long, "TYPE_STRING", HTTP_QUERYSTRING_TYPE_STRING
);
133 DCL_CONST(long, "TYPE_ARRAY", HTTP_QUERYSTRING_TYPE_ARRAY
);
134 DCL_CONST(long, "TYPE_OBJECT", HTTP_QUERYSTRING_TYPE_OBJECT
);
137 HTTP_LONG_CONSTANT("HTTP_QUERYSTRING_TYPE_BOOL", HTTP_QUERYSTRING_TYPE_BOOL
);
138 HTTP_LONG_CONSTANT("HTTP_QUERYSTRING_TYPE_INT", HTTP_QUERYSTRING_TYPE_INT
);
139 HTTP_LONG_CONSTANT("HTTP_QUERYSTRING_TYPE_FLOAT", HTTP_QUERYSTRING_TYPE_FLOAT
);
140 HTTP_LONG_CONSTANT("HTTP_QUERYSTRING_TYPE_STRING", HTTP_QUERYSTRING_TYPE_STRING
);
141 HTTP_LONG_CONSTANT("HTTP_QUERYSTRING_TYPE_ARRAY", HTTP_QUERYSTRING_TYPE_ARRAY
);
142 HTTP_LONG_CONSTANT("HTTP_QUERYSTRING_TYPE_OBJECT", HTTP_QUERYSTRING_TYPE_OBJECT
);
147 zend_object_value
_http_querystring_object_new(zend_class_entry
*ce TSRMLS_DC
)
149 return http_querystring_object_new_ex(ce
, NULL
);
152 zend_object_value
_http_querystring_object_new_ex(zend_class_entry
*ce
, http_querystring_object
**ptr TSRMLS_DC
)
154 zend_object_value ov
;
155 http_querystring_object
*o
;
157 o
= ecalloc(1, sizeof(http_querystring_object
));
164 ALLOC_HASHTABLE(OBJ_PROP(o
));
165 zend_hash_init(OBJ_PROP(o
), zend_hash_num_elements(&ce
->default_properties
), NULL
, ZVAL_PTR_DTOR
, 0);
166 zend_hash_copy(OBJ_PROP(o
), &ce
->default_properties
, (copy_ctor_func_t
) zval_add_ref
, NULL
, sizeof(zval
*));
168 ov
.handle
= putObject(http_querystring_object
, o
);
169 ov
.handlers
= &http_querystring_object_handlers
;
174 void _http_querystring_object_free(zend_object
*object TSRMLS_DC
)
176 http_querystring_object
*o
= (http_querystring_object
*) object
;
179 zend_hash_destroy(OBJ_PROP(o
));
180 FREE_HASHTABLE(OBJ_PROP(o
));
185 /* {{{ querystring helpers */
186 #define http_querystring_update(qa, qs) _http_querystring_update((qa), (qs) TSRMLS_CC)
187 static inline void _http_querystring_update(zval
*qarray
, zval
*qstring TSRMLS_DC
);
188 #define http_querystring_modify_array_ex(q, k, kl, pe) _http_querystring_modify_array_ex((q), (k), (kl), (pe) TSRMLS_CC)
189 static inline int _http_querystring_modify_array_ex(zval
*qarray
, char *key
, int keylen
, zval
*params_entry TSRMLS_DC
);
190 #define http_querystring_modify_array(q, p) _http_querystring_modify_array((q), (p) TSRMLS_CC)
191 static inline int _http_querystring_modify_array(zval
*qarray
, zval
*params TSRMLS_DC
);
192 #define http_querystring_modify(q, p) _http_querystring_modify((q), (p) TSRMLS_CC)
193 static inline int _http_querystring_modify(zval
*qarray
, zval
*params TSRMLS_DC
);
194 #define http_querystring_get(o, t, n, l, def, del, r) _http_querystring_get((o), (t), (n), (l), (def), (del), (r) TSRMLS_CC)
195 static inline void _http_querystring_get(zval
*this_ptr
, int type
, char *name
, uint name_len
, zval
*defval
, zend_bool del
, zval
*return_value TSRMLS_DC
);
197 #define http_querystring_xlate(a, p, ie, oe) _http_querystring_xlate((a), (p), (ie), (oe) TSRMLS_CC)
198 static inline int _http_querystring_xlate(zval
*array
, zval
*param
, const char *ie
, const char *oe TSRMLS_DC
)
202 char *xlate_str
= NULL
, *xkey
, *kstr
= NULL
;
203 size_t xlate_len
= 0, xlen
;
207 FOREACH_KEYLENVAL(pos
, param
, kstr
, klen
, kidx
, entry
) {
209 if (PHP_ICONV_ERR_SUCCESS
!= php_iconv_string(kstr
, klen
-1, &xkey
, &xlen
, oe
, ie
)) {
210 http_error_ex(HE_WARNING
, HTTP_E_QUERYSTRING
, "Failed to convert '%.*s' from '%s' to '%s'", klen
-1, kstr
, ie
, oe
);
215 if (Z_TYPE_PP(entry
) == IS_STRING
) {
216 if (PHP_ICONV_ERR_SUCCESS
!= php_iconv_string(Z_STRVAL_PP(entry
), Z_STRLEN_PP(entry
), &xlate_str
, &xlate_len
, oe
, ie
)) {
220 http_error_ex(HE_WARNING
, HTTP_E_QUERYSTRING
, "Failed to convert '%.*s' from '%s' to '%s'", Z_STRLEN_PP(entry
), Z_STRVAL_PP(entry
), ie
, oe
);
224 add_assoc_stringl_ex(array
, xkey
, xlen
+1, xlate_str
, xlate_len
, 0);
226 add_index_stringl(array
, kidx
, xlate_str
, xlate_len
, 0);
228 } else if (Z_TYPE_PP(entry
) == IS_ARRAY
) {
231 MAKE_STD_ZVAL(subarray
);
232 array_init(subarray
);
234 add_assoc_zval_ex(array
, xkey
, xlen
+1, subarray
);
236 add_index_zval(array
, kidx
, subarray
);
238 if (SUCCESS
!= http_querystring_xlate(subarray
, *entry
, ie
, oe
)) {
253 #endif /* HAVE_ICONV */
255 #define http_querystring_instantiate(g) _http_querystring_instantiate((g) TSRMLS_CC)
256 static inline zval
*_http_querystring_instantiate(zend_bool global TSRMLS_DC
)
258 zval
*zobj
, *zglobal
;
260 MAKE_STD_ZVAL(zglobal
);
261 ZVAL_BOOL(zglobal
, global
);
264 Z_TYPE_P(zobj
) = IS_OBJECT
;
265 Z_OBJVAL_P(zobj
) = http_querystring_object_new(http_querystring_object_ce
);
266 zend_call_method_with_1_params(&zobj
, Z_OBJCE_P(zobj
), NULL
, "__construct", NULL
, zglobal
);
268 zval_ptr_dtor(&zglobal
);
273 static inline void _http_querystring_update(zval
*qarray
, zval
*qstring TSRMLS_DC
)
278 if (Z_TYPE_P(qarray
) != IS_ARRAY
) {
279 convert_to_array(qarray
);
281 if (SUCCESS
== http_urlencode_hash_ex(Z_ARRVAL_P(qarray
), 0, NULL
, 0, &s
, &l
)) {
283 ZVAL_STRINGL(qstring
, s
, l
, 0);
285 http_error(HE_WARNING
, HTTP_E_QUERYSTRING
, "Failed to update query string");
288 static inline int _http_querystring_modify_array_ex(zval
*qarray
, char *key
, int keylen
, zval
*params_entry TSRMLS_DC
)
293 if (Z_TYPE_P(params_entry
) == IS_NULL
) {
294 return (SUCCESS
== zend_hash_del(Z_ARRVAL_P(qarray
), key
, keylen
));
298 if (SUCCESS
== zend_hash_find(Z_ARRVAL_P(qarray
), key
, keylen
, (void *) &qarray_entry
)) {
302 if (Z_TYPE_P(params_entry
) == IS_ARRAY
) {
303 return http_querystring_modify_array(*qarray_entry
, params_entry
);
306 if ((SUCCESS
== is_equal_function(&equal
, *qarray_entry
, params_entry TSRMLS_CC
)) && Z_BVAL(equal
)) {
312 ZVAL_ADDREF(params_entry
);
313 add_assoc_zval_ex(qarray
, key
, keylen
, params_entry
);
316 static inline int _http_querystring_modify_array(zval
*qarray
, zval
*params TSRMLS_DC
)
325 FOREACH_KEYLENVAL(pos
, params
, key
, keylen
, idx
, params_entry
) {
327 if (http_querystring_modify_array_ex(qarray
, key
, keylen
, *params_entry
)) {
331 keylen
= spprintf(&key
, 0, "%lu", idx
);
332 if (http_querystring_modify_array_ex(qarray
, key
, keylen
, *params_entry
)) {
342 static inline int _http_querystring_modify(zval
*qarray
, zval
*params TSRMLS_DC
)
344 if (Z_TYPE_P(params
) == IS_ARRAY
) {
345 return http_querystring_modify_array(qarray
, params
);
346 } else if (Z_TYPE_P(params
) == IS_OBJECT
) {
347 if (!instanceof_function(Z_OBJCE_P(params
), http_querystring_object_ce TSRMLS_CC
)) {
349 INIT_ZARR(temp_array
, HASH_OF(params
));
350 return http_querystring_modify_array(qarray
, &temp_array
);
352 return http_querystring_modify_array(qarray
, GET_PROP_EX(params
, queryArray
));
361 convert_to_string_ex(¶ms
);
362 sapi_module
.treat_data(PARSE_STRING
, estrdup(Z_STRVAL_P(params
)), &array TSRMLS_CC
);
363 zval_ptr_dtor(¶ms
);
364 rv
= http_querystring_modify_array(qarray
, &array
);
369 static inline void _http_querystring_get(zval
*this_ptr
, int type
, char *name
, uint name_len
, zval
*defval
, zend_bool del
, zval
*return_value TSRMLS_DC
)
371 zval
**arrval
, *qarray
= GET_PROP(queryArray
);
373 if ((Z_TYPE_P(qarray
) == IS_ARRAY
) && (SUCCESS
== zend_hash_find(Z_ARRVAL_P(qarray
), name
, name_len
+ 1, (void *) &arrval
))) {
374 RETVAL_ZVAL(*arrval
, 1, 0);
377 convert_to_type(type
, return_value
);
380 if (del
&& (SUCCESS
== zend_hash_del(Z_ARRVAL_P(qarray
), name
, name_len
+ 1))) {
381 http_querystring_update(qarray
, GET_PROP(queryString
));
384 RETURN_ZVAL(defval
, 1, 0);
389 /* {{{ proto final void HttpQueryString::__construct([bool global = true[, mixed add])
391 * Creates a new HttpQueryString object instance.
392 * Operates on and modifies $_GET and $_SERVER['QUERY_STRING'] if global is TRUE.
394 PHP_METHOD(HttpQueryString
, __construct
)
396 zend_bool global
= 1;
397 zval
*params
= NULL
, *qarray
= NULL
, *qstring
= NULL
, **_GET
, **_SERVER
, **QUERY_STRING
;
400 if (!sapi_module
.treat_data
) {
401 http_error(HE_ERROR
, HTTP_E_QUERYSTRING
, "The SAPI does not have a treat_data function registered");
402 } else if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|bz", &global
, ¶ms
)) {
405 zend_is_auto_global("_SERVER", lenof("_SERVER") TSRMLS_CC
);
407 if ( (SUCCESS
== zend_hash_find(&EG(symbol_table
), "_SERVER", sizeof("_SERVER"), (void *) &_SERVER
)) &&
408 (Z_TYPE_PP(_SERVER
) == IS_ARRAY
) &&
409 (SUCCESS
== zend_hash_find(Z_ARRVAL_PP(_SERVER
), "QUERY_STRING", sizeof("QUERY_STRING"), (void *) &QUERY_STRING
))) {
411 qstring
= *QUERY_STRING
;
413 zend_is_auto_global("_GET", lenof("_GET") TSRMLS_CC
);
415 if ((SUCCESS
== zend_hash_find(&EG(symbol_table
), "_GET", sizeof("_GET"), (void *) &_GET
)) && (Z_TYPE_PP(_GET
) == IS_ARRAY
)) {
418 http_error(HE_WARNING
, HTTP_E_QUERYSTRING
, "Could not acquire reference to superglobal GET array");
421 http_error(HE_WARNING
, HTTP_E_QUERYSTRING
, "Could not acquire reference to QUERY_STRING");
424 if (qarray
&& qstring
) {
425 if (Z_TYPE_P(qstring
) != IS_STRING
) {
426 convert_to_string(qstring
);
429 SET_PROP(queryArray
, qarray
);
430 SET_PROP(queryString
, qstring
);
431 GET_PROP(queryArray
)->is_ref
= 1;
432 GET_PROP(queryString
)->is_ref
= 1;
435 http_querystring_modify(GET_PROP(queryArray
), params
);
437 http_querystring_update(GET_PROP(queryArray
), GET_PROP(queryString
));
440 qarray
= ecalloc(1, sizeof(zval
));
443 SET_PROP(queryArray
, qarray
);
444 UPD_STRL(queryString
, "", 0);
446 if (params
&& http_querystring_modify(qarray
, params
)) {
447 http_querystring_update(qarray
, GET_PROP(queryString
));
455 /* {{{ proto string HttpQueryString::toString()
457 * Returns the string representation.
459 PHP_METHOD(HttpQueryString
, toString
)
462 RETURN_PROP(queryString
);
466 /* {{{ proto array HttpQueryString::toArray()
468 * Returns the array representation.
470 PHP_METHOD(HttpQueryString
, toArray
)
473 RETURN_PROP(queryArray
);
477 /* {{{ proto mixed HttpQueryString::get([string key[, mixed type = 0[, mixed defval = NULL[, bool delete = false]]]])
479 * Get (part of) the query string.
481 * The type parameter is either one of the HttpQueryString::TYPE_* constants or a type abbreviation like
482 * "b" for bool, "i" for int, "f" for float, "s" for string, "a" for array and "o" for a stdClass object.
484 PHP_METHOD(HttpQueryString
, get
)
490 zval
*ztype
= NULL
, *defval
= NULL
;
492 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|szzb", &name
, &name_len
, &ztype
, &defval
, &del
)) {
493 if (name
&& name_len
) {
495 if (Z_TYPE_P(ztype
) == IS_LONG
) {
496 type
= Z_LVAL_P(ztype
);
497 } else if(Z_TYPE_P(ztype
) == IS_STRING
) {
498 switch (Z_STRVAL_P(ztype
)[0])
501 case 'b': type
= HTTP_QUERYSTRING_TYPE_BOOL
; break;
503 case 'i': type
= HTTP_QUERYSTRING_TYPE_INT
; break;
505 case 'f': type
= HTTP_QUERYSTRING_TYPE_FLOAT
; break;
507 case 's': type
= HTTP_QUERYSTRING_TYPE_STRING
; break;
509 case 'a': type
= HTTP_QUERYSTRING_TYPE_ARRAY
; break;
511 case 'o': type
= HTTP_QUERYSTRING_TYPE_OBJECT
; break;
515 http_querystring_get(getThis(), type
, name
, name_len
, defval
, del
, return_value
);
517 RETURN_PROP(queryString
);
523 /* {{{ proto string HttpQueryString::set(mixed params)
525 * Set query string entry/entries. NULL values will unset the variable.
527 PHP_METHOD(HttpQueryString
, set
)
531 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "z", ¶ms
)) {
532 zval
*qarray
= GET_PROP(queryArray
);
533 if (http_querystring_modify(qarray
, params
)) {
534 http_querystring_update(qarray
, GET_PROP(queryString
));
539 RETURN_PROP(queryString
);
545 /* {{{ proto static HttpQueryString HttpQueryString::singleton([bool global = true])
547 * Get a single instance (differentiates between the global setting).
549 PHP_METHOD(HttpQueryString
, singleton
)
551 zend_bool global
= 1;
552 zval
*instance
= GET_STATIC_PROP(instance
);
555 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|b", &global
)) {
556 zval
**zobj_ptr
= NULL
, *zobj
= NULL
;
558 if (Z_TYPE_P(instance
) == IS_ARRAY
) {
559 if (SUCCESS
== zend_hash_index_find(Z_ARRVAL_P(instance
), global
, (void *) &zobj_ptr
)) {
560 RETVAL_ZVAL(*zobj_ptr
, 1, 0);
562 zobj
= http_querystring_instantiate(global
);
563 add_index_zval(instance
, global
, zobj
);
564 RETVAL_OBJECT(zobj
, 1);
567 MAKE_STD_ZVAL(instance
);
568 array_init(instance
);
570 zobj
= http_querystring_instantiate(global
);
571 add_index_zval(instance
, global
, zobj
);
572 RETVAL_OBJECT(zobj
, 1);
574 SET_STATIC_PROP(instance
, instance
);
575 zval_ptr_dtor(&instance
);
583 /* {{{ Getters by type */
584 #define HTTP_QUERYSTRING_GETTER(method, TYPE) \
585 PHP_METHOD(HttpQueryString, method) \
589 zval *defval = NULL; \
591 if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|zb", &name, &name_len, &defval, &del)) { \
592 http_querystring_get(getThis(), TYPE, name, name_len, defval, del, return_value); \
595 HTTP_QUERYSTRING_GETTER(getBool
, IS_BOOL
);
596 HTTP_QUERYSTRING_GETTER(getInt
, IS_LONG
);
597 HTTP_QUERYSTRING_GETTER(getFloat
, IS_DOUBLE
);
598 HTTP_QUERYSTRING_GETTER(getString
, IS_STRING
);
599 HTTP_QUERYSTRING_GETTER(getArray
, IS_ARRAY
);
600 HTTP_QUERYSTRING_GETTER(getObject
, IS_OBJECT
);
604 /* {{{ proto bool HttpQueryString::xlate(string ie, string oe)
606 * Converts the query string from the source encoding ie to the target encoding oe.
607 * WARNING: Don't use any character set that can contain NUL bytes like UTF-16.
609 * Returns TRUE on success or FALSE on failure.
611 PHP_METHOD(HttpQueryString
, xlate
)
618 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "ss", &ie
, &ie_len
, &oe
, &oe_len
)) {
622 qa
= GET_PROP(queryArray
);
623 qs
= GET_PROP(queryString
);
627 if (SUCCESS
== (rs
= http_querystring_xlate(&xa
, qa
, ie
, oe
))) {
628 zend_hash_clean(Z_ARRVAL_P(qa
));
629 zend_hash_copy(Z_ARRVAL_P(qa
), Z_ARRVAL(xa
), (copy_ctor_func_t
) zval_add_ref
, NULL
, sizeof(zval
*));
630 http_querystring_update(qa
, qs
);
637 #endif /* HAVE_ICONV */
639 /* {{{ proto string HttpQueryString::serialize()
641 * Implements Serializable.
643 PHP_METHOD(HttpQueryString
, serialize
)
646 RETURN_PROP(queryString
);
650 /* {{{ proto void HttpQueryString::unserialize(string serialized)
652 * Implements Serializable.
654 PHP_METHOD(HttpQueryString
, unserialize
)
659 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "z", &serialized
)) {
660 if (Z_TYPE_P(serialized
) == IS_STRING
) {
661 zval
*qa
= GET_PROP(queryArray
);
663 zend_hash_clean(Z_ARRVAL_P(qa
));
664 http_querystring_modify(qa
, serialized
);
665 http_querystring_update(qa
, GET_PROP(queryString
));
667 http_error(HE_WARNING
, HTTP_E_QUERYSTRING
, "Expected a string as parameter");
674 #endif /* ZEND_ENGINE_2 */
681 * vim600: noet sw=4 ts=4 fdm=marker
682 * vim<600: noet sw=4 ts=4