Jump to content

PHP extension access internal variables


castis

Recommended Posts

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, &currentPage) == 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. :)

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;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.