return (!str || 0 === str.length);
}
+// Extend date object with format method
+Date.prototype.format = function(format) {
+ format = format || 'YYYY-MM-DD hh:mm';
+
+ var zeropad = function(number, length) {
+ number = number.toString();
+ length = length || 2;
+ while(number.length < length)
+ number = '0' + number;
+ return number;
+ },
+ formats = {
+ YYYY: this.getFullYear(),
+ MM: zeropad(this.getMonth() + 1),
+ DD: zeropad(this.getDate()),
+ hh: zeropad(this.getHours()),
+ mm: zeropad(this.getMinutes()),
+ O: (function() {
+ localDate = new Date;
+ sign = (localDate.getTimezoneOffset() > 0) ? '-' : '+';
+ offset = Math.abs(localDate.getTimezoneOffset());
+ hours = zeropad(Math.floor(offset / 60));
+ minutes = zeropad(offset % 60);
+ return sign + hours + ":" + minutes;
+ })()
+ },
+ pattern = '(' + Object.keys(formats).join(')|(') + ')';
+
+ return format.replace(new RegExp(pattern, 'g'), function(match) {
+ return formats[match];
+ });
+};
+
+function dateToUtcString(datelocal) {
+ return new Date(
+ datelocal.getUTCFullYear(),
+ datelocal.getUTCMonth(),
+ datelocal.getUTCDate(),
+ datelocal.getUTCHours(),
+ datelocal.getUTCMinutes(),
+ datelocal.getUTCSeconds()
+ ).format();
+}
+
function show_link (url, reference, delete_code, crypt_key, date)
{
// Upload finished
b += encodeURIComponent(download_link_href) + "%0D";
if (false == isEmpty(date))
{
- b += "%0D" + encodeURIComponent("This file will be available until " + date.toString()) + "%0D";
+ b += "%0D" + encodeURIComponent("This file will be available until " + dateToUtcString(date)) + "%0D";
document.getElementById('upload_link_email').href = "mailto:?body=" + b + "&subject=" + encodeURIComponent(filename);
}
document.getElementById('validity').style.display = 'none';
}
else {
- document.getElementById('date').innerHTML = date.toString();
+ document.getElementById('date').innerHTML = '<span class="datetime">'
+ + dateToUtcString(date) + ' (GMT)'
+ + '</span>';
document.getElementById('validity').style.display = '';
}
return round($o, 1) . $u[$p];
}
+// Convert UTC timestamp to a datetime field
+function jirafeau_get_datetimefield($timestamp)
+{
+ $content = '<span class="datetime" data-datetime="' . strftime('%Y-%m-%d %H:%M', $timestamp) . '">'
+ . strftime('%Y-%m-%d %H:%M', $timestamp) . ' (GMT)</span>';
+ return $content;
+}
+
function jirafeau_clean_rm_link($link)
{
$p = s2p("$link");
echo '</td>';
echo '<td>' . $l['mime_type'] . '</td>';
echo '<td>' . jirafeau_human_size($l['file_size']) . '</td>';
- echo '<td>' . ($l['time'] == -1 ? '' : strftime('%c', $l['time'])) .
- '</td>';
+ echo '<td>' . ($l['time'] == -1 ? '∞' : jirafeau_get_datetimefield($l['time'])) . '</td>';
echo '<td>';
if ($l['onetime'] == 'O') {
echo 'Y';
echo 'N';
}
echo '</td>';
- echo '<td>' . strftime('%c', $l['upload_date']) . '</td>';
+ echo '<td>' . jirafeau_get_datetimefield($l['upload_date']) . '</td>';
echo '<td>' . $l['ip'] . '</td>';
echo '<td>' .
'<form method="post">' .
if (!jirafeau_has_upload_password($cfg)) {
return false;
}
-
+
foreach ($cfg['upload_password'] as $p) {
if ($password == $p) {
return true;