Security: we can now upload any type of file no matter how they are named.
Bug fix: in Jyraphe 0.5 stable, we were not able to add several times the same file with a different link file.
+++ /dev/null
-# Jyraphe, your web file repository
-# Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
-#
-# 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/>.
-
-WD="`dirname $0`"
-
-rm -f ${WD}/files/* ${WD}/links/* ${WD}/pub/*
+++ /dev/null
-Jyraphe, your web file repository
-=================================
-
-Jyraphe is a web application of file repository, easy to install and easy to
-use. Jyraphe is an entirely free application, it is distributed under the
-terms of the GNU Affero General Public License, version 3 or later. See the
-COPYING file in this directory.
-
-For more information, see:
-http://home.gna.org/jyraphe/
-
-Jyraphe 0.4 (20 april 2009)
----------------------------
-
- - SECURITY: possible path traversal by uploading a file R0...0 (32 zeroes)
- and calling file.php?h=../files/R0..0
- - BUG: possibility to download a protected file without a key
- - FEATURE: better form (without tables)
-
-
-Jyraphe 0.3 (28 may 2008)
--------------------------
- - SECURITY: a forged link file could be uploaded and accessed with
- get.php?h=../files/forgedfile so that any readable file could be accessed
- - FEATURE: install.php script with randomised name of the var/ directory
- - FEATURE: password protection
- - FEATURE: time limit
- - FEATURE: Javascript to show the extended options
- - FEATURE: support for multiple CSS and better handling of images in the css
- - FEATURE: better Content-Type handling and XHTML validation
- - SECURITY: now prevent .php from upload, rename it in .phps
- - FEATURE: renamed get.php in file.php (in prevision of thumb.php)
-
-
-Jyrahe 0.2 (22 april 2008)
---------------------------
- - SECURITY: .htaccess could be uploaded and change the access of var/
- - BUG: infinite loop when renaming a file in case of a collision
- - BUG: warning of the substr_compare when null mime-type
- - BUG: substr_compare not defined for old PHP4
-
-
-Jyraphe 0.1 (12 april 2008)
----------------------------
- - First release of Jyraphe
- - KNOWN BUG: when not defining $cgf['web_root'] in config.local.php, and
- having $cfg['use_redirect'] = true, the CSS does not appear in case of 404
- error. Workaround: define $cgf['web_root'] in your config.local.php
+++ /dev/null
-for next release
-
-- [feature] refactoring
-- [feature] help links near the features that redirect on the documentation
-- [feature] $cfg['trash']: put in trash/ or really delete
-- [bug] in case of password, the true name is not sent (due to the HTTP POST request?)
- see phpmyadmin and the dump function to see how it works for them - Cannot reproduce
-- [bug] true name even in case of viewable files
-
-
-if I have time
-
-- [doc] split the doc -> index(about)/user/hacker/developper
-- [doc] add a note on the version number
-- [doc] update and improve developper doc
-
-
-later, much later (if people ask for it)
-
-- [feature] upload progress
- http://www.haughin.com/2007/10/23/php-upload-progress-with-php-52-apc/
-- [feature] mail to the uploader
-- [feature] mini images and icons (Entilope aka thumb.php)
-- [feature] a list of the present files and possibility to purge them
-- [feature] an XML-RPC interface
+++ /dev/null
-# Jyraphe, your web file repository
-# Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
-#
-# 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/>.
-
-# This file prevents people to explore this directory
-# For Apache httpd, you need to have the following line in yo configuration:
-# AllowOverride Limit
-# If you can, uncomment the following lines:
-
-# Order deny,allow
-# Deny from all
--- /dev/null
+<?php
+/*
+ * Jirafeau, your web file repository
+ * Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
+ * 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/>.
+ */
+
+define('JIRAFEAU_ROOT', dirname(__FILE__) . '/');
+
+require(JIRAFEAU_ROOT . 'lib/config.php');
+require(JIRAFEAU_ROOT . 'lib/settings.php');
+require(JIRAFEAU_ROOT . 'lib/functions.php');
+
+if(isset($_GET['h']) && !empty($_GET['h'])) {
+ $link_name = $_GET['h'];
+
+ if(!ereg('[0-9a-f]{32}$', $link_name)) {
+ header("HTTP/1.0 404 Not Found");
+
+ require(JIRAFEAU_ROOT . 'lib/template/header.php');
+ echo '<div class="error"><p>Error 404: Not Found</p></div>';
+ require(JIRAFEAU_ROOT . 'lib/template/footer.php');
+ exit;
+ }
+
+ $link_file = VAR_LINKS . $link_name;
+ if(file_exists($link_file)) {
+ $content = file($link_file);
+ $file_name = trim($content[0]);
+ $mime_type = trim($content[1]);
+ $file_size = trim($content[2]);
+ $key = trim($content[3], NL);
+ $time = trim($content[4]);
+ $md5 = trim($content[5]);
+ $onetime = trim($content[6]);
+
+ if(!file_exists(VAR_FILES . $md5)) {
+ if (file_exists(VAR_FILES . $md5 . '_count')) {
+ unlink(VAR_FILES . $md5 . '_count');
+ }
+ unlink($link_file);
+ require(JIRAFEAU_ROOT . 'lib/template/header.php');
+ echo '<div class="error"><p>' . _('File not available.') . '</p></div>';
+ require(JIRAFEAU_ROOT . 'lib/template/footer.php');
+ exit;
+ }
+
+ $counter = 1;
+ if (file_exists(VAR_FILES . $md5 . '_count')) {
+ $content = file(VAR_FILES . $md5 . '_count');
+ $counter = trim($content[0], NL);
+ }
+
+ if($time != JIRAFEAU_INFINITY) {
+ if(time() > $time) {
+ unlink($link_file);
+
+ $counter--;
+ if ($counter >= 1) {
+ $handle = fopen(VAR_FILES . $md5 . '_count', 'w');
+ fwrite($handle, $counter);
+ fclose($handle);
+ }
+ elseif ($counter == 0) {
+ if (file_exists(VAR_FILES . $md5 . '_count')) {
+ unlink(VAR_FILES . $md5 . '_count');
+ }
+ $new_name = jirafeau_detect_collision($md5 . '_' . $file_name, VAR_TRASH);
+ rename(VAR_FILES . $md5, VAR_TRASH . $new_name);
+ }
+
+ require(JIRAFEAU_ROOT . 'lib/template/header.php');
+ echo '<div class="error"><p>' . _('The time limit of this file has expired. It has been deleted.') . '</p></div>';
+ require(JIRAFEAU_ROOT . 'lib/template/footer.php');
+ exit;
+ }
+ }
+
+ if(!empty($key)) {
+ if(!isset($_POST['key'])) {
+ require(JIRAFEAU_ROOT . 'lib/template/header.php');
+?>
+<div id="upload">
+<form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
+<input type="hidden" name="jirafeau" value="<?php echo JIRAFEAU_VERSION; ?>" />
+<fieldset>
+ <legend><?php echo _('Key protection'); ?></legend>
+ <table>
+ <tr>
+ <td><?php echo _('Give the key of this file:'); ?> <input type="password" name="key" /></td>
+ </tr>
+ <tr>
+ <td><input type="submit" value="<?php echo _('I have the right to download this file'); ?>" /></td>
+ </tr>
+ </table>
+</fieldset>
+</form>
+</div>
+<?php
+ require(JIRAFEAU_ROOT . 'lib/template/footer.php');
+ exit;
+ } else {
+ if($key != $_POST['key']) {
+ header("HTTP/1.0 403 Forbidden");
+
+ require(JIRAFEAU_ROOT . 'lib/template/header.php');
+ echo '<div class="error"><p>Error 403: Forbidden</p></div>';
+ require(JIRAFEAU_ROOT . 'lib/template/footer.php');
+ exit;
+ }
+ }
+ }
+
+ header('Content-Length: ' . $file_size);
+ header('Content-Type: ' . $mime_type);
+ if(!jirafeau_is_viewable($mime_type)) {
+ header('Content-Disposition: attachment; filename="' . $file_name . '"');
+ }
+ readfile(VAR_FILES . $md5);
+
+ if($onetime == 'O') {
+ unlink($link_file);
+
+ $counter--;
+ if ($counter >= 1) {
+ $handle = fopen(VAR_FILES . $md5 . '_count', 'w');
+ fwrite($handle, $counter);
+ fclose($handle);
+ }
+ elseif ($counter == 0) {
+ if (file_exists(VAR_FILES . $md5 . '_count')) {
+ unlink(VAR_FILES . $md5 . '_count');
+ }
+ $new_name = jirafeau_detect_collision($md5 . '_' . $file_name, VAR_TRASH);
+ rename(VAR_FILES . $md5, VAR_TRASH . $new_name);
+ }
+ }
+ exit;
+ } else {
+ header("HTTP/1.0 404 Not Found");
+
+ require(JIRAFEAU_ROOT . 'lib/template/header.php');
+ echo '<div class="error"><p>Error 404: Not Found</p></div>';
+ require(JIRAFEAU_ROOT . 'lib/template/footer.php');
+ exit;
+ }
+} else {
+ header('Location: ' . $cfg['web_root']);
+ exit;
+}
+
+?>
<?php
/*
- * Jyraphe, your web file repository
+ * Jirafeau, your web file repository
* Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
+ * 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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-define('JYRAPHE_ROOT', dirname(__FILE__) . '/');
+define('JIRAFEAU_ROOT', dirname(__FILE__) . '/');
define('DEBUG', true);
-require(JYRAPHE_ROOT . 'lib/config.php');
-require(JYRAPHE_ROOT . 'lib/settings.php');
-require(JYRAPHE_ROOT . 'lib/functions.php');
+require(JIRAFEAU_ROOT . 'lib/config.php');
+require(JIRAFEAU_ROOT . 'lib/settings.php');
+require(JIRAFEAU_ROOT . 'lib/functions.php');
/* check if the destination dirs are writable */
$writable = is_writable(VAR_FILES) && is_writable(VAR_LINKS) && is_writable(VAR_TRASH);
$res = array();
-if($writable && isset($_POST['jyraphe'])) {
+if($writable && isset($_POST['jirafeau'])) {
$key = $_POST['key'];
$time = time();
switch($_POST['time']) {
case 'minute':
- $time += JYRAPHE_MINUTE;
+ $time += JIRAFEAU_MINUTE;
break;
case 'hour':
- $time += JYRAPHE_HOUR;
+ $time += JIRAFEAU_HOUR;
break;
case 'day':
- $time += JYRAPHE_DAY;
+ $time += JIRAFEAU_DAY;
break;
case 'week':
- $time += JYRAPHE_WEEK;
+ $time += JIRAFEAU_WEEK;
break;
case 'month':
- $time += JYRAPHE_MONTH;
+ $time += JIRAFEAU_MONTH;
break;
default:
- $time = JYRAPHE_INFINITY;
+ $time = JIRAFEAU_INFINITY;
break;
}
- $res = jyraphe_upload($_FILES['file'], isset($_POST['one_time_download']), $key, $time, $cfg);
+ $res = jirafeau_upload($_FILES['file'], isset($_POST['one_time_download']), $key, $time, $cfg);
}
-require(JYRAPHE_ROOT . 'lib/template/header.php');
+require(JIRAFEAU_ROOT . 'lib/template/header.php');
/* Checking for errors. */
if(!is_writable(VAR_FILES)) {
}
/* Check if the install.php script is still in the directory. */
-if (file_exists(JYRAPHE_ROOT . 'install.php')) {
+if (file_exists(JIRAFEAU_ROOT . 'install.php')) {
add_error (_('Installer script still present'),
_('Please make sure to delete the installer script "install.php" before continuing.'));
}
if($cfg['rewrite']) {
$link .= 'file-' . $res['link'];
} else {
- $link .= 'file.php?h=' . $res['link']; // h because 'h' looks like a jyraphe ;)
+ $link .= 'file.php?h=' . $res['link']; // h because 'h' looks like a jirafeau ;)
}
echo '<div class="message">' . NL;
echo '<p>' . _('File uploaded! Copy the following URL to get it:') . '<br />' . NL;
echo '<a href="' . $link . '">' . $link . '</a>' . NL;
- if($time != JYRAPHE_INFINITY) {
+ if($time != JIRAFEAU_INFINITY) {
echo '<br />' . _('This file is valid until the following date:') . '<br /><strong>' . strftime('%c' ,$time) . '</strong>';
}
<div id="upload">
<form enctype="multipart/form-data" action="<?php echo $cfg['web_root']; ?>" method="post">
-<div><input type="hidden" name="jyraphe" value="<?php echo JYRAPHE_VERSION; ?>" /></div>
+<div><input type="hidden" name="jirafeau" value="<?php echo JIRAFEAU_VERSION; ?>" /></div>
<fieldset>
<legend><?php echo _('Upload a file'); ?></legend>
<p><input type="file" name="file" size="30" /></p>
- <p class="config"><?php printf(_('Maximum file size: %dMB'), jyraphe_get_max_upload_size()/(1024*1024)); ?></p>
+ <p class="config"><?php printf(_('Maximum file size: %dMB'), jirafeau_get_max_upload_size()/(1024*1024)); ?></p>
<p><input type="submit" value="<?php echo _('Send in the binary chaos'); ?>" /></p>
<hr />
<?php
}
-require(JYRAPHE_ROOT . 'lib/template/footer.php');
+require(JIRAFEAU_ROOT . 'lib/template/footer.php');
?>
<?php
/*
- * Jyraphe, your web file repository
+ * Jirafeau, your web file repository
* Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
*
* This program is free software: you can redistribute it and/or modify
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-define('JYRAPHE_ROOT', dirname(__FILE__) . '/');
+define('JIRAFEAU_ROOT', dirname(__FILE__) . '/');
define('NL', "\n");
define('QUOTE', "'");
-define('JYRAPHE_CFG', JYRAPHE_ROOT . 'lib/config.local.php');
-define('JYRAPHE_VAR_RAND_LENGTH', 15);
+define('JIRAFEAU_CFG', JIRAFEAU_ROOT . 'lib/config.local.php');
+define('JIRAFEAU_VAR_RAND_LENGTH', 15);
-require(JYRAPHE_ROOT . 'lib/config.php');
+require(JIRAFEAU_ROOT . 'lib/config.php');
-function jyraphe_quoted($str) {
+function jirafeau_quoted($str) {
return QUOTE . str_replace(QUOTE, "\'", $str) . QUOTE;
}
-function jyraphe_export_cfg($cfg) {
- $handle = fopen(JYRAPHE_CFG, 'w');
+function jirafeau_export_cfg($cfg) {
+ $handle = fopen(JIRAFEAU_CFG, 'w');
fwrite($handle, '<?php' . NL);
fwrite($handle, '/* ' . _('This file was generated by the install process. You can edit it. Please see config.php to understand the configuration items.') . ' */' . NL);
foreach($cfg as $key => $item) {
- fwrite($handle, '$cfg[' . jyraphe_quoted($key) . '] = ');
+ fwrite($handle, '$cfg[' . jirafeau_quoted($key) . '] = ');
if(is_bool($item)) {
fwrite($handle, ($item ? 'true' : 'false'));
} else if(is_string($item)) {
- fwrite($handle, jyraphe_quoted($item));
+ fwrite($handle, jirafeau_quoted($item));
} else {
fwrite($handle, 'null');
}
fclose($handle);
}
-function jyraphe_mkdir($path) {
+function jirafeau_mkdir($path) {
if(!file_exists($path)) {
if(!@mkdir($path, 0755)) {
return false;
* @param $path is the file or directory to be tested.
* @return true if $path is writable.
*/
-function jyraphe_is_writable($path) {
+function jirafeau_is_writable($path) {
return is_writable($path) || @chmod($path, 0777); // "@" gets rid of error messages.
}
-function jyraphe_check_var_dir($path) {
+function jirafeau_check_var_dir($path) {
$mkdir_str1 = _('The following directory could not be created:');
$mkdir_str2 = _('You should create this directory by hand.');
$write_str1 = _('The following directory is not writable:');
$write_str2 = _('You should give the write right to the web server on this directory.');
$solution_str = _('Here is a solution:');
- if(!jyraphe_mkdir($path)) {
+ if(!jirafeau_mkdir($path)) {
return array(
'has_error' => true,
'why' => $mkdir_str1 . '<br /><code>' . $path . '</code><br />' . $solution_str . '<br />' . $mkdir_str2
);
}
- if(!jyraphe_is_writable($path)) {
+ if(!jirafeau_is_writable($path)) {
return array(
'has_error' => true,
'why' => $write_str1 . '<br /><code>' . $path . '</code><br />' . $solution_str . '<br />' . $write_str2
foreach(array('files', 'links', 'trash') as $subdir) {
$subpath = $path . $subdir;
- if(!jyraphe_mkdir($subpath)) {
+ if(!jirafeau_mkdir($subpath)) {
return array(
'has_error' => true,
'why' => $mkdir_str1 . '<br /><code>' . $subpath . '</code><br />' . $solution_str . '<br />' . $mkdir_str2
);
}
- if(!jyraphe_is_writable($subpath)) {
+ if(!jirafeau_is_writable($subpath)) {
return array(
'has_error' => true,
'why' => $write_str1 . '<br /><code>' . $subpath . '</code><br />' . $solution_str . '<br />' . $write_str2
return array('has_error' => false, 'why' => '');
}
-function jyraphe_add_ending_slash($path) {
+function jirafeau_add_ending_slash($path) {
return $path . ((substr($path, -1) == '/') ? '' : '/');
}
-if(!file_exists(JYRAPHE_CFG)) {
+if(!file_exists(JIRAFEAU_CFG)) {
// we try to create an empty one
- if(!@touch(JYRAPHE_CFG)) {
- require(JYRAPHE_ROOT . 'lib/template/header.php');
+ if(!@touch(JIRAFEAU_CFG)) {
+ require(JIRAFEAU_ROOT . 'lib/template/header.php');
echo '<div class="error"><p>' . _('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.') . '</p></div>';
- require(JYRAPHE_ROOT . 'lib/template/footer.php');
+ require(JIRAFEAU_ROOT . 'lib/template/footer.php');
exit;
}
}
-if (!is_writable(JYRAPHE_CFG) && !@chmod(JYRAPHE_CFG, '0666')) {
- require(JYRAPHE_ROOT . 'lib/template/header.php');
+if (!is_writable(JIRAFEAU_CFG) && !@chmod(JIRAFEAU_CFG, '0666')) {
+ require(JIRAFEAU_ROOT . 'lib/template/header.php');
echo '<div class="error"><p>' . _('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.') . '</p></div>';
- require(JYRAPHE_ROOT . 'lib/template/footer.php');
+ require(JIRAFEAU_ROOT . 'lib/template/footer.php');
exit;
}
switch($_POST['step']) {
case 1:
$cfg['lang'] = $_POST['lang'];
- jyraphe_export_cfg($cfg);
+ jirafeau_export_cfg($cfg);
break;
case 2:
- $cfg['web_root'] = jyraphe_add_ending_slash($_POST['web_root']);
- $cfg['var_root'] = jyraphe_add_ending_slash($_POST['var_root']);
- jyraphe_export_cfg($cfg);
+ $cfg['web_root'] = jirafeau_add_ending_slash($_POST['web_root']);
+ $cfg['var_root'] = jirafeau_add_ending_slash($_POST['var_root']);
+ jirafeau_export_cfg($cfg);
break;
default:
}
-require(JYRAPHE_ROOT . 'lib/settings.php');
-require(JYRAPHE_ROOT . 'lib/template/header.php');
+require(JIRAFEAU_ROOT . 'lib/settings.php');
+require(JIRAFEAU_ROOT . 'lib/template/header.php');
$current = 1;
if(isset($_POST['next'])) {
switch($current) {
case 3:
?>
-<h2><?php printf(_('Installation of Jyraphe - step %d out of %d'), 3, 3); ?></h2>
+<h2><?php printf(_('Installation of Jirafeau - step %d out of %d'), 3, 3); ?></h2>
<div id="install">
<form action="<?php echo basename(__FILE__); ?>" method="post">
-<input type="hidden" name="jyraphe" value="<?php echo JYRAPHE_VERSION; ?>" />
+<input type="hidden" name="jirafeau" value="<?php echo JIRAFEAU_VERSION; ?>" />
<input type="hidden" name="step" value="3" />
<fieldset>
<legend><?php echo _('Finalisation'); ?></legend>
<table>
<tr>
- <td class="info" colspan="2"><?php echo _('Jyraphe is setting the website according to the configuration you provided.'); ?></td>
+ <td class="info" colspan="2"><?php echo _('Jirafeau is setting the website according to the configuration you provided.'); ?></td>
</tr>
<tr>
<td class="nav previous"><input type="submit" name="previous" value="<?php echo _('Previous step'); ?>" /></td>
</div>
<?php
- $err = jyraphe_check_var_dir($cfg['var_root']);
+ $err = jirafeau_check_var_dir($cfg['var_root']);
if($err['has_error']) {
echo '<div class="error"><p>' . $err['why'] . '<br />' . NL;
?>
<form action="<?php echo basename(__FILE__); ?>" method="post">
-<input type="hidden" name="jyraphe" value="<?php echo JYRAPHE_VERSION; ?>" />
+<input type="hidden" name="jirafeau" value="<?php echo JIRAFEAU_VERSION; ?>" />
<input type="hidden" name="step" value="3" />
<input type="submit" name="retry" value="<?php echo _('Retry this step'); ?>" />
</form>
case 2:
?>
-<h2><?php printf(_('Installation of Jyraphe - step %d out of %d'), 2, 3); ?></h2>
+<h2><?php printf(_('Installation of Jirafeau - step %d out of %d'), 2, 3); ?></h2>
<div id="install">
<form action="<?php echo basename(__FILE__); ?>" method="post">
-<input type="hidden" name="jyraphe" value="<?php echo JYRAPHE_VERSION; ?>" />
+<input type="hidden" name="jirafeau" value="<?php echo JIRAFEAU_VERSION; ?>" />
<input type="hidden" name="step" value="2" />
<fieldset>
<legend><?php echo _('Information'); ?></legend>
<table>
<tr>
- <td class="info" colspan="2"><?php echo _('The base address of Jyraphe 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!'); ?></td>
+ <td class="info" colspan="2"><?php echo _('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!'); ?></td>
</tr>
<tr>
<td class="label"><label for="input_web_root"><?php echo _('Base address:'); ?></label></td>
$alphanum = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$len_alphanum = strlen($alphanum);
$var = 'var-';
- for($i = 0; $i < JYRAPHE_VAR_RAND_LENGTH; $i++) {
+ for($i = 0; $i < JIRAFEAU_VAR_RAND_LENGTH; $i++) {
$var .= substr($alphanum, mt_rand(0, $len_alphanum - 1), 1);
}
- echo JYRAPHE_ROOT . $var . '/';
+ echo JIRAFEAU_ROOT . $var . '/';
} else {
echo $cfg['var_root'];
}
'fr_FR.UTF-8' => 'Français'
);
?>
-<h2><?php printf(_('Installation of Jyraphe - step %d out of %d'), 1, 3); ?></h2>
+<h2><?php printf(_('Installation of Jirafeau - step %d out of %d'), 1, 3); ?></h2>
<div id="install">
<form action="<?php echo basename(__FILE__); ?>" method="post">
-<input type="hidden" name="jyraphe" value="<?php echo JYRAPHE_VERSION; ?>" />
+<input type="hidden" name="jirafeau" value="<?php echo JIRAFEAU_VERSION; ?>" />
<input type="hidden" name="step" value="1" />
<fieldset>
<legend><?php echo _('Language'); ?></legend>
<table>
<tr>
- <td class="info" colspan="2"><?php echo _('The installation of Jyraphe is internationalised, so you can have it in your own language if the translation is available.'); ?></td>
+ <td class="info" colspan="2"><?php echo _('The installation of Jirafeau is internationalised, so you can have it in your own language if the translation is available.'); ?></td>
</tr>
<tr>
<td class="label"><label for="select_lang"><?php echo _('Choose your language:'); ?></label></td>
}
-require(JYRAPHE_ROOT . 'lib/template/footer.php');
+require(JIRAFEAU_ROOT . 'lib/template/footer.php');
/**
/*
- * Jyraphe, your web file repository
+ * Jirafeau, your web file repository
* Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
*
* This program is free software: you can redistribute it and/or modify
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-function jyraphe_toggle(id) {
+function jirafeau_toggle(id) {
if(document.getElementById(id).style.display == 'block') {
document.getElementById(id).style.display = 'none';
} else {
+++ /dev/null
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-04-14 13:02+0200\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=CHARSET\n"
-"Content-Transfer-Encoding: 8bit\n"
-
-#: pub/file.php:54
-msgid "The time limit of this file has expired. It has been deleted."
-msgstr ""
-
-#: pub/file.php:69
-msgid "Key protection"
-msgstr ""
-
-#: pub/file.php:72
-msgid "Give the key of this file:"
-msgstr ""
-
-#: pub/file.php:75
-msgid "I have the right to download this file"
-msgstr ""
-
-#: pub/index.php:63
-msgid "An error occurred."
-msgstr ""
-
-#: pub/index.php:72
-msgid "File uploaded! Copy the following URL to get it:"
-msgstr ""
-
-#: pub/index.php:76
-msgid "This file is valid until the following date:"
-msgstr ""
-
-#: pub/index.php:86
-msgid "The file directory is not writable!"
-msgstr ""
-
-#: pub/index.php:90
-msgid "The link directory is not writable!"
-msgstr ""
-
-#: pub/index.php:94
-msgid "The trash directory is not writable!"
-msgstr ""
-
-#: pub/index.php:104
-msgid "Upload a file"
-msgstr ""
-
-#: pub/index.php:106
-#, php-format
-msgid "Maximum file size: %dMB"
-msgstr ""
-
-#: pub/index.php:107
-msgid "Send in the binary chaos"
-msgstr ""
-
-#: pub/index.php:112
-msgid "One time download"
-msgstr ""
-
-#: pub/index.php:113
-msgid "File key:"
-msgstr ""
-
-#: pub/index.php:114
-msgid "Time limit:"
-msgstr ""
-
-#: pub/index.php:116
-msgid "None"
-msgstr ""
-
-#: pub/index.php:117
-msgid "One minute"
-msgstr ""
-
-#: pub/index.php:118
-msgid "One hour"
-msgstr ""
-
-#: pub/index.php:119
-msgid "One day"
-msgstr ""
-
-#: pub/index.php:120
-msgid "One week"
-msgstr ""
-
-#: pub/index.php:121
-msgid "One month"
-msgstr ""
-
-#: pub/install.php:36
-msgid ""
-"This file was generated by the install process. You can edit it. Please see "
-"config.php to understand the configuration items."
-msgstr ""
-
-#: pub/install.php:66
-msgid "The following directory could not be created:"
-msgstr ""
-
-#: pub/install.php:67
-msgid "You should create this directory by hand."
-msgstr ""
-
-#: pub/install.php:68
-msgid "The following directory is not writable:"
-msgstr ""
-
-#: pub/install.php:69
-msgid "You should give the write right to the web server on this directory."
-msgstr ""
-
-#: pub/install.php:70
-msgid "Here is a solution:"
-msgstr ""
-
-#: pub/install.php:116
-msgid ""
-"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."
-msgstr ""
-
-#: pub/install.php:124
-msgid ""
-"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."
-msgstr ""
-
-#: pub/install.php:163 pub/install.php:202 pub/install.php:258
-#, php-format
-msgid "Installation of Jyraphe - step %d out of %d"
-msgstr ""
-
-#: pub/install.php:169
-msgid "Finalisation"
-msgstr ""
-
-#: pub/install.php:172
-msgid ""
-"Jyraphe is setting the website according to the configuration you provided."
-msgstr ""
-
-#: pub/install.php:175 pub/install.php:241
-msgid "Previous step"
-msgstr ""
-
-#: pub/install.php:191
-msgid "Retry this step"
-msgstr ""
-
-#: pub/install.php:196
-msgid "Your website is now fully operational:"
-msgstr ""
-
-#: pub/install.php:208
-msgid "Information"
-msgstr ""
-
-#: pub/install.php:211
-msgid ""
-"The base address of Jyraphe 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!"
-msgstr ""
-
-#: pub/install.php:214
-msgid "Base address:"
-msgstr ""
-
-#: pub/install.php:222
-msgid ""
-"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!"
-msgstr ""
-
-#: pub/install.php:225
-msgid "Data directory:"
-msgstr ""
-
-#: pub/install.php:242 pub/install.php:283
-msgid "Next step"
-msgstr ""
-
-#: pub/install.php:264
-msgid "Language"
-msgstr ""
-
-#: pub/install.php:267
-msgid ""
-"The installation of Jyraphe is internationalised, so you can have it in your "
-"own language if the translation is available."
-msgstr ""
-
-#: pub/install.php:270
-msgid "Choose your language:"
-msgstr ""
-
-#: pub/lib/functions.php:86
-msgid "Your file exceeds the maximum authorized file size."
-msgstr ""
-
-#: pub/lib/functions.php:91
-msgid "Your file was not uploaded correctly. You may succeed in retrying."
-msgstr ""
-
-#: pub/lib/functions.php:97
-msgid "Internal error. You may not succeed in retrying."
-msgstr ""
-
-#: pub/lib/functions.php:103
-msgid "Unknown error."
-msgstr ""
-
-#: pub/lib/functions.php:125
-msgid "This file is forbidden for security reasons."
-msgstr ""
-
-#: pub/lib/template/footer.php:2
-msgid "powered by Jyraphe"
-msgstr ""
-
-#: pub/lib/template/header.php:15 pub/lib/template/header.php:22
-msgid "Jyraphe, your web file repository"
-msgstr ""
+++ /dev/null
-# Jyraphe translation file
-# Copyright (C) 2008 Jyraphe Project
-# This file is distributed under the same license as the Jyraphe package.
-# Julien "axolotl" BERNARD <axolotl@magieeternelle.org>, 2008.
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: Jyraphe 0.1\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-04-14 13:02+0200\n"
-"PO-Revision-Date: 2008-04-08 10:50+0200\n"
-"Last-Translator: Julien Bernard <axolotl@magieeternelle.org>\n"
-"Language-Team: French\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-
-#: pub/file.php:54
-msgid "The time limit of this file has expired. It has been deleted."
-msgstr "La durée limite de ce fichier a expiré. Il a été supprimé."
-
-#: pub/file.php:69
-msgid "Key protection"
-msgstr "Protection par clef"
-
-#: pub/file.php:72
-msgid "Give the key of this file:"
-msgstr "Donnez la clef de ce fichier :"
-
-#: pub/file.php:75
-msgid "I have the right to download this file"
-msgstr "J'ai le droit de télécharger ce fichier"
-
-#: pub/index.php:63
-msgid "An error occurred."
-msgstr "Une erreur s'est produite"
-
-#: pub/index.php:72
-msgid "File uploaded! Copy the following URL to get it:"
-msgstr "Fichier chargé ! Copiez l'URL suivante pour l'obtenir :"
-
-#: pub/index.php:76
-msgid "This file is valid until the following date:"
-msgstr "Ce fichier est valide juqu'Ã la date suivante :"
-
-#: pub/index.php:86
-msgid "The file directory is not writable!"
-msgstr "Le répertoire des fichiers n'est pas accessible en écriture !"
-
-#: pub/index.php:90
-msgid "The link directory is not writable!"
-msgstr "Le répertoire des liens n'est pas accessible en écriture !"
-
-#: pub/index.php:94
-msgid "The trash directory is not writable!"
-msgstr "Le répertoire de corbeille n'est pas accessible en écriture !"
-
-#: pub/index.php:104
-msgid "Upload a file"
-msgstr "Déposer un fichier"
-
-#: pub/index.php:106
-#, php-format
-msgid "Maximum file size: %dMB"
-msgstr "Taille de fichier maximale : %dMo"
-
-#: pub/index.php:107
-msgid "Send in the binary chaos"
-msgstr "Envoyer dans le chaos binaire"
-
-#: pub/index.php:112
-msgid "One time download"
-msgstr "Téléchargement à usage unique"
-
-#: pub/index.php:113
-msgid "File key:"
-msgstr "Clef du fichier :"
-
-#: pub/index.php:114
-msgid "Time limit:"
-msgstr "Durée limite :"
-
-#: pub/index.php:116
-msgid "None"
-msgstr "Aucune"
-
-#: pub/index.php:117
-msgid "One minute"
-msgstr "Une minute"
-
-#: pub/index.php:118
-msgid "One hour"
-msgstr "Une heure"
-
-#: pub/index.php:119
-msgid "One day"
-msgstr "Un jour"
-
-#: pub/index.php:120
-msgid "One week"
-msgstr "Une semaine"
-
-#: pub/index.php:121
-msgid "One month"
-msgstr "Un mois"
-
-#: pub/install.php:36
-msgid ""
-"This file was generated by the install process. You can edit it. Please see "
-"config.php to understand the configuration items."
-msgstr ""
-"Ce fichier a été généré par le processus d'installation. Vous pouvez "
-"l'éditer. Veuillez regarder config.php pour comprendre les éléments de "
-"configuration."
-
-#: pub/install.php:66
-msgid "The following directory could not be created:"
-msgstr "Le répertoire suivant n'a pas pu être créé :"
-
-#: pub/install.php:67
-msgid "You should create this directory by hand."
-msgstr "Vous devriez créer ce répertoire à la main."
-
-#: pub/install.php:68
-msgid "The following directory is not writable:"
-msgstr "Le répertoire suivant n'est pas accessible en écriture :"
-
-#: pub/install.php:69
-msgid "You should give the write right to the web server on this directory."
-msgstr ""
-"Vous devriez donner les droits en écriture au serveur web sur ce répertoire."
-
-#: pub/install.php:70
-msgid "Here is a solution:"
-msgstr "Voici une solution :"
-
-#: pub/install.php:116
-msgid ""
-"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."
-msgstr ""
-"La configuration locale n'a pas pu être créée. Créez un fichier <code>lib/"
-"config.local.php</code> et donnez les droits d'écriture au serveur web "
-"(solution préférée), ou donnez les droits d'écriture au serveur web sur le "
-"répertoire <code>lib</code>."
-
-#: pub/install.php:124
-msgid ""
-"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."
-msgstr ""
-"Le serveur web n'a pas les droits d'écriture sur la configuration locale. "
-"Donnez les droits d'écriture au serveur web sur le fichier <code>lib/config."
-"local.php</code>."
-
-#: pub/install.php:163 pub/install.php:202 pub/install.php:258
-#, php-format
-msgid "Installation of Jyraphe - step %d out of %d"
-msgstr "Installation de Jyraphe - étape %d sur %d"
-
-#: pub/install.php:169
-msgid "Finalisation"
-msgstr "Finalisation"
-
-#: pub/install.php:172
-msgid ""
-"Jyraphe is setting the website according to the configuration you provided."
-msgstr ""
-"Jyraphe est en train de mettre en place le site web en fonction de la "
-"configuration que vous avez fournie."
-
-#: pub/install.php:175 pub/install.php:241
-msgid "Previous step"
-msgstr "Étape précédente"
-
-#: pub/install.php:191
-msgid "Retry this step"
-msgstr "Répéter cette étape"
-
-#: pub/install.php:196
-msgid "Your website is now fully operational:"
-msgstr "Votre site web est maintenant pleinement opérationnel :"
-
-#: pub/install.php:208
-msgid "Information"
-msgstr "Information"
-
-#: pub/install.php:211
-msgid ""
-"The base address of Jyraphe 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!"
-msgstr ""
-"L'adresse de base de Jyraphe est la première partie de l'URL, jusqu'au slash "
-"final (inclus). Par exemple : «http://www.exemple.fr/». N'oubliez pas le "
-"slash final !"
-
-#: pub/install.php:214
-msgid "Base address:"
-msgstr "Adresse de base :"
-
-#: pub/install.php:222
-msgid ""
-"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!"
-msgstr ""
-"Le répertoire de données est le répertoire où vos fichiers et les "
-"informations à propos de vos fichiers seront sauvegardées. Vous devriez le "
-"placer en dehors de votre site web, ou au moins restreindre l'accès de ce "
-"répertoire. N'oubliez pas le slash final !"
-
-#: pub/install.php:225
-msgid "Data directory:"
-msgstr "Répertoire de données :"
-
-#: pub/install.php:242 pub/install.php:283
-msgid "Next step"
-msgstr "Étape suivante"
-
-#: pub/install.php:264
-msgid "Language"
-msgstr "Langue"
-
-#: pub/install.php:267
-msgid ""
-"The installation of Jyraphe is internationalised, so you can have it in your "
-"own language if the translation is available."
-msgstr ""
-"L'installation de Jyraphe est internationalisée, vous pouvez donc l'avoir "
-"dans votre propre langue si la traduction est disponible."
-
-#: pub/install.php:270
-msgid "Choose your language:"
-msgstr "Choisissez votre langue :"
-
-#: pub/lib/functions.php:86
-msgid "Your file exceeds the maximum authorized file size."
-msgstr "Votre fichier excède la taille de fichier maximale autorisée."
-
-#: pub/lib/functions.php:91
-msgid "Your file was not uploaded correctly. You may succeed in retrying."
-msgstr ""
-"Votre fichier n'a pas été déposé correctement. Vous pouvez recommencer."
-
-#: pub/lib/functions.php:97
-msgid "Internal error. You may not succeed in retrying."
-msgstr "Erreur interne."
-
-#: pub/lib/functions.php:103
-msgid "Unknown error."
-msgstr "Erreur inconnue."
-
-#: pub/lib/functions.php:125
-msgid "This file is forbidden for security reasons."
-msgstr "Ce fichier est interdit pour des raisons de sécurité."
-
-#: pub/lib/template/footer.php:2
-msgid "powered by Jyraphe"
-msgstr "propulsé par Jyraphe"
-
-#: pub/lib/template/header.php:15 pub/lib/template/header.php:22
-msgid "Jyraphe, your web file repository"
-msgstr "Jyraphe, votre dépôt de fichier en ligne"
-
-#~ msgid "Passwords are not the same. Try again."
-#~ msgstr "Les mots de passe ne sont pas identiques. Essayez à nouveau."
-
-#~ msgid "More options:"
-#~ msgstr "Plus d'options :"
-
-#~ msgid "activate password protection of the file"
-#~ msgstr "activer la protection par mot de passe du fichier"
-
-#~ msgid "file password:"
-#~ msgstr "mot de passe du fichier :"
-
-#~ msgid "file password again:"
-#~ msgstr "mot de passe du fichier à nouveau :"
-
-#~ msgid "activate time limit of the file"
-#~ msgstr "activer la durée limite du fichier"
<?php
/*
- * Jyraphe, your web file repository
+ * Jirafeau, your web file repository
* Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
*
* This program is free software: you can redistribute it and/or modify
$cfg['password'] = '';
-if((basename(__FILE__) != 'config.local.php') && file_exists(JYRAPHE_ROOT . 'lib/config.local.php')) {
- require(JYRAPHE_ROOT . 'lib/config.local.php');
+if((basename(__FILE__) != 'config.local.php') && file_exists(JIRAFEAU_ROOT . 'lib/config.local.php')) {
+ require(JIRAFEAU_ROOT . 'lib/config.local.php');
}
-?>
\ No newline at end of file
+?>
<?php
/*
- * Jyraphe, your web file repository
+ * Jirafeau, your web file repository
* Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
+ * 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
* @param $value the value from php.ini
* @returns an integer for this value
*/
-function jyraphe_ini_to_bytes($value) {
+function jirafeau_ini_to_bytes($value) {
$modifier = substr($value, -1);
$bytes = substr($value, 0, -1);
switch(strtoupper($modifier)) {
* gets the maximum upload size according to php.ini
* @returns the maximum upload size
*/
-function jyraphe_get_max_upload_size() {
- return min(jyraphe_ini_to_bytes(ini_get('post_max_size')), jyraphe_ini_to_bytes(ini_get('upload_max_filesize')));
+function jirafeau_get_max_upload_size() {
+ return min(jirafeau_ini_to_bytes(ini_get('post_max_size')), jirafeau_ini_to_bytes(ini_get('upload_max_filesize')));
}
/**
* @param $dir the directory to explore (finishing with a '/')
* @returns an alternate filename, possibly the initial filename
*/
-function jyraphe_detect_collision($name, $dir) {
+function jirafeau_detect_collision($name, $dir) {
if(!file_exists($dir . $name)) {
return $name;
}
* @param $code the error code
* @returns a string explaining the error
*/
-function jyraphe_upload_errstr($code) {
+function jirafeau_upload_errstr($code) {
switch($code) {
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
* 'error' => information on possible errors
* 'link' => the link name of the uploaded file
*/
-function jyraphe_upload($file, $one_time_download, $key, $time, $cfg) {
- if(!empty($file['tmp_name'])) {
-
- if($file['name'] == '.htaccess') {
- return(array(
- 'error' => array(
- 'has_error' => true,
- 'why' => _('This file is forbidden for security reasons.')),
- 'link' => '')
- );
- }
-
-
- if(is_uploaded_file($file['tmp_name'])) {
-
- /* array representing no error */
- $noerr = array('has_error' => false, 'why' => '');
-
- /* we check if this file is already here */
- $md5 = md5_file($file['tmp_name']);
- $link_name = ($one_time_download ? 'O' : 'R') . $md5;
- if(file_exists(VAR_LINKS . $link_name)) {
- return(array('error' => $noerr, 'link' => $link_name));
- }
-
- $mime_type = $file['type'];
- $final_name = trim($file['name']);
+function jirafeau_upload($file, $one_time_download, $key, $time, $cfg) {
+ if(empty($file['tmp_name']) || !is_uploaded_file($file['tmp_name'])) {
+ return(array('error' => array('has_error' => true, 'why' => jirafeau_upload_errstr($file['error'])), 'link' => ''));
+ }
- /* we prevent .php and make it a .phps for security reasons */
- if((strlen($final_name) >= 4) && (substr($final_name, -4) == '.php')) {
- $final_name .= 's';
- $mime_type = 'application/x-httpd-php-source';
- }
+ /* array representing no error */
+ $noerr = array('has_error' => false, 'why' => '');
- /* we check if there is a file with that name */
- $final_name = jyraphe_detect_collision($final_name, VAR_FILES);
+ /* file informations */
+ $md5 = md5_file($file['tmp_name']);
+ $name = trim($file['name']);
+ $mime_type = $file['type'];
+ $size = $file['size'];
- /* we move it to the right place and create the link */
- if(move_uploaded_file($file['tmp_name'], VAR_FILES . $final_name)) {
- $handle = fopen(VAR_LINKS . $link_name, 'w');
- fwrite($handle, $final_name . NL . $mime_type . NL . $file['size'] . NL . $key . NL . $time . NL);
- fclose($handle);
+ /* does file already exist ? */
+ $rc = false;
+ if(file_exists(VAR_FILES . $md5)) {
+ $rc = unlink($file['tmp_name']);
+ }
+ elseif(move_uploaded_file($file['tmp_name'], VAR_FILES . $md5)) {
+ $rc = true;
+ }
+ if(!$rc)
+ {
+ return(array(
+ 'error' => array(
+ 'has_error' => true,
+ 'why' => _('Internal error during file creation.')),
+ 'link' => '')
+ );
+ }
- return(array('error' => $noerr, 'link' => $link_name));
- }
+ /* increment or create count file */
+ $counter=0;
+ if(file_exists(VAR_FILES . $md5 . '_count')) {
+ $content = file(VAR_FILES . $md5 . '_count');
+ $counter = trim($content[0]);
+ }
+ $counter++;
+ $handle = fopen(VAR_FILES . $md5 . '_count', 'w');
+ fwrite($handle, $counter);
+ fclose($handle);
+
+ /* create link file */
+ $link_tmp_name = VAR_LINKS . $md5 . rand(0, 10000) . '.tmp';
+ $handle = fopen($link_tmp_name, 'w');
+ fwrite($handle, $name . NL . $mime_type . NL . $size . NL . $key . NL . $time . NL . $md5 . NL . ($one_time_download ? 'O' : 'R') . NL . date('U') . NL);
+ fclose($handle);
+ $md5_link = md5_file($link_tmp_name);
+ if(!rename($link_tmp_name, VAR_LINKS . $md5_link)) {
+ if ($counter > 1) {
+ $counter--;
+ $handle = fopen(VAR_FILES . $md5 . '_count', 'w');
+ fwrite($handle, $counter);
+ fclose($handle);
+ }
+ else {
+ unlink($link_tmp_name);
+ unlink(VAR_FILE . $md5 . '_count');
+ unlink(VAR_FILE . $md5);
}
+ return(array(
+ 'error' => array(
+ 'has_error' => true,
+ 'why' => _('Internal error during file creation.')),
+ 'link' => '')
+ );
}
-
- return(array('error' => array('has_error' => true, 'why' => jyraphe_upload_errstr($file['error'])), 'link' => ''));
+ return(array('error' => $noerr, 'link' => $md5_link));
}
/**
* @param $mime the mime type
* @returns a boolean telling if a mime type is viewable
*/
-function jyraphe_is_viewable($mime) {
+function jirafeau_is_viewable($mime) {
if(!empty($mime)) {
// actually, verify if mime-type is an image or a text
$viewable = array('image', 'text');
<?php
/*
- * Jyraphe, your web file repository
+ * Jirafeau, your web file repository
* Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
*
* This program is free software: you can redistribute it and/or modify
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Jyraphe constants
+// Jirafeau constants
-define('JYRAPHE_PACKAGE', 'Jyraphe');
-define('JYRAPHE_VERSION', '0.4');
+define('JIRAFEAU_PACKAGE', 'Jirafeau');
+define('JIRAFEAU_VERSION', '0.4');
// directories
setlocale(LC_ALL, $cfg['lang']);
-bindtextdomain(JYRAPHE_PACKAGE, JYRAPHE_ROOT . 'lib/locale');
-textdomain(JYRAPHE_PACKAGE);
+bindtextdomain(JIRAFEAU_PACKAGE, JIRAFEAU_ROOT . 'lib/locale');
+textdomain(JIRAFEAU_PACKAGE);
// useful constants
define('NL', "\n");
}
-define('JYRAPHE_INFINITY', -1);
-define('JYRAPHE_MINUTE', 60); // 60
-define('JYRAPHE_HOUR', 3600); // JYRAPHE_MINUTE * 60
-define('JYRAPHE_DAY', 86400); // JYRAPHE_HOUR * 24
-define('JYRAPHE_WEEK', 604800); // JYRAPHE_DAY * 7
-define('JYRAPHE_MONTH', 2419200); // JYRAPHE_WEEK * 4
+define('JIRAFEAU_INFINITY', -1);
+define('JIRAFEAU_MINUTE', 60); // 60
+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
-?>
\ No newline at end of file
+?>
--- /dev/null
+<div id="copyright">
+<p><a href="https://gitorious.org/jirafeau/"><?php echo _('powered by Jirafeau'); ?></a><br /><a href="http://www.gnu.org/licenses/agpl.html">copyright</a> © 2008-2009 <a href="https://gitorious.org/jirafeau/">Jirafeau Project</a></p>
+</div>
+</div>
+
+</body>
+</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title><?php echo _('Jyraphe, your web file repository'); ?></title>
+ <title><?php echo _('Jirafeau, your web file repository'); ?></title>
<meta http-equiv="Content-Type" content="<?php echo $content_type; ?>" />
<link href="<?php echo $cfg['web_root'] . 'media/' . $cfg['style'] . '/style.css.php'; ?>" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="content">
-<h1><a href="<?php echo $cfg['web_root']; ?>"><?php echo _('Jyraphe, your web file repository'); ?></a></h1>
+<h1><a href="<?php echo $cfg['web_root']; ?>"><?php echo _('Jirafeau, your web file repository'); ?></a></h1>
<?php
/*
- * Jyraphe, your web file repository
+ * Jirafeau, your web file repository
* Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
*
* This program is free software: you can redistribute it and/or modify
*/
/*
- * This stylesheet is the default stylesheet for Jyraphe.
+ * This stylesheet is the default stylesheet for Jirafeau.
* The content is dynamically generated for easier handling.
*/
#content {
padding: 0 4em;
- background: url('jyraphe.png') left top repeat-y;
+ background: url('jirafeau.png') left top repeat-y;
}
#upload {
#install .navleft {
float: left;
-}
\ No newline at end of file
+}
+++ /dev/null
-# Jyraphe, your web file repository
-# Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
-#
-# 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/>.
-
-# This file allows you to have nice redirect URLs
-# For Apache httpd, you need to have the following line in yo configuration:
-# AllowOverride FileInfo
-# If you can, uncomment the following lines:
-
-<IfModule mod_rewrite.c>
- RewriteEngine On
- RewriteRule file.php - [L]
- RewriteRule ^file-(.*)$ file.php?h=$1
-</IfModule>
+++ /dev/null
-<?php
-/*
- * Jyraphe, your web file repository
- * Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
- *
- * 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/>.
- */
-
-define('JYRAPHE_ROOT', dirname(__FILE__) . '/');
-
-require(JYRAPHE_ROOT . 'lib/config.php');
-require(JYRAPHE_ROOT . 'lib/settings.php');
-require(JYRAPHE_ROOT . 'lib/functions.php');
-
-if(isset($_GET['h']) && !empty($_GET['h'])) {
- $link_name = $_GET['h'];
-
- if(!ereg('^[OR][0-9a-f]{32}$', $link_name)) {
- header("HTTP/1.0 404 Not Found");
-
- require(JYRAPHE_ROOT . 'lib/template/header.php');
- echo '<div class="error"><p>Error 404: Not Found</p></div>';
- require(JYRAPHE_ROOT . 'lib/template/footer.php');
- exit;
- }
-
- $link_file = VAR_LINKS . $link_name;
- if(file_exists($link_file)) {
- $content = file($link_file);
- $file_name = trim($content[0]);
- $mime_type = trim($content[1]);
- $file_size = trim($content[2]);
- $key = trim($content[3], NL);
- $time = trim($content[4]);
-
- if($time != JYRAPHE_INFINITY) {
- if(time() > $time) {
- unlink($link_file);
- $new_name = jyraphe_detect_collision($file_name, VAR_TRASH);
- rename(VAR_FILES . $file_name, VAR_TRASH . $new_name);
-
- require(JYRAPHE_ROOT . 'lib/template/header.php');
- echo '<div class="error"><p>' . _('The time limit of this file has expired. It has been deleted.') . '</p></div>';
- require(JYRAPHE_ROOT . 'lib/template/footer.php');
- exit;
-
- }
- }
-
- if(!empty($key)) {
- if(!isset($_POST['key'])) {
- require(JYRAPHE_ROOT . 'lib/template/header.php');
-?>
-<div id="upload">
-<form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
-<input type="hidden" name="jyraphe" value="<?php echo JYRAPHE_VERSION; ?>" />
-<fieldset>
- <legend><?php echo _('Key protection'); ?></legend>
- <table>
- <tr>
- <td><?php echo _('Give the key of this file:'); ?> <input type="password" name="key" /></td>
- </tr>
- <tr>
- <td><input type="submit" value="<?php echo _('I have the right to download this file'); ?>" /></td>
- </tr>
- </table>
-</fieldset>
-</form>
-</div>
-<?php
- require(JYRAPHE_ROOT . 'lib/template/footer.php');
- exit;
- } else {
- if($key != $_POST['key']) {
- header("HTTP/1.0 403 Forbidden");
-
- require(JYRAPHE_ROOT . 'lib/template/header.php');
- echo '<div class="error"><p>Error 403: Forbidden</p></div>';
- require(JYRAPHE_ROOT . 'lib/template/footer.php');
- exit;
- }
- }
- }
-
- header('Content-Length: ' . $file_size);
- header('Content-Type: ' . $mime_type);
- if(!jyraphe_is_viewable($mime_type)) {
- header('Content-Disposition: attachment; filename="' . $file_name . '"');
- }
- readfile(VAR_FILES . $file_name);
-
- if($link_name[0] == 'O') {
- unlink($link_file);
- $new_name = jyraphe_detect_collision($file_name, VAR_TRASH);
- rename(VAR_FILES . $file_name, VAR_TRASH . $new_name);
- }
- exit;
- } else {
- header("HTTP/1.0 404 Not Found");
-
- require(JYRAPHE_ROOT . 'lib/template/header.php');
- echo '<div class="error"><p>Error 404: Not Found</p></div>';
- require(JYRAPHE_ROOT . 'lib/template/footer.php');
- exit;
- }
-} else {
- header('Location: ' . $cfg['web_root']);
- exit;
-}
-
-?>
+++ /dev/null
-<div id="copyright">
-<p><a href="http://home.gna.org/jyraphe/"><?php echo _('powered by Jyraphe'); ?></a><br /><a href="http://www.gnu.org/licenses/agpl.html">copyright</a> © 2008-2009 <a href="https://gna.org/projects/jyraphe/">Jyraphe Project</a></p>
-</div>
-</div>
-
-</body>
-</html>
+++ /dev/null
-#!/bin/sh
-#
-# Jyraphe, your web file repository
-# Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
-#
-# 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/>.
-#
-
-WD="`dirname $0`"
-
-PACKAGE=Jyraphe
-POT="${WD}/l10n/${PACKAGE}.pot"
-
-for PO in `ls ${WD}/l10n/po/*.po`
-do
- LANG=`basename "${PO}" | sed 's/.po//'`
- mkdir -p "${WD}/pub/lib/locale/${LANG}/LC_MESSAGES/"
- msgfmt -o "${WD}/pub/lib/locale/${LANG}/LC_MESSAGES/${PACKAGE}.mo" "${PO}"
-done
+++ /dev/null
-#!/bin/sh
-#
-# Jyraphe, your web file repository
-# Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
-#
-# 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/>.
-#
-
-WD="`dirname $0`"
-
-PACKAGE=Jyraphe
-POTFILES=`ls ${WD}/pub/*.php ${WD}/pub/lib/*.php ${WD}/pub/lib/template/*.php`
-POT="${WD}/l10n/${PACKAGE}.pot"
-
-xgettext --language=PHP --output "${WD}/${PACKAGE}.po" ${POTFILES}
-
-if cmp -s "${WD}/${PACKAGE}.po" "${POT}"
-then
- rm -f "${WD}/${PACKAGE}.po"
-else
- mv -f "${WD}/${PACKAGE}.po" "${WD}/l10n/${PACKAGE}.pot"
-fi
-
-for PO in `ls ${WD}/l10n/po/*.po`
-do
- LANG=`basename "${PO}" | sed 's/.po//'`
- if msgmerge "${PO}" "${POT}" > "${WD}/${LANG}.pot"
- then
- mv -f "${WD}/${LANG}.pot" "${PO}"
- echo "msgmerge of ${LANG} succeeded"
- else
- echo "msgmerge of ${LANG} failed"
- rm -f "${WD}/${LANG}.pot"
- fi
-done