Пример #1
0
<?php

error_reporting(E_ALL);
include_once '../../../../bootstrap.php';
use Cz\Git\GitRepository;
if (!$_SESSION['login']) {
    echo json_encode(array("result" => false, 'message' => 'Please login'));
    exit;
}
header('Content-Type: application/json');
$id = $_POST['id'];
$dir = REPOSITORY . '/' . $id . '/';
$repo = new GitRepository($dir);
$repo->checkout($_POST['branch_name']);
//var_dump($repo->getCurrentBranchName());
echo json_encode(array('result' => true));
Пример #2
0
    if ($_POST['init']) {
        if (is_remote_repository($document['name'])) {
            // clone repository
            $repo = GitRepository::cloneRepository($document['name'], $dir);
            $repo->setConfig($_SESSION['username']);
            $repo->setConfigExt('core.quotepath off');
            $repo->setConfigExt('core.precomposeunicode true');
            // update code project name
            $real_code_name = GitRepository::extractRepositoryNameFromUrl($document['name']);
            // TODO: update mongodb
            //
            // TODO: add code readme.md
            //
            //
        } else {
            $repo = GitRepository::init($dir);
            $repo->setConfig($_SESSION['username']);
            $repo->setConfigExt('core.quotepath off');
            $repo->setConfigExt('core.precomposeunicode true');
            // create a new file in repo
            $filename = $repo->getRepositoryPath() . '/README.md';
            file_put_contents($filename, "# Init Project");
            chmod($filename, 0777);
            // commit
            $repo->addFile($filename);
            $repo->commit('init project');
        }
    }
    echo json_encode(array('result' => true, 'id' => $id));
} else {
    echo json_encode(array('result' => false));
Пример #3
0
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);
$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;
            }
