|
Posted by Gazza on 05/21/06 17:24
>http://www.althorne.org/witm/witm.php
The use of addslashes() (to sort out the quotes for ReadList) and strpos
(to check for an occurrence of $ within $cmd) might of some use. I'd
create a separate little function tidyUp() that can make these checks,
then pass $cmd to it, before using it in MemoryConstrained[$cmd, ...]
-------------Untested Example -----------------
function tidyUp($cmd) {
/* Turns 1+10 to 1+10 */
/* Turns ReadList["/etc/passwd", String] to Readlist[\"/etc/passwd\",
String] */
/* Turns FactorInteger[141] to FactorInteger[141] */
addslashes($cmd);
/* Check $ doesn't occur */
if(strpos($cmd, '$') === false) {
/* If $ is absent, echo \"$cmd\"
$cmdTidied = '\"'.$cmd.'\"';
} else {
/* If $ is present...
$cmdTidied = "'".$cmd."'";
}
return $cmdTidied;
}
-----------------Then use: ---------------------
$cmd=$_POST['input_data'];
$cmdTidied = tidyUp($cmd);
$handle = popen("echo TimeConstrained[ MemoryConstrained[$cmdTidied,$maxram,
I've probably ballsed up getting the function to return the right quotes
etc above, so some testing will be needed...
--
Gazza
Mobile Number Network Checker - http://mnnc.net/
Navigation:
[Reply to this message]
|