source: trunk/admin/updates_pwg.php @ 26461

Last change on this file since 26461 was 26461, checked in by mistic100, 11 years ago

Update headers to 2014. Happy new year!!

File size: 5.9 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2014 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24if( !defined("PHPWG_ROOT_PATH") )
25{
26  die ("Hacking attempt!");
27}
28
29include_once(PHPWG_ROOT_PATH.'admin/include/updates.class.php');
30include_once(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php');
31
32/*
33STEP:
340 = check is needed. If version is latest or check fail, we stay on step 0
351 = new version on same branch AND new branch are available => user may choose upgrade.
362 = upgrade on same branch
373 = upgrade on different branch
38*/
39$step = isset($_GET['step']) ? $_GET['step'] : 0;
40$upgrade_to = isset($_GET['to']) ? $_GET['to'] : '';
41
42// +-----------------------------------------------------------------------+
43// |                                Step 0                                 |
44// +-----------------------------------------------------------------------+
45if ($step == 0)
46{
47  $template->assign(array(
48    'CHECK_VERSION' => false,
49    'DEV_VERSION' => false,
50    )
51  );
52
53  if (preg_match('/(\d+\.\d+)\.(\d+)/', PHPWG_VERSION, $matches))
54  {
55    $url = PHPWG_URL.'/download/all_versions.php';
56    $url .= '?rand='.md5(uniqid(rand(), true)); // Avoid server cache
57
58    if (@fetchRemote($url, $result)
59      and $all_versions = @explode("\n", $result)
60      and is_array($all_versions))
61    {
62      $template->assign('CHECK_VERSION', true);
63
64      $last_version = trim($all_versions[0]);
65      $upgrade_to = $last_version;
66
67      if (version_compare(PHPWG_VERSION, $last_version, '<'))
68      {
69        $new_branch = preg_replace('/(\d+\.\d+)\.\d+/', '$1', $last_version);
70        $actual_branch = $matches[1];
71
72        if ($new_branch == $actual_branch)
73        {
74          $step = 2;
75        }
76        else
77        {
78          $step = 3;
79
80          // Check if new version exists in same branch
81          foreach ($all_versions as $version)
82          {
83            $new_branch = preg_replace('/(\d+\.\d+)\.\d+/', '$1', $version);
84
85            if ($new_branch == $actual_branch)
86            {
87              if (version_compare(PHPWG_VERSION, $version, '<'))
88              {
89                $step = 1;
90              }
91              break;
92            }
93          }
94        }
95      }
96    }
97  }
98  else
99  {
100    $template->assign('DEV_VERSION', true);
101  }
102}
103
104// +-----------------------------------------------------------------------+
105// |                                Step 1                                 |
106// +-----------------------------------------------------------------------+
107if ($step == 1)
108{
109  $template->assign(array(
110    'MINOR_VERSION' => $version,
111    'MAJOR_VERSION' => $last_version,
112    )
113  );
114}
115
116// +-----------------------------------------------------------------------+
117// |                                Step 2                                 |
118// +-----------------------------------------------------------------------+
119if ($step == 2 and is_webmaster())
120{
121  if (isset($_POST['submit']) and isset($_POST['upgrade_to']))
122  {
123    updates::upgrade_to($_POST['upgrade_to'], $step);
124  }
125}
126
127// +-----------------------------------------------------------------------+
128// |                                Step 3                                 |
129// +-----------------------------------------------------------------------+
130if ($step == 3 and is_webmaster())
131{
132  if (isset($_POST['dumpDatabase']))
133  {
134    updates::dump_database(isset($_POST['includeHistory']));
135  }
136
137  if (isset($_POST['submit']) and isset($_POST['upgrade_to']))
138  {
139    updates::upgrade_to($_POST['upgrade_to'], $step);
140  }
141
142  $updates = new updates();
143  $updates->get_merged_extensions($upgrade_to);
144  $updates->get_server_extensions($upgrade_to);
145  $template->assign('missing', $updates->missing);
146}
147
148// +-----------------------------------------------------------------------+
149// |                        Process template                               |
150// +-----------------------------------------------------------------------+
151
152if (!is_webmaster())
153{
154  $page['errors'][] = l10n('Webmaster status is required.');
155}
156
157$template->assign(array(
158  'STEP'          => $step,
159  'PHPWG_VERSION' => PHPWG_VERSION,
160  'UPGRADE_TO'    => $upgrade_to,
161  'RELEASE_URL'   => PHPWG_URL.'/releases/'.$upgrade_to,
162  )
163);
164
165$template->set_filename('plugin_admin_content', 'updates_pwg.tpl');
166$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
167
168?>
Note: See TracBrowser for help on using the repository browser.