function getArchiveTree($level = 1) { $tree = []; if (isset($_GET['path'])) { //TODO: Common::checkPath($path) return false... $source = getWorkspacePath($_GET['path']); //$source = WORKSPACE . "/" . $_GET['path']; if (file_exists($source)) { $source_info = pathinfo($source); if (isset($source_info['extension']) && !empty($source_info['extension'])) { $des = dirname($source); if ($source_info['extension'] == 'zip') { if (class_exists('ZipArchive') && ($zip = new ZipArchive())) { if ($res = $zip->open($source)) { for ($i = 0; $i < $zip->numFiles; $i++) { $name = $zip->getNameIndex($i); $path = $name; $count = substr_count($path, '/'); if ($count > $level) { continue; } $tree[$name] = $path; } $zip->close(); } } } elseif ($source_info['extension'] == 'tar') { if (class_exists('PharData') && ($tar = new PharData($source))) { //TODO: get tar tree } } elseif ($source_info['extension'] == 'rar') { if (class_exists('rar_open') && ($rar = new rar_open())) { if ($res = $rar->open($source)) { $entries = rar_list($res); //TODO: get rar tree $rar->close(); } } } } } } return $tree; }
if (!file_exists($dest)) { if (rename($source, $dest)) { echo '{"status":"success","message":"Path moved"}'; } else { echo '{"status":"error","message":"Failed to move path!"}'; } } else { echo '{"status":"error","message":"Path already exists!"}'; } } else { echo '{"status":"error","message":"Missing Parameter"}'; } break; case 'getContent': if (isset($_GET['path'])) { $content = file_get_contents(getWorkspacePath($_GET['path'])); $result = array("status" => "success", "content" => $content); echo json_encode($result); } else { echo '{"status":"error","message":"Missing Parameter"}'; } break; default: echo '{"status":"error","message":"No Type"}'; break; } function getWorkspacePath($path) { if (strpos($path, "/") === 0) { //Unix absolute path return $path;
echo json_encode(array()); } break; case 'save': if (isset($_POST['data'])) { saveJSON(getFileName(), json_decode($_POST['data']), "config"); echo '{"status":"success","message":"Data saved"}'; } else { echo '{"status":"error","message":"Missing Parameter"}'; } break; case 'isDir': if (isset($_GET['path'])) { $result = array(); $result['status'] = "success"; $result['result'] = is_dir(getWorkspacePath($_GET['path'])); echo json_encode($result); } else { echo '{"status":"error","message":"Missing Parameter"}'; } break; default: echo '{"status":"error","message":"No Type"}'; break; } function getFileName() { return "ignore." . $_SESSION['user'] . ".php"; } function getWorkspacePath($path) {
<?php /* * Copyright (c) Codiad & Andr3as, distributed * as-is and without warranty under the MIT License. * See http://opensource.org/licenses/MIT for more information. * This information must remain intact. */ error_reporting(0); require_once '../../common.php'; checkSession(); switch ($_GET['action']) { case 'getScript': $path = getWorkspacePath($_GET['path']); if (file_exists($path)) { echo file_get_contents($path); } else { header("HTTP/1.0 404 Not Found"); } break; default: echo '{"status":"error","message":"No Type"}'; break; } function getWorkspacePath($path) { //Security check if (!Common::checkPath($path)) { die('{"status":"error","message":"Invalid path"}'); } if (strpos($path, "/") === 0) {
$tree = scanProject($path); foreach ($tree as $i => $file) { $tree[$i] = str_replace($path . "/", "", $file); } $result = array("status" => "success", "tree" => $tree); echo json_encode($result); } else { echo '{"status":"error","message":"Missing Parameter!"}'; } break; case 'saveContent': if (isset($_GET['path']) && isset($_POST['content'])) { $dir = dirname($_GET['path']); $base = basename($_GET['path']); $new = preg_replace("/(\\w+)(\\.scss|\\.sass)\$/", "\$1.css", $base); file_put_contents(getWorkspacePath($dir . "/" . $new), $_POST['content']); echo '{"status":"success","message":"Sass file compiled!"}'; } else { echo '{"status":"error","message":"Missing Parameter!"}'; } break; default: echo '{"status":"error","message":"No Type"}'; break; } function getWorkspacePath($path) { //Security check if (!Common::checkPath($path)) { die('{"status":"error","message":"Invalid path"}'); }
/* * Copyright (c) Codiad, Rafasashi & beli3ver, distributed * as-is and without warranty under the MIT License. * See http://opensource.org/licenses/MIT for more information. * This information must remain intact. */ error_reporting(0); require_once '../../common.php'; checkSession(); require_once './functions.php'; //need for rar filelist check $error = false; switch ($_GET['action']) { case 'extract': if (isset($_GET['path'])) { $source = getWorkspacePath($_GET['path']); $source_info = pathinfo($source); if (!isset($source_info['extension']) || empty($source_info['extension'])) { echo '{"status":"error","message":"Not an archive"}'; } else { $des = dirname($source); if ($source_info['extension'] == 'zip') { if (class_exists('ZipArchive') && ($zip = new ZipArchive())) { if ($res = $zip->open($source)) { $epath = ''; if (isset($_GET['epath'])) { $epath = trim($_GET['epath']); } if ($epath == '' || $epath == '/' || $epath == $source_info['basename']) { // extract all archive to the path we determined above if ($zip->extractTo($des)) {
<?php /* * Copyright (c) Codiad & Andr3as, distributed * as-is and without warranty under the MIT License. * See http://opensource.org/licenses/MIT for more information. * This information must remain intact. */ error_reporting(0); require_once '../../common.php'; checkSession(); switch ($_GET['action']) { case 'duplicate': if (isset($_GET['path']) && isset($_GET['name'])) { $source = getWorkspacePath($_GET['path']); $des = getWorkspacePath(dirname($_GET['path']) . "/" . $_GET['name']); if (copy($source, $des)) { echo '{"status":"success","message":"File duplicated"}'; } else { echo '{"status":"error","message":"Failed to duplicate"}'; } } else { echo '{"status":"error","message":"Missing Parameter"}'; } break; default: echo '{"status":"error","message":"No Type"}'; break; } function getWorkspacePath($path) {
echo '{"status":"success","data":' . json_encode($settings) . '}'; } else { echo '{"status":"error","message":"Missing parameter!"}'; } break; case 'setSettings': if (isset($_POST['settings']) && isset($_GET['path'])) { $settings = json_decode($_POST['settings'], true); $pluginSettings = getJSON('git.settings.php', 'config'); if ($pluginSettings['lockuser'] == "true") { $settings['username'] = $_SESSION['user']; if (strlen($settings['local_username']) != 0) { $settings['local_username'] = $_SESSION['user']; } } $git->setSettings($settings, getWorkspacePath($_GET['path'])); echo '{"status":"success","message":"Settings saved"}'; } else { echo '{"status":"error","message":"Missing parameter!"}'; } break; default: echo '{"status":"error","message":"No Type"}'; break; } function getWorkspacePath($path) { //Security check if (!Common::checkPath($path)) { die('{"status":"error","message":"Invalid path"}'); }