Add checkupdate
This commit is contained in:
parent
89ded3c21b
commit
c26afcdd9f
4 changed files with 38 additions and 25 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,6 +7,7 @@ header.php
|
|||
footer-page.php
|
||||
footer.php
|
||||
file2link_checkupdate
|
||||
file2link_checkupdate.php
|
||||
start-home.php
|
||||
end-home.php
|
||||
htmlPages/*.html
|
||||
|
|
|
@ -30,9 +30,12 @@ Make sure the "files" directory is writable
|
|||
- Passowrd for access
|
||||
- drag and drop for upload
|
||||
- limit by ip+cookies (sqlite) (limit abuse)
|
||||
- delete after first access
|
||||
- delete after first access OR define nb access (10, 20...)
|
||||
- BUG delete file, but already in storage
|
||||
- BUG "day' / "days"
|
||||
- crypt files
|
||||
- Ajout de fichier dans un répetoire déjà uploadé
|
||||
- checkupdate en javascript plutôt
|
||||
|
||||
- 0.1 (16/10/2019)
|
||||
- Configure with YAML file
|
||||
|
|
39
index.php
39
index.php
|
@ -428,9 +428,9 @@ if (isset($_GET['action']) && $_GET['action'] == 'del') {
|
|||
<div id="result"></div>
|
||||
|
||||
<div class="uploadArea">
|
||||
<div id="uploadInput"><input type="file" id="files" name="files[]" multiple/></div>
|
||||
<div class="newUpload"><img class="btn-upload" src="<?= $config['baseUrl'] ?>/lib/upload.svg" />
|
||||
<a class="myFiles" href="<?= $config['baseUrl'] ?>/My"><img src="<?= $config['baseUrl'] ?>/lib/folder.svg" /></a>
|
||||
<div id="uploadInput"><input title="<?= _('Choose one or more files') ?>" type="file" id="files" name="files[]" multiple/></div>
|
||||
<div class="newUpload"><img title="<?= _('Send file') ?>" class="btn-upload" src="<?= $config['baseUrl'] ?>/lib/upload.svg" />
|
||||
<a class="myFiles" title="<?= _('See the files already sent') ?>" href="<?= $config['baseUrl'] ?>/My"><img src="<?= $config['baseUrl'] ?>/lib/folder.svg" /></a>
|
||||
<script>
|
||||
if (localStorage.getItem('myFiles')) {
|
||||
$('.myFiles').show();
|
||||
|
@ -473,7 +473,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'del') {
|
|||
?>
|
||||
<div id="footer">
|
||||
<p class="footer_right"><?= _('By') ?> <a href="http://david.mercereau.info/">David Mercereau</a> (<a href="https://framagit.org/kepon/file2link"><?= _('Git repository') ?></a>)</p>
|
||||
<p class="footer_left">file2link <?= _('version') ?> <?= VERSION ?> <?= _('is an open software licensed <a href="https://en.wikipedia.org/wiki/Beerware">Beerware</a>') ?></p>
|
||||
<p class="footer_left">file2link <?= _('version') ?> <?= VERSION ?> <?= _('is an open software licensed <a href="https://en.wikipedia.org/wiki/Beerware">Beerware</a>') ?> <span id="upgrade"></span></p>
|
||||
<?php
|
||||
if ($config['htmlPages']) {
|
||||
echo '<p class="footer_htmlPages">';
|
||||
|
@ -483,9 +483,36 @@ if (isset($_GET['action']) && $_GET['action'] == 'del') {
|
|||
echo '</p>';
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
<?= CheckUpdate(); ?>
|
||||
<!-- Check Upgrade -->
|
||||
<?php if ($config['checkUpdate'] != false) { ?>
|
||||
<script type="text/javascript">
|
||||
function checkUpdate() {
|
||||
var timeStamp = Math.floor(Date.now() / 1000);
|
||||
if (! localStorage.getItem('checkUpdate') || Math.floor(parseInt(localStorage.getItem('checkUpdate'))+<?= $config['checkUpdate'] ?>) < timeStamp) {
|
||||
localStorage.setItem('checkUpdate', timeStamp);
|
||||
$.ajax({
|
||||
url: "https://dl.zici.fr/file2link_checkupdate.php",
|
||||
type: "GET",
|
||||
crossDomain: true,
|
||||
dataType: "html",
|
||||
success: function (response) {
|
||||
localStorage.setItem('getVersion', response);
|
||||
},
|
||||
error: function (xhr, status) {
|
||||
trucAdir(3, 'Erreur dans le checkupdate' + status);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
checkUpdate();
|
||||
if (localStorage.getItem('getVersion')) {
|
||||
if (localStorage.getItem('getVersion').replace(/\n|\r/g,'') != '<?= VERSION ?>') {
|
||||
$('#upgrade').html('(v' + localStorage.getItem('getVersion').replace(/\n|\r/g,'') + ' is ready, <a href="https://framagit.org/kepon/file2link">upgrade</a>)');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php } ?>
|
||||
<?php @include_once('./footer-page.php'); ?>
|
||||
<?php } // mod maintenance end ?>
|
||||
</div>
|
||||
|
|
|
@ -5,24 +5,6 @@ $langueEtLocalDispo=array( 'fr' => 'fr_FR',
|
|||
'en' => 'en_US'
|
||||
);
|
||||
|
||||
function CheckUpdate() {
|
||||
global $config;
|
||||
if ($config['checkUpdate']) {
|
||||
if (! is_file($config['uploadDir'].'/.checkupdate') || filemtime($config['uploadDir'].'/.checkupdate') + $config['checkUpdate'] < time()) {
|
||||
$file2link_get_version = file_get_contents('http://dl.zici.fr/file2link_checkupdate');
|
||||
$file2link_version_file=fopen($config['uploadDir'].'/.checkupdate','w');
|
||||
fputs($file2link_version_file, $file2link_get_version);
|
||||
fclose($file2link_version_file);
|
||||
}
|
||||
$file_current_version = trim(file_get_contents($config['uploadDir'].'/.checkupdate'));
|
||||
if ($file_current_version != '' && $file_current_version != VERSION) {
|
||||
return '<p id="upgrade">Upgrade note: Your version is in '.VERSION.' while the current version is in '.$file_current_version.'</p>';
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function convertHumain2octect($value) {
|
||||
if (preg_match('/[0-9]+[Kk]$/', $value)) {
|
||||
return intval($value) * 1024;
|
||||
|
|
Loading…
Reference in a new issue