/* 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'])) {