Пример #4
0
$components = $db->components;
$data = $components->findOne(array('_id' => new MongoId($_GET['id'])));
$isMy = true;
if ($_GET['id'] && ($data['login_type'] != $_SESSION['login_type'] || $data['userid'] != $_SESSION['userid'])) {
    $isMy = false;
}
$type = 'file';
// plugin name
include_once V2_PLUGIN . "/{$type}/meta.php";
$meta = implode(PHP_EOL, $metaList);
// 레파지토리 자동 생성
// 파일 디렉토리 생성
$repository = REPOSITORY . '/' . $_GET['id'] . '/';
if (!is_dir("{$repository}/.git")) {
    @mkdir($repository, 0777, true);
    GitRepository::init($repository);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0"> -->
<title>JENNIFER UI: Store</title>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">
<script type="text/javascript" src="/bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
<?php 
echo $meta;
Пример #5
0
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);
$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']);
Пример #6
0
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);
$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");
if ($is_dir) {
    $arr = explode('/', $prev_file);
    $filename = explode("/", $_POST['filename']);
    $arr[count($arr) - 2] = $filename[0];
    $repo->renameFile($prev_file, join("/", $arr));
Пример #7
0
<?php 
include_once V2_INC . '/property.php';
@(include_once V2_PLUGIN . "/code/ui.php");
@(include_once V2_PLUGIN . "/code/settings.php");
$id = $_GET['id'];
$dir = REPOSITORY . '/' . $id . '/';
use Cz\Git\GitRepository;
$repo = new GitRepository($dir);
$branches = $repo->getBranches();
$current_branch = $repo->getCurrentBranchName();
$branch_list = array();
foreach ($branches as $branch) {
    if (strpos($branch, 'HEAD') !== false) {
        continue;
    }
    if (strpos($branch, 'remotes/') !== false) {
        $arr = explode("/", $branch);
        $branch_type = array_shift($arr);
        $origin = array_shift($arr);
        $branch_name = implode("/", $arr);
        $branch_list[] = array('value' => $branch_name, 'text' => $branch_name, 'type' => 'remote', 'origin' => $origin, 'selected' => $branch_name == $current_branch);
    }
}
if (sizeof($branch_list) == 0) {
    $branches = $repo->getLocalBranches();
    $branch_list = array();
    foreach ($branches as $branch) {
        $branch_list[] = array('value' => $branch, 'text' => $branch, 'type' => 'local', 'selected' => $branch == $current_branch);
    }
}
Пример #8
0
$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 . '/';
mkdir($dir, 0777, true);
if (!is_dir("{$dir}/.git")) {
    $repo = GitRepository::init($dir);
    $repo->setConfig($_SESSION['username']);
    $repo->setConfigExt('core.quotepath false');
    $repo->setConfigExt('core.precomposeunicode true');
} else {
    $repo = new GitRepository($dir);
}
// 파일별 unique 아이디를 만들어서 저장
function file_numbering($name)
{
    $actual_name = pathinfo($name, PATHINFO_FILENAME);
    $dir_name = pathinfo($name, PATHINFO_DIRNAME);
    $original_name = $actual_name;
    $extension = pathinfo($name, PATHINFO_EXTENSION);
    $i = 1;
    while (file_exists($dirname . '/' . $actual_name . "." . $extension)) {
        $actual_name = (string) $original_name . $i;
        $name = $actual_name . "." . $extension;
        $i++;
    }
    return $dirname . '/' . $name;
Пример #9
0
$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'));
Пример #10
0
    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 . '/';
if ($_POST['file'] == "/{$id}") {
    $_POST['file'] = "/{$id}/";
}
$filepath = str_replace("/{$id}/", '', $_POST['file']);
$filename = basename($filepath);
$dirname = dirname($filepath);
$repo = new GitRepository($dir);
$root = $repo->getRepositoryPath();
if ($_POST['isFile'] == 'true') {
    $search_file = $filepath;
}
$arr = $repo->logs($search_file);
$temp = array();
foreach ($arr as $text) {
    $info = explode("||", $text);
    $temp[] = array('commitId' => $info[0], 'author' => $info[1], 'ago' => $info[2], 'message' => $info[3], "commit_day" => date('Y-m-d', strtotime($info[4])));
}
die(json_encode(array('result' => true, 'logs' => $temp)));
Пример #11
0
<?php

include_once '../../../../bootstrap.php';
include_once 'common.php';
use Cz\Git\GitRepository;
header('Content-Type: application/json');
if (!$_SESSION['login']) {
    echo json_encode(array("result" => false, 'message' => 'Please login to create chart.'));
    exit;
}
$id = $_POST['id'] ? $_POST['id'] : (string) $document['_id'];
$dir = REPOSITORY . '/' . $id . '/';
$repo = new GitRepository($dir);
// create a new file in repo
$filename = $dir . $_POST['filename'];
if (file_exists($filename)) {
    echo json_encode(array('result' => false, 'message' => 'already file is 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) {
    mkdir($filename, 0777, true);
    $repo->addFile($filename);
    echo json_encode(array('result' => true, 'message' => 'directory is success'));
    exit;
} else {
    if (!is_support_type($filename)) {
Пример #12
0
<?php

error_reporting(E_ALL);
include_once '../../../../bootstrap.php';
include_once 'common.php';
use Cz\Git\GitRepository;
header('Content-Type: application/json');
$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);
//var_dump($_POST);
setlocale(LC_CTYPE, "ko_KR.UTF-8");
$repo->setConfig($_SESSION['username']);
$commit_message = $_POST['commit_message'];
$ret = $repo->commit($commit_message, "-a");
die(json_encode(array('result' => $ret ? true : false)));
Пример #13
0
 * ex: $root = $_SERVER['DOCUMENT_ROOT'];
 */
//$root = null;
$root = REPOSITORY;
if (!$root) {
    exit("ERROR: Root filesystem directory not set in jqueryFileTree.php");
}
$postDir = rawurldecode($root . (isset($_POST['dir']) ? $_POST['dir'] : null));
// set checkbox if multiSelect set to true
$checkbox = isset($_POST['multiSelect']) && $_POST['multiSelect'] == 'true' ? "<input type='checkbox' />" : null;
$onlyFolders = isset($_POST['onlyFolders']) && $_POST['onlyFolders'] == 'true' ? true : false;
$onlyFiles = isset($_POST['onlyFiles']) && $_POST['onlyFiles'] == 'true' ? true : false;
if (file_exists($postDir)) {
    // get changed files
    $dir = $_POST['dir'];
    $repo = new GitRepository($postDir);
    $repoRoot = $repo->getRepositoryPath();
    $changedFiles = $repo->changedFilesByFileName('.');
    $files = preg_grep('/^([^.])/', scandir($postDir));
    $returnDir = substr($postDir, strlen($root));
    natcasesort($files);
    //if( count($files) > 2 ) { // The 2 accounts for . and ..
    echo "<ul class='jqueryFileTree'>";
    $dir_list = "";
    $file_list = "";
    foreach ($files as $file) {
        $htmlRel = htmlentities($returnDir . $file);
        $htmlName = htmlentities($file);
        $ext = preg_replace('/^.*\\./', '', $file);
        if (file_exists($postDir . $file) && $file != '.' && $file != '..') {
            if (is_dir($postDir . $file) && (!$onlyFiles || $onlyFolders)) {
Пример #14
0
    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 . '/';
$filepath = str_replace("/{$id}", '', $_POST['filepath']);
$repo = new GitRepository($dir . $filepath);
function file_numbering($name)
{
    $actual_name = pathinfo($name, PATHINFO_FILENAME);
    $dir_name = pathinfo($name, PATHINFO_DIRNAME);
    $extension = pathinfo($name, PATHINFO_EXTENSION);
    $name = $original_name = $actual_name;
    $i = 1;
    while (file_exists($dir_name . '/' . $actual_name . "." . $extension)) {
        $actual_name = (string) $original_name . '(' . $i . ')';
        $name = $actual_name . "." . $extension;
        $i++;
    }
    return $dir_name . '/' . $name . "." . $extension;
}
setlocale(LC_CTYPE, "ko_KR.UTF-8");
Пример #15
0
    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 . '/';
$filepath = str_replace("/{$id}", '', $_POST['filepath']);
$repo = new GitRepository($dir . $filepath);
$total = count($_FILES['files']['tmp_name']);
function file_numbering($name)
{
    $actual_name = pathinfo($name, PATHINFO_FILENAME);
    $dir_name = pathinfo($name, PATHINFO_DIRNAME);
    $original_name = $actual_name;
    $extension = pathinfo($name, PATHINFO_EXTENSION);
    $i = 1;
    while (file_exists($dirname . '/' . $actual_name . "." . $extension)) {
        $actual_name = (string) $original_name . $i;
        $name = $actual_name . "." . $extension;
        $i++;
    }
    return $dirname . '/' . $name;
}
Пример #16
0
<?php

error_reporting(E_ALL);
include_once '../../../../bootstrap.php';
include_once 'common.php';
use Cz\Git\GitRepository;
header('Content-Type: application/json');
if (!$_SESSION['login']) {
    echo json_encode(array("result" => false, 'message' => 'Please login to create chart.'));
    exit;
}
$id = $_POST['id'] ? $_POST['id'] : (string) $document['_id'];
$dir = REPOSITORY . '/' . $id . '/';
$repo = new GitRepository($dir);
// create a new file in repo
$filename = $dir . $_POST['filename'];
if (file_exists($filename)) {
    echo json_encode(array('result' => false, 'message' => 'already file is exists'));
    return;
}
$arr = array_map('trim', explode("/", $filename));
$is_dir = array_pop($arr) == '';
setlocale(LC_CTYPE, "ko_KR.UTF-8");
if ($is_dir) {
    mkdir($filename, 0777, true);
    $repo->setConfigExt('core.quotepath false');
    $repo->addFile($filename);
    echo json_encode(array('result' => true, 'message' => 'directory is success'));
    return;
} else {
    if (!is_support_type($filename)) {