\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
/* Operations may take a long time.\r
* Be sure PHP's safe mode is off.\r
*/\r
- set_time_limit(0);\r
+@set_time_limit(0);\r
+/* Remove errors. */\r
+@error_reporting(0);\r
\r
if ($_SERVER['REQUEST_METHOD'] == "GET" && count ($_GET) == 0)\r
{\r
require (JIRAFEAU_ROOT . 'lib/template/header.php');\r
- check_errors ();\r
+ check_errors ($cfg);\r
if (has_error ())\r
{\r
show_errors ();\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
/* Lets use interface now. */\r
header('Content-Type: text; charset=utf-8');\r
\r
+check_errors ($cfg);\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
+ if (jirafeau_has_upload_password ($cfg) &&\r
+ (!isset ($_POST['upload_password']) ||\r
+ !jirafeau_challenge_upload_password ($cfg, $_POST['upload_password'])))\r
+ {\r
+ echo "Error";\r
+ exit;\r
+ }\r
+\r
$key = '';\r
if (isset ($_POST['key']))\r
$key = $_POST['key'];\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
/* Initialize an asynchronous upload. */\r
elseif (isset ($_GET['init_async']))\r
{\r
+ if (jirafeau_has_upload_password ($cfg) &&\r
+ (!isset ($_POST['upload_password']) ||\r
+ !jirafeau_challenge_upload_password ($cfg, $_POST['upload_password'])))\r
+ {\r
+ echo "Error";\r
+ exit;\r
+ }\r
+\r
if (!isset ($_POST['filename']))\r
{\r
echo "Error";\r
$type = $_POST['type'];\r
\r
$key = '';\r
- if (isset ($_POST['password']))\r
- $key = $_POST['password'];\r
+ if (isset ($_POST['key']))\r
+ $key = $_POST['key'];\r
\r
$time = time ();\r
if (!isset ($_POST['time']))\r
|| !isset ($_POST['code']))\r
echo "Error";\r
else\r
- echo jirafeau_async_end ($_POST['ref'], $_POST['code']);\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 (jirafeau_has_upload_password ($cfg) &&\r
+ (!isset ($_POST['upload_password']) ||\r
+ !jirafeau_challenge_upload_password ($cfg, $_POST['upload_password'])))\r
+ {\r
+ echo "Error";\r
+ exit;\r
+ }\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