Monte Goulding a écrit :
>
> OK, I don't understand how you would do that. I'm only learining at this
> stage. Primarily how does Apache communicate with your long running process
> or do the clients communicate directly. This seems like a good plan saving
> mc to just handle cgi.
>
--snip--
To run this kind of .mc web/vpn apps servers on unixes in both console and
x-display modes (the second is usefull to debug using all the mc ide
facilities), you will need :
1.- to have php 3.015 or more installed ;
2.- this kind of .php script :
<?
if ($REQUEST_METHOD == POST) {
$headers = $HTTP_POST_VARS;
while (list($header, $value) = each($headers)) $exAE .= "$header=$value&";
$exAE = urlencode($exAE);
$connection = fsockopen("localhost", "567", &$error_number,
&$error_description, "30");
if ($connection) {
set_socket_blocking($connection, true);
fputs($connection,"");
fputs($connection,"$exAE"."\r\n");
fpassthru($connection);
}
else {
$connection = fsockopen("localhost", "4567", &$error_number,
&$error_description, "30");
if ($connection) {
set_socket_blocking($connection, true);
fputs($connection,"");
fputs($connection,"$exAE"."\r\n");
fpassthru($connection);
}
else print("erreur numéro $error_number ($error_description)<BR>\n");
}
}
else print("<HTML><HEAD><TITLE>ERROR: File Not Found</TITLE></HEAD>".
"<BODY background='/gif/fond-maison.gif'><H1>File Not Found</H1><P>".
"<H3>The file you have requested does not exist on this
server.</H3></BODY></HTML><BR>\n");
?>
where the "567" port will be the default port if you just want to have the mc.
apps server right running in console mode as a root process and "4567" the port
used if you want to lauch the mc.apps server from the x-windows desktop.
3.- If you want to start the .mc server as a background process in console mode,
you will have to store this kind of init system V .sh script in the rc2.d
directory :
#!/bin/sh
# Start/stop WMCL
case "$1" in
'start')
/usr/local/httpd/w-max/iassd/wmcstart &
;;
'stop')
/usr/local/httpd/w-max/iassd/wmcstop
;;
*)
echo "Usage: $0 { start | stop }"
;;
esac
exit 0
and this as an .mt "wmcstart" script :
#!/home/py/mc
on startup
open stack "/usr/local/httpd/w-max/iassd/ia931.mc"
end startup
We are far to the end...
4.- an html form, in "POST" or "GET" mode, even if i prefer personnaly the post
method. Use this as an example, if needed :
<HTML><HEAD>
<META HTTP-EQUIV="content-type" CONTENT="text/html;charset=iso-8859-1">
<META NAME="generator" CONTENT="BBEdit 5.0">
<META NAME="author" CONTENT="Pierre Sahores">
<META NAME="keywords" CONTENT="cndp c.n.d.p. centre national de documentation
pedagogique cyberlibrairie documentation en ligne té,lé,chargement
ingenierie educative enseignement metacard linux">
<TITLE>Bienvenue au CNDP</TITLE><SCRIPT><!--
var posBan4=0, ban4, delaiBan4, msgBan4;
function banniere4(delai) {
delaiBan4 = delai;
if (posBan4 >= msgBan4.length)
posBan4 = 0;
else if (posBan4 == 0) {
msgBan4 = ' ' + msgBan4;
while (msgBan4.length < 128)
msgBan4 += ' ' + msgBan4;
}
window.status = msgBan4.substring(posBan4,posBan4+msgBan4.length);
posBan4++;
ban4 = setTimeout("banniere4(delaiBan4)",delai);
}
function nonPret() {
alert("En construction : rubrique non renseignée.");
return true;
}
function goBdc() {
alert("Sélectionnez les références adéquates avant d'activer le bon de
commande.");
return true;
}
function infoSecu() {
alert("Toutes les données personnalisées sont protégées par encodage SSL.");
return true;
}
function checkdload() {
document.forms[0].submit();
return true;
}
function trioOK() {
if (document.forms[0].TDR.value.length < 3) {
alert("Entrez une chaîne de recherche de 3 caractères au moins.");
return false;
}
else return true;
}
function checkForm() {
if (trioOK() == false) return;
else document.forms[0].submit();
}
function trioOK2() {
var r = 0;
if (document.forms[0].TR1.value.length > 2) {
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].TR1.value) + "*";
r = 1;
}
if (document.forms[0].TR2.value.length > 2) {
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].TR2.value) + "*";
r = 1;
}
if (document.forms[0].TR3.value.length > 2) {
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].TR3.value) + "*";
r = 1;
}
if (document.forms[0].TR4.value.length > 2) {
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].TR4.value) + "*";
r = 1;
}
if (document.forms[0].TR5.value.length > 2) {
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].TR5.value) + "*";
r = 1;
}
if (document.forms[0].TR6.value.length > 2) {
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].TR6.value) + "*";
r = 1;
}
if (document.forms[0].TR7.value.length > 2) {
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].TR7.value) + "*";
r = 1;
}
if (document.forms[0].TR8.value.length > 2) {
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].TR8.value) + "*";
r = 1;
}
if (r == "0") {
alert("Entrez une chaine de recherche de 3 caracteres au moins.");
return false;
}
}
function checkForm2() {
if (trioOK2() == false) return;
else document.forms[0].submit();
}
function checkDomain() {
var x = (document.forms[0].THE.selectedIndex);
if (x > 1) (document.forms[0].TDR.value) = (document.forms[0].TDR.value) +
(document.forms[0].THE.options[x].value) + "*";
}
function checkRD1() {
var x = (document.forms[0].RD1.selectedIndex);
if (x > 1) {
(document.forms[0].TR1.value) = (document.forms[0].TR1.value) + "*" +
(document.forms[0].RD1.options[x].value) + "*";
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].RD1.options[x].value) + "*";
}
}
function checkRD2() {
var x = (document.forms[0].RD2.selectedIndex);
if (x > 1) {
(document.forms[0].TR2.value) = (document.forms[0].TR2.value) + "*" +
(document.forms[0].RD2.options[x].value) + "*";
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].RD2.options[x].value) + "*";
}
}
function checkRD3() {
var x = (document.forms[0].RD3.selectedIndex);
if (x > 1) {
(document.forms[0].TR3.value) = (document.forms[0].TR3.value) + "*" +
(document.forms[0].RD3.options[x].value) + "*";
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].RD3.options[x].value) + "*";
}
}
function checkRD4() {
var x = (document.forms[0].RD4.selectedIndex);
if (x > 1) {
(document.forms[0].TR4.value) = (document.forms[0].TR4.value) + "*" +
(document.forms[0].RD4.options[x].value) + "*";
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].RD4.options[x].value) + "*";
}
}
function checkRD5() {
var x = (document.forms[0].RD5.selectedIndex);
if (x > 1) {
(document.forms[0].TR5.value) = (document.forms[0].TR5.value) + "*" +
(document.forms[0].RD5.options[x].value) + "*";
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].RD5.options[x].value) + "*";
}
}
function checkRD6() {
var x = (document.forms[0].RD6.selectedIndex);
if (x > 1) {
(document.forms[0].TR6.value) = (document.forms[0].TR6.value) + "*" +
(document.forms[0].RD6.options[x].value) + "*";
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].RD6.options[x].value) + "*";
}
}
function checkRD7() {
var x = (document.forms[0].RD7.selectedIndex);
if (x > 1) {
(document.forms[0].TR7.value) = (document.forms[0].TR7.value) + "*" +
(document.forms[0].RD7.options[x].value) + "*";
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].RD7.options[x].value) + "*";
}
}
function checkRD8() {
var x = (document.forms[0].RD8.selectedIndex);
if (x > 1) {
(document.forms[0].TR8.value) = (document.forms[0].TR8.value) + "*" +
(document.forms[0].RD8.options[x].value) + "*";
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].RD8.options[x].value) + "*";
}
}
function checkRD9() {
var x = (document.forms[0].RD9.selectedIndex);
if (x > 1) {
(document.forms[0].TR9.value) = (document.forms[0].TR9.value) + "*" +
(document.forms[0].RD9.options[x].value) + "*";
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].RD9.options[x].value) + "*";
}
}
function checkR10() {
var x = (document.forms[0].R10.selectedIndex);
if (x > 1) {
(document.forms[0].T10.value) = (document.forms[0].T10.value) + "*" +
(document.forms[0].R10.options[x].value) + "*";
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].R10.options[x].value) + "*";
}
}
function checkR11() {
var x = (document.forms[0].R11.selectedIndex);
if (x > 1) {
(document.forms[0].T11.value) = (document.forms[0].T11.value) + "*" +
(document.forms[0].R11.options[x].value) + "*";
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].R11.options[x].value) + "*";
}
}
function checkR12() {
var x = (document.forms[0].R12.selectedIndex);
if (x > 1) {
(document.forms[0].T12.value) = (document.forms[0].T12.value) + "*" +
(document.forms[0].R12.options[x].value) + "*";
(document.forms[0].TDR.value) = (document.forms[0].TDR.value) + "*" +
(document.forms[0].R12.options[x].value) + "*";
}
}
function checkReset() {
(document.forms[0].TDR.value) = "";
(document.forms[0].TR1.value) = "";
(document.forms[0].TR2.value) = "";
(document.forms[0].TR3.value) = "";
(document.forms[0].TR4.value) = "";
(document.forms[0].TR5.value) = "";
(document.forms[0].TR6.value) = "";
(document.forms[0].TR7.value) = "";
(document.forms[0].TR8.value) = "";
setFocus();
}
function testID() {
if (document.forms[0].IDP.value.length != 8) {
alert("Erreur de saisie. Entrez un identifiant de huit caractères.");
(document.forms[0].IDP.value) = "";
}
}
function idOK() {
if (document.forms[0].IDP.value.length != 8) {
alert("Erreur de saisie. Entrez un identifiant de huit caractères.");
return false;
}
return true;
}
function checkID() {
if (idOK() == false) return;
else document.forms[0].submit(); //alert("En construction. Option
provisoirement désactivée.");
}
function setFocus() {
document.forms[0].TDR.focus();
}
// © 1999 Pierre Sahores [EMAIL PROTECTED] --></SCRIPT><NOSCRIPT><H2>Attention
! Votre navigateur est trop ancien pour interpréter le code javascript
utile au fonctionnement du site consult? !</H2></NOSCRIPT>
</HEAD><BODY bgcolor="white" text="darkblue" background="" ONLOAD="setFocus();
msgBan4='Site optimisé pour un affichage 800x600, 256 couleurs et Netscape
3.0/Explorer 4.0 minimum.';banniere4(100);" ONUNLOAD="clearTimeout(ban4)">
<table border="0" cellpadding="0" cellspacing="0" width="100%"
bgcolor='#EFEFEF'><tr>
<td width="10%" valign="middle" align="left"> <img src="/cndp/logoC.gif"><a
name="top"></td>
<td width="55%" valign="middle" align="center"><font size="6"
color="slateblue"><i>
Cyberlibrairie du réseau CNDP</i></font></td>
<FORM ACTION="wmc.xml" METHOD="POST">
<INPUT TYPE=HIDDEN NAME="mcsql" VALUE="1">
<INPUT TYPE="HIDDEN" VALUE="#MTNV#" NAME="CCL">
<INPUT TYPE="HIDDEN" VALUE="<? print("$REMOTE_ADDR"); ?>" NAME="IPC">
<td width="30%" valign="middle" align="right">
<img border="0" src="/cndp/semibandeau.gif" usemap="#menumap">
<map name="menumap">
<area shape="rect" coords="140,15,190,25" href="../aide.xml" target="aide">
<area shape="rect" coords="140,29,190,47" href="#recherche"
onclick="checkReset()">
<area shape="rect" coords="140,51,190,61" href="../infos.xml" target="infos">
</map>
</td></tr></table>
<table border="0" cellpadding="0" cellspacing="0" width=100%><TR>
<TD width="20%" bgcolor='#EFEFEF' valign="top">
<table border="0" cellpadding="6" cellspacing="0" align="center">
<TR><TD align="center">
<!--? require("cndp/cndpi.html"); ?-->
</TD></TR></table><BR></TD>
<td width="64%" align="center" valign='top'>
<table border="0" cellpadding="10" cellspacing="0">
<FONT SIZE="3">
<TR><TD align="left"></TD></TR>
<TR><TD align="center" valign="top"><FONT SIZE="2">M.A.J. de la
Cyberlibrairie.</font></td></tr>
<? require("cndp/rrapide.html"); ?>
<TR><TD align="center">
<INPUT TYPE="TEXT" NAME="TDR" SIZE="18" ONCHANGE="checkForm()"></TD></TR>
<TR><TD align="center"><b>
<INPUT TYPE="BUTTON" VALUE="M.A.J." ONCLICK="checkForm()">
<SPACER TYPE="block" WIDTH="5" HEIGHT="1">
<INPUT TYPE="reset" VALUE="Annuler" NAME="xcz" ONCLICK="checkReset()">
</b></TD></TR>
</font></table></TD>
<TD width="16%" valign="top">
</TD>
</TR></table><br>
<table border="0" cellpadding="0" cellspacing="0" width="100%"><TR>
<TD width="20%" valign="center"><FONT SIZE="3"><A
HREF=mailto:[EMAIL PROTECTED]><img src="/gif/sendmail.gif"
border="0"></A></FONT></TD>
<TD width="60%" valign="center" align="center"><FONT SIZE="3"
color="slateblue"><? print(date("d/m/Y").". ").(date("H:i").". "); ?>
Merci de votre visite.<br>© 2000 Centre National de Documentation
Pédagogique.</FONT></TD>
<TD width="20%" ROWSPAN="2" align="right">
<FONT SIZE="3" color="slateblue">en partenariat avec
<A HREF="http://www.metacard.com" target="pchezea">
<img src="/cndp/metacard.gif" height="20" align="right" border="0"></A>
<A HREF="http://www.alinka.com" target="pchezeb">
<img src="/cndp/alinka.gif" height="22" align="right" border="0"></A>
</font>
</TD></TR></table>
<INPUT TYPE="HIDDEN" VALUE="321" NAME="RDR">
</FORM></BODY></HTML>
... snip the unneeded javascripts...
and to the end :
5.- Store those scripts in the stack script of your new .mc apps server :
on newconnect s # reading the request from a new socket
read from socket s for 1 line with message "serverread"
end newconnect
on serverread x,y # processing the request
global PostIn,Retour,Debut,Lepath
--
# put the long seconds into Debut
put urldecode(y) into PostIn # données POST reçues de wmc.xml
put cr into char (length(PostIn))-1 to (length(PostIn)) of PostIn
put empty into Retour
set itemdelimiter to "&"
doswitcher
write Retour to socket x
close socket x # x = adresse IP & "|" & n° d'ordre du socket fils reçu de
wmc.xml
--
open file Lepath & "LOGia931.txt" for append
write the date && the long time && item 1 of PostIn && char 5 to -1 of item -2
of PostIn && opensockets() && \
char 5 to -1 of item 3 of PostIn && "200 OK" & cr to file Lepath &
"LOGia931.txt"
--
# if the num of lines in (opensockets()) > 1
# then close socket line 2 of (opensockets())
--
end serverread
on socketTimout
end socketTimout
on doswitcher
global PostIn,Retour
set itemDelimiter to "&"
if char 1 to 6 of item 1 of PostIn is "wm231="
then send WM231 to btn "Project" of stack "PEWEB"
else if char 1 to 9 of item 1 of PostIn is "prgbyrne="
then send laDHG to btn "Project" of stack "PEWEB"
# if platform() is "Linux" and opensockets() is empty
# then put "Content-Type: text/html" & cr & "Content-Length:" && the length of
Retour & cr & cr & Retour
end doswitcher
on PreOpenStack
global
Masq,AccPpx,Lepath,DsBp,PrAn,DsDx,DbGrl,DbAcP,DbAcF,DbIPR,DbAcPI,DbAcFI,Miam,EDHG
put " Please, wait. WMC server loading..."
set twelveHourTime to false
put "WMC HTTP DB/APP'S server up since" && the short date & "," && the short
time into binfo
--
open file Lepath & "COLia931.txt" for read -- 1
read from file Lepath & "COLia931.txt" until eof
put it into AccPpx
put " " & the result after pboot
close file Lepath & "COLia931.txt"
open file Lepath & "GRLia931.txt" for read -- 2
read from file Lepath & "GRLia931.txt" until eof
put it into DbGrl
put " " & the result after pboot
close file Lepath & "GRLia931.txt"
open file Lepath & "ACPia931.txt" for read -- 3
read from file Lepath & "ACPia931.txt" until eof
put it into DbAcP
put " " & the result after pboot
close file Lepath & "ACPia931.txt"
open file Lepath & "ACFia931.txt" for read -- 4
read from file Lepath & "ACFia931.txt" until eof
put it into DbAcF
put " " & the result after pboot
close file Lepath & "ACFia931.txt"
open file Lepath & "IPRia931.txt" for read -- 5
read from file Lepath & "IPRia931.txt" until eof
put it into DbIPR
put " " & the result after pboot
close file Lepath & "IPRia931.txt"
open file Lepath & "IPRACPia931.txt" for read -- 6
read from file Lepath & "IPRACPia931.txt" until eof
put it into DbAcPI
put " " & the result after pboot
close file Lepath & "IPRACPia931.txt"
open file Lepath & "IPRACFia931.txt" for read -- 7
read from file Lepath & "IPRACFia931.txt" until eof
put it into DbAcFI
put " " & the result after pboot
close file Lepath & "IPRACFia931.txt"
open file Lepath & "DHGia93.txt" for read -- 8
read from file Lepath & "DHGia93.txt" until eof
put it into EDHG
put " " & the result after pboot
close file Lepath & "DHGia93.txt"
set the socketTimeoutInterval to "10"
if the windows is "PEWEB"
then accept connections on port "567" with message "newconnect"
else accept connections on port "4567" with message "newconnect"
open file Lepath & "LOGia931.txt" for append
if the result is not empty then
write cr & the result & cr to file Lepath & "LOGia931.txt"
put " " & the result after pboot
else write cr & "Open sockets :" && the opensockets & cr to file Lepath &
"LOGia931.txt"
replace " eof" with "" in pboot
if the num of words in pboot > 0
then put "WMC not up :" & pboot
else put binfo
end PreOpenStack
As my two cents,...
In using this way, you will get a more usable, fast and fine config to serve
web/vpn apps and connect odbc sources than in using all the so poors java2
stuffs available for lots and lots of $ and time to spend in using them...
Regards, Pierre Sahores
WEB & VPN applications and databases servers
Inspection académique de la Seine-Saint-Denis
Penser la part du rêve et produire l'avantage
Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.