
Originally Posted by
DosFan
TinyApp could receive the querystring via the commandline, too?
I'd recomend doing some validation before you put anything into the command you feed to exec(). see escapeshellarg() to escape, but consider some strong validation too. You need to program very defensively on the web.

Originally Posted by
DosFan
How do I recognise in javascript that FatApp has finished?
This is where AJAX comes in, which is just an asynchronous functionality of javascript. When sending an ajax http request, the browser will send the request in the background asynchronously. The user can continue using the webpage, and will be unaware the browser is actually sending/loading something. Once the browser receives the response(from your php script), javascript will fire the onreadystatechange event. You can have javascript execute a callback function when this event gets fired. Your function would examine the response text your php script sent, and then make changes to the webpage based on it.
I'll use the jquery javascript library to simplify the ajax code needed.
Code:
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"></script>
<script type="text/javascript">
function myCallback(phpResponseText) {
if (phpResponseText.length < 1) {
var str = '...nothing...';
} else {
var str = phpResponseText;
document.getElementById('img').src = 'http://example.com/images/' + str;
}
document.getElementById('phpsays').innerHTML = str;
}
function sendRequest() {
var m = document.getElementById('message').value;
var c = document.getElementById('color').value;
var postData = {message : m, color: c};
var phpScriptUrl = 'http://example.com/script.php';
// jquery will send the ajax post request, posting the key values pairs found in 'data'
// when it gets a reply, it will execute myCallback
$.post(phpScriptUrl, postData, myCallback, "text");
}
</script>
</head>
<body>
php says:<span id="phpsays"></span><br>
<img id="img"><br>
message <input id="message"><br>
color <input id="color"><br>
<input type="button" onclick="sendRequest()">
</body>
</html>

Originally Posted by
DosFan
There is one point that worries me: Is it possible to run a Windows app, with real windows and message loops, on a server? I can move the window of FatApp outside the visible area, no problem, but I need an active window to do the drawing. If that is not possible, the only workaround would be to run the daemon on another desktop PC, and use net DDE to launch the request. Clumsy, and it needs extra hardware. Tomorrow I'll have access to the server, we'll see.
I have no idea. My experience in programming for the desktop is limited to using the shell, and a few hello world programs in java.
*Consider some type of flood control for this whole thing. A user could send a ton of image creation requests to try to DOS you, and without some type of flood control or queue, you may end up with a ton of tinyapp processes running.
Bookmarks