Hallo Alex,
Hat jemand eine bessere Idee?
$cmdtext = $_POST['command'];
$commands = array();
$curcmd = '';
$squote = false;
$dquote = false;
for ($i = 0; $i < strlen ($cmdtext); $i++) {
switch ($cmdtext{$i}) {
case ''':
if ($squote) {
$squote = false;
} else if (!$dquote) {
$squote = true;
}
break;
case '"':
if ($dquote) {
$dquote = false;
} else if (!$squote) {
$dquote = true;
}
break;
case ';':
if (!$squote && !$dquote) {
$commands[] = $curcmd;
$curcmd = '';
continue;
}
break;
case '\':
$curcmd .= $cmdtext{$i++};
break;
default:
break;
}
$curcmd .= $cmdtext{$i};
}
if (trim ($tmp) != '') {
$commands[] = $curcmd;
}
var_dump ($commands);
Ich übernehme natürlich keine Haftung.
Viele Grüße,
Christian
Hast Du einen Beitrag? Nur her damit!
http://aktuell.de.selfhtml.org/tippstricks/beitrag.htm
SELF-Code: (http://emmanuel.dammerer.at/selfcode.html)
sh:) fo:) ch:] rl:( br:> n4:& ie:% mo:) va:) de:] zu:) fl:( js:| ss:) ls:[