Skip to content

Commit

Permalink
removed mincPath, data and imagePath from the ConfigSettings
Browse files Browse the repository at this point in the history
removed mincPath and imagePath from get_file.php

replaced all instances of imagePath and mincPath by dataDirBasepath in the code

missed one instance of mincPath

Melanie's feedback

reintegrated imagePath to have one path for apache and one for the LORIS-MRI server if ever the paths are different

forgot to add again the imagePath to the Config SQL default schema...
  • Loading branch information
cmadjar committed Feb 27, 2019
1 parent fa29b10 commit def9351
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 20 deletions.
6 changes: 1 addition & 5 deletions SQL/0000-00-03-ConfigTables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType,
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, Label, OrderNumber) VALUES ('paths', 'Specify directories where LORIS-related files are stored or created. Take care when editing these fields as changing them incorrectly can cause certain modules to lose functionality.', 1, 0, 'Paths', 2);
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'imagePath', 'Path to images for display in Imaging Browser (e.g. /data/$project/data/) ', 1, 0, 'text', ID, 'Images', 9 FROM ConfigSettings WHERE Name="paths";
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'base', 'The base filesystem path where LORIS is installed', 1, 0, 'text', ID, 'Base', 1 FROM ConfigSettings WHERE Name="paths";
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'data', 'Path to main imaging data directory (e.g. /data/$project/data/) ', 1, 0, 'text', ID, 'Imaging data', 5 FROM ConfigSettings WHERE Name="paths";
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'extLibs', 'Path to external libraries', 1, 0, 'text', ID, 'External libraries', 3 FROM ConfigSettings WHERE Name="paths";
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'mincPath', 'Path to MINC files (e.g. /data/$project/data/)', 1, 0, 'text', ID, 'MINC files', 8 FROM ConfigSettings WHERE Name="paths";
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'DownloadPath', 'Where files are downloaded', 1, 0, 'text', ID, 'Downloads', 4 FROM ConfigSettings WHERE Name="paths";
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'log', 'Path to logs (relative path starting from /var/www/$projectname)', 1, 0, 'text', ID, 'Logs', 2 FROM ConfigSettings WHERE Name="paths";
INSERT INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent, Label, OrderNumber) SELECT 'MRICodePath', 'Path to directory where Loris-MRI (git) code is installed', 1, 0, 'text', ID, 'LORIS-MRI code', 6 FROM ConfigSettings WHERE Name="paths";
Expand Down Expand Up @@ -187,9 +185,7 @@ INSERT INTO Config (ConfigID, Value) SELECT ID, "YMd" FROM ConfigSettings WHERE

INSERT INTO Config (ConfigID, Value) SELECT ID, "/data/%PROJECTNAME%/data/" FROM ConfigSettings WHERE Name="imagePath";
INSERT INTO Config (ConfigID, Value) SELECT ID, "%LORISROOT%" FROM ConfigSettings WHERE Name="base";
INSERT INTO Config (ConfigID, Value) SELECT ID, "/data/%PROJECTNAME%/data/" FROM ConfigSettings WHERE Name="data";
INSERT INTO Config (ConfigID, Value) SELECT ID, "/PATH/TO/EXTERNAL/LIBRARY/" FROM ConfigSettings WHERE Name="extLibs";
INSERT INTO Config (ConfigID, Value) SELECT ID, "/data/%PROJECTNAME%/data/" FROM ConfigSettings WHERE Name="mincPath";
INSERT INTO Config (ConfigID, Value) SELECT ID, "%LORISROOT%" FROM ConfigSettings WHERE Name="DownloadPath";
INSERT INTO Config (ConfigID, Value) SELECT ID, "tools/logs/" FROM ConfigSettings WHERE Name="log";
INSERT INTO Config (ConfigID, Value) SELECT ID, "/data/%PROJECTNAME%/bin/mri/" FROM ConfigSettings WHERE Name="MRICodePath";
Expand Down Expand Up @@ -230,7 +226,7 @@ INSERT INTO Config (ConfigID, Value) SELECT ID, "Produced by LorisDB" FROM Confi
INSERT INTO Config (ConfigID, Value) SELECT ID, "S3cret" FROM ConfigSettings WHERE Name="JWTKey";


