Auto-Update feature

Issue #137 open
Christopher Kramer created an issue

Originally reported on Google Code with ID 137

We could easily add an auto-update feature.
So the user only clicks "update" and it downloads the new version and replaces the
phpliteadmin.php file (keeping settings).


Something like this (not tested, only to illustrate how it's done):
<?php

if(isset($_GET['update1']) {
// download the file to phpliteadmin_new.php
$new_file=file_get_contents($url_to_new_version);
file_put_contents("phpliteadmin_new.php",$new_file);
// redirect there
header("Location: phpliteadmin_new.php?update2");
}
if(isset($_GET['update2']) {
// delete the old version
unlink('phpliteadmin.php');
// copy the new version to phpliteadmin.php
copy('phpliteadmin_new.php','phpliteadmin.php');
// redirect there
header("Location: phpliteadmin_new.php?update3");
}
if(isset($_GET['update3])) {
// delete the temporary file (_new)
unlink('phpliteadmin_new.php');
}

?>

And on top of that, replace the configuration in the new file with the old one.
To do so we could have a comment in the new version like
// CONFIG_REPLACE_MARKER_FOR_AUTOUPDATES
It should be placed after the default settings.

And then in the first step of the update process, replace this marker with the current
settings like password and databases.

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

Comments (13)

  1. Christopher Kramer reporter
    Yah i offer also live update for Havalite CMS. if you need the CURL function, you can
    find it in havalite/data/updater.php. There is also unzip function (just in case...).
    
    (teryaki1963 in issue #134, copied here to separate issues)
    

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

  2. Christopher Kramer reporter
    I guess we can have a look at your updater to see what we can reuse.
    Probably we don't really need unzip as phpliteadmin is only a single file and is very
    small anyway.
    

    Reported by crazy4chrissi on 2012-11-07 13:51:46

  3. Former user Account Deleted
    As for me, enough would be simple version checker which will provide a link to new version.
    

    Reported by ykorotia on 2013-02-26 11:41:03

  4. Former user Account Deleted
    and option to disable autocheck! of course
    

    Reported by ykorotia on 2013-02-26 11:41:22

  5. Christopher Kramer reporter
    ok. Update-check is discussed in issue #136.
    

    Reported by crazy4chrissi on 2013-02-26 11:49:56

  6. dreadnaut
    Random thought on this:
    
    if we add this feature it should be 'off' by default, but enabled in the sample configuration.
    This way we won't overwrite user-modified files, unless they manually turn on auto-update.
    If they use the external configuration file, we can more safely overwrite phpliteadmin.php.
    

    Reported by dreadnaut on 2013-03-10 12:15:36

  7. Christopher Kramer reporter
    Maybe we should store an MD5 of the original file in the file and auto-updater should
    detect if it still matches before performing an update. If it doesn't match, it should
    give a warning that the file has been modified and that changes will get lost.
    

    Reported by crazy4chrissi on 2013-03-10 12:37:13

  8. dreadnaut
    | Maybe we should store an MD5 of the original file in the file
    
    I feel this could be tricky, tricky indeed :)
    

    Reported by dreadnaut on 2013-03-13 20:43:24

  9. Christopher Kramer reporter
    LOL. I did not think this through :-D
    

    Reported by crazy4chrissi on 2013-03-13 21:05:11

  10. Christopher Kramer reporter
    But can be easily solved: We could include the MD5 of the _previous_ version in the
    next one. The autoupdater needs to download the next one anyway.
    Or we could fetch only the MD5 via http.
    

    Reported by crazy4chrissi on 2013-03-13 21:07:35

  11. Christopher Kramer reporter
    || Maybe we should store an MD5 of the original file in the file
    | I feel this could be tricky, tricky indeed :)
    
    Our build script could also come in handy here: It could brute-force the MD5 until
    it accidentally matches. Anybody knows cheap providers of supercomputers or bot-nets?
    :-D
    

    Reported by crazy4chrissi on 2013-03-13 21:14:00

  12. dreadnaut
    That creates problems if the user as a twice-old version though and we 
    can't store all md5s of all versions :) All other method that come to my 
    mind require a server-side script comparing version numbers or hashes, 
    but there's surely a solution.
    
    I'm just not keen on the whole auto-update feature, I don't like when 
    software does that and the new version has some horrible bug (or 
    so-called "feature"). I'm fine with just being notified, and then being 
    able to decide myself.
    

    Reported by dreadnaut on 2013-03-13 21:15:06

  13. Christopher Kramer reporter
    | That creates problems if the user as a twice-old version though
    Yes. The solution would be to have a file on some webserver that contains md5 hashs
    of all versions. Simple and clean in my opinion.
    
    | I'm just not keen on the whole auto-update feature...
    True. But you can still update manually if you like. It would (should) ask you before
    updating ;-)
    | the new version has some horrible bug (or so-called "feature")
    We would never do that ;-). But: You usually also don't know this if you update manually.
    | I'm fine with just being notified, and then being able to decide myself.
    We will implement notifications first. I agree that as long as updating means only
    replacing 1 file, an update script is probably not necessary.
    
    Ah, and this issue is only "Accepted" because issues by project members are accepted
    by default ;-). I did not really intend this. I think it is still open for discussion,
    so I mark it "New".
    

    Reported by crazy4chrissi on 2013-03-13 21:23:50 - Status changed: New - Labels added: Priority-Low - Labels removed: Priority-Medium

  14. Log in to comment