OSDN Git Service

f1d2318936abee04b160ace8154d6af0741ddc05
[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-2009 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-2009 The Nucleus Group
15  * @version $Id: index.php 1678 2012-02-26 07:31:36Z sakamocchi $
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 }
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 }
32
33 upgrade_head();
34
35 echo "<h1>Upgrade Nucleus</h1>\n";
36 echo "<div class=\"note\">\n";
37 echo "<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>\n";
38 echo "</div>\n";
39 echo "<p>Database updates may be required when upgrading from an earlier version of Nucleus. This tool allows you to automate these updates.</p>\n";
40
41 // calculate current version
42 if ( !upgrade_checkinstall(96) )
43 {
44         $current = 95;
45 }
46 else if ( !upgrade_checkinstall(100) )
47 {
48         $current = 96;
49 }
50 else if ( !upgrade_checkinstall(110) )
51 {
52         $current = 100;
53 }
54 else if ( !upgrade_checkinstall(150) )
55 {
56         $current = 110;
57 }
58 else if ( !upgrade_checkinstall(200) )
59 {
60         $current = 150;
61 }
62 else if ( !upgrade_checkinstall(250) )
63 {
64         $current = 200;
65 }
66 else if ( !upgrade_checkinstall(300) )
67 {
68         $current = 250;
69 }
70 else if ( !upgrade_checkinstall(310) )
71 {
72         $current = 300;
73 }
74 else if ( !upgrade_checkinstall(320) )
75 {
76         $current = 310;
77 }
78 else if ( !upgrade_checkinstall(330) )
79 {
80         $current = 320;
81 }
82 else if ( !upgrade_checkinstall(340) )
83 {
84         $current = 330;
85 }
86 else if ( !upgrade_checkinstall(350) )
87 {
88         $current = 340;
89 }
90 else if ( !upgrade_checkinstall(360) )
91 {
92         $current = 350;
93 }
94 else if ( !upgrade_checkinstall(400)  )
95 {
96         $current = 360;
97 }
98 else
99 {
100         $current = 400;
101 }
102
103 if ( $current == 400 )
104 {
105         echo "<p class=\"ok\"> No database updates required! The database has already been updated to the latest version of Nucleus.</p>\n";
106 }
107 else
108 {
109         echo "<p class=\"warning\"><a href=\"upgrade.php?from={$current}\">Click here to upgrade the database to Nucleus v3.6</a>.</p>\n";
110 }
111
112 echo "<div class=\"note\">\n";
113 echo "<p><strong>Note:</strong> It is strongly recommended that you create a database backup <em>before</em> performing upgrades. </p>\n";
114 echo "</div>\n";
115
116 echo "<h1>Manual Updates</h1>\n";
117 echo "<p>Some updates need to be performed manually. Instructions are given below (if any).</p>\n";
118
119 $from = intGetVar('from');
120
121 if ( !$from )
122 {
123         $from = $current;
124 }
125
126 $sth = 0;
127
128 if ( !$DIR_MEDIA )
129 {
130         upgrade_manual_96();
131         $sth = 1;
132 }
133
134 if ( !$DIR_SKINS )
135 {
136         upgrade_manual_200();
137         $sth = 1;
138 }
139
140 // 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
141 if ( in_array($from, array(95, 96)) || $from < 340 )
142 {
143         upgrade_manual_340();
144         $sth = 1;
145 }
146
147 // upgrades from pre-350 version need to be told of deprecation of PHP4 support and two new plugins included with 3.5 and higher
148 if ( in_array($from, array(95, 96)) || $from < 350 )
149 {
150         upgrade_manual_350();
151         $sth = 1;
152 }
153
154 if ( $sth == 0 )
155 {
156         echo "<p class=\"ok\"> No manual changes needed. This must be your lucky day! </p>\n";
157 }
158
159 upgrade_foot();
160
161 /**
162  * 
163  * @param int $version
164  */
165 function upgrade_todo($version)
166 {
167         return upgrade_checkinstall($version) ? "(<span class='ok'>installed</span>)" : "(<span class='warning'>not yet installed</span>)";
168 }
169
170 /**
171  * Manual update instructions for version 0.96
172  */
173 function upgrade_manual_96()
174 {
175         global $DIR_NUCLEUS;
176         
177         $guess = str_replace('/nucleus/', '/media/', $DIR_NUCLEUS);
178         echo "<h2>Changes needed for Nucleus 0.96</h2>\n";
179         echo "<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>\n";
180         echo "<pre>\n";
181         echo "// path to media dir\n";
182         echo "$DIR_MEDIA = '<strong><?php echo i18n;;hsc($guess)?></strong>';\n";
183         echo "</pre>\n";
184         echo "<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>\n";
185         return;
186 }
187
188 /**
189  * Manual update instructions for version 2.0 and before
190  */
191 function upgrade_manual_200()
192 {
193         global $DIR_NUCLEUS;
194         
195         $guess = str_replace("/nucleus/", "/skins/", $DIR_NUCLEUS);
196         
197         echo "<h2>Changes needed for Nucleus 2.0</h2>\n";
198         echo "<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>\n";
199         echo "<pre>\n";
200         echo "// extra skin files for imported skins\n";
201         echo "$DIR_SKINS = '<strong>" . i18n::hsc($guess) . "</strong>';\n";
202         echo "</pre>\n";
203         echo "<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>\n";
204         
205         echo "<h3> RSS 2.0 and RSD skin </h3>\n";
206         echo "<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>\n";
207         return;
208 }
209
210 /**
211  * Manual update instructions for version 3.4 and before
212  */
213 function upgrade_manual_340()
214 {
215         global $DIR_NUCLEUS;
216         echo "<h2> Changes needed for Nucleus 3.4 </h2>\n";
217         echo "<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>\n";
218         
219         echo "<p> Instructions for applying the restrictions are found in the following two files on your server: </p>\n";
220         echo "<ul>\n";
221         echo "<li><a href=\"../../extra/media/readme.txt\">extra/media/readme.txt</a></li>\n";
222         echo "<li><a href=\"../../extra/skins/readme.txt\">extra/skins/readme.txt</a></li>\n";
223         echo "</ul>\n";
224         
225         return;
226 }
227
228 /**
229  * Manual update instructions for version 3.5 and before
230  */
231 function upgrade_manual_350()
232 {
233         global $DIR_NUCLEUS;
234         echo "<h2>Important Notices for Nucleus 3.5</h2>\n";
235         
236         // Give user warning if they are running old version of PHP
237         if ( phpversion() < '5' )
238         {
239                 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>';
240         }
241         
242         echo "<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>\n";
243         echo "<ul>\n";
244         echo "<li> <strong>NP_Text</strong>: Allows you to use internationalized skins to simplify translation. </li>\n";
245         echo "<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>\n";
246         echo "</ul>\n";
247 }