Skip to content

Commit

Permalink
Support for importing public shares
Browse files Browse the repository at this point in the history
  • Loading branch information
deltafunction committed Dec 4, 2021
1 parent 552d767 commit b498077
Show file tree
Hide file tree
Showing 8 changed files with 237 additions and 102 deletions.
2 changes: 1 addition & 1 deletion appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
'id' => 'importer_index',
'order' => 30,
'href' => OCP\Util::linkTo('importer', 'importer.php'),
'//icon' => OCP\Util::imagePath('importer', 'importer.svg'),
'icon' => OCP\Util::imagePath('importer', 'importer.svg'),
'name' => $l->t('Import')
));

Expand Down
2 changes: 1 addition & 1 deletion css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ div.dlbtn button.ui-button-text-only .ui-button-text {
#importer div#dllist div.elts{margin:10px 0 10px 0;}
#folder_pop div.elts{margin:0 0 10px 0;}
#folder_pop{width:740px;height:34px;}
#importer div#dllist div.elts input.url{width:520px;margin:4px 0 0 5px;height:14px;}
#importer div#dllist div.elts input.url{width:/*520px*/58%;margin:4px 0 0 5px;height:14px;}
#folder_pop div.elts span.urlc input.url{width:360px;margin:4px 0 0 5px;height:14px;}
#folder_pop div.elts span.load button{margin:2px 2px 6px 2px;}
#save_pop div.elts span.urlc input.url{width:260px;margin:4px 10px 0 5px;height:14px;}
Expand Down
6 changes: 4 additions & 2 deletions importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@
// Get user importer settings
if(!in_array('curl', get_loaded_extensions())){
$tmpl->assign('curl_error', TRUE);
}else{
}
else{
$l = new OC_L10N('importer');

$tmpl->assign('user_prov_set', OC_importer::getProvidersList());
$tmpl->assign('user_history', OC_importer::getUserHistory($l));
$tmpl->assign('download_folder', OC_importer::getDownloadFolder());
$tmpl->assign('get_url', OC_importer::getGetUrl());
$tmpl->assign('post_urls', OC_importer::getPostUrls());
}

$tmpl->printPage();
18 changes: 15 additions & 3 deletions js/dls.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ function getProvider(el){
group = '';
}
// Do the actual download
var iframeUri = OC.linkTo('importer','providers/'+s.n+'.php?u='+u+'&p='+p+'&k='+(el.find('input.slider-check').attr("checked")?1:0)+
'&o=1'+'&d='+dlFolder+'&g='+group);
var iframeUri = OC.linkTo('importer','providers/'+s.n+'.php?u='+encodeURIComponent(u)+'&p='+p+'&k='+(el.find('input.slider-check').attr("checked")?1:0)+
'&o=1'+'&d='+encodeURIComponent(dlFolder)+'&g='+encodeURIComponent(group));
iframe.load(function(){
var n_str = el.attr('id').replace('elt_','');
var new_n = parseInt(n_str)+1;
Expand Down Expand Up @@ -730,14 +730,26 @@ $(document).ready(function(){
loadFolderUrl();
});

$("#geturl").attr("disabled", "disabled");
if(!$('#dllist .elts .url[val!=""]').length && !$('#postUrls').length){
$("#geturl").attr("disabled", "disabled");
}
$('.elts.new .urlc input.url').each(function(el){
$(this).on('input', function(){
if($("#geturl").attr("disabled")=="disabled"){
$("#geturl").removeAttr("disabled");
}
});
});

if($('#postUrls').length){
var postUrls = JSON.parse($('#postUrls').text());
// We're assuming the first provider is HTTP
addFirstDownload(postUrls.shift(), 'pr_1', true);
$.each(postUrls, function(i, url){
addDownload(true, url, 'pr_1', true);
});
$('.addelt:visible:not(:last)').remove();
}

var mydialog1;
var buttons1 = {};
Expand Down
17 changes: 16 additions & 1 deletion lib/importer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public static function getMasterPw(){
$masterPw = self::my_decrypt($encMasterPw, $sessionPwHash);
return $masterPw;
}

public static function decryptPw($enc_pw, $master_pw=false){
$masterPw = $master_pw?$master_pw:self::getMasterPw();
$hashedMasterPw = md5($masterPw);
Expand All @@ -419,4 +419,19 @@ public static function decryptPw($enc_pw, $master_pw=false){
return $ret;
}

public static function getGetUrl(){
if(empty($_GET['url'])){
return "";
}
return $_GET['url'];
}

public static function getPostUrls(){
if(empty($_POST['urls'])){
return [];
}
$urls = json_decode($_POST['urls']);
return $urls;
}

}
Loading

0 comments on commit b498077

Please sign in to comment.