예제 #1
0
 public function actionOperation()
 {
     Yii::import('mod.core.components.fs');
     if (isset($_GET['operation'])) {
         //$fs = new fs(dirname(__FILE__) . DS . 'data' . DS . 'root' . DS);
         $fs = new fs(Yii::getPathOfAlias('webroot.themes'));
         try {
             $rslt = null;
             switch ($_GET['operation']) {
                 case 'get_node':
                     $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
                     $rslt = $fs->lst($node, isset($_GET['id']) && $_GET['id'] === '#');
                     break;
                 case "get_content":
                     $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
                     $rslt = $fs->data($node);
                     break;
                 case 'create_node':
                     $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
                     $rslt = $fs->create($node, isset($_GET['text']) ? $_GET['text'] : '', !isset($_GET['type']) || $_GET['type'] !== 'file');
                     break;
                 case 'rename_node':
                     $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
                     $rslt = $fs->rename($node, isset($_GET['text']) ? $_GET['text'] : '');
                     break;
                 case 'delete_node':
                     $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
                     $rslt = $fs->remove($node);
                     break;
                 case 'move_node':
                     $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
                     $parn = isset($_GET['parent']) && $_GET['parent'] !== '#' ? $_GET['parent'] : '/';
                     $rslt = $fs->move($node, $parn);
                     break;
                 case 'copy_node':
                     $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
                     $parn = isset($_GET['parent']) && $_GET['parent'] !== '#' ? $_GET['parent'] : '/';
                     $rslt = $fs->copy($node, $parn);
                     break;
                 default:
                     throw new Exception('Unsupported operation: ' . $_GET['operation']);
                     break;
             }
             header('Content-Type: application/json; charset=utf-8');
             echo json_encode($rslt);
         } catch (Exception $e) {
             header($_SERVER["SERVER_PROTOCOL"] . ' 500 Server Error');
             header('Status:  500 Server Error');
             echo $e->getMessage();
         }
         die;
     }
 }
예제 #2
0
파일: fs.ajax.php 프로젝트: cheese1/ampache
if (isset($_GET['operation'])) {
    $fs = new fs($rootdir);
    try {
        $rslt = null;
        switch ($_GET['operation']) {
            case 'get_node':
                $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
                $rslt = $fs->lst($node, isset($_GET['id']) && $_GET['id'] === '#');
                break;
            case "get_content":
                $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
                $rslt = $fs->data($node);
                break;
            case 'create_node':
                $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
                $rslt = $fs->create($node, isset($_GET['text']) ? $_GET['text'] : '', !isset($_GET['type']) || $_GET['type'] !== 'file');
                break;
            case 'rename_node':
                $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
                $rslt = $fs->rename($node, isset($_GET['text']) ? $_GET['text'] : '');
                break;
            case 'delete_node':
                $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
                $rslt = $fs->remove($node);
                break;
            case 'move_node':
                $node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
                $parn = isset($_GET['parent']) && $_GET['parent'] !== '#' ? $_GET['parent'] : '/';
                $rslt = $fs->move($node, $parn);
                break;
            case 'copy_node':
{
    return isset($parent) && $parent !== '#' ? $parent : '/';
}
$rslt = null;
$fs = new fs($url);
try {
    $node = getIdNode($id);
    switch ($operation) {
        case 'get_node':
            $rslt = $fs->lst($node, isset($id) && $id === '#');
            break;
        case "get_content":
            $rslt = $fs->data($node);
            break;
        case 'create_node':
            $rslt = $fs->create($node, getIdText($text), !isset($type) || $type !== 'file');
            break;
        case 'rename_node':
            $rslt = $fs->rename($node, getIdText($text));
            break;
        case 'delete_node':
            $rslt = $fs->remove($node);
            break;
        case 'move_node':
            $rslt = $fs->move($node, getParent($parent));
            break;
        case 'copy_node':
            $rslt = $fs->copy($node, getParent($parent));
            break;
        default:
            throw new Exception(_('Unsupported operation: ') . $operation);
    return isset($parent) && $parent !== '#' ? $parent : '/';
}
if (isset($operation)) {
    $fs = new fs($url);
    try {
        $rslt = null;
        $node = getIdNode($id);
        switch ($operation) {
            case 'get_node':
                $rslt = $fs->lst($node, isset($id) && $id === '#');
                break;
            case "get_content":
                $rslt = $fs->data($node);
                break;
            case 'create_node':
                $rslt = $fs->create($node, isset($text) ? $text : '', !isset($type) || $type !== 'file');
                break;
            case 'rename_node':
                $rslt = $fs->rename($node, isset($text) ? $text : '');
                break;
            case 'delete_node':
                $rslt = $fs->remove($node);
                break;
            case 'move_node':
                $rslt = $fs->move($node, getParent($parent));
                break;
            case 'copy_node':
                $rslt = $fs->copy($node, getParent($parent));
                break;
            default:
                throw new Exception(_('Unsupported operation: ') . $operation);