} $m = new MongoClient(); // select a rowbase $db = $m->store; $components = $db->components; $row = $components->findOne(array('_id' => new MongoId($id))); $isMy = true; if ($id && ($row['login_type'] != $_SESSION['login_type'] || $row['userid'] != $_SESSION['userid'])) { echo json_encode(array('result' => false, 'message' => 'Access denined.')); exit; } $dir = REPOSITORY . '/' . $id . '/'; $repo = new GitRepository($dir); $prev_file = str_replace("/{$id}", '', $_POST['prev_file']); // create a new file in repo $filename = $repo->getRepositoryPath() . $prev_file; if (!file_exists($filename)) { echo json_encode(array('result' => false, 'message' => 'file is not exists.')); return; } $arr = array_map('trim', explode("/", $filename)); $is_dir = array_pop($arr) == ''; setlocale(LC_CTYPE, "ko_KR.UTF-8"); $repo->setConfig($_SESSION['username']); $repo->setConfigExt('core.quotepath false'); if ($is_dir) { $arr = explode('/', $prev_file); $filename = explode("/", $_POST['filename']); $arr[count($arr) - 2] = $filename[0]; $repo->renameFile($prev_file, join("/", $arr)); echo json_encode(array('result' => true, 'message' => 'directory is success'));
echo json_encode(array('result' => false, 'message' => 'Not found')); exit; } $m = new MongoClient(); // select a rowbase $db = $m->store; $components = $db->components; $row = $components->findOne(array('_id' => new MongoId($id))); $isMy = true; if ($id && ($row['login_type'] != $_SESSION['login_type'] || $row['userid'] != $_SESSION['userid'])) { echo json_encode(array('result' => false, 'message' => 'Access denined.')); exit; } $dir = REPOSITORY . '/' . $id . '/'; $repo = new GitRepository($dir); $root = $repo->getRepositoryPath(); $isChanged = $repo->hasChanges(); $repo->setConfigExt('core.quotepath false'); $arr = $repo->changedFiles(); $newFiles = array(); foreach ($arr as $file) { if ($file['status'] == 'new') { $newFiles[$file['file']] = $file; } else { if ($file['status'] == 'modified') { if ($newFiles[$file['file']]) { $newFiles[$file['file']]['status'] = 'modified'; } else { $newFiles[$file['file']] = $file; } }
$id = $_POST['id']; if (!$id) { echo json_encode(array('result' => false, 'message' => 'Not found')); exit; } $m = new MongoClient(); // select a rowbase $db = $m->store; $components = $db->components; $row = $components->findOne(array('_id' => new MongoId($id))); $isMy = true; if ($id && ($row['login_type'] != $_SESSION['login_type'] || $row['userid'] != $_SESSION['userid'])) { echo json_encode(array('result' => false, 'message' => 'Access denined.')); exit; } $dir = REPOSITORY . '/' . $id . '/'; $repo = new GitRepository($dir); $filename = str_replace("/{$id}/", '', $_POST['filename']); // create a new file in repo $file_path = $repo->getRepositoryPath() . DIRECTORY_SEPARATOR . $filename; if (!file_exists($file_path)) { echo json_encode(array('result' => false, 'message' => 'file is not exists.')); return; } setlocale(LC_CTYPE, "ko_KR.UTF-8"); $repo->setConfig($_SESSION['username']); //$repo->removeFile($filename); $repo->setConfigExt('core.quotepath false'); //var_dump($filename); $repo->removeFile($filename); echo json_encode(array('result' => true, 'message' => 'delete is success'));