$result['result'] = implode($output); } else { if ($what == 'token') { $result['result'] = TokenC::create(); } else { if ($what == 'dicomscene') { $name = joinPaths(CHRIS_USERS, $parameters); // this only works with directories if (!is_dir($name)) { die; } $dicom_files = glob($name . "/{*.dcm,*.dicom}", GLOB_BRACE); $output = array("volume" => array("file" => array())); foreach ($dicom_files as &$df) { // 1. create a token $token = TokenC::create(); // 2. generate url (including the token) $url = CHRIS_TRANSFER_PROTOCOL . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?token=" . $token . "&action=download&what=file¶meters=" . joinPaths($parameters, basename($df)); // 3. attach to output $output['volume']['file'][] = $url; } // return JSON encoded output die(json_encode($output)); } } } } } } } }
$user_key_file = joinPaths(CHRIS_USERS, $username, CHRIS_USERS_CONFIG_DIR, CHRIS_USERS_CONFIG_SSHKEY); $ssh->exec('bash -c \' echo "export ENV_REMOTEUSERIDENTITY=' . $user_key_file . '" >> ' . $envfile . '\''); $ssh->exec('bash -c \' echo "umask 0002" >> ' . $envfile . '\''); $ssh->exec('bash -c \' echo "source ' . $envfile . ';" >> ' . $runfile . '\''); if ($status != 100) { $start_token = TokenC::create(); $ssh->exec('echo "' . $setStatus . '\'action=set&what=feed_status&feedid=' . $feed_id . '&op=set&status=1&token=' . $start_token . '\' ' . CHRIS_URL . '/api.php > ' . $job_path_output . '/curlA.std 2> ' . $job_path_output . '/curlA.err" >> ' . $runfile); } $ssh->exec('bash -c \'echo "echo \\"\\$(date) Running on \\$HOSTNAME\\" > ' . $job_path_output . '/chris.std" >> ' . $runfile . '\''); $ssh->exec('bash -c \' echo "' . $command . '" >> ' . $runfile . '\''); // generate the db.json file // to generate the db.json, we just call the viewer plugin with the correct input and ouput directories, $feed_path $viewer_plugin = CHRIS_PLUGINS_FOLDER . '/viewer/viewer'; $ssh->exec("echo '{$viewer_plugin} --directory {$job_path} --output {$job_path}/..;' >> {$runfile};"); if ($status != 100) { $end_token = TokenC::create(); $ssh->exec('echo "' . $setStatus . '\'action=set&what=feed_status&feedid=' . $feed_id . '&op=inc&status=+' . $status_step . '&token=' . $end_token . '\' ' . CHRIS_URL . '/api.php > ' . $job_path_output . '/curlB.std 2> ' . $job_path_output . '/curlB.err" >> ' . $runfile); } // make sure to update file permissions $ssh->exec("echo 'chmod 775 {$user_path} {$plugin_path}; chmod 755 {$feed_path}; cd {$feed_path} ; find . -type d -exec chmod o+rx,g+rx {} \\; ; find . -type f -exec chmod o+r,g+r {} \\;' >> {$runfile};"); $ssh->exec("chmod o+rx,g+rx {$runfile}"); $arguments = ' -l ' . $job_path; $arguments .= ' -m ' . $memory; $arguments .= ' -c "' . $runfile . '"'; $arguments .= ' -u "' . $username . '"'; $arguments .= ' -p "' . $password . '"'; $arguments .= ' -o "' . $feed_path . '"'; if ($force_chris_local) { // get user group id $groupID = $ssh->exec("id -g"); $groupID = trim($groupID);