[enh] update jirafeau version to 71f70e201e53baf6936fad1dc00b87c2c50e8c3d
30
sources/NEWCOMER.txt
Normal file
|
@ -0,0 +1,30 @@
|
|||
Hi,
|
||||
|
||||
This document is only made for newcomers in Jirafeau who are digging into
|
||||
the code.
|
||||
|
||||
Here is a little explaination of Jirafeau's arboresence in a simplified
|
||||
view only to show the most importants files and their role.
|
||||
|
||||
.
|
||||
├── admin.php : adminitration interface, also permits to download files
|
||||
├── f.php : permits to download files or show the download page
|
||||
├── index.php : only provide a html/javascript client to interact with API
|
||||
├── script.php : API interface and it's html documentation
|
||||
├── install.php : installation script
|
||||
├── tos.php : terms of use the user may edit
|
||||
├── lib
|
||||
│ ├── config.local.php : user's parameters
|
||||
│ ├── config.original.php : default parameters with their documentation
|
||||
│ ├── functions_*.js : javascript functions for html/javascript client
|
||||
│ ├── functions.php : core functions and tools of jirafeau
|
||||
│ ├── lang : langage folder, contain all langage files
|
||||
│ └── template
|
||||
│ ├── footer.php
|
||||
│ └── header.php
|
||||
├── media : folder containing all skins
|
||||
└── var-xxxxxxx : folder containing all data
|
||||
├── async : chunks of uploaded files
|
||||
├── files : all files that has been successfully uploaded
|
||||
└── links : all links pointing to files with meta-informations
|
||||
|
12
sources/README.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
Any project would be sad without it's README file :)
|
||||
|
||||
Jirafeau is a web site permitting to upload a file in a simple way and give
|
||||
an unique link to it.
|
||||
|
||||
Jirafeau is an Open-Source project under AGPL v3 license (see COPYING file)
|
||||
|
||||
To install Jirafeau project, just open your browser and go to /install.php
|
||||
|
||||
For more informations on Jirafeau project, go to it's web page:
|
||||
|
||||
https://gitlab.com/mojo42/Jirafeau/wikis/home
|
95
sources/admin.php
Executable file → Normal file
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Jirafeau, your web file repository
|
||||
* Copyright (C) 2012 Jerome Jutteau <j.jutteau@gmail.com>
|
||||
* Copyright (C) 2015 Jerome Jutteau <j.jutteau@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
|
@ -32,26 +32,8 @@ if (file_exists (JIRAFEAU_ROOT . 'install.php')
|
|||
exit;
|
||||
}
|
||||
|
||||
/* Check if the install.php script is still in the directory. */
|
||||
if (file_exists (JIRAFEAU_ROOT . 'install.php'))
|
||||
{
|
||||
require (JIRAFEAU_ROOT . 'lib/template/header.php');
|
||||
echo '<div class="error"><p>'.
|
||||
t('Installer script still present') .
|
||||
'</p></div>';
|
||||
require (JIRAFEAU_ROOT.'lib/template/footer.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$cfg['admin_user'] || $_SERVER['PHP_AUTH_USER'] != $cfg['admin_user'])
|
||||
{
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
/* Disable admin interface if we have a empty admin password. */
|
||||
/*
|
||||
if (!$cfg['admin_password'])
|
||||
if (empty($cfg['admin_password']) && empty($cfg['admin_http_auth_user']))
|
||||
{
|
||||
require (JIRAFEAU_ROOT . 'lib/template/header.php');
|
||||
echo '<div class="error"><p>'.
|
||||
|
@ -60,22 +42,16 @@ if (!$cfg['admin_password'])
|
|||
require (JIRAFEAU_ROOT.'lib/template/footer.php');
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
|
||||
/* Check session. */
|
||||
/*
|
||||
session_start();
|
||||
*/
|
||||
|
||||
/* Unlog if asked. */
|
||||
/*
|
||||
if (isset ($_POST['action']) && (strcmp ($_POST['action'], 'logout') == 0))
|
||||
$_SESSION['admin_auth'] = false;
|
||||
*/
|
||||
|
||||
/* Check password. */
|
||||
/*
|
||||
if (isset ($_POST['admin_password']))
|
||||
/* Check classic admin password authentification. */
|
||||
if (isset ($_POST['admin_password']) && empty($cfg['admin_http_auth_user']))
|
||||
{
|
||||
if (strcmp ($cfg['admin_password'], $_POST['admin_password']) == 0)
|
||||
$_SESSION['admin_auth'] = true;
|
||||
|
@ -89,11 +65,9 @@ if (isset ($_POST['admin_password']))
|
|||
exit;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/* Ask for password. */
|
||||
/*
|
||||
elseif (!isset ($_SESSION['admin_auth']) || $_SESSION['admin_auth'] != true)
|
||||
/* Ask for classic admin password authentification. */
|
||||
elseif ((!isset ($_SESSION['admin_auth']) || $_SESSION['admin_auth'] != true)
|
||||
&& empty($cfg['admin_http_auth_user']))
|
||||
{
|
||||
require (JIRAFEAU_ROOT . 'lib/template/header.php'); ?>
|
||||
<form action = "<?php echo basename(__FILE__); ?>" method = "post">
|
||||
|
@ -122,7 +96,25 @@ elseif (!isset ($_SESSION['admin_auth']) || $_SESSION['admin_auth'] != true)
|
|||
require (JIRAFEAU_ROOT.'lib/template/footer.php');
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
/* Check authenticated user if HTTP authentification is enable. */
|
||||
elseif ((!isset ($_SESSION['admin_auth']) || $_SESSION['admin_auth'] != true)
|
||||
&& !empty($cfg['admin_http_auth_user']))
|
||||
{
|
||||
if ($cfg['admin_http_auth_user'] == $_SERVER['PHP_AUTH_USER'])
|
||||
$_SESSION['admin_auth'] = true;
|
||||
}
|
||||
|
||||
/* Be sure that no one can access further without admin_auth. */
|
||||
if (!isset ($_SESSION['admin_auth']) || $_SESSION['admin_auth'] != true)
|
||||
{
|
||||
$_SESSION['admin_auth'] = false;
|
||||
require (JIRAFEAU_ROOT . 'lib/template/header.php');
|
||||
echo '<div class="error"><p>'.
|
||||
t('Sorry, you are not authenticated on admin interface.') .
|
||||
'</p></div>';
|
||||
require (JIRAFEAU_ROOT.'lib/template/footer.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
/* Operations may take a long time.
|
||||
* Be sure PHP's safe mode is off.
|
||||
|
@ -131,12 +123,12 @@ elseif (!isset ($_SESSION['admin_auth']) || $_SESSION['admin_auth'] != true)
|
|||
/* Remove errors. */
|
||||
@error_reporting(0);
|
||||
|
||||
/* Admin interface. */
|
||||
/* Show admin interface if not downloading a file. */
|
||||
if (!(isset ($_POST['action']) && strcmp ($_POST['action'], 'download') == 0))
|
||||
{
|
||||
require (JIRAFEAU_ROOT . 'lib/template/header.php');
|
||||
?><h2><?php echo t('Admin interface'); ?></h2><?php
|
||||
|
||||
/* Show admin interface. */
|
||||
{
|
||||
?><div id = "install">
|
||||
<fieldset><legend><?php echo t('Actions');?></legend>
|
||||
<table>
|
||||
|
@ -164,26 +156,6 @@ require (JIRAFEAU_ROOT . 'lib/template/header.php');
|
|||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
<?php
|
||||
if ($cfg['enable_blocks'])
|
||||
{
|
||||
?>
|
||||
<form action = "<?php echo basename(__FILE__); ?>" method = "post">
|
||||
<tr>
|
||||
<input type = "hidden" name = "action" value = "clean_block"/>
|
||||
<td class = "info">
|
||||
<?php echo t('Clean unused blocks'); ?>
|
||||
</td>
|
||||
<td></td>
|
||||
<td>
|
||||
<input type = "submit" value = "<?php echo t('Clean'); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<form action = "<?php echo basename(__FILE__); ?>" method = "post">
|
||||
<tr>
|
||||
<input type = "hidden" name = "action" value = "list"/>
|
||||
|
@ -265,14 +237,6 @@ if (isset ($_POST['action']))
|
|||
echo t('Number of cleaned files') . ' : ' . $total;
|
||||
echo '</p></div>';
|
||||
}
|
||||
elseif (strcmp ($_POST['action'], 'clean_block') == 0)
|
||||
{
|
||||
$total = jirafeau_admin_clean_block ();
|
||||
echo '<div class="message">' . NL;
|
||||
echo '<p>';
|
||||
echo t('Number of cleaned files') . ' : ' . $total;
|
||||
echo '</p></div>';
|
||||
}
|
||||
elseif (strcmp ($_POST['action'], 'list') == 0)
|
||||
{
|
||||
jirafeau_admin_list ("", "", "");
|
||||
|
@ -313,6 +277,7 @@ if (isset ($_POST['action']))
|
|||
$l['file_name'] . '"');
|
||||
if (file_exists(VAR_FILES . $p . $l['md5']))
|
||||
readfile (VAR_FILES . $p . $l['md5']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/*
|
||||
* Jirafeau, your web file repository
|
||||
* Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
|
||||
* Copyright (C) 2012 Jerome Jutteau <j.jutteau@gmail.com>
|
||||
* Copyright (C) 2015 Jerome Jutteau <j.jutteau@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
|
@ -58,20 +58,20 @@ if (count ($link) == 0)
|
|||
}
|
||||
|
||||
$delete_code = '';
|
||||
if (isset ($_GET['d']) && !empty ($_GET['d']))
|
||||
if (isset ($_GET['d']) && !empty ($_GET['d']) && $_GET['d'] != '1')
|
||||
$delete_code = $_GET['d'];
|
||||
|
||||
$crypt_key = '';
|
||||
if (isset ($_GET['k']) && !empty ($_GET['k']))
|
||||
$crypt_key = $_GET['k'];
|
||||
|
||||
$button_download = false;
|
||||
if (isset ($_GET['bd']) && !empty ($_GET['bd']))
|
||||
$button_download = true;
|
||||
$do_download = false;
|
||||
if (isset ($_GET['d']) && $_GET['d'] == '1')
|
||||
$do_download = true;
|
||||
|
||||
$button_preview = false;
|
||||
if (isset ($_GET['bp']) && !empty ($_GET['bp']))
|
||||
$button_preview = true;
|
||||
$do_preview = false;
|
||||
if (isset ($_GET['p']) && !empty ($_GET['p']))
|
||||
$do_preview = true;
|
||||
|
||||
$p = s2p ($link['md5']);
|
||||
if (!file_exists (VAR_FILES . $p . $link['md5']))
|
||||
|
@ -140,17 +140,17 @@ if (!empty ($link['key']))
|
|||
?><input type="submit" id = "submit_download" value="<?php echo t('Download'); ?>"
|
||||
onclick="document.getElementById('submit').action='
|
||||
<?php
|
||||
echo $cfg['web_root'] . '/f.php?h=' . $link_name . '&bd=1';
|
||||
echo $cfg['web_root'] . '/f.php?h=' . $link_name . '&d=1';
|
||||
if (!empty($crypt_key))
|
||||
echo '&k=' . urlencode($crypt_key);
|
||||
?>';
|
||||
document.getElementById('submit_download').submit ();"/><?php
|
||||
if ($cfg['download_page'] && $cfg['preview'])
|
||||
if ($cfg['download_page'] && $cfg['preview'] && jirafeau_is_viewable($link['mime_type']))
|
||||
{
|
||||
?><input type="submit" id = "submit_preview" value="<?php echo t('Preview'); ?>"
|
||||
onclick="document.getElementById('submit').action='
|
||||
<?php
|
||||
echo $cfg['web_root'] . '/f.php?h=' . $link_name . '&bp=1';
|
||||
echo $cfg['web_root'] . '/f.php?h=' . $link_name . '&p=1';
|
||||
if (!empty($crypt_key))
|
||||
echo '&k=' . urlencode($crypt_key);
|
||||
?>';
|
||||
|
@ -176,7 +176,7 @@ if (!empty ($link['key']))
|
|||
}
|
||||
}
|
||||
|
||||
if ($cfg['download_page'] && !$password_challenged && !$button_download && !$button_preview)
|
||||
if ($cfg['download_page'] && !$password_challenged && !$do_download && !$do_preview)
|
||||
{
|
||||
require (JIRAFEAU_ROOT.'lib/template/header.php');
|
||||
echo '<div>' .
|
||||
|
@ -194,18 +194,18 @@ if ($cfg['download_page'] && !$password_challenged && !$button_download && !$but
|
|||
?></td></tr><tr><td><input type="submit" id = "submit_download" value="<?php echo t('Download'); ?>"
|
||||
onclick="document.getElementById('submit').action='
|
||||
<?php
|
||||
echo $cfg['web_root'] . '/f.php?h=' . $link_name . '&bd=1';
|
||||
echo $cfg['web_root'] . '/f.php?h=' . $link_name . '&d=1';
|
||||
if (!empty($crypt_key))
|
||||
echo '&k=' . urlencode($crypt_key);
|
||||
?>';
|
||||
document.getElementById('submit_download').submit ();"/><?php
|
||||
|
||||
if ($cfg['download_page'] && $cfg['preview'])
|
||||
if ($cfg['download_page'] && $cfg['preview'] && jirafeau_is_viewable($link['mime_type']))
|
||||
{
|
||||
?><input type="submit" id = "submit_preview" value="<?php echo t('Preview'); ?>"
|
||||
onclick="document.getElementById('submit').action='
|
||||
<?php
|
||||
echo $cfg['web_root'] . '/f.php?h=' . $link_name . '&bp=1';
|
||||
echo $cfg['web_root'] . '/f.php?h=' . $link_name . '&p=1';
|
||||
if (!empty($crypt_key))
|
||||
echo '&k=' . urlencode($crypt_key);
|
||||
?>';
|
||||
|
@ -219,10 +219,9 @@ if ($cfg['download_page'] && !$password_challenged && !$button_download && !$but
|
|||
|
||||
header ('HTTP/1.0 200 OK');
|
||||
header ('Content-Length: ' . $link['file_size']);
|
||||
if (!jirafeau_is_viewable ($link['mime_type']) || !$cfg['preview'] || $button_download)
|
||||
if (!jirafeau_is_viewable ($link['mime_type']) || !$cfg['preview'] || $do_download)
|
||||
header ('Content-Disposition: attachment; filename="' .
|
||||
$link['file_name'] . '"');
|
||||
else
|
||||
header ('Content-Type: ' . $link['mime_type']);
|
||||
|
||||
/* Read encrypted file. */
|
||||
|
|
115
sources/index.php
Executable file → Normal file
|
@ -26,7 +26,7 @@ require (JIRAFEAU_ROOT . 'lib/functions.php');
|
|||
require (JIRAFEAU_ROOT . 'lib/lang.php');
|
||||
require (JIRAFEAU_ROOT . 'lib/template/header.php');
|
||||
|
||||
check_errors ();
|
||||
check_errors ($cfg);
|
||||
if (has_error ())
|
||||
{
|
||||
show_errors ();
|
||||
|
@ -35,19 +35,22 @@ if (has_error ())
|
|||
}
|
||||
|
||||
/* Ask password if upload password is set. */
|
||||
if (strlen ($cfg['upload_password']) > 0)
|
||||
if (jirafeau_has_upload_password ($cfg))
|
||||
{
|
||||
session_start();
|
||||
|
||||
/* Unlog if asked. */
|
||||
if (isset ($_POST['action']) && (strcmp ($_POST['action'], 'logout') == 0))
|
||||
$_SESSION['upload_auth'] = false;
|
||||
session_unset ();
|
||||
|
||||
/* Auth. */
|
||||
if (isset ($_POST['upload_password']))
|
||||
{
|
||||
if (strcmp ($cfg['upload_password'], $_POST['upload_password']) == 0)
|
||||
if (jirafeau_challenge_upload_password ($cfg, $_POST['upload_password']))
|
||||
{
|
||||
$_SESSION['upload_auth'] = true;
|
||||
$_SESSION['user_upload_password'] = $_POST['upload_password'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION['admin_auth'] = false;
|
||||
|
@ -91,18 +94,40 @@ if (strlen ($cfg['upload_password']) > 0)
|
|||
|
||||
?>
|
||||
<div id="upload_finished">
|
||||
<p>
|
||||
<?php echo t('File uploaded! Copy the following URL to get it') ?>:
|
||||
<p><?php echo t('File uploaded !') ?></p>
|
||||
<br />
|
||||
<a id="upload_link" href=""></a>
|
||||
<br />
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<?php echo t('Keep the following URL to delete it at any moment'); ?>:
|
||||
<?php if ($cfg['download_page'] == true) { ?>
|
||||
<div id="upload_finished_download_page">
|
||||
<?php echo t('Download page') ?>
|
||||
<p><a id="upload_link" href=""></a></p>
|
||||
<br />
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div id="upload_password_page">
|
||||
<p><?php echo t('Download page') ?>:</p>
|
||||
<p><a id="password_link" href=""></a></p>
|
||||
<br />
|
||||
</div>
|
||||
|
||||
<?php if ($cfg['preview'] == true) { ?>
|
||||
<div id="upload_finished_preview">
|
||||
<p><?php echo t('View link') ?>:</p>
|
||||
<p><a id="preview_link" href=""></a></p>
|
||||
<br />
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div id="upload_direct_download">
|
||||
<p><?php echo t('Direct download link') ?>:</p>
|
||||
<p><a id="direct_link" href=""></a></p>
|
||||
<br />
|
||||
</div>
|
||||
|
||||
<p><?php echo t('Delete link') ?>:</p>
|
||||
<p><a id="delete_link" href=""></a></p>
|
||||
<br />
|
||||
<a id="delete_link" href=""></a>
|
||||
</p>
|
||||
|
||||
<p id="validity">
|
||||
<?php echo t('This file is valid until the following date'); ?>:
|
||||
|
@ -112,10 +137,16 @@ if (strlen ($cfg['upload_password']) > 0)
|
|||
|
||||
<div id="uploading">
|
||||
<p>
|
||||
<?php echo t ('Uploading ...'); ?><div id="uploaded_percentage"></div>
|
||||
<?php echo t ('Uploading ...'); ?>
|
||||
<div id="uploaded_percentage"></div>
|
||||
<div id="uploaded_speed"></div>
|
||||
<div id="uploaded_time"></div>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="error_pop" class="error">
|
||||
</div>
|
||||
|
||||
<div id="upload">
|
||||
<fieldset>
|
||||
<legend>
|
||||
|
@ -123,10 +154,7 @@ if (strlen ($cfg['upload_password']) > 0)
|
|||
</legend>
|
||||
<p>
|
||||
<input type="file" id="file_select" size="30"
|
||||
onchange="
|
||||
document.getElementById('options').style.display = '';
|
||||
document.getElementById('send').style.display = '';
|
||||
"/>
|
||||
onchange="control_selected_file_size(<?php echo $cfg['maximal_upload_size'] ?>, '<?php echo t ('File is too big') . ', ' . t ('File size is limited to') . " " . $cfg['maximal_upload_size'] . " MB"; ?>')"/>
|
||||
</p>
|
||||
|
||||
<div id="options">
|
||||
|
@ -142,18 +170,54 @@ if (strlen ($cfg['upload_password']) > 0)
|
|||
<tr>
|
||||
<td><label for="select_time"><?php echo t('Time limit') . ':'; ?></label></td>
|
||||
<td><select name="time" id="select_time">
|
||||
<?php if ($cfg['availabilities']['none']) { ?>
|
||||
<option value="none"><?php echo t('None'); ?></option>
|
||||
<option value = "minute"><?php echo t('One minute'); ?></option>
|
||||
<option value = "hour"><?php echo t('One hour'); ?></option>
|
||||
<option value = "day"><?php echo t('One day'); ?></option>
|
||||
<option value = "week"><?php echo t('One week'); ?></option>
|
||||
<?php } ?>
|
||||
<?php if ($cfg['availabilities']['year']) { ?>
|
||||
<option value = "year"><?php echo t('One year');?></option>
|
||||
<?php } ?>
|
||||
<?php if ($cfg['availabilities']['month']) { ?>
|
||||
<option value = "month"><?php echo t('One month');?></option>
|
||||
<?php } ?>
|
||||
<?php if ($cfg['availabilities']['week']) { ?>
|
||||
<option value = "week"><?php echo t('One week'); ?></option>
|
||||
<?php } ?>
|
||||
<?php if ($cfg['availabilities']['day']) { ?>
|
||||
<option value = "day"><?php echo t('One day'); ?></option>
|
||||
<?php } ?>
|
||||
<?php if ($cfg['availabilities']['hour']) { ?>
|
||||
<option value = "hour"><?php echo t('One hour'); ?></option>
|
||||
<?php } ?>
|
||||
<?php if ($cfg['availabilities']['minute']) { ?>
|
||||
<option value = "minute"><?php echo t('One minute'); ?></option>
|
||||
<?php } ?>
|
||||
</select></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
if ($cfg['maximal_upload_size'] > 0)
|
||||
{
|
||||
echo '<p class="config">' . t ('File size is limited to');
|
||||
echo " " . $cfg['maximal_upload_size'] . " MB</p>";
|
||||
}
|
||||
?>
|
||||
|
||||
<p id="max_file_size" class="config"></p>
|
||||
<p>
|
||||
|
||||
<input type="hidden" id="upload_password" name="upload_password" value="<?php echo $cfg['upload_password']?>"/>
|
||||
<?php
|
||||
if (jirafeau_has_upload_password ($cfg) && $_SESSION['upload_auth'])
|
||||
{
|
||||
?>
|
||||
<input type="hidden" id="upload_password" name="upload_password" value="<?php echo $_SESSION['user_upload_password'] ?>"/>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
<input type="hidden" id="upload_password" name="upload_password" value=""/>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<input type="submit" id="send" value="<?php echo t('Send'); ?>"
|
||||
onclick="
|
||||
document.getElementById('upload').style.display = 'none';
|
||||
|
@ -165,7 +229,7 @@ if (strlen ($cfg['upload_password']) > 0)
|
|||
</div> </fieldset>
|
||||
|
||||
<?php
|
||||
if (strlen ($cfg['upload_password']) > 0)
|
||||
if (jirafeau_has_upload_password ($cfg))
|
||||
{
|
||||
?>
|
||||
<form action = "<?php echo basename(__FILE__); ?>" method = "post">
|
||||
|
@ -179,6 +243,7 @@ if (strlen ($cfg['upload_password']) > 0)
|
|||
</div>
|
||||
|
||||
<script lang="Javascript">
|
||||
document.getElementById('error_pop').style.display = 'none';
|
||||
document.getElementById('uploading').style.display = 'none';
|
||||
document.getElementById('upload_finished').style.display = 'none';
|
||||
document.getElementById('options').style.display = 'none';
|
||||
|
|
14
sources/install.php
Executable file → Normal file
|
@ -23,6 +23,7 @@ define ('QUOTE', "'");
|
|||
define ('JIRAFEAU_CFG', JIRAFEAU_ROOT.'lib/config.local.php');
|
||||
define ('JIRAFEAU_VAR_RAND_LENGTH', 15);
|
||||
|
||||
require (JIRAFEAU_ROOT . 'lib/functions.php');
|
||||
require (JIRAFEAU_ROOT . 'lib/lang.php');
|
||||
require (JIRAFEAU_ROOT . 'lib/config.original.php');
|
||||
|
||||
|
@ -51,6 +52,9 @@ jirafeau_export_cfg ($cfg)
|
|||
fwrite ($handle, jirafeau_quoted ($item));
|
||||
else if (is_int ($item))
|
||||
fwrite ($handle, $item);
|
||||
else if (is_array ($item))
|
||||
fwrite ($handle, str_replace(array("\n", "\r"), "",
|
||||
var_export ($item, true)));
|
||||
else
|
||||
fwrite ($handle, 'null');
|
||||
fwrite ($handle, ';'.NL);
|
||||
|
@ -97,7 +101,7 @@ jirafeau_check_var_dir ($path)
|
|||
$path . '</code><br />' . $solution_str .
|
||||
'<br />' . $mkdir_str2);
|
||||
|
||||
foreach (array ('files', 'links', 'async', 'block') as $subdir)
|
||||
foreach (array ('files', 'links', 'async') as $subdir)
|
||||
{
|
||||
$subpath = $path.$subdir;
|
||||
|
||||
|
@ -117,6 +121,12 @@ jirafeau_add_ending_slash ($path)
|
|||
return $path . ((substr ($path, -1) == '/') ? '' : '/');
|
||||
}
|
||||
|
||||
if ($cfg['installation_done'] === true)
|
||||
{
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!file_exists (JIRAFEAU_CFG))
|
||||
{
|
||||
/* We try to create an empty one. */
|
||||
|
@ -349,6 +359,8 @@ case 4:
|
|||
}
|
||||
else
|
||||
{
|
||||
$cfg['installation_done'] = true;
|
||||
jirafeau_export_cfg ($cfg);
|
||||
echo '<div class="message"><p>' .
|
||||
t('Jirafeau is now fully operational') . ':' .
|
||||
'<br /><a href="' . $cfg['web_root'] . '">' .
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
/*
|
||||
* Jirafeau, your web file repository
|
||||
* Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
|
||||
* Copyright (C) 2015 Jerome Jutteau <j.jutteau@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
|
@ -23,38 +24,70 @@
|
|||
*/
|
||||
global $cfg;
|
||||
|
||||
/* don't forget the ending '/' */
|
||||
/* Don't forget the ending '/' */
|
||||
$cfg['web_root'] = '';
|
||||
$cfg['var_root'] = '';
|
||||
|
||||
/* Lang choice between 'auto', 'en' and 'fr'.
|
||||
'auto' mode will take the user's browser informations. Will take english if
|
||||
user's langage is not available.
|
||||
* 'auto' mode will take the user's browser informations.
|
||||
* Will take english if user's langage is not available.
|
||||
*/
|
||||
$cfg['lang'] = 'auto';
|
||||
$cfg['style'] = 'modern';
|
||||
$cfg['rewrite'] = false;
|
||||
/* An empty admin password will disable the admin interface. */
|
||||
$cfg['admin_password'] = '';
|
||||
/* preview: false (will download file) or true (will preview in browser if
|
||||
* possible) . */
|
||||
/* Select your style :) See media folder */
|
||||
$cfg['style'] = 'courgette';
|
||||
/* Propose a preview link if file type is previewable is set to true. */
|
||||
$cfg['preview'] = true;
|
||||
/* Download page:
|
||||
* true: Will show a download page (with preview if permited and possible).
|
||||
* false: Will directly download file or preview (if permited and possible). */
|
||||
$cfg['download_page'] = false;
|
||||
/* Block feature:
|
||||
The scripting interface can propose to create, read, write, delete blocks
|
||||
of data. */
|
||||
$cfg['enable_blocks'] = false;
|
||||
/* Download page: propose a link to a download page is set to true. */
|
||||
$cfg['download_page'] = true;
|
||||
/* Encryption feature. disable it by default.
|
||||
* By enabling it, file-level deduplication won't work. */
|
||||
* By enabling it, file-level deduplication won't work.
|
||||
*/
|
||||
$cfg['enable_crypt'] = false;
|
||||
/* Split lenght of link refenrece. */
|
||||
$cfg['link_name_lenght'] = 8;
|
||||
/* Upload password. Empty string disable the password. */
|
||||
$cfg['upload_password'] = '';
|
||||
/* Upload password(s). Empty array disable password authentification.
|
||||
* $cfg['upload_password'] = array(); // No password
|
||||
* $cfg['upload_password'] = array('psw1'); // One password
|
||||
* $cfg['upload_password'] = array('psw1', 'psw2'); // Two passwords
|
||||
* ... and so on
|
||||
*/
|
||||
$cfg['upload_password'] = array();
|
||||
/* An empty admin password will disable the classic admin password
|
||||
* authentication.
|
||||
*/
|
||||
$cfg['admin_password'] = '';
|
||||
/* If set, let's the user to be authenticated as administrator.
|
||||
* The user provided here is the user authenticated by HTTP authentication.
|
||||
* Note that Jirafeau does not manage the HTTP login part, it just check
|
||||
* that the provided user is logged.
|
||||
* If admin_password parameter is also set, admin_password is ignored.
|
||||
*/
|
||||
$cfg['admin_http_auth_user'] = '';
|
||||
/* Select different options for availability of uploaded files.
|
||||
* Possible values in array:
|
||||
* 'minute': file is available for one minute
|
||||
* 'hour': file available for one hour
|
||||
* 'day': file available for one day
|
||||
* 'week': file available for one week
|
||||
* 'month': file is available for one month
|
||||
* 'year': file available for one year
|
||||
* 'none': unlimited availability
|
||||
*/
|
||||
$cfg['availabilities'] = array ('minute' => true,
|
||||
'hour' => true,
|
||||
'day' => true,
|
||||
'week' => true,
|
||||
'month' => true,
|
||||
'year' => false,
|
||||
'none' => false);
|
||||
/* Set maximal upload size expressed in MB.
|
||||
* 0 mean unlimited upload size.
|
||||
*/
|
||||
$cfg['maximal_upload_size'] = 0;
|
||||
/* Installation is done ? */
|
||||
$cfg['installation_done'] = false;
|
||||
|
||||
/* Try to include user's local configuration. */
|
||||
if ((basename (__FILE__) != 'config.local.php')
|
||||
&& file_exists (JIRAFEAU_ROOT.'lib/config.local.php'))
|
||||
{
|
||||
|
|
|
@ -1,301 +0,0 @@
|
|||
/*
|
||||
* Jirafeau, your web file repository
|
||||
* Copyright (C) 2012 Jerome Jutteau <j.jutteau@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function show_link (url, reference, delete_code, crypt_key, date)
|
||||
{
|
||||
var download_link = url + 'f.php?h=' + reference;
|
||||
var download_link_href = url + 'f.php?h=' + reference;
|
||||
if (crypt_key.length > 0)
|
||||
{
|
||||
download_link += '&k=' + crypt_key;
|
||||
download_link_href += '&k=' + crypt_key;
|
||||
}
|
||||
|
||||
var delete_link = url + 'f.php?h=' + reference + '&d=' + delete_code;
|
||||
var delete_link_href = url + 'f.php?h=' + reference + '&d=' + delete_code;
|
||||
|
||||
document.getElementById('upload_link').innerHTML = download_link;
|
||||
document.getElementById('upload_link').href = download_link_href;
|
||||
document.getElementById('delete_link').innerHTML = delete_link;
|
||||
document.getElementById('delete_link').href = delete_link_href;
|
||||
if (date)
|
||||
{
|
||||
document.getElementById('date').innerHTML = date;
|
||||
document.getElementById('validity').style.display = '';
|
||||
}
|
||||
else
|
||||
document.getElementById('validity').style.display = 'none';
|
||||
|
||||
document.getElementById('uploading').style.display = 'none';
|
||||
document.getElementById('upload').style.display = 'none';
|
||||
document.getElementById('upload_finished').style.display = '';
|
||||
document.title = 'Jirafeau - 100%';
|
||||
}
|
||||
|
||||
function show_upload_progression (p)
|
||||
{
|
||||
document.getElementById('uploaded_percentage').innerHTML = p;
|
||||
document.title = 'Jirafeau - ' + p;
|
||||
}
|
||||
|
||||
function upload_progress (e)
|
||||
{
|
||||
if (!e.lengthComputable)
|
||||
return;
|
||||
/* Show the user the operation do not reach 100%, the server need time
|
||||
* to give a response before providing the link.
|
||||
*/
|
||||
var p = Math.round (e.loaded * 100 / e.total);
|
||||
if (p == 100)
|
||||
show_upload_progression (' ');
|
||||
else
|
||||
show_upload_progression (p.toString() + '%');
|
||||
}
|
||||
|
||||
function upload_failed (e)
|
||||
{
|
||||
/* Todo: Considere showing a error div. */
|
||||
alert ('Sorry, upload failed');
|
||||
}
|
||||
|
||||
function classic_upload (url, file, time, password, one_time, upload_password)
|
||||
{
|
||||
var req = new XMLHttpRequest ();
|
||||
req.upload.addEventListener ("progress", upload_progress, false);
|
||||
req.addEventListener ("error", upload_failed, false);
|
||||
req.addEventListener ("abort", upload_failed, false);
|
||||
req.onreadystatechange = function ()
|
||||
{
|
||||
if (req.readyState == 4 && req.status == 200)
|
||||
{
|
||||
var res = req.responseText;
|
||||
if (res == "Error")
|
||||
return;
|
||||
res = res.split ("\n");
|
||||
if (time != 'none')
|
||||
{
|
||||
var d = new Date();
|
||||
if (time == 'minute')
|
||||
d.setSeconds (d.getSeconds() + 60);
|
||||
else if (time == 'hour')
|
||||
d.setSeconds (d.getSeconds() + 3600);
|
||||
else if (time == 'day')
|
||||
d.setSeconds (d.getSeconds() + 86400);
|
||||
else if (time == 'week')
|
||||
d.setSeconds (d.getSeconds() + 604800);
|
||||
else if (time == 'month')
|
||||
d.setSeconds (d.getSeconds() + 2419200);
|
||||
else
|
||||
return;
|
||||
show_link (url, res[0], res[1], res[2], d.toString());
|
||||
}
|
||||
else
|
||||
show_link (url, res[0], res[1], res[2]);
|
||||
}
|
||||
}
|
||||
req.open ("POST", url + 'script.php' , true);
|
||||
|
||||
var form = new FormData();
|
||||
form.append ("file", file);
|
||||
if (time)
|
||||
form.append ("time", time);
|
||||
if (password)
|
||||
form.append ("key", password);
|
||||
if (one_time)
|
||||
form.append ("one_time_download", '1');
|
||||
if (upload_password.length > 0)
|
||||
form.append ("upload_password", upload_password);
|
||||
|
||||
req.send (form);
|
||||
}
|
||||
|
||||
function check_html5_file_api ()
|
||||
{
|
||||
if (window.File && window.FileReader && window.FileList && window.Blob)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
var async_global_transfered = 0;
|
||||
var async_global_url = '';
|
||||
var async_global_file;
|
||||
var async_global_ref = '';
|
||||
var async_global_max_size = 0;
|
||||
var async_global_time;
|
||||
var async_global_transfering = 0;
|
||||
|
||||
function async_upload_start (url, max_size, file, time, password, one_time, upload_password)
|
||||
{
|
||||
async_global_transfered = 0;
|
||||
async_global_url = url;
|
||||
async_global_file = file;
|
||||
async_global_max_size = max_size;
|
||||
async_global_time = time;
|
||||
|
||||
var req = new XMLHttpRequest ();
|
||||
req.addEventListener ("error", upload_failed, false);
|
||||
req.addEventListener ("abort", upload_failed, false);
|
||||
req.onreadystatechange = function ()
|
||||
{
|
||||
if (req.readyState == 4 && req.status == 200)
|
||||
{
|
||||
var res = req.responseText;
|
||||
if (res == "Error")
|
||||
return;
|
||||
res = res.split ("\n");
|
||||
async_global_ref = res[0];
|
||||
var code = res[1];
|
||||
async_upload_push (code);
|
||||
}
|
||||
}
|
||||
req.open ("POST", async_global_url + 'script.php?init_async' , true);
|
||||
|
||||
var form = new FormData();
|
||||
form.append ("filename", async_global_file.name);
|
||||
form.append ("type", async_global_file.type);
|
||||
if (time)
|
||||
form.append ("time", time);
|
||||
if (password)
|
||||
form.append ("key", password);
|
||||
if (one_time)
|
||||
form.append ("one_time_download", '1');
|
||||
if (upload_password.length > 0)
|
||||
form.append ("upload_password", upload_password);
|
||||
|
||||
req.send (form);
|
||||
}
|
||||
|
||||
function async_upload_progress (e)
|
||||
{
|
||||
if (!e.lengthComputable && async_global_file.size != 0)
|
||||
return;
|
||||
var p = Math.round ((e.loaded + async_global_transfered) * 100 / (async_global_file.size));
|
||||
if (p == 100)
|
||||
show_upload_progression (' ');
|
||||
else
|
||||
show_upload_progression (p.toString() + '%');
|
||||
}
|
||||
|
||||
function async_upload_push (code)
|
||||
{
|
||||
if (async_global_transfered == async_global_file.size)
|
||||
{
|
||||
async_upload_end (code);
|
||||
return;
|
||||
}
|
||||
var req = new XMLHttpRequest ();
|
||||
req.upload.addEventListener ("progress", async_upload_progress, false);
|
||||
req.addEventListener ("error", upload_failed, false);
|
||||
req.addEventListener ("abort", upload_failed, false);
|
||||
req.onreadystatechange = function ()
|
||||
{
|
||||
if (req.readyState == 4 && req.status == 200)
|
||||
{
|
||||
var res = req.responseText;
|
||||
if (res == "Error")
|
||||
return;
|
||||
res = res.split ("\n");
|
||||
var code = res[0]
|
||||
async_global_transfered = async_global_transfering;
|
||||
async_upload_push (code);
|
||||
}
|
||||
}
|
||||
req.open ("POST", async_global_url + 'script.php?push_async' , true);
|
||||
|
||||
var chunk_size = parseInt (async_global_max_size * 0.50);
|
||||
var start = async_global_transfered;
|
||||
var end = start + chunk_size;
|
||||
if (end >= async_global_file.size)
|
||||
end = async_global_file.size;
|
||||
var blob = async_global_file.slice (start, end);
|
||||
async_global_transfering = end;
|
||||
|
||||
var form = new FormData();
|
||||
form.append ("ref", async_global_ref);
|
||||
form.append ("data", blob);
|
||||
form.append ("code", code);
|
||||
req.send (form);
|
||||
}
|
||||
|
||||
function async_upload_end (code)
|
||||
{
|
||||
var req = new XMLHttpRequest ();
|
||||
req.addEventListener ("error", upload_failed, false);
|
||||
req.addEventListener ("abort", upload_failed, false);
|
||||
req.onreadystatechange = function ()
|
||||
{
|
||||
if (req.readyState == 4 && req.status == 200)
|
||||
{
|
||||
var res = req.responseText;
|
||||
if (res == "Error")
|
||||
return;
|
||||
res = res.split ("\n");
|
||||
if (async_global_time != 'none')
|
||||
{
|
||||
var d = new Date();
|
||||
if (async_global_time == 'minute')
|
||||
d.setSeconds (d.getSeconds() + 60);
|
||||
else if (async_global_time == 'hour')
|
||||
d.setSeconds (d.getSeconds() + 3600);
|
||||
else if (async_global_time == 'day')
|
||||
d.setSeconds (d.getSeconds() + 86400);
|
||||
else if (async_global_time == 'week')
|
||||
d.setSeconds (d.getSeconds() + 604800);
|
||||
else if (async_global_time == 'month')
|
||||
d.setSeconds (d.getSeconds() + 2419200);
|
||||
else
|
||||
return;
|
||||
show_link (async_global_url, res[0], res[1], res[2], d.toString());
|
||||
}
|
||||
else
|
||||
show_link (async_global_url, res[0], res[1], res[2]);
|
||||
}
|
||||
}
|
||||
req.open ("POST", async_global_url + 'script.php?end_async' , true);
|
||||
|
||||
var form = new FormData();
|
||||
form.append ("ref", async_global_ref);
|
||||
form.append ("code", code);
|
||||
req.send (form);
|
||||
}
|
||||
|
||||
function upload (url, max_size)
|
||||
{
|
||||
if (check_html5_file_api ()
|
||||
&& document.getElementById('file_select').files[0].size >= max_size)
|
||||
{
|
||||
async_upload_start (url,
|
||||
max_size,
|
||||
document.getElementById('file_select').files[0],
|
||||
document.getElementById('select_time').value,
|
||||
document.getElementById('input_key').value,
|
||||
document.getElementById('one_time_download').checked,
|
||||
document.getElementById('upload_password').value
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
classic_upload (url,
|
||||
document.getElementById('file_select').files[0],
|
||||
document.getElementById('select_time').value,
|
||||
document.getElementById('input_key').value,
|
||||
document.getElementById('one_time_download').checked,
|
||||
document.getElementById('upload_password').value
|
||||
);
|
||||
}
|
||||
}
|
429
sources/lib/functions.php
Executable file → Normal file
|
@ -2,7 +2,7 @@
|
|||
/*
|
||||
* Jirafeau, your web file repository
|
||||
* Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
|
||||
* Copyright (C) 2012 Jerome Jutteau <j.jutteau@gmail.com>
|
||||
* Copyright (C) 2015 Jerome Jutteau <j.jutteau@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
|
@ -90,6 +90,18 @@ jirafeau_gen_random ($l)
|
|||
return $code;
|
||||
}
|
||||
|
||||
function is_ssl() {
|
||||
if ( isset($_SERVER['HTTPS']) ) {
|
||||
if ( 'on' == strtolower($_SERVER['HTTPS']) )
|
||||
return true;
|
||||
if ( '1' == $_SERVER['HTTPS'] )
|
||||
return true;
|
||||
} elseif ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function
|
||||
jirafeau_human_size ($octets)
|
||||
{
|
||||
|
@ -333,7 +345,9 @@ jirafeau_upload ($file, $one_time_download, $key, $time, $ip, $crypt, $link_name
|
|||
/* Crypt file if option is enabled. */
|
||||
$crypted = false;
|
||||
$crypt_key = '';
|
||||
if ($crypt == true && extension_loaded('mcrypt'))
|
||||
if ($crypt == true && !(extension_loaded('mcrypt') == true))
|
||||
error_log ("PHP extension mcrypt not loaded, won't encrypt in Jirafeau");
|
||||
if ($crypt == true && extension_loaded('mcrypt') == true)
|
||||
{
|
||||
$crypt_key = jirafeau_encrypt_file ($file['tmp_name'], $file['tmp_name']);
|
||||
if (strlen($crypt_key) > 0)
|
||||
|
@ -429,7 +443,7 @@ jirafeau_upload ($file, $one_time_download, $key, $time, $ip, $crypt, $link_name
|
|||
}
|
||||
|
||||
/**
|
||||
* tells if a mime-type is viewable in a browser
|
||||
* Tells if a mime-type is viewable in a browser
|
||||
* @param $mime the mime type
|
||||
* @returns a boolean telling if a mime type is viewable
|
||||
*/
|
||||
|
@ -439,7 +453,7 @@ jirafeau_is_viewable ($mime)
|
|||
if (!empty ($mime))
|
||||
{
|
||||
/* Actually, verify if mime-type is an image or a text. */
|
||||
$viewable = array ('image', 'text');
|
||||
$viewable = array ('image', 'text', 'video', 'audio');
|
||||
$decomposed = explode ('/', $mime);
|
||||
return in_array ($decomposed[0], $viewable);
|
||||
}
|
||||
|
@ -491,10 +505,10 @@ show_errors ()
|
|||
}
|
||||
}
|
||||
|
||||
function check_errors ()
|
||||
function check_errors ($cfg)
|
||||
{
|
||||
if (file_exists (JIRAFEAU_ROOT . 'install.php')
|
||||
&& !file_exists (JIRAFEAU_ROOT . 'lib/config.local.php'))
|
||||
&& !($cfg['installation_done'] === true))
|
||||
{
|
||||
header('Location: install.php');
|
||||
exit;
|
||||
|
@ -512,15 +526,6 @@ function check_errors ()
|
|||
|
||||
if (!is_writable (VAR_ASYNC))
|
||||
add_error (t('The async directory is not writable!'), VAR_ASYNC);
|
||||
|
||||
if (!is_writable (VAR_BLOCK))
|
||||
add_error (t('The block directory is not writable!'), VAR_BLOCK);
|
||||
|
||||
/* Check if the install.php script is still in the directory. */
|
||||
if (file_exists (JIRAFEAU_ROOT . 'install.php'))
|
||||
add_error (t('Installer script still present'),
|
||||
t('Please make sure to delete the installer script ' .
|
||||
'"install.php" before continuing.'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -549,6 +554,8 @@ jirafeau_get_link ($hash)
|
|||
$out['link_code'] = trim ($c[9]);
|
||||
if (trim ($c[10]) == 'C')
|
||||
$out['crypted'] = true;
|
||||
else
|
||||
$out['crypted'] = false;
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
@ -834,10 +841,11 @@ jirafeau_async_init ($filename, $type, $one_time, $key, $time, $ip)
|
|||
* @param $ref asynchronous upload reference
|
||||
* @param $file piece of data
|
||||
* @param $code client code for this operation
|
||||
* @param $max_file_size maximum allowed file size
|
||||
* @return a string containing a next code to use or the string "Error"
|
||||
*/
|
||||
function
|
||||
jirafeau_async_push ($ref, $data, $code)
|
||||
jirafeau_async_push ($ref, $data, $code, $max_file_size)
|
||||
{
|
||||
/* Get async infos. */
|
||||
$a = jirafeau_get_async_ref ($ref);
|
||||
|
@ -851,9 +859,21 @@ jirafeau_async_push ($ref, $data, $code)
|
|||
|
||||
$p = s2p ($ref);
|
||||
|
||||
/* File path. */
|
||||
$r_path = $data['tmp_name'];
|
||||
$w_path = VAR_ASYNC . $p . $ref . '_data';
|
||||
|
||||
/* Check that file size is not above upload limit. */
|
||||
if ($max_file_size > 0 &&
|
||||
filesize ($r_path) + filesize ($w_path) > $max_file_size * 1024 * 1024)
|
||||
{
|
||||
jirafeau_async_delete ($ref);
|
||||
return "Error";
|
||||
}
|
||||
|
||||
/* Concatenate data. */
|
||||
$r = fopen ($data['tmp_name'], 'r');
|
||||
$w = fopen (VAR_ASYNC . $p . $ref . '_data', 'a');
|
||||
$r = fopen ($r_path, 'r');
|
||||
$w = fopen ($w_path, 'a');
|
||||
while (!feof ($r))
|
||||
{
|
||||
if (fwrite ($w, fread ($r, 1024)) === false)
|
||||
|
@ -866,7 +886,7 @@ jirafeau_async_push ($ref, $data, $code)
|
|||
}
|
||||
fclose ($r);
|
||||
fclose ($w);
|
||||
unlink ($data['tmp_name']);
|
||||
unlink ($r_path);
|
||||
|
||||
/* Update async file. */
|
||||
$code = jirafeau_gen_random (4);
|
||||
|
@ -903,7 +923,7 @@ jirafeau_async_end ($ref, $code, $crypt, $link_name_length)
|
|||
|
||||
$crypted = false;
|
||||
$crypt_key = '';
|
||||
if ($crypt == true && extension_loaded('mcrypt'))
|
||||
if ($crypt == true && extension_loaded('mcrypt') == true)
|
||||
{
|
||||
$crypt_key = jirafeau_encrypt_file ($p, $p);
|
||||
if (strlen($crypt_key) > 0)
|
||||
|
@ -952,346 +972,6 @@ jirafeau_async_end ($ref, $code, $crypt, $link_name_length)
|
|||
return $md5_link . NL . $delete_link_code . NL . urlencode($crypt_key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a block.
|
||||
* @param $id identifier of the block.
|
||||
*/
|
||||
function
|
||||
jirafeau_block_delete_ ($id)
|
||||
{
|
||||
$p = VAR_BLOCK . s2p ($id);
|
||||
if (!file_exists ($p))
|
||||
return;
|
||||
|
||||
if (file_exists ($p . $id))
|
||||
unlink ($p . $id);
|
||||
if (file_exists ($p . $id . '_infos'))
|
||||
unlink ($p . $id . '_infos');
|
||||
$parse = $p;
|
||||
$scan = array();
|
||||
while (file_exists ($parse)
|
||||
&& ($scan = scandir ($parse))
|
||||
&& count ($scan) == 2 // '.' and '..' folders => empty.
|
||||
&& basename ($parse) != basename (VAR_BLOCK))
|
||||
{
|
||||
rmdir ($parse);
|
||||
$parse = substr ($parse, 0, strlen($parse) - strlen(basename ($parse)) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a file filled with zeros.
|
||||
* @param $size size of the file.
|
||||
* @return a string corresponding to an id or the string "Error"
|
||||
*/
|
||||
function
|
||||
jirafeau_block_init ($size)
|
||||
{
|
||||
if (!ctype_digit ($size) || $size <= 0)
|
||||
return "Error";
|
||||
|
||||
/* Create folder. */
|
||||
$id;
|
||||
do
|
||||
{
|
||||
$id = jirafeau_gen_random (32);
|
||||
$p = VAR_BLOCK . s2p ($id);
|
||||
} while (file_exists ($p));
|
||||
@mkdir ($p, 0755, true);
|
||||
if (!file_exists ($p))
|
||||
{
|
||||
echo "Error";
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create block. */
|
||||
$p .= $id;
|
||||
$h = fopen ($p, 'w');
|
||||
$fill = str_repeat ("\0", 1024);
|
||||
for ($cnt = 0; $cnt < $size; $cnt += 1024)
|
||||
{
|
||||
if ($size - $cnt < 1024)
|
||||
$fill = str_repeat ("\0", $size - $cnt);
|
||||
if (fwrite ($h, $fill) === false)
|
||||
{
|
||||
fclose ($h);
|
||||
jirafeau_block_delete_ ($id);
|
||||
return "Error";
|
||||
}
|
||||
}
|
||||
fclose ($h);
|
||||
|
||||
/* Generate a write/delete code. */
|
||||
$code = jirafeau_gen_random (12);
|
||||
|
||||
/* Add block infos. */
|
||||
if (file_put_contents ($p . '_infos', date ('U') . NL . $size . NL . $code) === FALSE)
|
||||
{
|
||||
jirafeau_block_delete_ ($id);
|
||||
return "Error";
|
||||
}
|
||||
|
||||
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
|
||||
* @param $start where to read data (starting from zero).
|
||||
* @param $length length to read.
|
||||
* @return echo data
|
||||
*/
|
||||
function
|
||||
jirafeau_block_read ($id, $start, $length)
|
||||
{
|
||||
if (!ctype_digit ($start) || $start < 0
|
||||
|| !ctype_digit ($length) || $length <= 0)
|
||||
{
|
||||
echo "Error";
|
||||
return;
|
||||
}
|
||||
|
||||
$p = VAR_BLOCK . s2p ($id) . $id;
|
||||
if (!file_exists ($p))
|
||||
{
|
||||
echo "Error";
|
||||
return;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
echo "Error";
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* Remove data. */
|
||||
elseif (date ('U') - $date >= JIRAFEAU_MONTH)
|
||||
{
|
||||
echo date ('U'). " $date ";
|
||||
jirafeau_block_delete_ ($id);
|
||||
echo "Error";
|
||||
return;
|
||||
}
|
||||
|
||||
if ($start + $length > $block_size)
|
||||
{
|
||||
echo "Error";
|
||||
return;
|
||||
}
|
||||
|
||||
/* Read content. */
|
||||
header ('Content-Length: ' . $length);
|
||||
header ('Content-Disposition: attachment');
|
||||
|
||||
$r = fopen ($p, 'r');
|
||||
if (fseek ($r, $start) != 0)
|
||||
{
|
||||
echo "Error";
|
||||
return;
|
||||
}
|
||||
$c = 1024;
|
||||
for ($cnt = 0; $cnt < $length && !feof ($r); $cnt += 1024)
|
||||
{
|
||||
if ($length - $cnt < 1024)
|
||||
$c = $length - $cnt;
|
||||
print fread ($r, $c);
|
||||
ob_flush();
|
||||
}
|
||||
fclose ($r);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write some data in a block.
|
||||
* @param $id identifier of the block
|
||||
* @param $start where to writing data (starting from zero).
|
||||
* @param $data data to write.
|
||||
* @param $code code to allow writing.
|
||||
* @return string "Ok" or string "Error".
|
||||
*/
|
||||
function
|
||||
jirafeau_block_write ($id, $start, $data, $code)
|
||||
{
|
||||
if (!ctype_digit ($start) || $start < 0
|
||||
|| strlen ($code) == 0)
|
||||
return "Error";
|
||||
|
||||
$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)
|
||||
{
|
||||
jirafeau_block_delete_ ($id);
|
||||
return "Error";
|
||||
}
|
||||
|
||||
/* Check code. */
|
||||
if ($stored_code != $code)
|
||||
{
|
||||
echo "Error";
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check data. */
|
||||
$size = $data['size'];
|
||||
if ($size <= 0)
|
||||
return "Error";
|
||||
if ($start + $size > $block_size)
|
||||
return "Error";
|
||||
|
||||
/* Open data. */
|
||||
$r = fopen ($data['tmp_name'], 'r');
|
||||
|
||||
/* Open Block. */
|
||||
$w = fopen ($p, 'r+');
|
||||
if (fseek ($w, $start) != 0)
|
||||
return "Error";
|
||||
|
||||
/* Write content. */
|
||||
$c = 1024;
|
||||
for ($cnt = 0; $cnt <= $size && !feof ($w); $cnt += 1024)
|
||||
{
|
||||
if ($size - $cnt < 1024)
|
||||
$c = $size - $cnt;
|
||||
$d = fread ($r, $c);
|
||||
fwrite ($w, $d);
|
||||
}
|
||||
fclose ($r);
|
||||
fclose ($w);
|
||||
unlink ($data['tmp_name']);
|
||||
return "Ok";
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a block.
|
||||
* @param $id identifier of the block.
|
||||
* @param $code code to allow writing.
|
||||
* @return string "Ok" or string "Error".
|
||||
*/
|
||||
function
|
||||
jirafeau_block_delete ($id, $code)
|
||||
{
|
||||
$p = VAR_BLOCK . s2p ($id) . $id;
|
||||
|
||||
if (!file_exists ($p))
|
||||
return "Error";
|
||||
|
||||
$f = file ($p . '_infos');
|
||||
$date = trim ($f[0]);
|
||||
$block_size = trim ($f[1]);
|
||||
$stored_code = trim ($f[2]);
|
||||
|
||||
if ($code != $stored_code)
|
||||
return "Error";
|
||||
|
||||
jirafeau_block_delete_ ($id);
|
||||
return "Ok";
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean old unused blocks.
|
||||
* @return number of cleaned blocks.
|
||||
*/
|
||||
function
|
||||
jirafeau_admin_clean_block ()
|
||||
{
|
||||
$count = 0;
|
||||
/* Get all blocks. */
|
||||
$stack = array (VAR_BLOCK);
|
||||
while (($d = array_shift ($stack)) && $d != NULL)
|
||||
{
|
||||
$dir = scandir ($d);
|
||||
|
||||
foreach ($dir as $node)
|
||||
{
|
||||
if (strcmp ($node, '.') == 0 || strcmp ($node, '..') == 0)
|
||||
continue;
|
||||
|
||||
if (is_dir ($d . $node))
|
||||
{
|
||||
/* Push new found directory. */
|
||||
$stack[] = $d . $node . '/';
|
||||
}
|
||||
elseif (is_file ($d . $node) && preg_match ('/\_infos/i', "$node"))
|
||||
{
|
||||
/* Read block informations. */
|
||||
$f = file ($d . $node);
|
||||
$date = trim ($f[0]);
|
||||
$block_size = trim ($f[1]);
|
||||
if (date ('U') - $date >= JIRAFEAU_MONTH)
|
||||
{
|
||||
jirafeau_block_delete_ (substr($node, 0, -6));
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
function
|
||||
jirafeau_crypt_create_iv($base, $size)
|
||||
{
|
||||
|
@ -1312,7 +992,7 @@ function
|
|||
jirafeau_encrypt_file ($fp_src, $fp_dst)
|
||||
{
|
||||
$fs = filesize ($fp_src);
|
||||
if ($fs === false || $fs == 0 || !extension_loaded('mcrypt'))
|
||||
if ($fs === false || $fs == 0 || !(extension_loaded('mcrypt') == true))
|
||||
return '';
|
||||
|
||||
/* Prepare module. */
|
||||
|
@ -1351,7 +1031,7 @@ function
|
|||
jirafeau_decrypt_file ($fp_src, $fp_dst, $k)
|
||||
{
|
||||
$fs = filesize ($fp_src);
|
||||
if ($fs === false || $fs == 0 || !extension_loaded('mcrypt'))
|
||||
if ($fs === false || $fs == 0 || !(extension_loaded('mcrypt') == true))
|
||||
return false;
|
||||
|
||||
/* Init module */
|
||||
|
@ -1377,4 +1057,27 @@ jirafeau_decrypt_file ($fp_src, $fp_dst, $k)
|
|||
return true;
|
||||
}
|
||||
|
||||
?>
|
||||
/**
|
||||
* Check if Jirafeau is password protected for visitors.
|
||||
* @return true if Jirafeau is password protected, false otherwise.
|
||||
*/
|
||||
function jirafeau_has_upload_password ($cfg)
|
||||
{
|
||||
return count ($cfg['upload_password']) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Challenge password for a visitor.
|
||||
* @param $password password to be challenged
|
||||
* @return true if password is valid, false otherwise.
|
||||
*/
|
||||
function jirafeau_challenge_upload_password ($cfg, $password)
|
||||
{
|
||||
if (!jirafeau_has_upload_password($cfg))
|
||||
return false;
|
||||
forEach ($cfg['upload_password'] as $p)
|
||||
if ($password == $p)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
560
sources/lib/functions_v3.js
Normal file
|
@ -0,0 +1,560 @@
|
|||
/*
|
||||
* Jirafeau, your web file repository
|
||||
* Copyright (C) 2015 Jerome Jutteau <j.jutteau@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function show_link (url, reference, delete_code, crypt_key, date)
|
||||
{
|
||||
// Download page if element exists
|
||||
var download_link = url + 'f.php?h=' + reference;
|
||||
var download_link_href = url + 'f.php?h=' + reference;
|
||||
if (crypt_key.length > 0)
|
||||
{
|
||||
download_link += '&k=' + crypt_key;
|
||||
download_link_href += '&k=' + crypt_key;
|
||||
}
|
||||
if (!!document.getElementById('upload_finished_download_page'))
|
||||
{
|
||||
document.getElementById('upload_link').innerHTML = download_link;
|
||||
document.getElementById('upload_link').href = download_link_href;
|
||||
}
|
||||
|
||||
// Is the preview allowed ?
|
||||
if (!!document.getElementById('preview_link'))
|
||||
{
|
||||
document.getElementById('upload_finished_preview').style.display = 'none';
|
||||
var preview_link = url + 'f.php?h=' + reference + '&p=1';
|
||||
var preview_link_href = url + 'f.php?h=' + reference + '&p=1';
|
||||
if (crypt_key.length > 0)
|
||||
{
|
||||
preview_link += '&k=' + crypt_key;
|
||||
preview_link_href += '&k=' + crypt_key;
|
||||
}
|
||||
|
||||
// Test if content can be previewed
|
||||
type = document.getElementById('file_select').files[0].type;
|
||||
if (type.indexOf("image") > -1 ||
|
||||
type.indexOf("audio") > -1 ||
|
||||
type.indexOf("text") > -1 ||
|
||||
type.indexOf("video") > -1)
|
||||
{
|
||||
document.getElementById('preview_link').innerHTML = preview_link;
|
||||
document.getElementById('preview_link').href = preview_link_href;
|
||||
document.getElementById('upload_finished_preview').style.display = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Only show link to password page if password is set
|
||||
document.getElementById('upload_password_page').style.display = 'none';
|
||||
if (document.getElementById('input_key').value.length > 0)
|
||||
{
|
||||
if (!!document.getElementById('upload_finished_download_page'))
|
||||
document.getElementById('upload_finished_download_page').style.display = 'none';
|
||||
document.getElementById('upload_password_page').style.display = '';
|
||||
if (!!document.getElementById('upload_finished_preview'))
|
||||
document.getElementById('upload_finished_preview').style.display = 'none';
|
||||
document.getElementById('upload_direct_download').style.display = 'none';
|
||||
|
||||
document.getElementById('password_link').innerHTML = download_link;
|
||||
document.getElementById('password_link').href = download_link_href;
|
||||
}
|
||||
// Direct download link
|
||||
else
|
||||
{
|
||||
var direct_download_link = url + 'f.php?h=' + reference + '&d=1';
|
||||
var direct_download_link_href = url + 'f.php?h=' + reference + '&d=1';
|
||||
if (crypt_key.length > 0)
|
||||
{
|
||||
direct_download_link += '&k=' + crypt_key;
|
||||
direct_download_link_href += '&k=' + crypt_key;
|
||||
}
|
||||
document.getElementById('direct_link').innerHTML = direct_download_link;
|
||||
document.getElementById('direct_link').href = direct_download_link_href;
|
||||
}
|
||||
|
||||
// Delete link
|
||||
var delete_link = url + 'f.php?h=' + reference + '&d=' + delete_code;
|
||||
var delete_link_href = url + 'f.php?h=' + reference + '&d=' + delete_code;
|
||||
document.getElementById('delete_link').innerHTML = delete_link;
|
||||
document.getElementById('delete_link').href = delete_link_href;
|
||||
|
||||
if (date)
|
||||
{
|
||||
document.getElementById('date').innerHTML = date;
|
||||
document.getElementById('validity').style.display = '';
|
||||
}
|
||||
else
|
||||
document.getElementById('validity').style.display = 'none';
|
||||
|
||||
document.getElementById('uploading').style.display = 'none';
|
||||
document.getElementById('upload').style.display = 'none';
|
||||
document.getElementById('upload_finished').style.display = '';
|
||||
document.title = 'Jirafeau - 100%';
|
||||
}
|
||||
|
||||
function show_upload_progression (percentage, speed, time_left)
|
||||
{
|
||||
document.getElementById('uploaded_percentage').innerHTML = percentage;
|
||||
document.getElementById('uploaded_speed').innerHTML = speed;
|
||||
document.getElementById('uploaded_time').innerHTML = time_left;
|
||||
document.title = 'Jirafeau - ' + percentage;
|
||||
}
|
||||
|
||||
function hide_upload_progression ()
|
||||
{
|
||||
document.getElementById('uploaded_percentage').style.display = 'none';
|
||||
document.getElementById('uploaded_speed').style.display = 'none';
|
||||
document.getElementById('uploaded_time').style.display = 'none';
|
||||
document.title = 'Jirafeau';
|
||||
}
|
||||
|
||||
function upload_progress (e)
|
||||
{
|
||||
if (!e.lengthComputable)
|
||||
return;
|
||||
|
||||
// Init time estimation if needed
|
||||
if (upload_time_estimation_total_size == 0)
|
||||
upload_time_estimation_total_size = e.total;
|
||||
|
||||
// Compute percentage
|
||||
var p = Math.round (e.loaded * 100 / e.total);
|
||||
var p_str = ' ';
|
||||
if (p != 100)
|
||||
p_str = p.toString() + '%';
|
||||
// Update estimation speed
|
||||
upload_time_estimation_add(e.loaded);
|
||||
// Get speed string
|
||||
var speed_str = upload_time_estimation_speed_string();
|
||||
// Get time string
|
||||
var time_str = chrono_update(upload_time_estimation_time());
|
||||
|
||||
show_upload_progression (p_str, speed_str, time_str);
|
||||
}
|
||||
|
||||
function control_selected_file_size(max_size, error_str)
|
||||
{
|
||||
f_size = document.getElementById('file_select').files[0].size;
|
||||
if (max_size > 0 && f_size > max_size * 1024 * 1024)
|
||||
{
|
||||
pop_failure(error_str);
|
||||
document.getElementById('send').style.display = 'none';
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById('options').style.display = '';
|
||||
document.getElementById('send').style.display = '';
|
||||
document.getElementById('error_pop').style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function pop_failure (e)
|
||||
{
|
||||
var text = "An error occured";
|
||||
if (typeof e !== 'undefined')
|
||||
text = e;
|
||||
text = "<p>" + text + "</p>";
|
||||
document.getElementById('error_pop').innerHTML = e;
|
||||
|
||||
document.getElementById('uploading').style.display = 'none';
|
||||
document.getElementById('error_pop').style.display = '';
|
||||
document.getElementById('upload').style.display = '';
|
||||
document.getElementById('send').style.display = '';
|
||||
}
|
||||
|
||||
function classic_upload (url, file, time, password, one_time, upload_password)
|
||||
{
|
||||
// Delay time estimation init as we can't have file size
|
||||
upload_time_estimation_init(0);
|
||||
|
||||
var req = new XMLHttpRequest ();
|
||||
req.upload.addEventListener ("progress", upload_progress, false);
|
||||
req.addEventListener ("error", pop_failure, false);
|
||||
req.addEventListener ("abort", pop_failure, false);
|
||||
req.onreadystatechange = function ()
|
||||
{
|
||||
if (req.readyState == 4 && req.status == 200)
|
||||
{
|
||||
var res = req.responseText;
|
||||
if (res == "Error")
|
||||
{
|
||||
pop_failure ();
|
||||
return;
|
||||
}
|
||||
res = res.split ("\n");
|
||||
if (time != 'none')
|
||||
{
|
||||
var d = new Date();
|
||||
if (time == 'minute')
|
||||
d.setSeconds (d.getSeconds() + 60);
|
||||
else if (time == 'hour')
|
||||
d.setSeconds (d.getSeconds() + 3600);
|
||||
else if (time == 'day')
|
||||
d.setSeconds (d.getSeconds() + 86400);
|
||||
else if (time == 'week')
|
||||
d.setSeconds (d.getSeconds() + 604800);
|
||||
else if (time == 'month')
|
||||
d.setSeconds (d.getSeconds() + 2419200);
|
||||
else if (time == 'year')
|
||||
d.setSeconds (d.getSeconds() + 29030400);
|
||||
else
|
||||
return;
|
||||
show_link (url, res[0], res[1], res[2], d.toString());
|
||||
}
|
||||
else
|
||||
show_link (url, res[0], res[1], res[2]);
|
||||
}
|
||||
}
|
||||
req.open ("POST", url + 'script.php' , true);
|
||||
|
||||
var form = new FormData();
|
||||
form.append ("file", file);
|
||||
if (time)
|
||||
form.append ("time", time);
|
||||
if (password)
|
||||
form.append ("key", password);
|
||||
if (one_time)
|
||||
form.append ("one_time_download", '1');
|
||||
if (upload_password.length > 0)
|
||||
form.append ("upload_password", upload_password);
|
||||
|
||||
req.send (form);
|
||||
}
|
||||
|
||||
function check_html5_file_api ()
|
||||
{
|
||||
if (window.File && window.FileReader && window.FileList && window.Blob)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
var async_global_transfered = 0;
|
||||
var async_global_url = '';
|
||||
var async_global_file;
|
||||
var async_global_ref = '';
|
||||
var async_global_max_size = 0;
|
||||
var async_global_time;
|
||||
var async_global_transfering = 0;
|
||||
|
||||
function async_upload_start (url, max_size, file, time, password, one_time, upload_password)
|
||||
{
|
||||
async_global_transfered = 0;
|
||||
async_global_url = url;
|
||||
async_global_file = file;
|
||||
async_global_max_size = max_size;
|
||||
async_global_time = time;
|
||||
|
||||
var req = new XMLHttpRequest ();
|
||||
req.addEventListener ("error", pop_failure, false);
|
||||
req.addEventListener ("abort", pop_failure, false);
|
||||
req.onreadystatechange = function ()
|
||||
{
|
||||
if (req.readyState == 4 && req.status == 200)
|
||||
{
|
||||
var res = req.responseText;
|
||||
if (res == "Error")
|
||||
{
|
||||
pop_failure ();
|
||||
return;
|
||||
}
|
||||
res = res.split ("\n");
|
||||
async_global_ref = res[0];
|
||||
var code = res[1];
|
||||
async_upload_push (code);
|
||||
}
|
||||
}
|
||||
req.open ("POST", async_global_url + 'script.php?init_async' , true);
|
||||
|
||||
var form = new FormData();
|
||||
form.append ("filename", async_global_file.name);
|
||||
form.append ("type", async_global_file.type);
|
||||
if (time)
|
||||
form.append ("time", time);
|
||||
if (password)
|
||||
form.append ("key", password);
|
||||
if (one_time)
|
||||
form.append ("one_time_download", '1');
|
||||
if (upload_password.length > 0)
|
||||
form.append ("upload_password", upload_password);
|
||||
|
||||
// Start time estimation
|
||||
upload_time_estimation_init(async_global_file.size);
|
||||
|
||||
req.send (form);
|
||||
}
|
||||
|
||||
function async_upload_progress (e)
|
||||
{
|
||||
if (!e.lengthComputable && async_global_file.size != 0)
|
||||
return;
|
||||
|
||||
// Compute percentage
|
||||
var p = Math.round ((e.loaded + async_global_transfered) * 100 / (async_global_file.size));
|
||||
var p_str = ' ';
|
||||
if (p != 100)
|
||||
p_str = p.toString() + '%';
|
||||
// Update estimation speed
|
||||
upload_time_estimation_add(e.loaded + async_global_transfered);
|
||||
// Get speed string
|
||||
var speed_str = upload_time_estimation_speed_string();
|
||||
// Get time string
|
||||
var time_str = chrono_update(upload_time_estimation_time());
|
||||
|
||||
show_upload_progression (p_str, speed_str, time_str);
|
||||
}
|
||||
|
||||
function async_upload_push (code)
|
||||
{
|
||||
if (async_global_transfered == async_global_file.size)
|
||||
{
|
||||
hide_upload_progression ();
|
||||
async_upload_end (code);
|
||||
return;
|
||||
}
|
||||
var req = new XMLHttpRequest ();
|
||||
req.upload.addEventListener ("progress", async_upload_progress, false);
|
||||
req.addEventListener ("error", pop_failure, false);
|
||||
req.addEventListener ("abort", pop_failure, false);
|
||||
req.onreadystatechange = function ()
|
||||
{
|
||||
if (req.readyState == 4 && req.status == 200)
|
||||
{
|
||||
var res = req.responseText;
|
||||
if (res == "Error")
|
||||
{
|
||||
pop_failure ();
|
||||
return;
|
||||
}
|
||||
res = res.split ("\n");
|
||||
var code = res[0]
|
||||
async_global_transfered = async_global_transfering;
|
||||
async_upload_push (code);
|
||||
}
|
||||
}
|
||||
req.open ("POST", async_global_url + 'script.php?push_async' , true);
|
||||
|
||||
var chunk_size = parseInt (async_global_max_size * 0.50);
|
||||
var start = async_global_transfered;
|
||||
var end = start + chunk_size;
|
||||
if (end >= async_global_file.size)
|
||||
end = async_global_file.size;
|
||||
var blob = async_global_file.slice (start, end);
|
||||
async_global_transfering = end;
|
||||
|
||||
var form = new FormData();
|
||||
form.append ("ref", async_global_ref);
|
||||
form.append ("data", blob);
|
||||
form.append ("code", code);
|
||||
req.send (form);
|
||||
}
|
||||
|
||||
function async_upload_end (code)
|
||||
{
|
||||
var req = new XMLHttpRequest ();
|
||||
req.addEventListener ("error", pop_failure, false);
|
||||
req.addEventListener ("abort", pop_failure, false);
|
||||
req.onreadystatechange = function ()
|
||||
{
|
||||
if (req.readyState == 4 && req.status == 200)
|
||||
{
|
||||
var res = req.responseText;
|
||||
if (res == "Error")
|
||||
{
|
||||
pop_failure ();
|
||||
return;
|
||||
}
|
||||
res = res.split ("\n");
|
||||
if (async_global_time != 'none')
|
||||
{
|
||||
var d = new Date();
|
||||
if (async_global_time == 'minute')
|
||||
d.setSeconds (d.getSeconds() + 60);
|
||||
else if (async_global_time == 'hour')
|
||||
d.setSeconds (d.getSeconds() + 3600);
|
||||
else if (async_global_time == 'day')
|
||||
d.setSeconds (d.getSeconds() + 86400);
|
||||
else if (async_global_time == 'week')
|
||||
d.setSeconds (d.getSeconds() + 604800);
|
||||
else if (async_global_time == 'month')
|
||||
d.setSeconds (d.getSeconds() + 2419200);
|
||||
else if (async_global_time == 'year')
|
||||
d.setSeconds (d.getSeconds() + 29030400);
|
||||
else
|
||||
return;
|
||||
show_link (async_global_url, res[0], res[1], res[2], d.toString());
|
||||
}
|
||||
else
|
||||
show_link (async_global_url, res[0], res[1], res[2]);
|
||||
}
|
||||
}
|
||||
req.open ("POST", async_global_url + 'script.php?end_async' , true);
|
||||
|
||||
var form = new FormData();
|
||||
form.append ("ref", async_global_ref);
|
||||
form.append ("code", code);
|
||||
req.send (form);
|
||||
}
|
||||
|
||||
function upload (url, max_size)
|
||||
{
|
||||
if (check_html5_file_api ()
|
||||
&& document.getElementById('file_select').files[0].size >= max_size)
|
||||
{
|
||||
async_upload_start (url,
|
||||
max_size,
|
||||
document.getElementById('file_select').files[0],
|
||||
document.getElementById('select_time').value,
|
||||
document.getElementById('input_key').value,
|
||||
document.getElementById('one_time_download').checked,
|
||||
document.getElementById('upload_password').value
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
classic_upload (url,
|
||||
document.getElementById('file_select').files[0],
|
||||
document.getElementById('select_time').value,
|
||||
document.getElementById('input_key').value,
|
||||
document.getElementById('one_time_download').checked,
|
||||
document.getElementById('upload_password').value
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
var upload_time_estimation_total_size = 42;
|
||||
var upload_time_estimation_transfered_size = 42;
|
||||
var upload_time_estimation_transfered_date = 42;
|
||||
var upload_time_estimation_moving_average_speed = 42;
|
||||
|
||||
function upload_time_estimation_init(total_size)
|
||||
{
|
||||
upload_time_estimation_total_size = total_size;
|
||||
upload_time_estimation_transfered_size = 0;
|
||||
upload_time_estimation_moving_average_speed = 0;
|
||||
var d = new Date();
|
||||
upload_time_estimation_transfered_date = d.getTime();
|
||||
}
|
||||
|
||||
function upload_time_estimation_add(total_transfered_size)
|
||||
{
|
||||
// Let's compute the current speed
|
||||
var d = new Date();
|
||||
var speed = upload_time_estimation_moving_average_speed;
|
||||
if (d.getTime() - upload_time_estimation_transfered_date != 0)
|
||||
speed = (total_transfered_size - upload_time_estimation_transfered_size)
|
||||
/ (d.getTime() - upload_time_estimation_transfered_date);
|
||||
// Let's compute moving average speed on 30 values
|
||||
var m = (upload_time_estimation_moving_average_speed * 29 + speed) / 30;
|
||||
// Update global values
|
||||
upload_time_estimation_transfered_size = total_transfered_size;
|
||||
upload_time_estimation_transfered_date = d.getTime();
|
||||
upload_time_estimation_moving_average_speed = m;
|
||||
}
|
||||
|
||||
function upload_time_estimation_speed_string()
|
||||
{
|
||||
// speed ms -> s
|
||||
var s = upload_time_estimation_moving_average_speed * 1000;
|
||||
var res = 0;
|
||||
var scale = '';
|
||||
if (s <= 1000)
|
||||
{
|
||||
res = s.toString();
|
||||
scale = "o/s";
|
||||
}
|
||||
else if (s < 1000000)
|
||||
{
|
||||
res = Math.floor(s/100) / 10;
|
||||
scale = "Ko/s";
|
||||
}
|
||||
else
|
||||
{
|
||||
res = Math.floor(s/100000) / 10;
|
||||
scale = "Mo/s";
|
||||
}
|
||||
if (res == 0)
|
||||
return '';
|
||||
else
|
||||
return res.toString() + ' ' + scale;
|
||||
}
|
||||
|
||||
function milliseconds_to_time_string (milliseconds)
|
||||
{
|
||||
function numberEnding (number) {
|
||||
return (number > 1) ? 's' : '';
|
||||
}
|
||||
|
||||
var temp = Math.floor(milliseconds / 1000);
|
||||
var years = Math.floor(temp / 31536000);
|
||||
if (years) {
|
||||
return years + ' year' + numberEnding(years);
|
||||
}
|
||||
var days = Math.floor((temp %= 31536000) / 86400);
|
||||
if (days) {
|
||||
return days + ' day' + numberEnding(days);
|
||||
}
|
||||
var hours = Math.floor((temp %= 86400) / 3600);
|
||||
if (hours) {
|
||||
return hours + ' hour' + numberEnding(hours);
|
||||
}
|
||||
var minutes = Math.floor((temp %= 3600) / 60);
|
||||
if (minutes) {
|
||||
return minutes + ' minute' + numberEnding(minutes);
|
||||
}
|
||||
var seconds = temp % 60;
|
||||
if (seconds) {
|
||||
return seconds + ' second' + numberEnding(seconds);
|
||||
}
|
||||
return 'less than a second';
|
||||
}
|
||||
|
||||
function upload_time_estimation_time()
|
||||
{
|
||||
// Estimate remaining time
|
||||
if (upload_time_estimation_moving_average_speed == 0)
|
||||
return 0;
|
||||
return (upload_time_estimation_total_size - upload_time_estimation_transfered_size)
|
||||
/ upload_time_estimation_moving_average_speed;
|
||||
}
|
||||
|
||||
var chrono_last_update = 0;
|
||||
var chrono_time_ms = 0;
|
||||
var chrono_time_ms_last_update = 0;
|
||||
function chrono_update(time_ms)
|
||||
{
|
||||
var d = new Date();
|
||||
var chrono = 0;
|
||||
// Don't update too often
|
||||
if (d.getTime() - chrono_last_update < 3000 &&
|
||||
chrono_time_ms_last_update > 0)
|
||||
chrono = chrono_time_ms;
|
||||
else
|
||||
{
|
||||
chrono_last_update = d.getTime();
|
||||
chrono_time_ms = time_ms;
|
||||
chrono = time_ms;
|
||||
chrono_time_ms_last_update = d.getTime();
|
||||
}
|
||||
|
||||
// Adjust chrono for smooth estimation
|
||||
chrono = chrono - (d.getTime() - chrono_time_ms_last_update);
|
||||
|
||||
// Let's update chronometer
|
||||
var time_str = '';
|
||||
if (chrono > 0)
|
||||
time_str = milliseconds_to_time_string (chrono);
|
||||
return time_str;
|
||||
}
|
2
sources/lib/lang.php
Executable file → Normal file
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Jirafeau, your web file repository
|
||||
* Copyright (C) 2012 Jerome Jutteau <j.jutteau@gmail.com>
|
||||
* Copyright (C) 2015 Jerome Jutteau <j.jutteau@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
|
|
29
sources/lib/lang/fr.php
Executable file → Normal file
|
@ -31,24 +31,31 @@ $tr = array (
|
|||
'Maximum file size' => 'Taille maximale',
|
||||
'powered by Open-Source project Jirafeau' => 'Propulsé par le projet Open-Source Jirafeau',
|
||||
'Jirafeau Project' => 'Projet Jirafeau',
|
||||
'None' => 'Aucune',
|
||||
'One minute' => 'Une minute',
|
||||
'One hour' => 'Une heure',
|
||||
'One day' => 'Une journée',
|
||||
'One week' => 'Une semaine',
|
||||
'One month' => 'Un mois',
|
||||
'One year' => 'Une année',
|
||||
'None' => 'Aucune',
|
||||
'Upload password' => 'Mot de passe',
|
||||
'File is too big' => 'Le fichier est trop volumineux',
|
||||
'File size is limited to' => 'La taille de fichier est limité à',
|
||||
'The file directory is not writable' => 'Le dossier \'file\' ne peut être écrit.',
|
||||
'The link directory is not writable' => 'Le dossier \'link\' ne peut être écrit.',
|
||||
'The async directory is not writable!' => 'Le dossier \'async\' ne peut être écrit.',
|
||||
'Installer script still present' => 'Le script d\'installation est toujours présent',
|
||||
'Please make sure to delete the installer script "install.php" before continuing.' => 'Merci de supprimer le fichier "install.php" avant de continuer.',
|
||||
'An error occurred.' => 'Une erreur s\'est produite',
|
||||
'File uploaded! Copy the following URL to get it' => 'Fichier envoyé! Le fichier sera accessible à l\'adresse suivante',
|
||||
'File uploaded !' => 'Fichier envoyé !',
|
||||
'Download page' => 'Page de téléchargement',
|
||||
'This file is valid until the following date' => 'Ce fichier est valable jusqu\'à la date suivante',
|
||||
'Keep the following URL to delete it at any moment' => 'Vous pouvez supprimer le fichier lorsque vous le désirez via l\'adresse suivante',
|
||||
'View link' => 'Lien d\'affichage',
|
||||
'Direct download link' => 'Lien de téléchargement direct',
|
||||
'Delete link' => 'Lien de suppression',
|
||||
/* f.php */
|
||||
'Download' => 'Télécharger',
|
||||
'Preview' => 'Prévisualiser',
|
||||
'Sorry, the requested file is not found' => 'Désolé, le fichier que vous demandez n\'existe pas ou n\'existe plus',
|
||||
'File not available.' => 'Fichier non disponible',
|
||||
'File has been deleted.' => 'Le fichier a été supprimé.',
|
||||
|
@ -80,7 +87,6 @@ $tr = array (
|
|||
'step' => 'étape',
|
||||
'out of' => 'sur',
|
||||
'Administration password' => 'Mot de passe d\'administration',
|
||||
'Clean unused blocks' => 'Nettoie les bloques inutilisés',
|
||||
'Finalisation' => 'Finalisation',
|
||||
'Jirafeau is setting the website according to the configuration you provided.' => 'Jirafeau se configure selon les paramêtres donnés',
|
||||
'Previous step' => 'Etape précedente',
|
||||
|
@ -103,6 +109,7 @@ $tr = array (
|
|||
'Administration password' => 'Mot de passe d\'administration',
|
||||
/* admin.php */
|
||||
'Sorry, the admin interface is not enabled.' => 'Désolé, l\'interface d\'administration n\'est pas activée.',
|
||||
'Sorry, you are not authenticated on admin interface.' => 'Désolé, vous n\'êtes pas authentifié sur l\'interface d\'administration',
|
||||
'Login' => 'Connexion',
|
||||
'Wrong password.' => 'Mot de passe invalide.',
|
||||
'Admin interface' => 'Interface d\'administration',
|
||||
|
@ -138,6 +145,8 @@ $tr = array (
|
|||
'This interface permits to script your uploads and downloads.' => 'Cette interface permet de programmer vos envoie et téléversements.',
|
||||
'The instructions above show how to query this interface.' => 'Les instructions ci-dessous montrent comment interroger cette interface.',
|
||||
'Get server capacity' => 'Récupérer la capacité d\'envoie du serveur',
|
||||
'Maximal allowed size of an uploaded file' => 'Récupérer la taille maximal autorisée d\'un envoie de fichier',
|
||||
'First line returns size (in MB).' => 'La première ligne correspond à la taille exprimée en MB.',
|
||||
'Get Jirafeau\'s version' => 'Récupérer la version de Jirafeau',
|
||||
'Send a GET query to' => 'Envoyez une requette GET à',
|
||||
'Send a POST query to' => 'Envoyez une requette POST à',
|
||||
|
@ -155,7 +164,7 @@ $tr = array (
|
|||
'This will return "Ok" if succeded, "Error" otherwhise.' => 'Retourne "OK" en cas de succès, "Error" dans le cas contraire.',
|
||||
'Get a generated scripts' => 'Récupérer un script généré',
|
||||
'This will return brut text content of the code.' => 'Renvoie le code sous forme the texte brut.',
|
||||
'Initalize a asynchronous transfert' => 'Initialiser un transfert asynchrone',
|
||||
'Initalize an asynchronous transfert' => 'Initialiser un transfert asynchrone',
|
||||
'The goal is to permit to transfert big file, chunk by chunk.' => 'Le but est de permettre de transférer de gros fichiers, morceaux par morceaux.',
|
||||
'Chunks of data must be sent in order.' => 'Chaque morceau doit être envoyé dans l\'ordre.',
|
||||
'First line is the asynchronous transfert reference and the second line the code to use in the next operation.'
|
||||
|
@ -163,16 +172,6 @@ $tr = array (
|
|||
'Push data during asynchronous transfert' => 'Envoyer des données pendant un transfert asynchrone',
|
||||
'Returns the next code to use.' => 'Renvoie le prochain code à utiliser.',
|
||||
'Finalize asynchronous transfert' => 'Finaliser un transfert asynchrone',
|
||||
'Create a data block' => 'Creer un bloque de données',
|
||||
'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.',
|
||||
'This will return asked data or "Error" string.' => 'Retourne les données ou la chaine "Error".',
|
||||
'Delete a block' => 'Supprimer un bloque',
|
||||
'This will return "Ok" or "Error" string.' => 'Retourn la chaine "Ok" ou "Error".',
|
||||
);
|
||||
?>
|
||||
|
|
157
sources/lib/lang/template.php
Normal file
|
@ -0,0 +1,157 @@
|
|||
<?php
|
||||
$tr = array (
|
||||
/* index.php */
|
||||
'Jirafeau, your web file repository' => '',
|
||||
'Select a file' => '',
|
||||
'Send' => '',
|
||||
'Uploading ...' => '',
|
||||
'One time download' => '',
|
||||
'Password' => '',
|
||||
'Time limit' => '',
|
||||
'Maximum file size' => '',
|
||||
'powered by Open-Source project Jirafeau' => '',
|
||||
'Jirafeau Project' => '',
|
||||
'One minute' => '',
|
||||
'One hour' => '',
|
||||
'One day' => '',
|
||||
'One week' => '',
|
||||
'One month' => '',
|
||||
'One year' => '',
|
||||
'None' => '',
|
||||
'Upload password' => '',
|
||||
'File is too big' => '',
|
||||
'File size is limited to' => '',
|
||||
'The file directory is not writable' => '',
|
||||
'The link directory is not writable' => '',
|
||||
'The async directory is not writable!' => '',
|
||||
'Installer script still present' => '',
|
||||
'Please make sure to delete the installer script "install.php" before continuing.' => '',
|
||||
'An error occurred.' => '',
|
||||
'File uploaded !' => '',
|
||||
'Download page' => '',
|
||||
'This file is valid until the following date' => '',
|
||||
'View link' => '',
|
||||
'Direct download link' => '',
|
||||
'Delete link' => '',
|
||||
/* f.php */
|
||||
'Download' => '',
|
||||
'Preview' => '',
|
||||
'Sorry, the requested file is not found' => '',
|
||||
'File not available.' => '',
|
||||
'File has been deleted.' => '',
|
||||
'The time limit of this file has expired.' => '',
|
||||
'Password protection' => '',
|
||||
'Give the password of this file' => '',
|
||||
'Access denied' => '',
|
||||
'You are about to download' => '',
|
||||
'By using our services, you accept of our' => '',
|
||||
'Term Of Service' => '',
|
||||
/* functions.php */
|
||||
'Internal error during file creation.' => '',
|
||||
/* install.hpp */
|
||||
'This file was generated by the install process. You can edit it. Please see config.original.php to understand the configuration items.' => '',
|
||||
'The following directory could not be created' => '',
|
||||
'You should create this directory by hand.' => '',
|
||||
'The following directory is not writable' => '',
|
||||
'You should give the write right to the web server on this directory.' => '',
|
||||
'Here is a solution' => 'Une solution possible',
|
||||
'The local configuration file could not be created. Create a ' .
|
||||
'<code>lib/config.local.php</code> file and give the write ' .
|
||||
'right to the web server (preferred solution), or give the ' .
|
||||
'write right to the web server on the <code>lib</code> ' .
|
||||
'directory.' => '',
|
||||
'The local configuration is not writable by the web server. ' .
|
||||
'Give the write right to the web server on the ' .
|
||||
'<code>lib/config.local.php</code> file.' => '',
|
||||
'Installation of Jirafeau' => '',
|
||||
'step' => '',
|
||||
'out of' => '',
|
||||
'Administration password' => '',
|
||||
'Finalisation' => '',
|
||||
'Jirafeau is setting the website according to the configuration you provided.' => '',
|
||||
'Previous step' => '',
|
||||
'Retry this step' => '',
|
||||
'Jirafeau is now fully operational' => '',
|
||||
'Information' => '',
|
||||
'The base address of Jirafeau is the first part of the URL, until (and including) the last slash. For example: "http://www.example.com/". Do not forget the ending slash!'
|
||||
=> '',
|
||||
'Base address' => 'Addresse d\'origine',
|
||||
'The data directory is where your files and information about your files will be stored. You should put it outside your web site, or at least restrict the access of this directory. Do not forget the ending slash!'
|
||||
=> '',
|
||||
'Data directory' => '',
|
||||
'Jirafeau is internationalised. Choose a specific langage or choose Automatic (langage is provided by user\'s browser).'
|
||||
=> '',
|
||||
'Choose the default language' => '',
|
||||
'Next step' => '',
|
||||
'' .
|
||||
'You can set a password to access the intercace or let it be empty ' .
|
||||
'to disable the interface.' => '',
|
||||
'Administration password' => '',
|
||||
/* admin.php */
|
||||
'Sorry, the admin interface is not enabled.' => '',
|
||||
'Sorry, you are not authenticated on admin interface.' => '',
|
||||
'Login' => '',
|
||||
'Wrong password.' => '',
|
||||
'Admin interface' => '',
|
||||
'Clean expired files' => '',
|
||||
'Clean old unfinished transferts' => '',
|
||||
'Clean' => '',
|
||||
'Search files by name' => '',
|
||||
'Search' => '',
|
||||
'List all files' => '',
|
||||
'List' => '',
|
||||
'Actions' => '',
|
||||
'Search files by file hash' => '',
|
||||
'Search a specific link' => '',
|
||||
'Number of cleaned files' => '',
|
||||
'Logout' => 'Déconnexion',
|
||||
'You are now Logout' => '',
|
||||
'Link deleted' => '',
|
||||
'Filename' => '',
|
||||
'file' => '',
|
||||
'link' => '',
|
||||
'Type' => '',
|
||||
'Size' => '',
|
||||
'Expire' => '',
|
||||
'Onetime' => '',
|
||||
'Upload date' => '',
|
||||
'Origin' => '',
|
||||
'Action' => '',
|
||||
'Del link' => '',
|
||||
'Del file and links' => '',
|
||||
'Deleted links' => '',
|
||||
/* script.php */
|
||||
'Welcome to Jirafeau\'s query interface' => '',
|
||||
'This interface permits to script your uploads and downloads.' => '',
|
||||
'The instructions above show how to query this interface.' => '',
|
||||
'Get server capacity' => '',
|
||||
'Maximal allowed size of an uploaded file' => '',
|
||||
'First line returns size (in MB).' => '',
|
||||
'Get Jirafeau\'s version' => '',
|
||||
'Send a GET query to' => '',
|
||||
'Send a POST query to' => '',
|
||||
'Upload a file' => '',
|
||||
'Get a file' => '',
|
||||
'Required' => '',
|
||||
'Optional' => '',
|
||||
'Parameters' => '',
|
||||
'This will return brut text content.' => '',
|
||||
'First line is the download reference and the second line the delete code.' => '',
|
||||
'First line is the server capacity (in Bytes).' => '',
|
||||
'Example' => 'Exemple',
|
||||
'If a password has been set, send a POST request with it.' => '',
|
||||
'Delete a file' => '',
|
||||
'This will return "Ok" if succeded, "Error" otherwhise.' => '',
|
||||
'Get a generated scripts' => '',
|
||||
'This will return brut text content of the code.' => '',
|
||||
'Initalize an asynchronous transfert' => '',
|
||||
'The goal is to permit to transfert big file, chunk by chunk.' => '',
|
||||
'Chunks of data must be sent in order.' => '',
|
||||
'First line is the asynchronous transfert reference and the second line the code to use in the next operation.'
|
||||
=> '',
|
||||
'Push data during asynchronous transfert' => '',
|
||||
'Returns the next code to use.' => '',
|
||||
'Finalize asynchronous transfert' => '',
|
||||
'This will return "Ok" or "Error" string.' => '',
|
||||
);
|
||||
?>
|
|
@ -24,7 +24,6 @@ define ('JIRAFEAU_VERSION', '1.0');
|
|||
define ('VAR_FILES', $cfg['var_root'] . 'files/');
|
||||
define ('VAR_LINKS', $cfg['var_root'] . 'links/');
|
||||
define ('VAR_ASYNC', $cfg['var_root'] . 'async/');
|
||||
define ('VAR_BLOCK', $cfg['var_root'] . 'block/');
|
||||
|
||||
/* Useful constants. */
|
||||
if (!defined ('NL'))
|
||||
|
@ -36,5 +35,6 @@ define ('JIRAFEAU_HOUR', 3600); // JIRAFEAU_MINUTE * 60
|
|||
define ('JIRAFEAU_DAY', 86400); // JIRAFEAU_HOUR * 24
|
||||
define ('JIRAFEAU_WEEK', 604800); // JIRAFEAU_DAY * 7
|
||||
define ('JIRAFEAU_MONTH', 2419200); // JIRAFEAU_WEEK * 4
|
||||
define ('JIRAFEAU_YEAR', 29030400); // JIRAFEAU_MONTH * 12
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
<div id="copyright">
|
||||
<p><a href="https://gitorious.org/jirafeau"></a><br /><a href="http://www.gnu.org/licenses/agpl.html">agplv3</a> | <a href="https://gitorious.org/jirafeau">Jirafeau Project</a> | <a href="<?php echo $cfg['web_root'] . '/tos.php'; ?>">Terms of Service</a></p>
|
||||
<p><a href="https://gitlab.com/mojo42/Jirafeau/wikis/home"></a><br /><a href="http://www.gnu.org/licenses/agpl.html">agplv3</a> | <a href="https://gitlab.com/mojo42/Jirafeau/wikis/home">Jirafeau Project</a> | <a href="<?php echo $cfg['web_root'] . '/tos.php'; ?>">Terms of Service</a></p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="jyraphe">
|
||||
|
|
|
@ -8,9 +8,15 @@ if (stristr ($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml'))
|
|||
|
||||
header('Content-Type: ' . $content_type);
|
||||
|
||||
$protocol = (bool)is_ssl() ? 'https' : 'http';
|
||||
|
||||
if ( !empty($cfg['web_root']) ) {
|
||||
$cfg['web_root'] = preg_replace('#https?://#', $protocol . '://', $cfg['web_root'], 1);
|
||||
}
|
||||
|
||||
/* Avoids irritating errors with the installer (no conf file is present then). */
|
||||
if (!isset ($cfg['web_root']))
|
||||
$web_root = 'http://' . $_SERVER['HTTP_HOST'] . '/';
|
||||
$web_root = $protocol+'://' . $_SERVER['HTTP_HOST'] . '/';
|
||||
else
|
||||
$web_root = $cfg['web_root'];
|
||||
|
||||
|
@ -29,6 +35,6 @@ else
|
|||
<link href="<?php echo $web_root . 'media/' . $style . '/style.css.php'; ?>" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<script language="Javascript" src="lib/functions.js"></script>
|
||||
<script language="Javascript" src="lib/functions_v3.js"></script>
|
||||
<div id="content">
|
||||
<h1><a href="<?php echo $web_root; ?>"><?php echo t('Jirafeau, your web file repository'); ?></a></h1>
|
||||
|
|
|
@ -38,6 +38,7 @@ header("Content-type: text/css");
|
|||
3 = Options
|
||||
4 = Upload
|
||||
5 = Terms of service
|
||||
6 = Admin
|
||||
|
||||
========================================================================== */
|
||||
|
||||
|
@ -45,12 +46,6 @@ header("Content-type: text/css");
|
|||
1 = Basic Style
|
||||
========================================================================== */
|
||||
|
||||
* {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #efebe9;
|
||||
font-family: Arial, sans-serif;
|
||||
|
@ -66,6 +61,8 @@ h1 a {
|
|||
width: 194px;
|
||||
height: 185px;
|
||||
margin: 1em auto;
|
||||
position: relative;
|
||||
left: 0.4em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
|
@ -77,10 +74,11 @@ fieldset {
|
|||
border: 0;
|
||||
padding: 1.5em;
|
||||
margin: 0 auto;
|
||||
border-radius: 2px;
|
||||
width: 25em;
|
||||
border-radius: 8px;
|
||||
width: 20em;
|
||||
border: 7px dashed #bcaaa4;
|
||||
min-height: 17em;
|
||||
min-height: 15em;
|
||||
min-width: 30em;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
|
@ -90,10 +88,17 @@ legend {
|
|||
color: #663D1C;
|
||||
font-size: 1.2em;
|
||||
display: block;
|
||||
width: 100%;
|
||||
min-width: 8em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
table a { color: #000;}
|
||||
|
||||
table a:hover,
|
||||
table a:focus {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
input[type="submit"] {
|
||||
background: #0D9CB2;
|
||||
border: 0;
|
||||
|
@ -102,68 +107,27 @@ input[type="submit"] {
|
|||
color: #FFF;
|
||||
border-bottom: 5px solid #085B69;
|
||||
cursor: pointer;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
select,
|
||||
input[type="text"],
|
||||
input[type="password"] {
|
||||
border: 1;
|
||||
padding: 5px 5px;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
select { width: 100%; }
|
||||
|
||||
input[type="submit"]:hover,
|
||||
input[type="submit"]:focus {
|
||||
border: 0;
|
||||
position: relative;
|
||||
top: 5px;
|
||||
margin-bottom: 5px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
select,
|
||||
input[type="text"],
|
||||
input[type="password"] {
|
||||
border: 0;
|
||||
padding: 0.5em 1em;
|
||||
font-size: 1em;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
label {
|
||||
font-weight: bold;
|
||||
color: #663D1C;
|
||||
}
|
||||
|
||||
#upload_password { width: 80%; }
|
||||
|
||||
.next input[type="submit"] {
|
||||
position: relative;
|
||||
margin-top: 0.5em;
|
||||
padding: 0.4em 2.65em;
|
||||
}
|
||||
|
||||
input[value="Déconnexion"] {
|
||||
background: none;
|
||||
color: #663D1C;
|
||||
border: 0;
|
||||
display: block;
|
||||
margin: auto;
|
||||
padding-left: 4em;
|
||||
font-size: 1em;
|
||||
font-style:italic;
|
||||
}
|
||||
|
||||
input[value="Déconnexion"]:hover,
|
||||
input[value="Déconnexion"]:focus {
|
||||
top: 0;
|
||||
margin-bottom: 0;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
form[action="index.php"] .label {
|
||||
width: 7em;
|
||||
}
|
||||
|
||||
form[action="index.php"] fieldset {
|
||||
border: 0;
|
||||
background: #d7ccc8;
|
||||
min-height: 5em;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.inner {
|
||||
margin-top: 3em;
|
||||
}
|
||||
|
@ -181,6 +145,10 @@ form[action="index.php"] fieldset {
|
|||
border-color: #663D1C;
|
||||
}
|
||||
|
||||
#upload > form {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#file_select {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
@ -201,6 +169,7 @@ form[action="index.php"] fieldset {
|
|||
text-align: center;
|
||||
font-size: 0.8em;
|
||||
color: #795548;
|
||||
padding-left: 3em;
|
||||
}
|
||||
|
||||
#copyright a {
|
||||
|
@ -221,18 +190,18 @@ form[action="index.php"] fieldset {
|
|||
position: relative;
|
||||
z-index: 10;
|
||||
background: #efebe9;
|
||||
width: 100%;
|
||||
height: 90%;
|
||||
}
|
||||
|
||||
#options tr { height: 2.7em; }
|
||||
|
||||
#option_table tr:first-child td:first-child {
|
||||
width: 12em;
|
||||
font-weight: bold;
|
||||
color: #663D1C;
|
||||
#option_table tr:first-child {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#option_table tr td:first-child {
|
||||
|
||||
#option_table td:first-child {
|
||||
}
|
||||
|
||||
#options input[type="submit"] {
|
||||
|
@ -250,20 +219,16 @@ form[action="index.php"] fieldset {
|
|||
.error {
|
||||
text-align: center;
|
||||
color: #795548;
|
||||
padding-left: 3em;
|
||||
}
|
||||
|
||||
#upload_finished a,
|
||||
#uploading a,
|
||||
#submit a {
|
||||
#uploading a {
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
color: #795548;
|
||||
}
|
||||
|
||||
#submit a:before {
|
||||
content: "› ";
|
||||
}
|
||||
|
||||
#uploaded_percentage {
|
||||
font-size: 2em;
|
||||
font-weight: bold;
|
||||
|
@ -272,28 +237,15 @@ form[action="index.php"] fieldset {
|
|||
#upload_finished a:hover,
|
||||
#uploading a:hover,
|
||||
#upload_finished a:focus,
|
||||
#uploading a:focus,
|
||||
#submit a:hover,
|
||||
#submit a:focus {
|
||||
#uploading a:focus {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.message,
|
||||
.error {
|
||||
color: #d55548;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#submit tr:first-child td:first-child {
|
||||
font-weight: bold;
|
||||
color: #795548;
|
||||
}
|
||||
|
||||
#submit tr + tr td {
|
||||
padding-top: 1em;
|
||||
}
|
||||
|
||||
#submit td {
|
||||
color: #795548;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
|
@ -330,3 +282,72 @@ textarea[readonly="readonly"] + p a:focus,
|
|||
textarea[readonly="readonly"] + p + p a:focus {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
6 = Admin
|
||||
========================================================================== */
|
||||
|
||||
#install fieldset,
|
||||
#install + fieldset {
|
||||
width: auto;
|
||||
max-width: 50em;
|
||||
border: 7px dashed #bcaaa4;
|
||||
}
|
||||
|
||||
#install table,
|
||||
#install + fieldset table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
border-bottom: 2px solid #FFF;
|
||||
}
|
||||
|
||||
#install td,
|
||||
#install + fieldset td {
|
||||
padding: 0.5em 1em;
|
||||
border: 2px solid #FFF;
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
#install td:empty {
|
||||
width: 13.1em;
|
||||
}
|
||||
|
||||
#install table form:nth-child(odd),
|
||||
#install + fieldset tr:nth-child(odd) {
|
||||
background: #bcaaa4;
|
||||
}
|
||||
|
||||
#install fieldset > form {
|
||||
margin-top: 2em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#install form {
|
||||
display: table;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#install td:last-child { text-align: left; }
|
||||
|
||||
#install .info { width: 19em; }
|
||||
|
||||
#install input[type="submit"] {
|
||||
min-width: 10.5em;
|
||||
}
|
||||
|
||||
#install + fieldset table {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
#install + fieldset td:first-child input[type="submit"] {
|
||||
background: none;
|
||||
padding: 0;
|
||||
color: #000;
|
||||
font-weight: bold;
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
#install + fieldset td:first-child input[type="submit"]:hover,
|
||||
#install + fieldset td:first-child input[type="submit"]:focus {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
|
0
sources/media/industrial/bandeau.png
Executable file → Normal file
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 2 KiB |
0
sources/media/industrial/error.png
Executable file → Normal file
Before Width: | Height: | Size: 525 B After Width: | Height: | Size: 525 B |
0
sources/media/industrial/jyraphe.png
Executable file → Normal file
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
0
sources/media/industrial/ok.png
Executable file → Normal file
Before Width: | Height: | Size: 492 B After Width: | Height: | Size: 492 B |
8
sources/media/industrial/style.css.php
Executable file → Normal file
|
@ -158,13 +158,7 @@ input:hover {
|
|||
margin-right: 5%;
|
||||
}
|
||||
|
||||
#upload {
|
||||
text-align: center;
|
||||
width: 30em;
|
||||
background: #E2f5ff;
|
||||
border: 2px solid #02233f;
|
||||
margin: auto;
|
||||
}
|
||||
#upload {}
|
||||
|
||||
#uploading {
|
||||
text-align: center;
|
||||
|
|
Before Width: | Height: | Size: 525 B After Width: | Height: | Size: 525 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 492 B After Width: | Height: | Size: 492 B |
0
sources/media/modern/bandeau.png
Executable file → Normal file
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 2 KiB |
0
sources/media/modern/error.png
Executable file → Normal file
Before Width: | Height: | Size: 729 B After Width: | Height: | Size: 729 B |
0
sources/media/modern/jyraphe.png
Executable file → Normal file
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
0
sources/media/modern/ok.png
Executable file → Normal file
Before Width: | Height: | Size: 688 B After Width: | Height: | Size: 688 B |
6
sources/media/modern/style.css.php
Executable file → Normal file
|
@ -81,6 +81,12 @@ h1 a {
|
|||
color: #333;
|
||||
}
|
||||
|
||||
h2 {
|
||||
text-decoration: none;
|
||||
color: #333;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
fieldset p {
|
||||
margin-left: 25%;
|
||||
}
|
||||
|
|
196
sources/script.php
Executable file → Normal file
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Jirafeau, your web file repository
|
||||
* Copyright (C) 2012 Jerome Jutteau <j.jutteau@gmail.com>
|
||||
* Copyright (C) 2015 Jerome Jutteau <j.jutteau@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
|
@ -43,7 +43,7 @@ require (JIRAFEAU_ROOT . 'lib/lang.php');
|
|||
if ($_SERVER['REQUEST_METHOD'] == "GET" && count ($_GET) == 0)
|
||||
{
|
||||
require (JIRAFEAU_ROOT . 'lib/template/header.php');
|
||||
check_errors ();
|
||||
check_errors ($cfg);
|
||||
if (has_error ())
|
||||
{
|
||||
show_errors ();
|
||||
|
@ -83,15 +83,29 @@ if ($_SERVER['REQUEST_METHOD'] == "GET" && count ($_GET) == 0)
|
|||
echo t('Example') . ": <a href=\"" . $web_root . "script.php?get_capacity=1\">" . $web_root . "script.php?get_capacity=1</a> ";
|
||||
echo '</p>';
|
||||
|
||||
echo '<h3>' . t('Maximal allowed size of an uploaded file') . ':</h3>';
|
||||
echo '<p>';
|
||||
echo t('Send a GET query to') . ': <i>' . $web_root . 'script.php</i><br />';
|
||||
echo '<br />';
|
||||
echo t('Parameters') . ':<br />';
|
||||
echo "<b>get_maximal_upload_size=</b>1<i> (" . t('Required') . ")</i> <br />";
|
||||
echo '</p>';
|
||||
echo '<p>' . t('This will return brut text content.') . ' ' .
|
||||
t('First line returns size (in MB).') . '<br /></p>';
|
||||
echo '<p>';
|
||||
echo t('Example') . ": <a href=\"" . $web_root . "script.php?get_maximal_upload_size=1\">" . $web_root . "script.php?get_maximal_upload_size=1</a> ";
|
||||
echo '</p>';
|
||||
|
||||
echo '<h3>' . t('Upload a file') . ':</h3>';
|
||||
echo '<p>';
|
||||
echo t('Send a POST query to') . ': <i>' . $web_root . 'script.php</i><br />';
|
||||
echo '<br />';
|
||||
echo t('Parameters') . ':<br />';
|
||||
echo "<b>file=</b>C:\\your\\file\\path<i> (" . t('Required') . ")</i> <br />";
|
||||
echo "<b>time=</b>[minute|hour|day|week|month|none]<i> (" . t('Optional') . ', '. t('default: none') . ")</i> <br />";
|
||||
echo "<b>time=</b>[minute|hour|day|week|month|year|none]<i> (" . t('Optional') . ', '. t('default: none') . ")</i> <br />";
|
||||
echo "<b>password=</b>your_password<i> (" . t('Optional') . ")</i> <br />";
|
||||
echo "<b>one_time_download=</b>1<i> (" . t('Optional') . ")</i> <br />";
|
||||
echo "<b>upload_password=</b>your_upload_password<i> (" . t('Optional') . ")</i> <br />";
|
||||
echo '</p>';
|
||||
echo '<p>' . t('This will return brut text content.') . ' ' .
|
||||
t('First line is the download reference and the second line the delete code.') . '<br /></p>';
|
||||
|
@ -143,7 +157,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET" && count ($_GET) == 0)
|
|||
echo "$name: <a href=\"" . $web_root . "script.php?lang=$lang\">" . $web_root . "script.php?lang=$lang</a> ";
|
||||
echo '</p>';
|
||||
|
||||
echo '<h3>' . t('Initalize a asynchronous transfert') . ':</h3>';
|
||||
echo '<h3>' . t('Initalize an asynchronous transfert') . ':</h3>';
|
||||
echo '<p>';
|
||||
echo t('The goal is to permit to transfert big file, chunk by chunk.') . ' ';
|
||||
echo t('Chunks of data must be sent in order.');
|
||||
|
@ -154,9 +168,10 @@ if ($_SERVER['REQUEST_METHOD'] == "GET" && count ($_GET) == 0)
|
|||
echo t('Parameters') . ':<br />';
|
||||
echo "<b>filename=</b>file_name.ext<i> (" . t('Required') . ")</i> <br />";
|
||||
echo "<b>type=</b>MIME_TYPE<i> (" . t('Optional') . ")</i> <br />";
|
||||
echo "<b>time=</b>[minute|hour|day|week|month|none]<i> (" . t('Optional') . ', '. t('default: none') . ")</i> <br />";
|
||||
echo "<b>time=</b>[minute|hour|day|week|month|year|none]<i> (" . t('Optional') . ', '. t('default: none') . ")</i> <br />";
|
||||
echo "<b>password=</b>your_password<i> (" . t('Optional') . ")</i> <br />";
|
||||
echo "<b>one_time_download=</b>1<i> (" . t('Optional') . ")</i> <br />";
|
||||
echo "<b>upload_password=</b>your_upload_password<i> (" . t('Optional') . ")</i> <br />";
|
||||
echo '</p>';
|
||||
echo '<p>' . 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.') . '<br /></p>';
|
||||
|
@ -184,66 +199,6 @@ if ($_SERVER['REQUEST_METHOD'] == "GET" && count ($_GET) == 0)
|
|||
echo '<p>' . t('This will return brut text content.') . ' ' .
|
||||
t('First line is the download reference and the second line the delete code.') . '<br /></p>';
|
||||
|
||||
if ($cfg['enable_blocks'])
|
||||
{
|
||||
echo '<h3>' . t('Create a data block') . ':</h3>';
|
||||
echo '<p>';
|
||||
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 '</p>';
|
||||
echo '<p>';
|
||||
echo t('Send a GET query to') . ': <i>' . $web_root . 'script.php?init_block</i><br />';
|
||||
echo '<br />';
|
||||
echo t('Parameters') . ':<br />';
|
||||
echo "<b>size=</b>size_in_bytes<i> (" . t('Required') . ")</i> <br />";
|
||||
echo '</p>';
|
||||
echo '<p>' . t('This will return brut text content.') . ' ' .
|
||||
t('First line is a block id the second line the edit/delete code.') . '<br /></p>';
|
||||
|
||||
echo '<h3>' . t('Get block size') . ':</h3>';
|
||||
echo '<p>';
|
||||
echo t('Send a GET query to') . ': <i>' . $web_root . 'script.php?get_block_size</i><br />';
|
||||
echo '<br />';
|
||||
echo t('Parameters') . ':<br />';
|
||||
echo "<b>id=</b>block_id<i> (" . t('Required') . ")</i> <br />";
|
||||
echo '</p>';
|
||||
echo '<p>' . t('This will return asked data or "Error" string.') . '<br /></p>';
|
||||
|
||||
echo '<h3>' . t('Read data in a block') . ':</h3>';
|
||||
echo '<p>';
|
||||
echo t('Send a GET query to') . ': <i>' . $web_root . 'script.php?read_block</i><br />';
|
||||
echo '<br />';
|
||||
echo t('Parameters') . ':<br />';
|
||||
echo "<b>id=</b>block_id<i> (" . t('Required') . ")</i> <br />";
|
||||
echo "<b>start=</b>byte_position_starting_from_zero<i> (" . t('Required') . ")</i> <br />";
|
||||
echo "<b>length=</b>length_to_read_in_bytes<i> (" . t('Required') . ")</i> <br />";
|
||||
echo '</p>';
|
||||
echo '<p>' . t('This will return asked data or "Error" string.') . '<br /></p>';
|
||||
|
||||
echo '<h3>' . t('Write data in a block') . ':</h3>';
|
||||
echo '<p>';
|
||||
echo t('Send a GET query to') . ': <i>' . $web_root . 'script.php?write_block</i><br />';
|
||||
echo '<br />';
|
||||
echo t('Parameters') . ':<br />';
|
||||
echo "<b>id=</b>block_id<i> (" . t('Required') . ")</i> <br />";
|
||||
echo "<b>code=</b>block_code<i> (" . t('Required') . ")</i> <br />";
|
||||
echo "<b>start=</b>byte_position_starting_from_zero<i> (" . t('Required') . ")</i> <br />";
|
||||
echo "<b>data=</b>data_to_write<i> (" . t('Required') . ")</i> <br />";
|
||||
echo '</p>';
|
||||
echo '<p>' . t('This will return "Ok" or "Error" string.') . '<br /></p>';
|
||||
|
||||
echo '<h3>' . t('Delete a block') . ':</h3>';
|
||||
echo '<p>';
|
||||
echo t('Send a GET query to') . ': <i>' . $web_root . 'script.php?delete_block</i><br />';
|
||||
echo '<br />';
|
||||
echo t('Parameters') . ':<br />';
|
||||
echo "<b>id=</b>block_id<i> (" . t('Required') . ")</i> <br />";
|
||||
echo "<b>code=</b>block_code<i> (" . t('Required') . ")</i> <br />";
|
||||
echo '</p>';
|
||||
echo '<p>' . t('This will return "Ok" or "Error" string.') . '<br /></p>';
|
||||
}
|
||||
|
||||
echo '</div><br />';
|
||||
require (JIRAFEAU_ROOT . 'lib/template/footer.php');
|
||||
exit;
|
||||
|
@ -252,7 +207,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET" && count ($_GET) == 0)
|
|||
/* Lets use interface now. */
|
||||
header('Content-Type: text; charset=utf-8');
|
||||
|
||||
check_errors ();
|
||||
check_errors ($cfg);
|
||||
if (has_error ())
|
||||
{
|
||||
echo "Error";
|
||||
|
@ -263,7 +218,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;
|
||||
|
@ -274,8 +231,11 @@ if (isset ($_FILES['file']) && is_writable (VAR_FILES)
|
|||
$key = $_POST['key'];
|
||||
|
||||
$time = time ();
|
||||
if (!isset ($_POST['time']))
|
||||
$time = JIRAFEAU_INFINITY;
|
||||
if (!isset ($_POST['time']) || !$cfg['availabilities'][$_POST['time']])
|
||||
{
|
||||
echo "Error";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
switch ($_POST['time'])
|
||||
{
|
||||
|
@ -294,10 +254,22 @@ if (isset ($_FILES['file']) && is_writable (VAR_FILES)
|
|||
case 'month':
|
||||
$time += JIRAFEAU_MONTH;
|
||||
break;
|
||||
case 'year':
|
||||
$time += JIRAFEAU_YEAR;
|
||||
break;
|
||||
default:
|
||||
$time = JIRAFEAU_INFINITY;
|
||||
break;
|
||||
}
|
||||
|
||||
// Check file size
|
||||
if ($cfg['maximal_upload_size'] > 0 &&
|
||||
$_FILES['file']['size'] > $cfg['maximal_upload_size'] * 1024 * 1024)
|
||||
{
|
||||
echo "Error";
|
||||
exit;
|
||||
}
|
||||
|
||||
$res = jirafeau_upload ($_FILES['file'],
|
||||
isset ($_POST['one_time_download']),
|
||||
$key, $time, $_SERVER['REMOTE_ADDR'],
|
||||
|
@ -386,6 +358,10 @@ elseif (isset ($_GET['get_capacity']))
|
|||
echo min (jirafeau_ini_to_bytes (ini_get ('post_max_size')),
|
||||
jirafeau_ini_to_bytes (ini_get ('upload_max_filesize')));
|
||||
}
|
||||
elseif (isset ($_GET['get_maximal_upload_size']))
|
||||
{
|
||||
echo $cfg['maximal_upload_size'];
|
||||
}
|
||||
elseif (isset ($_GET['get_version']))
|
||||
{
|
||||
echo JIRAFEAU_VERSION;
|
||||
|
@ -404,7 +380,7 @@ elseif (isset ($_GET['lang']))
|
|||
# Config
|
||||
proxy='' # ex: proxy='proxysever.test.com:3128' or set JIRAFEAU_PROXY global variable
|
||||
url='<?php echo $cfg['web_root'] . 'script.php'; ?>' # or set JIRAFEAU_URL ex: url='http://mysite/jirafeau/script.php'
|
||||
time='none' # minute, hour, day, week, month or none. Or set JIRAFEAU_TIME.
|
||||
time='none' # minute, hour, day, week, month, year or none. Or set JIRAFEAU_TIME.
|
||||
one_time='' # ex: one_time="1" or set JIRAFEAU_ONE_TIME.
|
||||
curl='' # curl path to download or set JIRAFEAU_CURL_PATH.
|
||||
# End of config
|
||||
|
@ -455,7 +431,7 @@ if [ -z "$2" ]; then
|
|||
echo "Global variables to export:"
|
||||
echo " JIRAFEAU_PROXY : example: proxysever.test.com:3128"
|
||||
echo " JIRAFEAU_URL : example: http://mysite/jirafeau/script.php"
|
||||
echo " JIRAFEAU_TIME : minute, hour, day, week, month or none"
|
||||
echo " JIRAFEAU_TIME : minute, hour, day, week, year, month or none"
|
||||
echo " JIRAFEAU_ONE_TIME : set anything or set empty"
|
||||
echo " JIRAFEAU_CURL : path to your curl binary"
|
||||
|
||||
|
@ -529,7 +505,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;
|
||||
|
@ -546,12 +524,15 @@ elseif (isset ($_GET['init_async']))
|
|||
$type = $_POST['type'];
|
||||
|
||||
$key = '';
|
||||
if (isset ($_POST['password']))
|
||||
$key = $_POST['password'];
|
||||
if (isset ($_POST['key']))
|
||||
$key = $_POST['key'];
|
||||
|
||||
$time = time ();
|
||||
if (!isset ($_POST['time']))
|
||||
$time = JIRAFEAU_INFINITY;
|
||||
if (!isset ($_POST['time']) || !$cfg['availabilities'][$_POST['time']])
|
||||
{
|
||||
echo "Error";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
switch ($_POST['time'])
|
||||
{
|
||||
|
@ -570,6 +551,9 @@ elseif (isset ($_GET['init_async']))
|
|||
case 'month':
|
||||
$time += JIRAFEAU_MONTH;
|
||||
break;
|
||||
case 'year':
|
||||
$time += JIRAFEAU_YEAR;
|
||||
break;
|
||||
default:
|
||||
$time = JIRAFEAU_INFINITY;
|
||||
break;
|
||||
|
@ -589,7 +573,12 @@ elseif (isset ($_GET['push_async']))
|
|||
|| (!isset ($_POST['code'])))
|
||||
echo "Error";
|
||||
else
|
||||
echo jirafeau_async_push ($_POST['ref'], $_FILES['data'], $_POST['code']);
|
||||
{
|
||||
echo jirafeau_async_push ($_POST['ref'],
|
||||
$_FILES['data'],
|
||||
$_POST['code'],
|
||||
$cfg['maximal_upload_size']);
|
||||
}
|
||||
}
|
||||
/* Finalize an asynchronous upload. */
|
||||
elseif (isset ($_GET['end_async']))
|
||||
|
@ -600,59 +589,8 @@ 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;
|
||||
?>
|
||||
|
||||
|
|