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

Filemanager fix related to session locked issue #55

Open
wants to merge 1 commit into
base: mautic-2-16-2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,18 @@ public function __construct($extraConfig = '')
// else it takes $_SERVER['DOCUMENT_ROOT'] default value
if ($this->config['options']['fileRoot'] !== false) {
if ($this->config['options']['serverRoot'] === true) {
$this->doc_root = $_SERVER['DOCUMENT_ROOT'];
// modif DDC pour coller a la config des server wmk
$this->doc_root = substr(__DIR__, 0, strpos(__DIR__, '/app/'));
$this->separator = basename($this->config['options']['fileRoot']);
$this->path_to_files = $_SERVER['DOCUMENT_ROOT'].'/'.$this->config['options']['fileRoot'];
$this->path_to_files = substr(__DIR__, 0, strpos(__DIR__, '/app/')).'/'.$this->config['options']['fileRoot'];
} else {
$this->doc_root = $this->config['options']['fileRoot'];
$this->separator = basename($this->config['options']['fileRoot']);
$this->path_to_files = $this->config['options']['fileRoot'];
}
} else {
$this->doc_root = $_SERVER['DOCUMENT_ROOT'];
// modif DDC pour coller a la config des server wmk
$this->doc_root = substr(__DIR__, 0, strpos(__DIR__, '/app/'));
$this->path_to_files = $this->root.$this->separator.'/';
}

Expand All @@ -112,9 +114,8 @@ public function setup($extraconfig)
// allow Filemanager to be used with dynamic folders
public function setFileRoot($path, $documentRoot = null)
{
if ($documentRoot == null) {
$documentRoot = $_SERVER['DOCUMENT_ROOT'];
}
// modif pour coller au server wmk
$documentRoot = substr(__DIR__, 0, strpos(__DIR__, '/app/'));

// Paths are bit complex to handle - kind of nightmare actually ....
// 3 parts are availables
Expand Down Expand Up @@ -971,7 +972,7 @@ public function preview($thumbnail)
header('Content-Transfer-Encoding: Binary');
header('Content-length: '.filesize($returned_path));
header('Content-Disposition: inline; filename="'.basename($returned_path).'"');

usleep(rand(500000, 1000000));
readfile($returned_path);

exit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@
$container->get('event_dispatcher')->dispatch(KernelEvents::REQUEST, $event);

$session = $container->get('session');
$userDir = $session->get('mautic.imagepath', false);
$baseDir = $session->get('mautic.basepath', false);
$docRoot = $session->get('mautic.docroot', false);

$securityToken = $container->get('security.token_storage');
$token = $securityToken->getToken();
session_abort();
$authenticated = ($token instanceof TokenInterface) ? count($token->getRoles()) : false;
} catch (\Exception $exception) {
error_log($exception);
Expand Down Expand Up @@ -81,10 +86,6 @@ function auth()
$fm = new Filemanager();

if ($authenticated) {
$userDir = $session->get('mautic.imagepath', false);
$baseDir = $session->get('mautic.basepath', false);
$docRoot = $session->get('mautic.docroot', false);

if (substr($userDir, -1) !== '/') {
$userDir .= '/';
}
Expand Down