472,950 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,950 software developers and data experts.

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 2038
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Robert Oschler | last post by:
Hello, I have a web site that has an audio file on it that I make available for download. Right now I'm using the "right-click/save-as" approach. This is because left-clicking the link to the...
6
by: ´َرم | last post by:
I want to create a multi-stream file using C#,but System.IO.File.Create method do not support this.
6
by: Kaki | last post by:
Given a file, how do I know if it's ascii or unicode or binary? And how do I know if it's rtf or html or etc? In other words, how do I find the stream type or mime type? (No, file extension cannot...
7
by: Jeronimo Bertran | last post by:
Hello , I am trying to read a resource in my .net app using a stream. I found the GetMainfestResourceStream but I am having trouble using it with the resources I edit with the resource editor. ...
2
by: RahulatCSE | last post by:
My requirement is to stream realtime stock-quote data to HTML page using IIS. Is there any workout apart from creating ISAPI extension?
1
by: Petr Prikryl | last post by:
Do you think that the following could became PEP (pre PEP). Please, read it, comment it, reformulate it,... Abstract Introduction of the mechanism for language extensions via modules...
12
by: Aleks Kleyn | last post by:
I use streamReader to read files from hard drive. Some files which I read have spaces at the end of line. However whatever code I use StreamReader1 = System.IO.File.OpenText(file) or...
1
by: Datawright | last post by:
This might be a daft post but I am very new to the SOAP Extension class. Basically I have taken the MSDN example that writes the SOAP request and response to a log file in C#. The code works...
5
by: Chuck Anderson | last post by:
I run Apache 2.0.55, and Php (both 4.4.1 and 5.2.5) on my home PC (Windows XP). One of the scripts that I run daily needs to access a secure URL (https://..............). When I am running Php4,...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.