473,396 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 2052
"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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.