X-Git-Url: https://git.p6c8.net/jirafeau.git/blobdiff_plain/145950308252425226bcc5b97993550fefac3c15..38069302c9544b4fcc1eb2492138dbcbe83d7bd7:/script.php?ds=sidebyside diff --git a/script.php b/script.php index 44fe449..bb44562 100644 --- a/script.php +++ b/script.php @@ -92,6 +92,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET" && count ($_GET) == 0) echo "time=[minute|hour|day|week|month|none] (" . t('Optional') . ', '. t('default: none') . ")
"; echo "password=your_password (" . t('Optional') . ")
"; echo "one_time_download=1 (" . t('Optional') . ")
"; + echo "upload_password=your_upload_password (" . t('Optional') . ")
"; echo '

'; echo '

' . t('This will return brut text content.') . ' ' . t('First line is the download reference and the second line the delete code.') . '

'; @@ -143,7 +144,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET" && count ($_GET) == 0) echo "$name: " . $web_root . "script.php?lang=$lang "; echo '

'; - echo '

' . t('Initalize a asynchronous transfert') . ':

'; + echo '

' . t('Initalize an asynchronous transfert') . ':

'; echo '

'; echo t('The goal is to permit to transfert big file, chunk by chunk.') . ' '; echo t('Chunks of data must be sent in order.'); @@ -157,6 +158,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET" && count ($_GET) == 0) echo "time=[minute|hour|day|week|month|none] (" . t('Optional') . ', '. t('default: none') . ")
"; echo "password=your_password (" . t('Optional') . ")
"; echo "one_time_download=1 (" . t('Optional') . ")
"; + echo "upload_password=your_upload_password (" . t('Optional') . ")
"; echo '

'; echo '

' . t('This will return brut text content.') . ' ' . t('First line is the asynchronous transfert reference and the second line the code to use in the next operation.') . '

'; @@ -184,66 +186,6 @@ if ($_SERVER['REQUEST_METHOD'] == "GET" && count ($_GET) == 0) echo '

' . t('This will return brut text content.') . ' ' . t('First line is the download reference and the second line the delete code.') . '

'; - if ($cfg['enable_blocks']) - { - echo '

' . t('Create a data block') . ':

'; - echo '

'; - echo t('This interface permits to create a block of data filled with zeros.') . - ' ' . t('You can read selected parts, write (using a code) and delete the block.') . - ' ' . t('Blocks may be removed after a month of non usage.'); - echo '

'; - echo '

'; - echo t('Send a GET query to') . ': ' . $web_root . 'script.php?init_block
'; - echo '
'; - echo t('Parameters') . ':
'; - echo "size=size_in_bytes (" . t('Required') . ")
"; - echo '

'; - echo '

' . t('This will return brut text content.') . ' ' . - t('First line is a block id the second line the edit/delete code.') . '

'; - - echo '

' . t('Get block size') . ':

'; - echo '

'; - echo t('Send a GET query to') . ': ' . $web_root . 'script.php?get_block_size
'; - echo '
'; - echo t('Parameters') . ':
'; - echo "id=block_id (" . t('Required') . ")
"; - echo '

'; - echo '

' . t('This will return asked data or "Error" string.') . '

'; - - echo '

' . t('Read data in a block') . ':

'; - echo '

'; - echo t('Send a GET query to') . ': ' . $web_root . 'script.php?read_block
'; - echo '
'; - echo t('Parameters') . ':
'; - echo "id=block_id (" . t('Required') . ")
"; - echo "start=byte_position_starting_from_zero (" . t('Required') . ")
"; - echo "length=length_to_read_in_bytes (" . t('Required') . ")
"; - echo '

'; - echo '

' . t('This will return asked data or "Error" string.') . '

'; - - echo '

' . t('Write data in a block') . ':

'; - echo '