INSERT INTO Config (ConfigID, Value) SELECT ID, "/PATH/TO/DATA/location" FROM ConfigSettings cs WHERE cs.Name="Loris-MRI Data Directory";
INSERT INTO Config (ConfigID, Value) SELECT ID, "/data/%PROJECTNAME%/data/" FROM ConfigSettings cs WHERE cs.Name="dataDirBasepath";
INSERT INTO Config (ConfigID, Value) SELECT ID, "project" FROM ConfigSettings cs WHERE cs.Name="prefix";
INSERT INTO Config (ConfigID, Value) SELECT ID, "yourname\@example.com" FROM ConfigSettings cs WHERE cs.Name="mail_user";
INSERT INTO Config (ConfigID, Value) SELECT ID, "/PATH/TO/get_dicom_info.pl" FROM ConfigSettings cs WHERE cs.Name="get_dicom_info";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Remove entries for mincPath and data from the Config table
DELETE
FROM Config
WHERE ConfigID IN (
SELECT ID
FROM ConfigSettings
WHERE Name IN ('mincPath', 'data')
);

-- Remove entries for mincPath and data from the ConfigSettings table
DELETE
FROM ConfigSettings
WHERE Name IN ('mincPath', 'data');
2 changes: 1 addition & 1 deletion htdocs/api/v0.0.2/candidates/visits/images/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ protected function getAssemblyRoot()
{
$factory = \NDB_Factory::singleton();
$config = $factory->Config();
return $config->getSetting("mincPath");
return $config->getSetting("imagePath");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion htdocs/api/v0.0.3-dev/candidates/visits/images/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ protected function getAssemblyRoot()
{
$factory = \NDB_Factory::singleton();
$config = $factory->Config();
return $config->getSetting("mincPath");
return $config->getSetting("imagePath");
}

/**
Expand Down
19 changes: 8 additions & 11 deletions htdocs/mri/jiv/get_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@

$imagePath = $paths['imagePath'];
$DownloadPath = $paths['DownloadPath'];
$mincPath = $paths['mincPath'];
$tarchivePath = $pipeline['tarchiveLibraryDir'];
// Basic config validation
if (!validConfigPaths(
array(
$imagePath,
$DownloadPath,
$mincPath,
$tarchivePath,
)
)) {
Expand Down Expand Up @@ -90,17 +88,17 @@
$DownloadFilename = '';
switch($FileExt) {
case 'mnc':
$FullPath = $mincPath . '/' . $File;
$FullPath = $imagePath . '/' . $File;
$MimeType = "application/x-minc";
$DownloadFilename = basename($File);
break;
case 'nii':
$FullPath = $mincPath . '/' . $File;
$FullPath = $imagePath . '/' . $File;
$MimeType = "application/x-nifti";
$DownloadFilename = basename($File);
break;
case 'nii.gz':
$FullPath = $mincPath . '/' . $File;
$FullPath = $imagePath . '/' . $File;
$MimeType = "application/x-nifti-gz";
$DownloadFilename = basename($File);
break;
Expand Down Expand Up @@ -190,17 +188,16 @@ function validConfigPaths(array $paths): bool
foreach ($paths as $p) {
if (empty($p)) {
throw new \LorisException(
'Config paths are not initialized. Please ensure that valid ' .
'paths are set for imagePath, downloadPath, mincPath and ' .
'tarchiveLibraryDir'
'Config paths are not initialized. Please ensure that valid paths ' .
'are set for imagePath, downloadPath and tarchiveLibraryDir'
);
return false;
}
if ($p === '/') {
throw new \LorisException(
'Config path invalid. Paths cannot be set to root, i.e., `/`' .
' Please verify your path settings for imagePath, ' .
'downloadPath, mincPath and tarchiveLibraryDir.'
'downloadPath and tarchiveLibraryDir.'
);
return false;
}
Expand All @@ -226,8 +223,8 @@ function validDownloadPath($path): bool
}
// Make sure that the user isn't trying to break out of the $path by
// using a relative filename.
// No need to check for '/' since all downloads are relative to $imagePath,
// $DownloadPath or $mincPath
// No need to check for '/' since all downloads are relative to $imagePath or
// $DownloadPath
if (strpos($path, "..") !== false) {
error_log(
'ERROR: Invalid filename. Contains path traversal characters'
Expand Down
2 changes: 1 addition & 1 deletion modules/brainbrowser/ajax/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function getFileLocation()
{
$config = & NDB_Config::singleton();
$paths = $config->getSetting('paths');
$image_path = $paths['mincPath'];
$image_path = $paths['imagePath'];
return $image_path;
}

Expand Down
1 change: 0 additions & 1 deletion php/installer/Installer.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ class Installer

$this->_updateConfig($DB, "imagePath", $datadir);
$this->_updateConfig($DB, "data", $datadir);
$this->_updateConfig($DB, "mincPath", $datadir);
$this->_updateConfig($DB, "MRICodePath", $datadir);

// Update the host based and URL based on the location that
Expand Down

0 comments on commit def9351

Please sign in to comment.