Skip to content

Commit

Permalink
Add referer and user agent setting for ftp
Browse files Browse the repository at this point in the history
  • Loading branch information
e-alfred committed Sep 17, 2017
1 parent 0b8d79e commit 50e4025
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
12 changes: 11 additions & 1 deletion controller/ftpdownloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ public function Add ()
$OPTIONS['ftp-user'] = $_POST['OPTIONS']['FTPUser'];
$OPTIONS['ftp-passwd'] = $_POST['OPTIONS']['FTPPasswd'];
}
if (isset ($_POST['OPTIONS']['FTPReferer']) && strlen (trim ($_POST['OPTIONS']['FTPReferer'])) > 0)
{
$OPTIONS['referer'] = $_POST['OPTIONS']['FTPReferer'];
}

if (isset ($_POST['OPTIONS']['FTPUseragent']) && strlen (trim ($_POST['OPTIONS']['FTPUseragent'])) > 0)
{
$OPTIONS['user-agent'] = $_POST['OPTIONS']['FTPUseragent'];
}

if (isset ($_POST['OPTIONS']['FTPPasv']) && strlen (trim ($_POST['OPTIONS']['FTPPasv'])) > 0)
{
$OPTIONS['ftp-pasv'] = strcmp ($_POST['OPTIONS']['FTPPasv'], "true") == 0 ? true : false;
Expand Down Expand Up @@ -205,4 +215,4 @@ public function Add ()
return new JSONResponse (Array ('ERROR' => true, 'MESSAGE' => (string)$this->L10N->t ('Please check the URL you\'ve just provided')));
}
}
}
}
6 changes: 5 additions & 1 deletion js/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ $(document).ready (function ()
{
FTPUser: $('#option-ftp-user').val (),
FTPPasswd: $('#option-ftp-pwd').val (),
FTPPasv: $('#option-ftp-pasv').prop ('checked')
FTPPasv: $('#option-ftp-pasv').prop ('checked'),
FTPReferer: $('#option-ftp-referer').val (),
FTPUseragent: $('#option-ftp-useragent').val ()
});
}
else
Expand All @@ -106,6 +108,8 @@ $(document).ready (function ()
$('#option-ftp-user').val ('');
$('#option-ftp-pwd').val ('');
$('#option-ftp-pasv').prop ('checked', true);
$('#option-ftp-referer').val ('');
$('#option-ftp-useragent').val ('');
});

// Launch YT download
Expand Down
2 changes: 1 addition & 1 deletion js/add.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions templates/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
<div class="group-option">
<label for="option-ftp-user"><?php print ($l->t ('FTP User')); ?> :</label><input type="text" id="option-ftp-user" placeholder="<?php print ($l->t ('Username')); ?>" />
<label for="option-ftp-pwd"><?php print ($l->t ('FTP Password')); ?> :</label><input type="password" id="option-ftp-pwd" placeholder="<?php print ($l->t ('Password')); ?>" />
<label for="option-ftp-referer"><?php print ($l->t ('Referer')); ?> :</label><input type="text" id="option-ftp-referer" placeholder="<?php print ($l->t ('Referer')); ?>" />
<label for="option-ftp-useragent"><?php print ($l->t ('User Agent')); ?> :</label><input type="text" id="option-ftp-useragent" placeholder="<?php print ($l->t ('Useragent')); ?>" />
</div>
<div class="group-option">
<label for="option-ftp-pasv"><?php print ($l->t ('Passive Mode')); ?> :</label><input type="checkbox" id="option-ftp-pasv" checked />
Expand Down

0 comments on commit 50e4025

Please sign in to comment.