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 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]


Удаленная работа для программистов  •  Как заработать на 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

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