Upgrade Notification

Issue #136 resolved
Christopher Kramer created an issue

Originally reported on Google Code with ID 136

How about offering a message in the footer saying: There is a new version of phpLiteAdmin
1.9.5

This is easy done:
create here a js file with the content: var upgrade = '1.9.4';

that all, now we need to call the script in phpliteadmin.php and compare with VERSION

<script src="http://code.google.com/p/phpliteadmin/upgrade.js"></scrip>
<script>
if(upgrade > '<?php echo VERSION; ?>'){
document.getElementById("upgrade").innerHTML = "There is a new version of <a href='http://code.google.com/p/phpliteadmin'>phpLiteAdmin
" + upgrade + "</a>";
}
</script>

(teryaki1963 in issue #134, copied here to separate issues)

Reported by crazy4chrissi on 2012-11-07 13:33:13

Comments (11)

  1. Christopher Kramer reporter
    In general a good idea. But why implementing this as JS? Why not using php?
    
    like:
    <?php
    $version = file_get_contents("http://..../version.txt");
    if($version>VERSION) echo "New version, download here...";
    ?>
    
    Note: we need to be careful with > on version numbers: string "1.8.10" < "1.8.2" might
    cause problems.
    
    We could also easily add an auto-update feature. [I'll open a separate issue for that]
    

    Reported by crazy4chrissi on 2012-11-07 13:34:21

  2. Christopher Kramer reporter
    file_get_contents does not work if allow_url_fopen is disabled (same in my case too)
    I thought of JS cause its much easier and it works fine.
    if you want to handle it with php then better use CURL.
    
    (teryaki1963 in issue #134, copied here to separate issues)
    

    Reported by crazy4chrissi on 2012-11-07 13:38:01

  3. Christopher Kramer reporter
    Yes, file_get_contents is not always available for http. But it works more or less the
    same way only with some more lines of code using cURL (which also needs to be enabled!)
    or network-functions like fsockopen.
    
    I just always try to avoid JS whenever possible because there are lots of users with
    NoScript and so on.
    

    Reported by crazy4chrissi on 2012-11-07 13:48:50

  4. Christopher Kramer reporter
    Regarding the problem I mentioned in comment 2 regarding comparison of versions:
    PHP makes this easy with version_compare() (see http://www.php.net/manual/de/function.version-compare.php
    ).
    

    Reported by crazy4chrissi on 2013-02-10 16:50:07

  5. Former user Account Deleted
    i'm for async JS request
    

    Reported by ykorotia on 2013-02-26 14:42:21

    <hr> * Attachment: kill-for-5-sec.png<br>kill-for-5-sec.png

  6. Former user Account Deleted
    curl vs js? depends what percentage has js and curl?
    some users has no js these days? that's joke probably
    

    Reported by ykorotia on 2013-02-26 14:48:11

  7. Former user Account Deleted
    that's how I see it
    

    Reported by ykorotia on 2013-02-28 08:51:09

    <hr> * Attachment: async-check.png<br>async-check.png

  8. Christopher Kramer reporter
    yes, asynchronous checking is of course a plus.
    
    >curl vs js? depends what percentage has js and curl?
    Well, you can usually make sure you have the necessary stuff installed on the server
    side whereas you often cannot on the client side. Of course if you run phpLiteAdmin
    on the localhost and only use it yourself you can control both sides.
    
    > some users has no js these days? that's joke probably
    No joke.
    I am not saying they don't have js, I am saying they disable it per default and only
    enable it for some sites. See http://noscript.net/ for an example of what lots of people
    use (although I see less noscript users nowadays than one or two years ago).
    
    But I agree that the js solution is probably better. Checking for updates is no fundamental
    feature. If there is no js, then you don't get update notifications. No problem.
    Of course we need to make it compatible with most browsers. So if we use ajax, maybe
    better use a framework to cope with browser issues. But I agree that using ajax might
    be better than including a js file as proposed in the initial comment.
    
    I think it's time to implement this. But it's a bit of a problem currently because
    we consider moving the project from google code to some other service (see discussion
    group), and we need some comparably stable URL from where we check the version.
    
    Aside: We should not include any resource (e.g. no js-file) via http because if phpLiteAdmin
    is used over https, browsers would complain that some stuff is not encrypted. So we
    should use https in this case.
    

    Reported by crazy4chrissi on 2014-01-15 14:48:17 - Labels added: Target-1.9.6

  9. Christopher Kramer reporter
    Hmmmm... if we do this with ajax, its a cross-origin-request. The browser will block
    it unless we use CORS, which requires the appropriate header on the server side. Neither
    google code nor bitbucket send this header when serving raw text files out of the git
    repository over https.
    So what we need is a server responding with the right headers. And phpLiteAdmin should
    work over https without mixed content problems, so the server needs a proper ssl certificate.
    I am going to set this up....
    

    Reported by crazy4chrissi on 2014-12-28 22:42:53

  10. Christopher Kramer reporter
    Fixed with revision da5df1adbced76a014d28941c8f4cde758013898.
    The current version(s) are fetched from https://phpliteadmin.christosoft.de/current_version.php
    via a CORS ajax request and if the installed version is not included in this list,
    a warning message is displayed.
    The server uses SNI, so Internet Explorers on Windows XP and other ancient browsers
    will not be able to fetch the file, also browsers that do not support CORS (and noscript
    users of course).
    So these users might not see an update notification. But I guess people still using
    ancient browsers would not upgrade their phpLiteAdmin anyway :D
    

    Reported by crazy4chrissi on 2014-12-29 15:23:09 - Status changed: Fixed

  11. Log in to comment