\r
define ('JIRAFEAU_ROOT', dirname (__FILE__) . '/');\r
\r
-require (JIRAFEAU_ROOT . 'lib/config.php');\r
+require (JIRAFEAU_ROOT . 'lib/config.original.php');\r
require (JIRAFEAU_ROOT . 'lib/settings.php');\r
require (JIRAFEAU_ROOT . 'lib/functions.php');\r
require (JIRAFEAU_ROOT . 'lib/lang.php');\r
\r
-if (file_exists (JIRAFEAU_ROOT . 'install.php'))\r
-{\r
- header('Content-Type: text; charset=utf-8');\r
- echo "Error";\r
- exit;\r
-}\r
-\r
global $script_langages;\r
$script_langages = array ('bash' => 'Bash');\r
\r
+/* Operations may take a long time.\r
+ * Be sure PHP's safe mode is off.\r
+ */\r
+ set_time_limit(0);\r
+\r
if ($_SERVER['REQUEST_METHOD'] == "GET" && count ($_GET) == 0)\r
{\r
require (JIRAFEAU_ROOT . 'lib/template/header.php');\r
+ check_errors ();\r
+ if (has_error ())\r
+ {\r
+ show_errors ();\r
+ require (JIRAFEAU_ROOT . 'lib/template/footer.php');\r
+ exit;\r
+ }\r
echo '<div class="info">';\r
echo '<h2>' . t('Welcome to Jirafeau\'s query interface') . '</h2>';\r
echo '<p>';\r
foreach ($script_langages as $lang => $name)\r
echo "$name: <a href=\"" . $web_root . "script.php?lang=$lang\">" . $web_root . "script.php?lang=$lang</a> ";\r
echo '</p>';\r
+ \r
+ echo '<h3>' . t('Initalize a asynchronous transfert') . ':</h3>';\r
+ echo '<p>';\r
+ echo t('The goal is to permit to transfert big file, chunk by chunk.') . ' ';\r
+ echo t('Chunks of data must be sent in order.');\r
+ echo '</p>';\r
+ echo '<p>';\r
+ echo t('Send a GET query to') . ': <i>' . $web_root . 'script.php?init_async</i><br />';\r
+ echo '<br />';\r
+ echo t('Parameters') . ':<br />';\r
+ echo "<b>filename=</b>file_name.ext<i> (" . t('Required') . ")</i> <br />";\r
+ echo "<b>type=</b>MIME_TYPE<i> (" . t('Optional') . ")</i> <br />";\r
+ echo "<b>time=</b>[minute|hour|day|week|month|none]<i> (" . t('Optional') . ', '. t('default: none') . ")</i> <br />";\r
+ echo "<b>password=</b>your_password<i> (" . t('Optional') . ")</i> <br />";\r
+ echo "<b>one_time_download=</b>1<i> (" . t('Optional') . ")</i> <br />";\r
+ echo '</p>';\r
+ echo '<p>' . t('This will return brut text content.') . ' ' .\r
+ t('First line is the asynchronous transfert reference and the second line the code to use in the next operation.') . '<br /></p>';\r
+\r
+ echo '<h3>' . t('Push data during asynchronous transfert') . ':</h3>';\r
+ echo '<p>';\r
+ echo t('Send a GET query to') . ': <i>' . $web_root . 'script.php?push_async</i><br />';\r
+ echo '<br />';\r
+ echo t('Parameters') . ':<br />';\r
+ echo "<b>ref=</b>async_reference<i> (" . t('Required') . ")</i> <br />";\r
+ echo "<b>data=</b>data_chunk<i> (" . t('Required') . ")</i> <br />";\r
+ echo "<b>code=</b>last_provided_code<i> (" . t('Required') . ")</i> <br />";\r
+ echo '</p>';\r
+ echo '<p>' . t('This will return brut text content.') . ' ' .\r
+ t('Returns the next code to use.') . '<br /></p>';\r
+\r
+ echo '<h3>' . t('Finalize asynchronous transfert') . ':</h3>';\r
+ echo '<p>';\r
+ echo t('Send a GET query to') . ': <i>' . $web_root . 'script.php?end_async</i><br />';\r
+ echo '<br />';\r
+ echo t('Parameters') . ':<br />';\r
+ echo "<b>ref=</b>async_reference<i> (" . t('Required') . ")</i> <br />";\r
+ echo "<b>code=</b>last_provided_code<i> (" . t('Required') . ")</i> <br />";\r
+ echo '</p>';\r
+ echo '<p>' . t('This will return brut text content.') . ' ' .\r
+ t('First line is the download reference and the second line the delete code.') . '<br /></p>';\r
+\r
+ if ($cfg['enable_blocks'])\r
+ {\r
+ echo '<h3>' . t('Create a data block') . ':</h3>';\r
+ echo '<p>';\r
+ echo t('This interface permits to create a block of data filled with zeros.') .\r
+ ' ' . t('You can read selected parts, write (using a code) and delete the block.') .\r
+ ' ' . t('Blocks may be removed after a month of non usage.');\r
+ echo '</p>';\r
+ echo '<p>';\r
+ echo t('Send a GET query to') . ': <i>' . $web_root . 'script.php?init_block</i><br />';\r
+ echo '<br />';\r
+ echo t('Parameters') . ':<br />';\r
+ echo "<b>size=</b>size_in_bytes<i> (" . t('Required') . ")</i> <br />";\r
+ echo '</p>';\r
+ echo '<p>' . t('This will return brut text content.') . ' ' .\r
+ t('First line is a block id the second line the edit/delete code.') . '<br /></p>';\r
+\r
+ echo '<h3>' . t('Get block size') . ':</h3>';\r
+ echo '<p>';\r
+ echo t('Send a GET query to') . ': <i>' . $web_root . 'script.php?get_block_size</i><br />';\r
+ echo '<br />';\r
+ echo t('Parameters') . ':<br />';\r
+ echo "<b>id=</b>block_id<i> (" . t('Required') . ")</i> <br />";\r
+ echo '</p>';\r
+ echo '<p>' . t('This will return asked data or "Error" string.') . '<br /></p>';\r
+\r
+ echo '<h3>' . t('Read data in a block') . ':</h3>';\r
+ echo '<p>';\r
+ echo t('Send a GET query to') . ': <i>' . $web_root . 'script.php?read_block</i><br />';\r
+ echo '<br />';\r
+ echo t('Parameters') . ':<br />';\r
+ echo "<b>id=</b>block_id<i> (" . t('Required') . ")</i> <br />";\r
+ echo "<b>start=</b>byte_position_starting_from_zero<i> (" . t('Required') . ")</i> <br />";\r
+ echo "<b>length=</b>length_to_read_in_bytes<i> (" . t('Required') . ")</i> <br />";\r
+ echo '</p>';\r
+ echo '<p>' . t('This will return asked data or "Error" string.') . '<br /></p>';\r
+\r
+ echo '<h3>' . t('Write data in a block') . ':</h3>';\r
+ echo '<p>';\r
+ echo t('Send a GET query to') . ': <i>' . $web_root . 'script.php?write_block</i><br />';\r
+ echo '<br />';\r
+ echo t('Parameters') . ':<br />';\r
+ echo "<b>id=</b>block_id<i> (" . t('Required') . ")</i> <br />";\r
+ echo "<b>code=</b>block_code<i> (" . t('Required') . ")</i> <br />";\r
+ echo "<b>start=</b>byte_position_starting_from_zero<i> (" . t('Required') . ")</i> <br />";\r
+ echo "<b>data=</b>data_to_write<i> (" . t('Required') . ")</i> <br />";\r
+ echo '</p>';\r
+ echo '<p>' . t('This will return "Ok" or "Error" string.') . '<br /></p>';\r
+\r
+ echo '<h3>' . t('Delete a block') . ':</h3>';\r
+ echo '<p>';\r
+ echo t('Send a GET query to') . ': <i>' . $web_root . 'script.php?delete_block</i><br />';\r
+ echo '<br />';\r
+ echo t('Parameters') . ':<br />';\r
+ echo "<b>id=</b>block_id<i> (" . t('Required') . ")</i> <br />";\r
+ echo "<b>code=</b>block_code<i> (" . t('Required') . ")</i> <br />";\r
+ echo '</p>';\r
+ echo '<p>' . t('This will return "Ok" or "Error" string.') . '<br /></p>';\r
+ }\r
\r
echo '</div><br />';\r
require (JIRAFEAU_ROOT . 'lib/template/footer.php');\r
/* Lets use interface now. */\r
header('Content-Type: text; charset=utf-8');\r
\r
+check_errors ();\r
+if (has_error ())\r
+{\r
+ echo "Error";\r
+ exit;\r
+}\r
+\r
/* Upload file */\r
if (isset ($_FILES['file']) && is_writable (VAR_FILES)\r
&& is_writable (VAR_LINKS))\r
}\r
$res = jirafeau_upload ($_FILES['file'],\r
isset ($_POST['one_time_download']),\r
- $key, $time, $_SERVER['REMOTE_ADDR']);\r
+ $key, $time, $_SERVER['REMOTE_ADDR'],\r
+ $cfg['enable_crypt'], $cfg['link_name_lenght']);\r
\r
if (empty($res) || $res['error']['has_error'])\r
{\r
}\r
/* Print direct link. */\r
echo $res['link'];\r
- echo NL;\r
/* Print delete link. */\r
+ echo NL;\r
echo $res['delete_link'];\r
+ /* Print decrypt key. */\r
+ echo NL;\r
+ echo urlencode($res['crypt_key']);\r
}\r
elseif (isset ($_GET['h']))\r
{\r
if (isset ($_GET['d']))\r
$d = $_GET['d'];\r
\r
- if (!preg_match ('/[0-9a-zA-Z_-]{22}$/', $link_name))\r
+ if (!preg_match ('/[0-9a-zA-Z_-]+$/', $link_name))\r
{\r
echo "Error";\r
exit;\r
exit;\r
}\r
\r
+ /* Read file. */\r
header ('Content-Length: ' . $link['file_size']);\r
header ('Content-Type: ' . $link['mime_type']);\r
header ('Content-Disposition: attachment; filename="' .\r
$link['file_name'] . '"');\r
- readfile (VAR_FILES . $p . $link['md5']);\r
+\r
+ $r = fopen (VAR_FILES . $p . $link['md5'], 'r');\r
+ while (!feof ($r))\r
+ {\r
+ print fread ($r, 1024);\r
+ ob_flush();\r
+ }\r
+ fclose ($r);\r
\r
if ($link['onetime'] == 'O')\r
jirafeau_delete_link ($link_name);\r
exit;\r
}\r
}\r
+/* Initialize an asynchronous upload. */\r
+elseif (isset ($_GET['init_async']))\r
+{\r
+ if (!isset ($_POST['filename']))\r
+ {\r
+ echo "Error";\r
+ exit;\r
+ }\r
+\r
+ $type = '';\r
+ if (isset ($_POST['type']))\r
+ $type = $_POST['type'];\r
+ \r
+ $key = '';\r
+ if (isset ($_POST['password']))\r
+ $key = $_POST['password'];\r
+\r
+ $time = time ();\r
+ if (!isset ($_POST['time']))\r
+ $time = JIRAFEAU_INFINITY;\r
+ else\r
+ switch ($_POST['time'])\r
+ {\r
+ case 'minute':\r
+ $time += JIRAFEAU_MINUTE;\r
+ break;\r
+ case 'hour':\r
+ $time += JIRAFEAU_HOUR;\r
+ break;\r
+ case 'day':\r
+ $time += JIRAFEAU_DAY;\r
+ break;\r
+ case 'week':\r
+ $time += JIRAFEAU_WEEK;\r
+ break;\r
+ case 'month':\r
+ $time += JIRAFEAU_MONTH;\r
+ break;\r
+ default:\r
+ $time = JIRAFEAU_INFINITY;\r
+ break;\r
+ }\r
+ echo jirafeau_async_init ($_POST['filename'],\r
+ $type,\r
+ isset ($_POST['one_time_download']),\r
+ $key,\r
+ $time,\r
+ $_SERVER['REMOTE_ADDR']);\r
+}\r
+/* Continue an asynchronous upload. */\r
+elseif (isset ($_GET['push_async']))\r
+{\r
+ if ((!isset ($_POST['ref']))\r
+ || (!isset ($_FILES['data']))\r
+ || (!isset ($_POST['code'])))\r
+ echo "Error";\r
+ else\r
+ echo jirafeau_async_push ($_POST['ref'], $_FILES['data'], $_POST['code']); \r
+}\r
+/* Finalize an asynchronous upload. */\r
+elseif (isset ($_GET['end_async']))\r
+{\r
+ if (!isset ($_POST['ref'])\r
+ || !isset ($_POST['code']))\r
+ echo "Error";\r
+ else\r
+ echo jirafeau_async_end ($_POST['ref'], $_POST['code'], $cfg['enable_crypt'], $cfg['link_name_lenght']);\r
+}\r
+/* Initialize block. */\r
+elseif (isset ($_GET['init_block']) && $cfg['enable_blocks'])\r
+{\r
+ if (!isset ($_POST['size']))\r
+ echo "Error";\r
+ else\r
+ echo jirafeau_block_init ($_POST['size']);\r
+}\r
+/* Get block size. */\r
+elseif (isset ($_GET['get_block_size']) && $cfg['enable_blocks'])\r
+{\r
+ if (!isset ($_POST['id']))\r
+ echo "Error";\r
+ else\r
+ echo jirafeau_block_get_size ($_POST['id']);\r
+}\r
+/* Read data in block. */\r
+elseif (isset ($_GET['read_block']) && $cfg['enable_blocks'])\r
+{\r
+ if (!isset ($_POST['id'])\r
+ || !isset ($_POST['start'])\r
+ || !isset ($_POST['length']))\r
+ echo "Error";\r
+ else\r
+ jirafeau_block_read ($_POST['id'], $_POST['start'], $_POST['length']);\r
+}\r
+/* Write data in block. */\r
+elseif (isset ($_GET['write_block']) && $cfg['enable_blocks'])\r
+{\r
+ if (!isset ($_POST['id'])\r
+ || !isset ($_POST['start'])\r
+ || !isset ($_FILES['data'])\r
+ || !isset ($_POST['code']))\r
+ echo "Error";\r
+ else\r
+ echo jirafeau_block_write ($_POST['id'], $_POST['start'], $_FILES['data'], $_POST['code']);\r
+}\r
+/* Delete block. */\r
+elseif (isset ($_GET['delete_block']) && $cfg['enable_blocks'])\r
+{\r
+ if (!isset ($_POST['id'])\r
+ || !isset ($_POST['code']))\r
+ echo "Error";\r
+ else\r
+ echo jirafeau_block_delete ($_POST['id'], $_POST['code']);\r
+}\r
else\r
echo "Error";\r
exit;\r
-?>
\ No newline at end of file
+?>\r