function shell_converse($conversation = array(), $env = array(), $cwd = '/tmp') { $result = ''; $z = sizeof($conversation); if ($z > 1) { $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w")); $cmd = shell_escape($conversation[0]); $process = proc_open($cmd, $descriptorspec, $pipes, $cwd, $env); if (is_resource($process)) { for ($i = 1; $i < $z; $i++) { $cmd = shell_escape($conversation[$i]); $result .= nextResourceLine($pipes[2]); fwrite($pipes[0], $cmd . "\n"); } $result .= nextResourceLine($pipes[2]); fclose($pipes[2]); fclose($pipes[1]); fclose($pipes[0]); $code = proc_close($process); $result .= join("\n", $conversation); } } return $result; }
function git_log_commit($commit, $class = null, $id = null) { $cmd = "git show -U99999 " . shell_escape($commit) . ($class ? " --follow -- " . shell_escape("{$class}/{$id}.json") : ""); return _git_log_exec($cmd); }
function ajax_save_remove_feature($param, $postdata) { global $data_path; if (!check_param($param)) { return array('saved' => false, 'error' => 'Invalid ID'); } git_init(); if (array_key_exists('rev', $param)) { git_checkout($param['rev']); } // create directory for map data $path = "{$data_path}/{$param['id']}"; if (!is_dir($path)) { mkdir($path); } $feature_id = $postdata; git_exec("rm " . shell_escape("{$param['id']}/_" . $feature_id . '.json')); git_commit("remove feature"); $rev = git_rev(); if (!git_merge()) { return array('saved' => false, 'rev' => $rev, 'error' => "Conflict when merging changes. Please reload and re-do changes."); } return array('saved' => true, 'rev' => $rev); }