OSDN Git Service

FIX:アップグレードスクリプトがNucleus3.6上で動作するように修正
[nucleus-jp/nucleus-next.git] / nucleus / upgrades / index.php
1 <?php
2 /*
3  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4  * Copyright (C) 2002-2012 The Nucleus Group
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  * (see nucleus/documentation/index.html#license for more info)
11  */
12 /**
13  * @license http://nucleuscms.org/license.txt GNU General Public License
14  * @copyright Copyright (C) 2002-2012 The Nucleus Group
15  * @version $Id: index.php 1690 2012-03-08 22:45:08Z ftruscot $
16  *
17  */
18
19         include('upgrade.functions.php');
20
21         // begin if: make sure user is logged in
22         if ( !$member->isLoggedIn() )
23         {
24                 upgrade_showLogin('index.php');
25         } // end if
26
27         // begin if: make sure user is an admin
28         if ( !$member->isAdmin() )
29         {
30                 upgrade_error('Only super administrators are allowed to perform upgrades');
31         } // end if
32
33         upgrade_head();
34 ?>
35
36         <h1> Upgrade Nucleus </h1>
37
38         <div class="note">
39                 <p> <strong>Note:</strong> If you just installed Nucleus for the first time and are not upgrading from an earlier version, you will not need these files. </p>
40         </div>
41
42         <p> Database updates may be required when upgrading from an earlier version of Nucleus. This tool allows you to automate these updates. </p>
43
44 <?php
45         // calculate current version
46         if ( !upgrade_checkinstall(96) )
47         {
48                 $current = 95;
49         }
50         else if ( !upgrade_checkinstall(100) )
51         {
52                 $current = 96;
53         }
54         else if ( !upgrade_checkinstall(110) )
55         {
56                 $current = 100;
57         }
58         else if ( !upgrade_checkinstall(150) )
59         {
60                 $current = 110;
61         }
62         else if ( !upgrade_checkinstall(200) )
63         {
64                 $current = 150;
65         }
66         else if ( !upgrade_checkinstall(250) )
67         {
68                 $current = 200;
69         }
70         else if ( !upgrade_checkinstall(300) )
71         {
72                 $current = 250;
73         }
74         else if ( !upgrade_checkinstall(310) )
75         {
76                 $current = 300;
77         }
78         else if ( !upgrade_checkinstall(320) )
79         {
80                 $current = 310;
81         }
82         else if ( !upgrade_checkinstall(330) )
83         {
84                 $current = 320;
85         }
86         else if ( !upgrade_checkinstall(340) )
87         {
88                 $current = 330;
89         }
90         else if ( !upgrade_checkinstall(350) )
91         {
92                 $current = 340;
93         }
94         else if ( !upgrade_checkinstall(360) )
95         {
96                 $current = 350;
97         }
98         else if ( !upgrade_checkinstall(400)  )
99         {
100                 $current = 360;
101         }
102         else
103         {
104                 $current = 400;
105         }
106         
107         if ( $current == 400 )
108         {
109 ?>
110         <p class="ok"> No database updates required! The database has already been updated to the latest version of Nucleus. </p>
111 <?php
112         }
113         else
114         {
115 ?>
116         <p class="warning"> <a href="upgrade.php?from=<?php echo $current?>">Click here to upgrade the database to Nucleus v4.0</a>. </p>
117 <?php
118         }
119 ?>
120
121         <div class="note">
122                 <p> <strong>Note:</strong> It is strongly recommended that you create a database backup <em>before</em> performing upgrades. </p>
123         </div>
124
125         <h1> Manual Updates </h1>
126         <p> Some updates need to be performed manually. Instructions are given below (if any). </p>
127
128 <?php
129         $from = intGetVar('from');
130
131         if ( !$from )
132         {
133                 $from = $current;
134         }
135
136         $sth = 0;
137
138         if ( !$DIR_MEDIA )
139         {
140                 upgrade_manual_96();
141                 $sth = 1;
142         }
143
144         if ( !$DIR_SKINS )
145         {
146                 upgrade_manual_200();
147                 $sth = 1;
148         }
149
150         // upgrades from pre-340 version need to be told of recommended .htaccess files for the media and skins folders. these .htaccess files are included in new installs of 340 or higher
151         if ( in_array($from, array(95, 96)) || $from < 340 )
152         {
153                 upgrade_manual_340();
154                 $sth = 1;
155         }
156
157         // upgrades from pre-350 version need to be told of deprecation of PHP4 support and two new plugins included with 3.5 and higher
158         if ( in_array($from, array(95, 96)) || $from < 350 )
159         {
160                 upgrade_manual_350();
161                 $sth = 1;
162         }
163
164         // upgrades from pre-400 version need to be warned of possible plugin incompatibility in general and specifically where known.
165         // may also need to do some things for db encoding?
166         if ( in_array($from, array(95, 96)) || $from < 400 )
167         {
168                 upgrade_manual_400();
169                 $sth = 1;
170         }
171
172
173         if ( $sth == 0 )
174         {
175                 echo '<p class="ok"> No manual changes needed. This must be your lucky day! </p>';
176         }
177
178         upgrade_foot();
179
180
181         /**
182          * 
183          * @param int $version
184          */
185         function upgrade_todo($version)
186         {
187                 return upgrade_checkinstall($version) ? "(<span class='ok'>installed</span>)" : "(<span class='warning'>not yet installed</span>)";
188         }
189
190
191         /**
192          * Manual update instructions for version 0.96
193          */
194         function upgrade_manual_96()
195         {
196                 global $DIR_NUCLEUS;
197
198                 $guess = str_replace('/nucleus/', '/media/', $DIR_NUCLEUS);
199 ?>
200         <h2> Changes needed for Nucleus 0.96 </h2>
201         <p> A manual addition needs to be made to <em>config.php</em>, in order to get the media functions to work. Here's what to add: </p>
202         <pre>
203         // path to media dir
204         $DIR_MEDIA = '<strong><?php echo htmlspecialchars($guess)?></strong>';
205         </pre>
206
207         <p> Also, it will be necessary to create that directory yourself. If you want to make file upload possible, you should set the permissions of the media/ directory to 777 (see the documentation/tips.html in Nucleus 0.96+ for a quick guide on setting permissions). </p>
208
209 <?php
210         } // end function upgrade_manual_96()
211
212
213         /**
214          * Manual update instructions for version 2.0 and before
215          */
216         function upgrade_manual_200()
217         {
218                 global $DIR_NUCLEUS;
219
220                 $guess = str_replace("/nucleus/", "/skins/", $DIR_NUCLEUS);
221 ?>
222         <h2> Changes needed for Nucleus 2.0 </h2>
223         <p> A manual addition needs to be made to <i>config.php</i>, in order to get imported skins to work correctly. Here's what to add: </p>
224         <pre>
225         // extra skin files for imported skins
226         $DIR_SKINS = '<strong><?php echo htmlspecialchars($guess)?></strong>';
227         </pre>
228
229         <p> Also, it will be necessary to create this directory yourself. Downloaded skins can then be expanded into that directory and be imported from inside the Nucleus admin area. </p>
230
231         <h3> RSS 2.0 and RSD skin </h3>
232
233         <p> When a fresh version of Nucleus 2.0 is installed, an RSS 2.0 (Really Simple Syndication) syndication skin is also installed, as well as an RSD skin (Really Simple Discovery). The files <code>xml-rss2.php</code> and <code>rsd.php</code> are available in the upgrade, however the skin itself needs to be installed manually. After you've uploaded the contents of the <code>upgrade-files</code>, open <code>admin area &gt; nucleus management &gt; skin import</code>. From there, you can install both skins. (Unless you don't want them installed, that is) </p>
234
235 <?php
236         } // end function upgrade_manual_200()
237
238
239         /**
240          * Manual update instructions for version 3.4 and before
241          */
242         function upgrade_manual_340()
243         {
244                 global $DIR_NUCLEUS;
245 ?>
246         <h2> Changes needed for Nucleus 3.4 </h2>
247         <p> It is recommended that you apply some restrictions to what you allow the web server to do with files in the <i>media</i> and <i>skins</i> folders. These restrictions are not necessary to the functioning of the software, nor to the security of the software. However, they can be an important help under the security principle of denying any access that is not required. </p>
248
249         <p> Instructions for applying the restrictions are found in the following two files on your server: </p>
250         <ul>
251                 <li> <a href="../../extra/media/readme.txt">extra/media/readme.txt</a> </li>
252                 <li> <a href="../../extra/skins/readme.txt">extra/skins/readme.txt</a> </li>
253         </ul>
254
255 <?php
256         } // end function upgrade_manual_340()
257
258
259         /**
260          * Manual update instructions for version 3.5 and before
261          */
262         function upgrade_manual_350()
263         {
264                 global $DIR_NUCLEUS;
265 ?>
266         <h2> Important Notices for Nucleus 3.5 </h2>
267
268 <?php
269         // Give user warning if they are running old version of PHP
270         if ( phpversion() < '5' )
271         {
272                 echo '<p> WARNING: You are running NucleusCMS on a older version of PHP that is no longer supported by NucleusCMS. Please upgrade to PHP5! </p>';
273         }
274 ?>
275
276         <p> Two new plugins have been included with version 3.5. You may want to consider installing them from the Plugins page of the admin area. </p>
277         <ul>
278                 <li> <strong>NP_Text</strong>: Allows you to use internationalized skins to simplify translation. </li>
279                 <li> <strong>NP_SecurityEnforcer</strong>: Enforces some security properties like password complexity and maximum failed login attempts. Note that it is disabled by default and must be enabled after installation. </li>
280         </ul>
281
282 <?php
283         } // end function upgrade_manual_350()
284
285
286         /**
287          * Manual update instructions for version 4.0 and before
288          */
289         function upgrade_manual_400()
290         {
291                 global $DIR_NUCLEUS, $manager;
292 ?>
293         <h2> Important Notices for Nucleus 4.0 </h2>
294
295 <?php
296         // Give user warning if they are running old version of PHP
297         if ( phpversion() < '5' )
298         {
299                 echo '<p> WARNING: You are running NucleusCMS on a older version of PHP that is no longer supported by NucleusCMS. Please upgrade to PHP5! </p>';
300         }
301         
302         // find if any of the known plugin incompatibilities are installed.
303         $pluginsToCheck = array(
304                                                         array("NP_ShowComments","Not installed","1.30"),
305                                                         array("NP_MultiLanguage","Not installed","1.10")
306                                                 );
307         foreach ( $pluginsToCheck as $plug )
308         {
309                 if ( $manager->pluginInstalled($plug[0]) )
310                 {
311                         $plug[1] = $manager->getPlugin($plug[0])->getVersion();
312                 }
313         }
314 ?>
315
316         <p> Nucleus CMS 4.0 represents a lot of fundamental code changes behind the scenes to make use of PHP5 features, to establish a single multi-byte code base, and to generally improve some of the structure to comply with contempary coding standards.
317             As such, despite the best efforts of the development team to maintain backward compatibility with plugins, there are areas where compatibility could not be maintained due to the nature of the 3rd-party plugin system. 
318                 The following table shows the list of known plugin incompatibilities, please review it and upgrade your plugins as needed. If you experience compatibility issues with any plugins, 
319                 please request help at our <a href="http://forum.nucleuscms.org">support forum</a>.</p>
320         <table>
321         <tr><th>Plugin Name</th><th>Installed Version</th><th>4.0-compatible version</th></tr>
322 <?php
323         foreach ( $pluginsToCheck as $plug )
324         {
325                 echo '<tr><td>'.$plug[0].'</td><td>'.$plug[1].'</td><td>'.$plug[2].'</td></tr>';
326         }
327 ?>
328         </table>
329
330 <?php
331         } // end function upgrade_manual_350()