470,862 Members | 1,708 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,862 developers. It's quick & easy.

PHP Stream in Extension Programming

Hi,

I am having problems trying to connect to php://input through a stream in a
php extension. The extension successfully connects to php://input but when
I pass data to it, the code I have sent does not execute. I also want to
retrieve the output from php as well. You'll see what I mean in the code I
have provided below. I am new to extension programming in PHP, so any help
with the structure or layout of my program would be most appreciated.

THANKS IN ADVANCED!

#include "php.h"
#include "php_streams.h"
#include <stdio.h>
#include <string.h>

PHP_MINFO_FUNCTION(benchivers);
ZEND_FUNCTION(hello_world);
ZEND_FUNCTION(passphp);

zend_function_entry benchivers_functions[] =
{
ZEND_FE(passphp, NULL)
ZEND_FE(hello_world, NULL)
{NULL, NULL, NULL}
};

zend_module_entry benchivers_module_entry = {
STANDARD_MODULE_HEADER,
"Testing",
benchivers_functions,
NULL,
NULL,
NULL,
NULL,
PHP_MINFO(benchivers),
NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
};
#ifdef COMPILE_DL_BENCHIVERS
ZEND_GET_MODULE(benchivers)
#endif

PHP_MINFO_FUNCTION(benchivers){
php_info_print_table_start();
php_info_print_table_row(2, "Testing", "enabled");
php_info_print_table_end();
}

ZEND_FUNCTION(hello_world)
{
zend_printf("Hello Ben Chivers<br>");
}

ZEND_FUNCTION(passphp)
{
char buf1[1024] = "<?php mkdir('C:\\Documents and
Settings\\Administrator\\Desktop\\BenChivers', 0755); ?>";
size_t bt;

php_stream * stream = php_stream_open_wrapper("php://input", "w+b",
REPORT_ERRORS, NULL);
if (stream) {
zend_printf("Connected<br>");

bt = php_stream_write(stream, buf1, sizeof(buf1));

while(!php_stream_eof(stream)) {
char buf[1024];

if (php_stream_gets(stream, buf, sizeof(buf))) {
zend_printf("Printing output<br>");
zend_printf(buf);
} else {
break;
}
}
php_stream_close(stream);
}
}

Many Regards,
Ben Chivers
Jul 17 '05 #1
1 1980
"Ben Chivers" <be***********@ntlworld.com> wrote in message
news:8b**************************@posting.google.c om...
Hi,

I am having problems trying to connect to php://input through a stream in a php extension. The extension successfully connects to php://input but when I pass data to it, the code I have sent does not execute. I also want to
retrieve the output from php as well. You'll see what I mean in the code I have provided below. I am new to extension programming in PHP, so any help with the structure or layout of my program would be most appreciated.


php://input is read-only, so maybe that's the problem.
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by īů—„ | last post: by
6 posts views Thread by Kaki | last post: by
7 posts views Thread by Jeronimo Bertran | last post: by
2 posts views Thread by RahulatCSE | last post: by
12 posts views Thread by Aleks Kleyn | last post: by
1 post views Thread by Datawright | last post: by
5 posts views Thread by Chuck Anderson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.