'; - echo t('Send a GET query to') . ': ' . $web_root . 'script.php?write_block
'; - echo '
'; - echo t('Parameters') . ':
'; - echo "id=block_id (" . t('Required') . ")
"; - echo "code=block_code (" . t('Required') . ")
"; - echo "start=byte_position_starting_from_zero (" . t('Required') . ")
"; - echo "data=data_to_write (" . t('Required') . ")
"; - echo '

'; - echo '

' . t('This will return "Ok" or "Error" string.') . '

'; - - echo '

' . t('Delete a block') . ':

'; - echo '

'; - echo t('Send a GET query to') . ': ' . $web_root . 'script.php?delete_block
'; - echo '
'; - echo t('Parameters') . ':
'; - echo "id=block_id (" . t('Required') . ")
"; - echo "code=block_code (" . t('Required') . ")
"; - echo '

'; - echo '

' . t('This will return "Ok" or "Error" string.') . '

'; - } - echo '
'; require (JIRAFEAU_ROOT . 'lib/template/footer.php'); exit; @@ -263,7 +205,9 @@ if (has_error ()) if (isset ($_FILES['file']) && is_writable (VAR_FILES) && is_writable (VAR_LINKS)) { - if (strlen ($cfg['upload_password']) > 0 && (!isset ($_POST['upload_password']) || $_POST['upload_password'] != $cfg['upload_password'])) + if (jirafeau_has_upload_password ($cfg) && + (!isset ($_POST['upload_password']) || + !jirafeau_challenge_upload_password ($cfg, $_POST['upload_password']))) { echo "Error"; exit; @@ -529,7 +473,9 @@ fi /* Initialize an asynchronous upload. */ elseif (isset ($_GET['init_async'])) { - if (strlen ($cfg['upload_password']) > 0 && (!isset ($_POST['upload_password']) || $_POST['upload_password'] != $cfg['upload_password'])) + if (jirafeau_has_upload_password ($cfg) && + (!isset ($_POST['upload_password']) || + !jirafeau_challenge_upload_password ($cfg, $_POST['upload_password']))) { echo "Error"; exit; @@ -600,58 +546,6 @@ elseif (isset ($_GET['end_async'])) else echo jirafeau_async_end ($_POST['ref'], $_POST['code'], $cfg['enable_crypt'], $cfg['link_name_lenght']); } -/* Initialize block. */ -elseif (isset ($_GET['init_block']) && $cfg['enable_blocks']) -{ - if (strlen ($cfg['upload_password']) > 0 && (!isset ($_POST['upload_password']) || $_POST['upload_password'] != $cfg['upload_password'])) - { - echo "Error"; - exit; - } - - if (!isset ($_POST['size'])) - echo "Error"; - else - echo jirafeau_block_init ($_POST['size']); -} -/* Get block size. */ -elseif (isset ($_GET['get_block_size']) && $cfg['enable_blocks']) -{ - if (!isset ($_POST['id'])) - echo "Error"; - else - echo jirafeau_block_get_size ($_POST['id']); -} -/* Read data in block. */ -elseif (isset ($_GET['read_block']) && $cfg['enable_blocks']) -{ - if (!isset ($_POST['id']) - || !isset ($_POST['start']) - || !isset ($_POST['length'])) - echo "Error"; - else - jirafeau_block_read ($_POST['id'], $_POST['start'], $_POST['length']); -} -/* Write data in block. */ -elseif (isset ($_GET['write_block']) && $cfg['enable_blocks']) -{ - if (!isset ($_POST['id']) - || !isset ($_POST['start']) - || !isset ($_FILES['data']) - || !isset ($_POST['code'])) - echo "Error"; - else - echo jirafeau_block_write ($_POST['id'], $_POST['start'], $_FILES['data'], $_POST['code']); -} -/* Delete block. */ -elseif (isset ($_GET['delete_block']) && $cfg['enable_blocks']) -{ - if (!isset ($_POST['id']) - || !isset ($_POST['code'])) - echo "Error"; - else - echo jirafeau_block_delete ($_POST['id'], $_POST['code']); -} else echo "Error"; exit;