castis Posted January 5, 2009 Share Posted January 5, 2009 I have an extension that gives you filterGet(), it's being called via filterGet($_GET, [arg, ...]); and i'd like to eliminate the first argument and grab $_GET straight from the engine. How would I go about doing that? Thanks! Link to comment https://forums.phpfreaks.com/topic/139578-php-extension-access-internal-variables/ Share on other sites More sharing options...
rhodesa Posted January 5, 2009 Share Posted January 5, 2009 instead of: function filterGet ( $get ) { ... return $get; } it would just be: function filterGet ( ) { $get = $_GET; return $get; } Link to comment https://forums.phpfreaks.com/topic/139578-php-extension-access-internal-variables/#findComment-730197 Share on other sites More sharing options...
castis Posted January 5, 2009 Author Share Posted January 5, 2009 I'm doing this in c the code I currently am fiddling with is ZEND_FUNCTION(autopage){ long threadCount = 0; int perPage = 0; int currentPage = 0; /* get and assign arguments */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lii", &threadCount, &perPage, ¤tPage) == FAILURE){ RETURN_STRING("Bad parameters!", true); } long totalPagesDecimal = threadCount/perPage; double totalPages = ceil(totalPagesDecimal); RETURN_DOUBLE(totalPages); } i want to know how to get $_GET directly from the engine while inside an extension. Link to comment https://forums.phpfreaks.com/topic/139578-php-extension-access-internal-variables/#findComment-730212 Share on other sites More sharing options...
corbin Posted January 6, 2009 Share Posted January 6, 2009 It seems like it would kind of go against logic to have the function check the GET array its self.... Link to comment https://forums.phpfreaks.com/topic/139578-php-extension-access-internal-variables/#findComment-730581 Share on other sites More sharing options...
btherl Posted January 8, 2009 Share Posted January 8, 2009 I see code like this: PG(http_globals)[TRACK_VARS_GET] It appears to be a zval *. That might be the one you're looking for. Link to comment https://forums.phpfreaks.com/topic/139578-php-extension-access-internal-variables/#findComment-732164 Share on other sites More sharing options...
castis Posted January 13, 2009 Author Share Posted January 13, 2009 btherl, you're the man. the code that works is as follows if you have ?apples=oranges at the end of your page, this will filterGet() will return 'oranges' ZEND_FUNCTION(filterGet) { zval **data; HashTable *arr_hash; HashPosition pointer; int array_count; zval *arr = PG(http_globals)[TRACK_VARS_GET]; arr_hash = Z_ARRVAL_P(arr); array_count = zend_hash_num_elements(arr_hash); for( zend_hash_internal_pointer_reset_ex(arr_hash, &pointer); zend_hash_get_current_data_ex(arr_hash, (void**) &data, &pointer) == SUCCESS; zend_hash_move_forward_ex(arr_hash, &pointer)) { if (Z_TYPE_PP(data) == IS_STRING) { PHPWRITE(Z_STRVAL_PP(data), Z_STRLEN_PP(data)); } return; } RETURN_NULL(); return; } Link to comment https://forums.phpfreaks.com/topic/139578-php-extension-access-internal-variables/#findComment-736358 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.