<h2>Scripting interface</h2>
<p>This interface permits to script your uploads and downloads.</p>
<p>See <a href="https://gitlab.com/mojo42/Jirafeau/blob/master/script.php">source code</a> of this interface to get available calls :)</p>
- <p>You may download a preconfigured <a href="<?php echo JIRAFEAU_ABSPREFIX . 'script.php?lang=bash'; ?>">Bash Script</a> to easily send to and get files from the API via command line.</p>
+ <p>You may download a preconfigured <a href="script.php?lang=bash">Bash Script</a> to easily send to and get files from the API via command line.</p>
</div>
<br />
<?php
/* Upload file */
if (isset($_FILES['file']) && is_writable(VAR_FILES)
&& is_writable(VAR_LINKS)) {
- if (!jirafeau_challenge_upload_ip($cfg, get_ip_address($cfg))) {
- echo 'Error 2';
- exit;
- }
-
- if (jirafeau_has_upload_password($cfg) &&
- (!isset($_POST['upload_password']) ||
- !jirafeau_challenge_upload_password($cfg, $_POST['upload_password']))) {
- echo 'Error 3';
- exit;
+ if (isset ($_POST['upload_password'])) {
+ if (!jirafeau_challenge_upload($cfg, get_ip_address($cfg), $_POST['upload_password'])) {
+ echo 'Error 3: Invalid password';
+ exit;
+ }
+ } else {
+ if (!jirafeau_challenge_upload($cfg, get_ip_address($cfg), null)) {
+ echo 'Error 2: No password nor allowed IP';
+ exit;
+ }
}
-
+
$key = '';
if (isset($_POST['key'])) {
$key = $_POST['key'];
}
/* Create alias. */
elseif (isset($_GET['alias_create'])) {
- $ip = get_ip_address($cfg);
- if (!jirafeau_challenge_upload_ip($cfg, $ip)) {
- echo 'Error 13';
- exit;
- }
-
- if (jirafeau_has_upload_password($cfg) &&
- (!isset($_POST['upload_password']) ||
- !jirafeau_challenge_upload_password($cfg, $_POST['upload_password']))) {
- echo 'Error 14';
- exit;
+ if (isset($_POST['upload_password'])){
+ if (!jirafeau_challenge_upload($cfg, get_ip_address($cfg), $_POST['upload_password'])) {
+ echo 'Error 14: Invalid password';
+ exit;
+ }
+ } else {
+ if (!jirafeau_challenge_upload($cfg, get_ip_address($cfg), null)) {
+ echo 'Error 13: No password nor allowed IP';
+ exit;
+ }
}
if (!isset($_POST['alias']) ||
}
/* Initialize an asynchronous upload. */
elseif (isset($_GET['init_async'])) {
- if (!jirafeau_challenge_upload_ip($cfg, get_ip_address($cfg))) {
- echo 'Error 19';
- exit;
- }
-
- if (jirafeau_has_upload_password($cfg) &&
- (!isset($_POST['upload_password']) ||
- !jirafeau_challenge_upload_password($cfg, $_POST['upload_password']))) {
- echo 'Error 20';
- exit;
+ if (isset($_POST['upload_password'])){
+ if (!jirafeau_challenge_upload($cfg, get_ip_address($cfg), $_POST['upload_password'])) {
+ echo 'Error 20: Invalid password';
+ exit;
+ }
+ } else {
+ if (!jirafeau_challenge_upload($cfg, get_ip_address($cfg), null)) {
+ echo 'Error 19: No password nor allowed IP';
+ exit;
+ }
}
if (!isset($_POST['filename'])) {