Changeset 3898 for extensions
- Timestamp:
- Sep 22, 2009, 4:26:37 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/autoupdate/autoupdate.php
r3604 r3898 13 13 if (is_dir($pathfile)) 14 14 { 15 deltree($pathfile);15 autoupdate_deltree($pathfile); 16 16 } 17 17 else … … 23 23 closedir($fh); 24 24 return @rmdir($path); 25 } 26 } 27 28 function check_version_for_autoupdate($version=PHPWG_VERSION) 29 { 30 global $conf, $header_notes; 31 32 if (preg_match('/(\d+\.\d+)\.(\d+)/', $version, $matches) and @fetchRemote(PHPWG_URL.'/download/latest_version', $result)) 33 { 34 $lines = @explode("\r\n", $result); 35 $new_version = trim($lines[1]); 36 $new_branch = preg_replace('/(\d+\.\d+)\.\d+/', '$1', $new_version); 37 $actual_branch = $matches[1]; 38 $update_to = $actual_branch . '.' . ($matches[2]+1); 39 40 if (version_compare($version, $new_version) < 0 41 and $actual_branch == $new_branch) 42 { 43 $path = $conf['local_data_dir'].'/autoupdate/'; 44 $code = $version.'_to_'.$update_to; 45 $filename = $path.$version.'_to_'.$update_to.'.zip'; 46 mkgetdir($path); 47 48 if (!file_exists($filename) or !filesize($filename)) 49 { 50 $zip = @fopen($filename, 'w+'); 51 @fetchRemote(PHPWG_URL.'/download/dlcounter.php?code='.str_replace(array('.', '_'), '', $code), $zip); 52 @fclose($zip); 53 } 54 55 if (file_exists($filename) and filesize($filename)) 56 { 57 if (isset($_GET['autoupdate']) and preg_match('/\d+\.\d+\.\d+_to_'.preg_quote($version).'/', $_GET['autoupdate'])) 58 { 59 redirect('admin.php?autoupdate='.$code); 60 } 61 else 62 { 63 array_push($header_notes, 64 '<p>'.l10n('A new version of Piwigo is available.').'<br>', 65 '<a href="admin.php?autoupdate='.$code.'" onClick="return confirm(\''.l10n('autoupdate_alert').'\');">'.l10n('Click here to upgrade automatically').'</a></p>' 66 ); 67 } 68 } 69 } 25 70 } 26 71 } … … 58 103 } 59 104 } 105 if (preg_match('/\d+\.\d+\.\d+_to_(\d+\.\d+\.\d+)/', $_GET['autoupdate'], $matches)) 106 { 107 check_version_for_autoupdate($matches[1]); 108 } 60 109 autoupdate_deltree($conf['local_data_dir'].'/autoupdate'); 61 110 invalidate_user_cache(true); … … 74 123 } 75 124 } 76 else if (preg_match('/\d+\.\d+\.\d+/', PHPWG_VERSION) and fetchRemote(PHPWG_URL.'/download/latest_version', $result))125 else 77 126 { 78 $lines = @explode("\r\n", $result); 79 $new_version = trim($lines[1]); 80 $new_branch = substr($new_version, 0, 3); 81 $actual_branch = substr(PHPWG_VERSION, 0, 3); 82 $actual_version = $actual_branch . '.x'; 127 check_version_for_autoupdate(); 128 } 83 129 84 if (version_compare(PHPWG_VERSION, $new_version) < 085 and $actual_branch == $new_branch)86 {87 $path = $conf['local_data_dir'].'/autoupdate/';88 $filename = $path.$actual_version.'_to_'.$new_version.'.zip';89 mkgetdir($path);90 91 if (!file_exists($filename) or !filesize($filename))92 {93 $zip = @fopen($filename, 'w+');94 @fetchRemote(PHPWG_URL.'/download/dlcounter.php?code='.str_replace('.', '', $actual_version).'to'.str_replace('.', '', $new_version), $zip);95 @fclose($zip);96 }97 98 if (file_exists($filename) and filesize($filename))99 {100 array_push($header_notes,101 l10n('A new version of Piwigo is available.').'<br>',102 '<a href="admin.php?autoupdate='.$actual_version.'_to_'.$new_version.'" onClick="return confirm(\''.l10n('autoupdate_alert').'\');">'.l10n('Click here to upgrade automatically').'</a>'103 );104 }105 }106 }107 130 ?>
Note: See TracChangeset
for help on using the changeset viewer.