You are here: Re: How do I quote this in php? « All PHP « IT news, forums, messages
Re: How do I quote this in php?

Posted by Owen Rees on 05/22/06 23:33

On Mon, 22 May 2006 11:32:31 +0100, "Dave (from the UK)"
<see-my-signature@southminster-branch-line.org.uk> wrote in
<44719340@212.67.96.135>:

>Owen Rees wrote:
>> I suspect that you would do better to create the whole of the input to
>> Mathematica as a string first, then make that string the parameter to
>> echo, putting it in single quotes:
>> ... popen("echo '$string' | tee ...", "r") ...
>
>Unfortunately Mathematica seems to use just about every character that
>might cause a problem - *, $, ', ", `, /, <. >, \ etc. In fact it has a
>shell escape:

Here (modulo line wrapping) is a fragment that does what I described
above. I think you have to undo the effect of PHP's "magic quote"
abomination first in order to costruct the string that you want to
deliver to Mathematica. Once you have that string, you have to quote it
to get past the shell - Jon's escapeshellarg function does that part of
the job.

....

if (isset($_POST['submit'])) {
$cmd=$_POST['input_data'];
// Undo the effect of the magic quote abomination
if (get_magic_quotes_gpc()) {
$cmd=stripslashes($cmd);
}
$fullcmd=escapeshellarg("TimeConstrained[
MemoryConstrained[$cmd,$maxmemory,\"Too Much RAM has been used so we are
Aborting. This is currently limited to $maxmemory Mb in witm.php, but
can be changed on the web server.\"],$maxtime,\"This is taking too long,
so is being aborted. There is a limit of $maxtime seconds, which can be
changed\"]");
$handle = popen("echo $fullcmd | tee stdin.txt | $mathprog | tee
stdout.txt | $tailprog", "r");
$data = fgets($handle);
pclose($handle);
}

....

--
Owen Rees
[one of] my preferred email address[es] and more stuff can be
found at <http://www.users.waitrose.com/~owenrees/index.html>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация