updater.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Frank Karlitschek
  6. * @copyright 2010 Frank Karlitschek karlitschek@kde.org
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * Class that handels autoupdating of ownCloud
  24. */
  25. class OC_Updater{
  26. /**
  27. * Check if a new version is available
  28. */
  29. public static function check(){
  30. OC_Appconfig::setValue('core', 'lastupdatedat',microtime(true));
  31. $updaterurl='http://apps.owncloud.com/updater.php';
  32. $version=OC_Util::getVersion();
  33. $version['installed']=OC_Config::getValue('installedat');
  34. $version['updated']=OC_Appconfig::getValue('core', 'lastupdatedat', OC_Config::getValue( 'lastupdatedat'));
  35. $version['updatechannel']='stable';
  36. $version['edition']=OC_Util::getEditionString();
  37. $versionstring=implode('x',$version);
  38. //fetch xml data from updater
  39. $url=$updaterurl.'?version='.$versionstring;
  40. $xml=@file_get_contents($url);
  41. if($xml==FALSE){
  42. return array();
  43. }
  44. $data=@simplexml_load_string($xml);
  45. $tmp=array();
  46. $tmp['version'] = $data->version;
  47. $tmp['versionstring'] = $data->versionstring;
  48. $tmp['url'] = $data->url;
  49. $tmp['web'] = $data->web;
  50. return $tmp;
  51. }
  52. public static function ShowUpdatingHint(){
  53. $data=OC_Updater::check();
  54. if(isset($data['version']) and $data['version']<>'') {
  55. $txt='<span style="color:#AA0000; font-weight:bold;">'.$data['versionstring'].' is available. Get <a href="'.$data['web'].'">more information</a></span>';
  56. }else{
  57. $txt='up to date';
  58. }
  59. return($txt);
  60. }
  61. /**
  62. * do ownCloud update
  63. */
  64. public static function doUpdate(){
  65. //update ownCloud core
  66. //update all apps
  67. //update version in config
  68. }
  69. }
  70. ?>