/* {{{ proto bool virtual(string uri) Perform an apache sub-request */ PHP_FUNCTION(virtual) { char *filename; size_t filename_len; request_rec *rr; if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &filename, &filename_len) == FAILURE) { return; } if (!(rr = php_apache_lookup_uri(filename))) { php_error_docref(NULL, E_WARNING, "Unable to include '%s' - URI lookup failed", filename); RETURN_FALSE; } if (rr->status != HTTP_OK) { php_error_docref(NULL, E_WARNING, "Unable to include '%s' - error finding URI", filename); ap_destroy_sub_req(rr); RETURN_FALSE; } /* Flush everything. */ php_output_end_all(); php_header(); /* Ensure that the ap_r* layer for the main request is flushed, to * work around http://issues.apache.org/bugzilla/show_bug.cgi?id=17629 */ ap_rflush(rr->main); if (ap_run_sub_req(rr)) { php_error_docref(NULL, E_WARNING, "Unable to include '%s' - request execution failed", filename); ap_destroy_sub_req(rr); RETURN_FALSE; } ap_destroy_sub_req(rr); RETURN_TRUE; }
PHP_METHOD(imageObj, saveImage) { zval *zobj = getThis(); zval *zmap = NULL; char *filename = NULL; long filename_len = 0; php_image_object *php_image; php_map_object *php_map; int status = MS_SUCCESS; /* stdout specific vars */ int size=0; void *iptr=NULL; PHP_MAPSCRIPT_ERROR_HANDLING(TRUE); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO", &filename, &filename_len, &zmap, mapscript_ce_map) == FAILURE) { PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE); return; } PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE); php_image = (php_image_object *) zend_object_store_get_object(zobj TSRMLS_CC); if (zmap) php_map = (php_map_object *) zend_object_store_get_object(zmap TSRMLS_CC); if(filename_len > 0) { if ((status = msSaveImage((zmap ? php_map->map:NULL), php_image->image, filename) != MS_SUCCESS)) { mapscript_throw_mapserver_exception("Failed writing image to %s" TSRMLS_CC, filename); return; } RETURN_LONG(status); } /* no filename - read stdout */ /* if there is no output buffer active, set the header */ //handle changes in PHP 5.4.x #if PHP_VERSION_ID < 50399 if (OG(ob_nesting_level)<=0) { php_header(TSRMLS_C); } #else if (php_output_get_level(TSRMLS_C)<=0) { php_header(TSRMLS_C); } #endif if (MS_RENDERER_PLUGIN(php_image->image->format)) { iptr = (void *)msSaveImageBuffer(php_image->image, &size, php_image->image->format); } else if (php_image->image->format->name && (strcasecmp(php_image->image->format->name, "imagemap")==0)) { iptr = php_image->image->img.imagemap; size = strlen(php_image->image->img.imagemap); } if (size == 0) { mapscript_throw_mapserver_exception("Failed writing image to stdout" TSRMLS_CC); return; } else { php_write(iptr, size TSRMLS_CC); status = MS_SUCCESS; /* status = size; why should we return the size ?? */ msFree(iptr); } RETURN_LONG(status); }