function add_directory_listing($dir, $disabled, $makediff, $stats, &$list)
{
    global $diffpath;
    $handle = opendir($dir);
    while (($entry = readdir($handle)) !== false) {
        if ($entry != '.' && $entry != '..') {
            $type = filetype($dir . $entry);
            if ($type == 'file') {
                $file = $dir . $entry;
                $hash = get_file_hash($file);
                $parsed = array('file' => $file, 'hash' => $hash);
                $parsed['state'] = 'New';
                $parsed['staged'] = 'N';
                if ($makediff) {
                    $command = $diffpath;
                    $args = array('-u', '/dev/null', $parsed['file']);
                    $h = start_command($command, $args);
                    close_stdin($h);
                    $diff = htmlentities(get_all_data($h));
                    clean_up($h);
                } else {
                    $diff = false;
                }
                list($str, $prefix) = html_file($file, $parsed['state'], $parsed['staged'], $parsed['hash'], $diff, $disabled);
                echo $str;
                $parsed['prefix'] = $prefix;
                $list[] = $parsed;
            } elseif ($type == 'dir') {
                add_directory_listing($dir . $entry . '/', $disabled, $makediff, $stats, $list);
            } else {
                interpret_not_supported($dir . $entry, __FILE__, __LINE__);
            }
        }
    }
    return $list;
}
Example #2
0
             // array('tab'=>$tab, 'uuid'=>$uuid, 'hostname'=>$hostname)));
             exit;
         } else {
             $coh_id = $_POST["coh_id"];
             start_command_on_host($coh_id);
             header("Location: " . urlStrRedirect("{$module}/{$submod}/{$page}", $url));
             // array('tab'=>$tab, 'uuid'=>$uuid, 'hostname'=>$hostname)));
             exit;
         }
     }
 } else {
     if (strlen($_POST['gid']) && !strlen($_POST["coh_id"])) {
         /* The start command must be done on a group of computers */
         $cmd_id = $_POST["cmd_id"];
         $gid = $_POST["gid"];
         start_command($cmd_id);
         header("Location: " . urlStrRedirect("{$module}/{$submod}/{$page}", $url));
         // array('tab'=>$tab, 'gid'=>$gid)));
         exit;
     } else {
         if (strlen($_POST['gid'])) {
             /* The start command is done on a commands_on_host for a group of
                computers */
             $coh_id = $_POST["coh_id"];
             $cmd_id = $_POST["cmd_id"];
             $gid = $_POST["gid"];
             start_command_on_host($coh_id);
             header("Location: " . urlStrRedirect("{$module}/{$submod}/{$page}", $url));
             // array('tab'=>$tab, 'cmd_id'=>$cmd_id, 'gid'=>$gid)));
             exit;
         } else {