Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using "Copy URL to Clipboard" option for a root folder as / on Filemanager #258

Closed
mpaletou opened this issue Nov 11, 2017 · 7 comments

Comments

@mpaletou
Copy link

I am currently using Filemanager (with the PHP connector) on my file servers. The root filemanager folder is located in /var/www/data.

Everything works perfectly except the option 'Copy URL to Clipboard' which redirects me to a wrong link (http://my_server_ip/downloads/myfile).

@psolom
Copy link
Owner

psolom commented Nov 11, 2017

Hm, I can't reproduce the issue.
Most likely you caught a javascript error. Check your browser console.

Btw, what RFM version do you use and what is your OS?
Also share your configuration (both: filemanager.php and filemanager.config.json)

@psolom
Copy link
Owner

psolom commented Nov 17, 2017

Have you solved your issue? Let us know what was the reason.

@mpaletou
Copy link
Author

mpaletou commented Nov 19, 2017

Nothing in the Javascript console to explain why the link is work.

I'm using RFM 2.6.3 on Debian 9.

My filemanager.php file:

<?php
/**
 * Entry point for PHP connector, put your customizations here.
 *
 * @license     MIT License
 * @author      Pavel Solomienko <https://github.com/servocoder/>
 * @copyright   Authors
 */

// only for debug
// error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
// ini_set('display_errors', '1');

require 'vendor/autoload.php';

// fix display non-latin chars correctly
// https://github.com/servocoder/RichFilemanager/issues/7
setlocale(LC_CTYPE, 'en_US.UTF-8');

// fix for undefined timezone in php.ini
// https://github.com/servocoder/RichFilemanager/issues/43
if(!ini_get('date.timezone')) {
    date_default_timezone_set('GMT');
}


// This function is called for every server connection. It must return true.
//
// Implement this function to authenticate the user, for example to check a
// password login, or restrict client IP address.
//
// This function only authorizes the user to connect and/or load the initial page.
// Authorization for individual files or dirs is provided by the two functions below.
//
// NOTE: If using session variables, the session must be started first (session_start()).
function fm_authenticate()
{
    // Customize this code as desired.
    return true;

    // If this function returns false, the user will just see an error.
    // If this function returns an array with "redirect" key, the user will be redirected to the specified URL:
    // return ['redirect' => 'http://domain.my/login'];
}


// This function is called before any filesystem read operation, where
// $filepath is the file or directory being read. It must return true,
// otherwise the read operation will be denied.
//
// Implement this function to do custom individual-file permission checks, such as
// user/group authorization from a database, or session variables, or any other custom logic.
//
// Note that this is not the only permissions check that must pass. The read operation
// must also pass:
//   * Filesystem permissions (if any), e.g. POSIX `rwx` permissions on Linux
//   * The $filepath must be allowed according to config['patterns'] and config['extensions']
//
function fm_has_read_permission($filepath)
{
    // Customize this code as desired.
    return true;
}


// This function is called before any filesystem write operation, where
// $filepath is the file or directory being written to. It must return true,
// otherwise the write operation will be denied.
//
// Implement this function to do custom individual-file permission checks, such as
// user/group authorization from a database, or session variables, or any other custom logic.
//
// Note that this is not the only permissions check that must pass. The write operation
// must also pass:
//   * Filesystem permissions (if any), e.g. POSIX `rwx` permissions on Linux
//   * The $filepath must be allowed according to config['patterns'] and config['extensions']
//   * config['read_only'] must be set to false, otherwise all writes are disabled
//
function fm_has_write_permission($filepath)
{
    // Customize this code as desired.
    return true;
}


$config = [];

// example to override the default config
//$config = [
//    'security' => [
//        'readOnly' => true,
//        'extensions' => [
//            'policy' => 'ALLOW_LIST',
//            'restrictions' => [
//                'jpg',
//                'jpe',
//                'jpeg',
//                'gif',
//                'png',
//            ],
//        ],
//    ],
//];

$app = new \RFM\Application();

$local = new \RFM\Repository\Local\Storage($config);

$local->setRoot('/var/www/drive/vividec76@gmail.com', true, false);
$app->setStorage($local);
$app->api = new RFM\Api\LocalApi();
$app->run();

Filemanager.config.json:

{
    "_comment": "IMPORTANT : go to the wiki page to know about options configuration https://github.com/servocoder/RichFilemanager/wiki/Configuration-options",
    "options": {
        "theme": "flat-dark",
        "showTitleAttr": false,
        "showConfirmation": true,
        "browseOnly": false,
        "searchBox": true,
        "fileSorting": "NAME_ASC",
        "folderPosition": "bottom",
        "quickSelect": false,
        "logger": false,
        "allowFolderDownload": true,
        "allowChangeExtensions": false,
        "capabilities": [
            "select",
            "upload",
            "download",
            "rename",
            "copy",
            "move",
            "delete",
            "extract"
        ]
    },
    "language": {
        "default": "en",
        "available": ["ar", "bs", "ca", "cs", "da", "de", "el", "en", "es", "fa", "fi", "fr", "he", "hu", "it", "ja", "nl", "pl", "pt", "ru", "sv", "th", "tr", "vn", "zh-cn", "zh-tw"]
    },
    "filetree": {
        "enabled": true,
        "foldersOnly": false,
        "reloadOnClick": true,
        "expandSpeed": 200,
        "showLine": true,
        "width": 200,
        "minWidth": 200
    },
    "manager": {
        "defaultViewMode": "grid",
        "dblClickOpen": false,
        "selection": {
            "enabled": true,
            "useCtrlKey": true
        },
        "renderer": {
            "position": false,
            "indexFile": "readme.md"
        }
    },
    "api": {
        "lang": "php",
        "connectorUrl": false,
        "requestParams": {
            "GET": {},
            "POST": {},
            "MIXED": {}
        }
    },
    "upload": {
        "multiple": true,
        "maxNumberOfFiles": 5,
        "chunkSize": false
    },
    "clipboard": {
        "enabled": true,
        "encodeCopyUrl": true
    },
    "filter": {
        "image": ["jpg", "jpeg", "gif", "png", "svg"],
        "media": ["ogv", "avi", "mkv", "mp4", "webm", "m4v", "ogg", "mp3", "wav"],
        "office": ["txt", "pdf", "odp", "ods", "odt", "rtf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "csv", "md"],
        "archive": ["zip", "tar", "rar"],
        "audio": ["ogg", "mp3", "wav"],
        "video": ["ogv", "avi", "mkv", "mp4", "webm", "m4v"]
    },
    "viewer": {
        "absolutePath": true,
        "previewUrl": false,
        "image": {
            "enabled": true,
            "lazyLoad": true,
            "showThumbs": true,
            "thumbMaxWidth": 64,
            "extensions": [
                "jpg",
                "jpe",
                "jpeg",
                "gif",
                "png",
                "svg"
            ]
        },
        "video": {
            "enabled": true,
            "extensions": [
                "ogv",
                "mp4",
                "webm",
                "m4v"
            ],
            "playerWidth": 400,
            "playerHeight": 222
        },
        "audio": {
            "enabled": true,
            "extensions": [
                "ogg",
                "mp3",
                "wav"
            ]
        },
        "iframe": {
            "enabled": true,
            "extensions": [
                "htm",
                "html"
            ],
            "readerWidth": "95%",
            "readerHeight": "600"
        },
        "onlyoffice": {
            "enabled": false,
            "extensions": [
                "doc",
                "docx",
                "odt",
                "rtf",
                "txt",
                "pdf",
                "html",
                "epub",
                "xps",
                "djvu",
                "xls",
                "xlsx",
                "ods",
                "csv",
                "pptx",
                "ppt",
                "odp"
            ],
            "editorWidth": "95%",
            "editorHeight": "600",
            "apiUrl": "https://doc.onlyoffice.com/web-apps/apps/api/documents/api.js",
            "connectorUrl": false,
            "downloadUrl": false,
            "callbackUrl": false
        },
        "opendoc": {
            "enabled": true,
            "extensions": [
                "pdf",
                "odt",
                "odp",
                "ods"
            ],
            "readerWidth": "640",
            "readerHeight": "480"
        },
        "google": {
            "enabled": true,
            "extensions": [
                "doc",
                "docx",
                "xls",
                "xlsx",
                "ppt",
                "pptx"
            ],
            "readerWidth": "640",
            "readerHeight": "480"
        },
        "codeMirrorRenderer": {
            "enabled": true,
            "extensions": [
                "txt",
                "csv"
            ]
        },
        "markdownRenderer": {
            "enabled": true,
            "extensions": [
                "md"
            ]
        }
    },
    "editor": {
        "enabled": true,
        "theme": "default",
        "lineNumbers": true,
        "lineWrapping": true,
        "codeHighlight": true,
        "matchBrackets": true,
        "extensions": [
            "html",
            "txt",
            "csv",
            "md"
        ]
    },
    "customScrollbar": {
        "enabled": true,
        "theme": "inset-2-dark",
        "button": true
    },
    "extras": {
        "extra_js": [],
        "extra_js_async": true
    },
    "url": "https://github.com/servocoder/RichFilemanager",
    "version": "2.6.3"
}

Moreover, these file extensions are not showed by RichFilemanager:
.exe
.flac
.cue
.m3u
.m3u8
.xml
.json
.log
.nfo
.cab
.mst
.msi
.rsd
.rar

@psolom
Copy link
Owner

psolom commented Nov 19, 2017

To show extensions that you wish you have to specify them in the restrictions white-list:

$config = [
    'security' => [
        'extensions' => [
            'policy' => 'ALLOW_LIST',
            'restrictions' => [
                'jpg',
                'jpe',
                'jpeg',
                'gif',
                'png',
            ],
        ],
    ],
];

in filemanager.php file.

There are much more server-side configuration options available. I believe you missed the PHP-connector guidelines. Please read it thoroughly.

@psolom
Copy link
Owner

psolom commented Nov 19, 2017

As to your initial complaint. Your configs looks quite default. I have to ask few additinal questions:

  1. Are you able to reproduce the issue at the demo-site?
  2. Clarification required regarding the 'Copy URL to Clipboard'. Do you mean the option that you can see in the context menu when you right-click with mouse on particular item? There is also a button when you preview a file.
  3. You mentioned that issue happens for "root folder". This concept is not very clear. Can you make a screenshot and highlight an element which cause a problem? That would be a great assistance.
  4. I still think this may be a JS problem. If you use Chrome browser open its console and check "Preserve log" option. This will allow you to observe JS errors that happen in RichFilemanager page (if any) before redirect happened.

@psolom
Copy link
Owner

psolom commented Nov 23, 2017

Any feedback?

@psolom
Copy link
Owner

psolom commented Nov 29, 2017

Closed, because of no feedback.

@psolom psolom closed this as completed Nov 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants