]>
git.p6c8.net - jirafeau_mojo42.git/blob - index.php
3 * Jirafeau, your web file repository
4 * Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
5 * Copyright (C) 2012 Jerome Jutteau <j.jutteau@gmail.com>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 define('JIRAFEAU_ROOT', dirname(__FILE__
) . '/');
22 define('DEBUG', true);
24 require(JIRAFEAU_ROOT
. 'lib/config.php');
25 require(JIRAFEAU_ROOT
. 'lib/settings.php');
26 require(JIRAFEAU_ROOT
. 'lib/functions.php');
28 /* check if the destination dirs are writable */
29 $writable = is_writable(VAR_FILES
) && is_writable(VAR_LINKS
);
32 if($writable && isset($_POST['jirafeau'])) {
37 switch($_POST['time']) {
39 $time +
= JIRAFEAU_MINUTE
;
42 $time +
= JIRAFEAU_HOUR
;
45 $time +
= JIRAFEAU_DAY
;
48 $time +
= JIRAFEAU_WEEK
;
51 $time +
= JIRAFEAU_MONTH
;
54 $time = JIRAFEAU_INFINITY
;
58 $res = jirafeau_upload($_FILES['file'], isset($_POST['one_time_download']), $key, $time, $cfg, $_SERVER['REMOTE_ADDR']);
61 require(JIRAFEAU_ROOT
. 'lib/template/header.php');
63 /* Checking for errors. */
64 if(!is_writable(VAR_FILES
)) {
65 add_error (_('The file directory is not writable!'), VAR_FILES
);
68 if(!is_writable(VAR_LINKS
)) {
69 add_error (_('The link directory is not writable!'), VAR_LINKS
);
72 /* Check if the install.php script is still in the directory. */
73 if (file_exists(JIRAFEAU_ROOT
. 'install.php')) {
74 add_error (_('Installer script still present'),
75 _('Please make sure to delete the installer script "install.php" before continuing.'));
78 if(!has_error() && !empty($res)) {
79 if($res['error']['has_error']) {
80 add_error (_('An error occurred.'), $res['error']['why']);
82 $link = $cfg['web_root'];
83 $delete_link = $cfg['web_root'];
86 $link .= 'file-' . $res['link'];
87 $delete_link .= 'file-' . $res['link'] . '-delete-' . $res['delete_link'];
89 $link .= 'file.php?h=' . $res['link']; // h because 'h' looks like a jirafeau ;)
90 $delete_link .= 'file.php?h=' . $res['link'] . '&d=' . $res['delete_link'];
93 echo '<div class="message">' . NL
;
94 echo '<p>' . _('File uploaded! Copy the following URL to get it:') . '<br />' . NL
;
95 echo '<a href="' . $link . '">' . $link . '</a>' . NL
;
97 if($time != JIRAFEAU_INFINITY
) {
98 echo '<br />' . _('This file is valid until the following date:') . '<br /><strong>' . strftime('%c' ,$time) . '</strong>';
103 echo '<div class="message">' . NL
;
104 echo '<p>' . _('Keep the following URL to delete it:') . '<br />' . NL
;
105 echo '<a href="' . $delete_link . '">' . $delete_link . '</a>' . NL
;
114 if(!has_error () && $writable) {
118 <form enctype
="multipart/form-data" action
="<?php echo $cfg['web_root']; ?>" method
="post">
119 <div
><input type
="hidden" name
="jirafeau" value
="<?php echo JIRAFEAU_VERSION; ?>" /></div
>
121 <legend
><?php
echo _('Upload a file'); ?
></legend
>
122 <p
><input type
="file" name
="file" size
="30" /></p
>
123 <p
class="config"><?php
printf(_('Maximum file size: %dMB'), jirafeau_get_max_upload_size()/(1024*1024)); ?
></p
>
124 <p
><input type
="submit" value
="<?php echo _('Send in the binary chaos'); ?>" /></p
>
128 <div id
="moreoptions">
129 <p
><label
><input type
="checkbox" name
="one_time_download" /> <?php
echo _('One time download'); ?
></label
></p
>
130 <p
><label
for="input_key"><?php
echo _('File key:'); ?
></label
> <input type
="text" name
="key" id
="input_key" /></p
>
131 <p
><label
for="select_time"><?php
echo _('Time limit:'); ?
></label
>
132 <select name
="time" id
="select_time">
133 <option value
="none"><?php
echo _('None'); ?
></option
>
134 <option value
="minute"><?php
echo _('One minute'); ?
></option
>
135 <option value
="hour"><?php
echo _('One hour'); ?
></option
>
136 <option value
="day"><?php
echo _('One day'); ?
></option
>
137 <option value
="week"><?php
echo _('One week'); ?
></option
>
138 <option value
="month"><?php
echo _('One month'); ?
></option
>
149 require(JIRAFEAU_ROOT
. 'lib/template/footer.php');
patrick-canterino.de