You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2016/03/11 08:00:33 UTC
[17/21] airavata-php-gateway git commit: fixing file download
fixing file download
Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/33829878
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/33829878
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/33829878
Branch: refs/heads/master
Commit: 338298789b34c2178acaa72c5058bfa51074e1d0
Parents: ce33ae9
Author: scnakandala <su...@gmail.com>
Authored: Tue Mar 8 14:12:52 2016 -0500
Committer: scnakandala <su...@gmail.com>
Committed: Tue Mar 8 14:12:52 2016 -0500
----------------------------------------------------------------------
app/controllers/FilemanagerController.php | 2 +-
app/libraries/ExperimentUtilities.php | 4 ++--
app/routes.php | 14 +++++++++-----
public/js/filemanager.js | 2 +-
4 files changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/33829878/app/controllers/FilemanagerController.php
----------------------------------------------------------------------
diff --git a/app/controllers/FilemanagerController.php b/app/controllers/FilemanagerController.php
index 45e8bd4..127358f 100644
--- a/app/controllers/FilemanagerController.php
+++ b/app/controllers/FilemanagerController.php
@@ -10,7 +10,7 @@ class FilemanagerController extends BaseController
}
public function browse(){
- //FIXME check for no ../ paths
+ //FIXME check for no ../ parts in the path
if(Input::has("path") && (0 == strpos(Input::get("path"), Session::get('username'))
|| 0 == strpos(Input::get("path"), "/" . Session::get('username')))){
$path = Input::get("path");
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/33829878/app/libraries/ExperimentUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ExperimentUtilities.php b/app/libraries/ExperimentUtilities.php
index 3a0952e..6b5016c 100644
--- a/app/libraries/ExperimentUtilities.php
+++ b/app/libraries/ExperimentUtilities.php
@@ -76,7 +76,7 @@ class ExperimentUtilities
if ($input->type == DataType::URI && empty($input->metaData)) {
$inputArray = explode('/', $input->value);
echo '<p><a target="_blank"
- href="' . URL::to("/") . '/download/' .
+ href="' . URL::to("/") . '/download?path=' .
$inputArray[ count($inputArray)-4] . "/" .
$inputArray[ count($inputArray)-3] . '/' .
$inputArray[ count($inputArray)-2] . '/' .
@@ -659,7 +659,7 @@ class ExperimentUtilities
$outputPathArray = explode("/", $output->value);
echo '<p>' . $output->name . ' : ' . '<a target="_blank"
- href="' . URL::to("/") . '/download/' .
+ href="' . URL::to("/") . '/download?path=' .
$outputPathArray[ count($outputPathArray)-5] . "/" .
$outputPathArray[ count($outputPathArray)-4] . "/" .
$outputPathArray[ count($outputPathArray)-3] . "/" .
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/33829878/app/routes.php
----------------------------------------------------------------------
diff --git a/app/routes.php b/app/routes.php
index 2e74b92..ac4c5a8 100644
--- a/app/routes.php
+++ b/app/routes.php
@@ -98,11 +98,15 @@ Route::get("experiment/browse", "ExperimentController@browseView");
Route::post("experiment/browse", "ExperimentController@browseView");
-Route::get("download/{username}/{proj_folder}/{exp_folder}/{exp_file}", function( $username, $proj_folder, $exp_folder, $exp_file){
- //FIXME check for no ../ paths
- if( $username == Session::get("username")){
- $downloadLink = Config::get('pga_config.airavata')['experiment-data-absolute-path'] . '/' . $username
- . '/' . $proj_folder . "/" . $exp_folder . '/' . $exp_file;
+Route::get("download", function(){
+ //FIXME check for no ../ parts in the path
+ if(Input::has("path") && (0 == strpos(Input::get("path"), Session::get('username'))
+ || 0 == strpos(Input::get("path"), "/" . Session::get('username')))){
+ $path = Input::get("path");
+ if(0 === strpos($path, '/')){
+ $path = substr($path, 1);
+ }
+ $downloadLink = Config::get('pga_config.airavata')['experiment-data-absolute-path'] . '/' . $path;
return Response::download( $downloadLink);
}
});
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/33829878/public/js/filemanager.js
----------------------------------------------------------------------
diff --git a/public/js/filemanager.js b/public/js/filemanager.js
index 35b99b0..7f241dc 100644
--- a/public/js/filemanager.js
+++ b/public/js/filemanager.js
@@ -97,7 +97,7 @@ function show_table(files){
name_link = '<a href="#" onclick=dir_click("' + f.link + '")> ' + f.name + "</a>";
} else {
icon_class = 'glyphicon glyphicon-save-file';
- name_link = '<a href="../download/' + f.link + '"> ' + f.name + '</a>';
+ name_link = '<a href="../download?path=' + f.link + '"> ' + f.name + '</a>';
}
html += '<tr>'