return $id . NL . $code;
}
+/** Get block size in bytes.
+ * @param $id identifier of the block
+ * @return block size in bytes
+ */
+function
+jirafeau_block_get_size ($id)
+{
+ $p = VAR_BLOCK . s2p ($id) . $id;
+ if (!file_exists ($p))
+ return "Error";
+
+ /* Check date. */
+ $f = file ($p . '_infos');
+ $date = trim ($f[0]);
+ $block_size = trim ($f[1]);
+ $stored_code = trim ($f[2]);
+ /* Update date. */
+ if (date ('U') - $date > JIRAFEAU_HOUR
+ && date ('U') - $date < JIRAFEAU_MONTH)
+ {
+ if (file_put_contents ($p . '_infos', date ('U') . NL . $block_size . NL . $stored_code) === FALSE)
+ {
+ jirafeau_block_delete_ ($id);
+ return "Error";
+ }
+ }
+ /* Remove data. */
+ elseif (date ('U') - $date >= JIRAFEAU_MONTH)
+ {
+ echo date ('U'). " $date ";
+ jirafeau_block_delete_ ($id);
+ return "Error";
+ }
+
+ return $block_size;
+}
+
/**
* Read some data in a block.
* @param $id identifier of the block
'This interface permits to create a block of data filled with zeros.' => 'Cette interface permet de creer un bloque de données remplies de zeros.',
'You can read selected parts, write (using a code) and delete the block.' => 'Vous pouvez lire, écrire (en utilisant un code) et supprimer le bloque.',
'Blocks may be removed after a month of non usage.' => 'Les bloques non utilisés depuis plus d\'un mois seront probablement supprimés.',
+ 'Get block size' => 'Récupérer la taille d\'un bloque',
'Read data in a block' => 'Lire des données dans un bloque',
'Write data in a block' => 'Ecrire des données dans un bloque',
'First line is a block id the second line the edit/delete code.' => 'La premiere ligne est l\'identifiant du bloque, la seconde est son code d\'écriture/suppression.',
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
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