コード例 #1
0
ファイル: user.php プロジェクト: KasaiDot/SharkDev
 public static function copyDirectory($from, $to)
 {
     if (self::$_files) {
         return 'Can\'t write storage in commit mode';
     }
     $to = Lib::normalizePath($to);
     if (is_file($from)) {
         return 'Origin path is a file';
     }
     if (!is_dir($from)) {
         return 'File not found';
     }
     if (is_file($to)) {
         return 'Destination path is a file';
     }
     if (is_dir($to)) {
         return 'Destination path already exists';
     }
     try {
         Lib::recurseCopy($from, $to);
     } catch (Exception $e) {
         return 'Internal server error';
     }
     return 'true';
 }
コード例 #2
0
ファイル: API.php プロジェクト: KasaiDot/SharkDev
 public static function createUserLinkedProject($toUser, $fromUser, $fromProject, $confidentialityLevel = 'private')
 {
     chdir(__DIR__);
     global $shark;
     global $db;
     $toUser = Lib::normalizePath($toUser);
     $fromUser = Lib::normalizePath($fromUser);
     if ($confidentialityLevel !== 'public' && $confidentialityLevel !== 'private') {
         return $shark['msg']['bad-request'];
     }
     if (!self::existsUser($fromUser) && $fromUser !== '.model') {
         return 'User doesn\'t exists';
     }
     if (!is_dir('users/' . $fromUser . '/public/' . $fromProject)) {
         return 'Project not found';
     }
     try {
         mkdir('users/' . $toUser . '/' . $confidentialityLevel . '/' . $fromProject);
         Lib::recurseCopy('users/' . $fromUser . '/public/' . $fromProject, 'users/' . $toUser . '/' . $confidentialityLevel . '/' . $fromProject);
     } catch (Exception $e) {
         return $shark['msg']['API-error'];
     }
     return $shark['msg']['API-done'];
 }
コード例 #3
0
ファイル: get-compiler.php プロジェクト: KasaiDot/SharkDev
<?php

chdir(__DIR__);
require_once '../framework/lib.php';
require_once 'config.php';
//require_once('API.php');
if (!isset($_GET['name']) || empty($_GET['name'])) {
    die($shark['msg']['bad-request']);
}
$path = 'compilers/' . Lib::normalizePath($_GET['name']);
if (!is_dir($path)) {
    die($shark['msg']['not-found']);
}
$json = json_decode(file_get_contents($path . '/package.json'), true);
$json['compiler'] = file_get_contents($path . '/' . $json['package']['compiler']);
if (isset($json['runner'])) {
    $json['runner'] = file_get_contents($path . '/' . $json['package']['runner']);
}
$json['files'] = array();
foreach ($json['package']['require'] as $i => $file) {
    $json['files'][$file] = file_get_contents($path . '/' . $file);
}
die(json_encode($json));