php-windows Digest 21 Dec 2001 16:05:07 -0000 Issue 912
Topics (messages 11051 through 11063):
Re: email() problem
11051 by: Daniel Parsons
11052 by: Michael Sims
FrameSet Problem with PHP, Pls Help!
11053 by: Jack
Problem with Getting Values from Cookie
11054 by: Jack
Cookie Can't Display Name on other page
11055 by: Jack
11063 by: Chris Lee
Newbie Q - PHP on Apache file not found Q
11056 by: James Mansfield
Send CTRL + Z ( EOF ) key to a PHP (console) program created with CreateProcess
11057 by: Silverio Diquigiovanni
11058 by: FPU.WHITES1.FRIENDSPROVIDENT.CO.UK
PHP dll's
11059 by: J_L
11062 by: Jonathan David Edwin Wright
error mesage -configure php on wind98 +apache1.3
11060 by: p13zo
11061 by: Jonathan David Edwin Wright
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
When using IIS it is a good idea to use '\r\n' instead of '\n' when
using the mail() function.
I've also had problems with the 'From:' header in the past. This syntax
seems to work though:
$mailheaders = 'From: "A display name" <[EMAIL PROTECTED]>\r\n'
IIS seems to have real problem with that if you leave out the email
address (and just have '"Name" <>'). The foramtting above is the one
that I worked for me when wrestling with it myself and I haven't had the
will to see how much IIS will let you play with it.
HTH,
D.
> -----Original Message-----
> From: Thomas Orr [mailto:[EMAIL PROTECTED]]
> Sent: Friday, 21 December 2001 3:34 p.m.
> To: [EMAIL PROTECTED]
> Subject: [PHP-WIN] email() problem
>
>
> I need help with a basic issue. I can't seem to get the
> mail() function to
> work with php4 on an xp machine running iis5. I'm new to php
> and really
> want to get it down, but every little thing I try to do
> throws errors at me.
> I just need to know what needs to be adjusted to get this
> script working.
> I've got a form that submits some fields to a php file that
> sends an email
> and generates a thank you message. Thank you for any help anyone can
> provide. This is the code:
> <?php
> $msg = "Sender Name:\t$fname $lname\n";
> $msg .= "Sender E-Mail:\t$email\n";
> $msg .= "Message:\t$street\n\n";
>
> $recipient = "[EMAIL PROTECTED]";
> $subject = "Intake Form";
>
> $mailheaders = "From: My Web Site <> \n";
> $mailheaders .= "Reply-To: $email\n\n";
>
> mail($recipient, $subject, $msg, $mailheaders);
> <------*THIS IS WHERE
> IT SCREWS UP*
>
> echo "<html><HEAD><TITLE>Information Sent!</TITLE></HEAD><BODY>";
> echo "<H1 align=center>Thank You, $fname $lname</H1>";
> echo "<P align=center>Your information has been sent.</P>";
> echo "</BODY></HTML>";
> ?>
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
> [EMAIL PROTECTED]
>
--- End Message ---
--- Begin Message ---
At 09:34 PM 12/20/2001 -0500, Thomas Orr wrote:
>I need help with a basic issue. I can't seem to get the mail() function to
>work with php4 on an xp machine running iis5. I'm new to php and really
[...]
>mail($recipient, $subject, $msg, $mailheaders); <------*THIS IS WHERE
>IT SCREWS UP*
What is the error message that you get?
What is the value of
sendmail_from =
in your PHP.INI?
What is the value of SMTP = ?
Have you tried to manually connect to your mail server and send the
message? You can do this by telnetting to port 25 on the mail server and
issuing the following:
EHLO yourdomain.com
MAIL FROM: your sendmail_from setting
RCPT TO: who you are sending the mail to
At this point you'll either get a 200 OK or some sort of 550 error. If you
get a 550 then the problem doesn't lie with PHP, but most likely the mail
server you are attempting to use doesn't permit you to relay from the IP or
with the MAIL FROM address you are using.
--- End Message ---
--- Begin Message ---
Dear all
I had designed a Index.php, this page is made of different Frames by using
UltraDev.The Frame included are Top, Left and Main. In my Left Frame which i
used left.php, i had use JavaScript to make a Menu. Top Frame is a Banner
and Main is just some content. When i browse preview it, the page just go
Perfect!
Then Later on.
I had a Login.php page which will let user login before they can access my
Internal Website.
In my Login.php Page, the user will type in the Username and Password, and i
had set to post these two var to Index.php. and in Index.php just before the
<html> tag, i add a scrpt:
<? requrie ("check.php")?> This Check.php is actually the script which will
verify the Username and Password passed from Login.php.
Once <? requrie ("check.php")?> and add into Index.html, then there is
nothing shows up, not even frames, menu or any Banner!!
Could someone pls help me with this!! I'm Stuck!!!
Thx a lot!!
Jack
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Dear all
Here is my Code in
Login Page!!!
<?php
// *** Start the session
session_start();
// *** Validate request to log in to this site.
$KT_LoginAction = $PHP_SELF;
if ($QUERY_STRING!="") $KT_LoginAction .= "?".$QUERY_STRING;
$KT_valUsername=$user;
if (isset($KT_valUsername)) {
$KT_fldUserAuthorization="Username";
$KT_redirectLoginSuccess="main.php";
$KT_redirectLoginFailed="LOGIN.php";
$KT_rsUser_Source="SELECT Username, Password ";
if ($KT_fldUserAuthorization != "") $KT_rsUser_Source .= "," .
$KT_fldUserAuthorization;
$KT_rsUser_Source .= " FROM login WHERE Username='" . $KT_valUsername . "'
AND Password='" . $password . "'";
$KT_rsUser=$Mysql_nedcorhk->Execute($KT_rsUser_Source) or
DIE($Mysql_nedcorhk->ErrorMsg());
if ($KT_rsUser->RecordCount()==1) {
// username and password match - this is a valid user
$KT_Username=$KT_valUsername;
session_register("KT_Username");
setcookie("username",$KT_Username,time()+600);
if ($KT_fldUserAuthorization != "") {
$KT_UserAuthorization=$KT_rsUser->Fields($KT_fldUserAuthorization);
} else {
$KT_UserAuthorization="";
}
session_register("KT_UserAuthorization");
if (isset($accessdenied) && false) {
$KT_redirectLoginSuccess = $accessdenied;
}
$KT_rsUser->Close();
session_register("KT_login_failed");
$KT_login_failed = false;
header ("Location: $KT_redirectLoginSuccess");
exit;
}
$KT_rsUser->Close();
session_register("KT_login_failed");
$KT_login_failed = true;
header ("Location: $KT_redirectLoginFailed");
exit;
}
?>
What i want to do is after i had set the cookie, then i got to main.php
which is one of the page within the site and i type :
<?
echo $HTTP_COOKIE_VARS["username"];
?>
It got nothing to print out!!!
Pls help!!
Jack
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Dear all
Here is the Code for my Login.php page
<?php
// *** Start the session
session_start();
// *** Validate request to log in to this site.
$KT_LoginAction = $PHP_SELF;
if ($QUERY_STRING!="") $KT_LoginAction .= "?".$QUERY_STRING;
$KT_valUsername=$user;
if (isset($KT_valUsername)) {
$KT_fldUserAuthorization="Username";
$KT_redirectLoginSuccess="index.php";
$KT_redirectLoginFailed="LOGIN.php";
$KT_rsUser_Source="SELECT Username, Password ";
if ($KT_fldUserAuthorization != "") $KT_rsUser_Source .= "," .
$KT_fldUserAuthorization;
$KT_rsUser_Source .= " FROM login WHERE Username='" . $KT_valUsername . "'
AND Password='" . $password . "'";
$KT_rsUser=$Mysql_nedcorhk->Execute($KT_rsUser_Source) or
DIE($Mysql_nedcorhk->ErrorMsg());
if ($KT_rsUser->RecordCount()==1) {
// username and password match - this is a valid user
$KT_Username=$KT_valUsername;
session_register("KT_Username");
if ($KT_fldUserAuthorization != "") {
$KT_UserAuthorization=$KT_rsUser->Fields($KT_fldUserAuthorization);
} else {
$KT_UserAuthorization="";
}
session_register("KT_UserAuthorization");
if (isset($accessdenied) && false) {
$KT_redirectLoginSuccess = $accessdenied;
}
$KT_rsUser->Close();
session_register("KT_login_failed");
$KT_login_failed = false;
header ("Location: $KT_redirectLoginSuccess");
exit;
}
$KT_rsUser->Close();
session_register("KT_login_failed");
$KT_login_failed = true;
header ("Location: $KT_redirectLoginFailed");
exit;
setcookie("username",$user);
}
?>
<html>
<head>
<title>Login Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function MM_findObj(n, d) { file://v4.0
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function MM_validateForm() { file://v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2];
val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an
e-mail address.\n';
} else if (test!='R') {
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (val<min || max<val) errors+='- '+nm+' must contain a number
between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is
required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
file://-->
</script>
</head>
<body bgcolor="#E8E9E0" text="#000000" link="#0000FF" vlink="#0000FF"
alink="#FF0000">
<div align="center">
<p><b><font size="+3"><u>Nedcor Internal WebSite</u></font></b></p>
<p><b>Please Provide your Username and Password for the Internal
Web.</b></p>
<?
print ("Diagnostic Information<br>");
print ("Session Name : " . session_name() . "<br>\n");
print ("Session ID : " . session_id() . "<br>\n");
?>
<form action="<?php echo $KT_LoginAction?>" name="LOGIN" method="post"
onSubmit="MM_validateForm('user','','R','password','','R');return
document.MM_returnValue">
<table width="75%" border="0">
<tr>
<td width="49%">
<div align="right"><b>Username</b></div>
</td>
<td width="51%">
<input type="text" name="user">
</td>
</tr>
<tr>
<td width="49%">
<div align="right"><b>Password</b></div>
</td>
<td width="51%">
<input type="password" name="password">
</td>
</tr>
</table>
<p>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset">
</p>
</form>
<p> </p>
</div>
</body>
</html>
I had use the setcookie function in the script which is
<?setcookie("username",$user);?>, then in the Main.php page, i set another
script <?echo $HTTP_COOKIE_VARS["username"];?>.
Then the strange things happen, the Main.php won't show the name from
cookie! actually the $user you saw in setcookie is the input box where the
user input their username to login!!
Another way i had tried is , if i set the cookie like this
<?setcookie("username","jack");?>, then the Main.php will display it.
Could someone pls tell me why it happen like this???
Thx a lot!!
Jack
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
wow sessions and cookie on the same page? why dont you just use one or the
other? I pref sessions. never the less.
your not setting the exp, path, or domain in your setcookie() you must do
all those.
setcookie('name', 'chris lee', time()+84700, '/',
'www.mediawaveonline.com');
--
Chris Lee
[EMAIL PROTECTED]
"Jack" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Dear all
> Here is the Code for my Login.php page
>
> <?php
> // *** Start the session
> session_start();
> // *** Validate request to log in to this site.
> $KT_LoginAction = $PHP_SELF;
> if ($QUERY_STRING!="") $KT_LoginAction .= "?".$QUERY_STRING;
> $KT_valUsername=$user;
> if (isset($KT_valUsername)) {
> $KT_fldUserAuthorization="Username";
> $KT_redirectLoginSuccess="index.php";
> $KT_redirectLoginFailed="LOGIN.php";
> $KT_rsUser_Source="SELECT Username, Password ";
> if ($KT_fldUserAuthorization != "") $KT_rsUser_Source .= "," .
> $KT_fldUserAuthorization;
> $KT_rsUser_Source .= " FROM login WHERE Username='" . $KT_valUsername .
"'
> AND Password='" . $password . "'";
> $KT_rsUser=$Mysql_nedcorhk->Execute($KT_rsUser_Source) or
> DIE($Mysql_nedcorhk->ErrorMsg());
> if ($KT_rsUser->RecordCount()==1) {
> // username and password match - this is a valid user
> $KT_Username=$KT_valUsername;
> session_register("KT_Username");
> if ($KT_fldUserAuthorization != "") {
> $KT_UserAuthorization=$KT_rsUser->Fields($KT_fldUserAuthorization);
> } else {
> $KT_UserAuthorization="";
> }
> session_register("KT_UserAuthorization");
> if (isset($accessdenied) && false) {
> $KT_redirectLoginSuccess = $accessdenied;
> }
> $KT_rsUser->Close();
> session_register("KT_login_failed");
> $KT_login_failed = false;
> header ("Location: $KT_redirectLoginSuccess");
> exit;
> }
> $KT_rsUser->Close();
> session_register("KT_login_failed");
> $KT_login_failed = true;
> header ("Location: $KT_redirectLoginFailed");
> exit;
> setcookie("username",$user);
> }
> ?>
> <html>
> <head>
> <title>Login Page</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> <script language="JavaScript">
> <!--
> function MM_findObj(n, d) { file://v4.0
> var p,i,x; if(!d) d=document;
> if((p=n.indexOf("?"))>0&&parent.frames.length) {
> d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
> if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
> x=d.forms[i][n];
> for(i=0;!x&&d.layers&&i<d.layers.length;i++)
> x=MM_findObj(n,d.layers[i].document);
> if(!x && document.getElementById) x=document.getElementById(n); return
x;
> }
>
> function MM_validateForm() { file://v4.0
> var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
> for (i=0; i<(args.length-2); i+=3) { test=args[i+2];
> val=MM_findObj(args[i]);
> if (val) { nm=val.name; if ((val=val.value)!="") {
> if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
> if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an
> e-mail address.\n';
> } else if (test!='R') {
> if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
> if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
> min=test.substring(8,p); max=test.substring(p+1);
> if (val<min || max<val) errors+='- '+nm+' must contain a number
> between '+min+' and '+max+'.\n';
> } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is
> required.\n'; }
> } if (errors) alert('The following error(s) occurred:\n'+errors);
> document.MM_returnValue = (errors == '');
> }
> file://-->
> </script>
> </head>
> <body bgcolor="#E8E9E0" text="#000000" link="#0000FF" vlink="#0000FF"
> alink="#FF0000">
> <div align="center">
> <p><b><font size="+3"><u>Nedcor Internal WebSite</u></font></b></p>
> <p><b>Please Provide your Username and Password for the Internal
> Web.</b></p>
> <?
> print ("Diagnostic Information<br>");
> print ("Session Name : " . session_name() . "<br>\n");
> print ("Session ID : " . session_id() . "<br>\n");
> ?>
> <form action="<?php echo $KT_LoginAction?>" name="LOGIN" method="post"
> onSubmit="MM_validateForm('user','','R','password','','R');return
> document.MM_returnValue">
> <table width="75%" border="0">
> <tr>
> <td width="49%">
> <div align="right"><b>Username</b></div>
> </td>
> <td width="51%">
> <input type="text" name="user">
> </td>
> </tr>
> <tr>
> <td width="49%">
> <div align="right"><b>Password</b></div>
> </td>
> <td width="51%">
> <input type="password" name="password">
> </td>
> </tr>
> </table>
> <p>
> <input type="submit" name="Submit" value="Submit">
> <input type="reset" name="Submit2" value="Reset">
> </p>
> </form>
> <p> </p>
>
> </div>
> </body>
> </html>
>
> I had use the setcookie function in the script which is
> <?setcookie("username",$user);?>, then in the Main.php page, i set another
> script <?echo $HTTP_COOKIE_VARS["username"];?>.
> Then the strange things happen, the Main.php won't show the name from
> cookie! actually the $user you saw in setcookie is the input box where the
> user input their username to login!!
> Another way i had tried is , if i set the cookie like this
> <?setcookie("username","jack");?>, then the Main.php will display it.
> Could someone pls tell me why it happen like this???
>
> Thx a lot!!
> Jack
> [EMAIL PROTECTED]
>
>
--- End Message ---
--- Begin Message ---
I am sure this is a simple one but its doing my head in:
My php page works fine in the root directory of my Apache server but when I
put it in a subdirectory of the server I get a 404 file not found error. I
mean it points to localhost/newdirectory/page.php but it does nto work??
Do I have to included some files in this directory or change the
httpd.config file to include the new directory??
--- End Message ---
--- Begin Message ---
Hi to all,
I've a question to ask you.
I've do a function which interface PHP.EXE and redirect the stdin / stdout
so I can pass it a TMemoryStream object with stdin and I receive a
TMemoryStream
with stdout. All is done with a console program in which I launch the
PHP.EXE
between the CreateProcess API. The process is hidden so you don't see
never...
At this point I've a problem.
The Pipe don't pass the EOF (CTRL + Z) char to PHP.EXE stdin so I don't able
to inform PHP.EXE of end of my input stdin sequence.
What I must do to do that ?
Follow a snapshot of my C++ code....
Thank you very much....
Silverio Diquigiovanni
bool __fastcall RunPHP(TStream *Input, TStream *Output)
{
bool Result = false;
// sets security informations
SECURITY_DESCRIPTOR sd;
SECURITY_ATTRIBUTES sa;
LPSECURITY_ATTRIBUTES lpsa = NULL;
if (IsWindowsNT())
{
InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&sd, true, NULL, false);
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = true;
sa.lpSecurityDescriptor = &sd;
lpsa = &sa;
}
// creates & checks stdin pipe
HANDLE h_IN_ReadPipe;
HANDLE h_IN_WritePipe;
assert(CreatePipe(&h_IN_ReadPipe, &h_IN_WritePipe, lpsa, 0));
// creates & checks stdout pie
HANDLE h_OUT_ReadPipe;
HANDLE h_OUT_WritePipe;
assert(CreatePipe(&h_OUT_ReadPipe, &h_OUT_WritePipe, lpsa, 0));
// sets process informations
STARTUPINFO si;
PROCESS_INFORMATION pi;
memset(&si, 0, sizeof (STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW |STARTF_USESTDHANDLES;
si.wShowWindow = SW_SHOW;
si.wShowWindow = SW_HIDE;
si.hStdInput = h_IN_ReadPipe;
si.hStdOutput = h_OUT_WritePipe;
si.hStdError = h_OUT_WritePipe;
// creates process
bool process_run = CreateProcess
(
NULL,
"PHP.EXE",
NULL,
NULL,
TRUE,
0,
0,
0,
&si,
&pi
);
// checks process running
if (process_run)
{
THandleStream *InStream = new THandleStream((int) h_IN_WritePipe);
Input->Position = 0;
InStream->CopyFrom(Input, Input->Size);
//
// Here I must send the CTRL + Z to the PHP.EXE but I don't know how....
//
/* tentative n.1: no good :(
TerminateProcess(pi.hProcess, 0x1a);
*/
/* tentative n.2: no good :(
HWND CalledHandle = FindWindow(NULL, "PHP");
SendMessage(CalledHandle, 0x0501, 0x1, 0x010d86a4);
*/
/* tentative n.3: no good :(
HWND CalledHandle = FindWindow(NULL, "PHP");
bool b_ok = BringWindowToTop(CalledHandle);
keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), 0, 0);
keybd_event('Z', MapVirtualKey('Z', 0), 0, 0);
keybd_event('Z', MapVirtualKey('Z', 0), KEYEVENTF_KEYUP, 0);
keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), KEYEVENTF_KEYUP,
0);
// Xxx...
WaitForSingleObject(pi.hProcess, INFINITE);
// Xxx...
DWORD BytesRead;
char Buffer[1024];
while (1)
{
memset(Buffer, 0, sizeof (Buffer));
assert
(
ReadFile
(
h_OUT_ReadPipe,
&Buffer,
sizeof (Buffer),
&BytesRead,
NULL
)
);
Output->Write(Buffer, BytesRead);
if (BytesRead < 1024)
break;
}
Result = true;
// frees objects
delete InStream;
CloseHandle(pi.hProcess);
}
// frees objects
CloseHandle(h_IN_ReadPipe);
CloseHandle(h_IN_WritePipe);
CloseHandle(h_OUT_ReadPipe);
CloseHandle(h_OUT_WritePipe);
return Result;
}
/***************************************************************************
****
* Event handler method
****************************************************************************
***/
void __fastcall TDesktop::RunPHPClick(TObject *Sender)
{
// creates PHPCode & HTMLCode
TMemoryStream *PHPCode = new TMemoryStream;
TMemoryStream *HTMLCode = new TMemoryStream;
// creates a little PHP script flow
AnsiString s =
(
"<?php" + CRLF +
"echo (\"<br>\n\");" + CRLF +
"for ($a = 1; $a < 6; $a++)" + CRLF +
"{" + CRLF +
"echo (\"Ciao per la $a volta <br>\n\");" + CRLF +
"}" + CRLF +
"exit;" + CRLF +
"?>" + CRLF
);
PHPCode->Write(s.c_str(), s.Length());
// calls & checks PHP html generator
if(::RunPHP(PHPCode, HTMLCode) == true)
{
HTMLCode->SaveToFile("C:\\index.html");
WebBrowser->Navigate((WideString) "C:\\index.html");
}
// frees objects
delete PHPCode;
delete HTMLCode;
}
--- End Message ---
--- Begin Message ---
--- Received from FPU.WHITES1 799 3703 21-12-01 11:44
----------------
-> [EMAIL PROTECTED]
-> [EMAIL PROTECTED]
I'm not familiar with the THandleStream (I guess you're using Borland...?) but doesn't
it allow
you to send data straight to the stream? All your attempts are aimed at talking to php
externally.
Does THandleStream provide something that will let you do:
InStream->Write("0x1A");
...or is the InStream automatically closing when the pipe data finishes.
I'd be much more inclined to insert this into the same pipe rather than coming at it
from the
outside (which probably won't work anyway now you've redirected stdin/stdout).
Alternatively you could just write an intermediate proxy executable that takes charge
of talking
to PHP and can add the CTRLZ itself:
YourProg--[data]-->proxy--[data+CTRLZ]-->PHP
-Steve
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Date: Fri, 21 Dec 2001 12:33:30 +0100
Subject: [PHP-WIN] Send CTRL + Z ( EOF ) key to a PHP (console) program created with
CreateProcess
Hi to all,
I've a question to ask you.
I've do a function which interface PHP.EXE and redirect the stdin / stdout
so I can pass it a TMemoryStream object with stdin and I receive a
TMemoryStream
with stdout. All is done with a console program in which I launch the
PHP.EXE
between the CreateProcess API. The process is hidden so you don't see
never...
At this point I've a problem.
The Pipe don't pass the EOF (CTRL + Z) char to PHP.EXE stdin so I don't able
to inform PHP.EXE of end of my input stdin sequence.
What I must do to do that ?
Follow a snapshot of my C++ code....
Thank you very much....
Silverio Diquigiovanni
bool __fastcall RunPHP(TStream *Input, TStream *Output)
bool Result = false;
// sets security informations
SECURITY_DESCRIPTOR sd;
SECURITY_ATTRIBUTES sa;
LPSECURITY_ATTRIBUTES lpsa = NULL;
if (IsWindowsNT())
{
InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&sd, true, NULL, false);
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = true;
sa.lpSecurityDescriptor = &sd;
lpsa = &sa;
}
// creates & checks stdin pipe
HANDLE h_IN_ReadPipe;
HANDLE h_IN_WritePipe;
assert(CreatePipe(&h_IN_ReadPipe, &h_IN_WritePipe, lpsa, 0));
// creates & checks stdout pie
HANDLE h_OUT_ReadPipe;
HANDLE h_OUT_WritePipe;
assert(CreatePipe(&h_OUT_ReadPipe, &h_OUT_WritePipe, lpsa, 0));
// sets process informations
STARTUPINFO si;
PROCESS_INFORMATION pi;
memset(&si, 0, sizeof (STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW |STARTF_USESTDHANDLES;
si.wShowWindow = SW_SHOW;
si.wShowWindow = SW_HIDE;
si.hStdInput = h_IN_ReadPipe;
si.hStdOutput = h_OUT_WritePipe;
si.hStdError = h_OUT_WritePipe;
// creates process
bool process_run = CreateProcess
(
NULL,
"PHP.EXE",
NULL,
NULL,
TRUE,
0,
0,
0,
&si,
&pi
);
// checks process running
if (process_run)
{
THandleStream *InStream = new THandleStream((int) h_IN_WritePipe);
Input->Position = 0;
InStream->CopyFrom(Input, Input->Size);
//
// Here I must send the CTRL + Z to the PHP.EXE but I don't know how....
//
/* tentative n.1: no good :(
TerminateProcess(pi.hProcess, 0x1a);
*/
/* tentative n.2: no good :(
HWND CalledHandle = FindWindow(NULL, "PHP");
SendMessage(CalledHandle, 0x0501, 0x1, 0x010d86a4);
*/
/* tentative n.3: no good :(
HWND CalledHandle = FindWindow(NULL, "PHP");
bool b_ok = BringWindowToTop(CalledHandle);
keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), 0, 0);
keybd_event('Z', MapVirtualKey('Z', 0), 0, 0);
keybd_event('Z', MapVirtualKey('Z', 0), KEYEVENTF_KEYUP, 0);
keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), KEYEVENTF_KEYUP,
0);
// Xxx...
WaitForSingleObject(pi.hProcess, INFINITE);
// Xxx...
DWORD BytesRead;
char Buffer[1024];
while (1)
{
memset(Buffer, 0, sizeof (Buffer));
assert
(
ReadFile
(
h_OUT_ReadPipe,
&Buffer,
sizeof (Buffer),
&BytesRead,
NULL
)
);
Output->Write(Buffer, BytesRead);
if (BytesRead < 1024)
break;
}
Result = true;
// frees objects
delete InStream;
CloseHandle(pi.hProcess);
}
// frees objects
CloseHandle(h_IN_ReadPipe);
CloseHandle(h_IN_WritePipe);
CloseHandle(h_OUT_ReadPipe);
CloseHandle(h_OUT_WritePipe);
return Result;
/***************************************************************************
****
* Event handler method
****************************************************************************
***/
void __fastcall TDesktop::RunPHPClick(TObject *Sender)
// creates PHPCode & HTMLCode
TMemoryStream *PHPCode = new TMemoryStream;
TMemoryStream *HTMLCode = new TMemoryStream;
// creates a little PHP script flow
AnsiString s =
(
"<?php" + CRLF +
"echo (\"<br>\n\");" + CRLF +
"for ($a = 1; $a < 6; $a++)" + CRLF +
"{" + CRLF +
"echo (\"Ciao per la $a volta <br>\n\");" + CRLF +
"}" + CRLF +
"exit;" + CRLF +
"?>" + CRLF
);
PHPCode->Write(s.c_str(), s.Length());
// calls & checks PHP html generator
if(::RunPHP(PHPCode, HTMLCode) == true)
{
HTMLCode->SaveToFile("C:\\index.html");
WebBrowser->Navigate((WideString) "C:\\index.html");
}
// frees objects
delete PHPCode;
delete HTMLCode;
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
This e-mail may contain confidential information and/or copyright
material. This e-mail is intended for the use of the addressee
only. Any unauthorised use may be unlawful.
If you receive this e-mail by mistake please advise the sender
immediately by using the reply facility in your e-mail software.
Friends Provident Marketing Group consists of the following
companies:
Friends Provident Life and Pensions Limited.
Registered number 4096141.
Friends' Provident Unit Trust Managers Limited.
Registered number 970641
FP Life Assurance Limited.
Registered number 782698
Friends Provident Pensions Limited.
Registered number 475201
Friends Ivory & Sime Managed Pensions Funds Limited.
Registered number 1020044
Registered and Head Office of each of the above companies is at Pixham End,
Dorking, Surrey RH4 1QA.
Registered in England. Incorporated companies limited by shares.
Ivory & Sime Trustlink Limited. Registered number 151198
Registered and Head Office: One Charlotte Square, Edinburgh EH2
4DZ. Registered in Scotland. Incorporated company limited by
shares.
Companies within this Group transact life assurance, pension,
permanent health, unit trust and investment trust business
All are regulated by the Financial Services Authority.
--- End Message ---
--- Begin Message ---
hi.
where I can find the all of db dll's ??? to downlaod it, I donīt have c++.
my machine is a WME.
--- End Message ---
--- Begin Message ---
Hiya,
If you download the larger package from php.net, most of the dlls are
included. You can also try www.php4win.com. They usually have a much more
complete range of extensions.
At 10:35 21.12.2001 -0200, you wrote:
>hi.
>where I can find the all of db dll's ??? to downlaod it, I donīt have c++.
>
>my machine is a WME.
>
>
>
>--
>PHP Windows Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
// Jonathan Wright
// [EMAIL PROTECTED]
// GCS d- s: a-- C++(+) US> P+++ L+> E> W+++ !N w !O M- V- PS+@ PE+
// Y PGP t+ !5 X R- tv(-) b(+) DI++++> D+(++) G h-- r-- z--(++)
--- End Message ---
--- Begin Message ---
i cant configure php to work on my window98 +apache 1.3
i stop apache and edit httpd.conf with notepad and add this line (i read
this on some tutorial books) ;
#for the apache module
LoadModule php4_module c:/php/sapi/php4apache.dll
AddType application/x-httpd-php.php4
#for the cgi binary (you can use that one compiled with force cgi redirect
too)
ScriptAlias /php4/ "C:/php/"
Action application/x-httpd-php4 "/php4/php.exe"
AddType application/x-httpd-php4.php
*please note that i dont have any clue on writing a php code, so i just type
anything the book suggest. so it could be a misstype.
anyway, i put those line after the last line of the codes inside httpd.conf.
then i move php4ts.dll to c/windows/system and copy php.ini-dist into
sysroot C:/windows/ and rename it php.ini
when done, starting apache came up with this error;
Syntax error on line 1035 of c:/apache/conf/httpd.conf:
AddType requires at least two arguments, a mime type followed by one or mo
e extensions
any idea what i did wrong?
--- End Message ---
--- Begin Message ---
Yep...
At 00:22 21.12.2001 +0700, p13zo wrote:
>i cant configure php to work on my window98 +apache 1.3
>i stop apache and edit httpd.conf with notepad and add this line (i read
>this on some tutorial books) ;
>
>#for the apache module
>LoadModule php4_module c:/php/sapi/php4apache.dll
>AddType application/x-httpd-php.php4
>
>#for the cgi binary (you can use that one compiled with force cgi redirect
>too)
>ScriptAlias /php4/ "C:/php/"
>Action application/x-httpd-php4 "/php4/php.exe"
>AddType application/x-httpd-php4.php
AddType should read:
AddType application/x-httpd-php4 .php
A space is needed before .php as it's telling Apache what extensions to
send to the parser - if you do something like
AddType application/x-httpd-php4 .php .phtml .php3 .php4
Apache will process all the extensions using the parser.
>*please note that i dont have any clue on writing a php code, so i just type
>anything the book suggest. so it could be a misstype.
>anyway, i put those line after the last line of the codes inside httpd.conf.
>then i move php4ts.dll to c/windows/system and copy php.ini-dist into
>sysroot C:/windows/ and rename it php.ini
>when done, starting apache came up with this error;
>
>Syntax error on line 1035 of c:/apache/conf/httpd.conf:
>AddType requires at least two arguments, a mime type followed by one or mo
>e extensions
>
>any idea what i did wrong?
It should work now! :)
>--
>PHP Windows Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
// Jonathan Wright
// [EMAIL PROTECTED]
// GCS d- s: a-- C++(+) US> P+++ L+> E> W+++ !N w !O M- V- PS+@ PE+
// Y PGP t+ !5 X R- tv(-) b(+) DI++++> D+(++) G h-- r-- z--(++)
--- End Message ---