OSDN Git Service

FIXED: When inclusion tried to do the special skin type by skin of error types, ...
[nucleus-jp/nucleus-jp-ancient.git] / euc / install.php
1 <?php
2 /*
3  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4  * Copyright (C) 2002-2007 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  * This script will install the Nucleus tables in your SQL-database, and initialize the data in
12  * those tables.
13  *
14  * Below is a friendly way of letting users on non-php systems know that Nucleus won't run there.
15  * ?><div style="font-size: xx-large;">If you see this text in your browser when you open <i>install.php</i>, your web server is not able to run PHP-scripts, and therefor Nucleus will not be able to run there. </div><div style="display: none"><?php
16  */
17
18 /**
19  * @license http://nucleuscms.org/license.txt GNU General Public License
20  * @copyright Copyright (C) 2002-2007 The Nucleus Group
21  * @version $Id: install.php,v 1.6 2007-04-25 06:34:13 kimitake Exp $
22  * $NucleusJP: install.php,v 1.5 2007/04/04 07:52:04 kimitake Exp $
23  */
24
25 /*
26         This part of the install.php code allows for customization of the install process.
27         When distributing plugins or skins together with a Nucleus installation, the
28         configuration below will instruct to install them
29
30         -- Start Of Configurable Part --
31 */
32
33 // array with names of plugins to install. Plugin files must be present in the nucleus/plugin/
34 // directory.
35 //
36 // example:
37 //     array('NP_TrackBack', 'NP_MemberGoodies')
38 $aConfPlugsToInstall = array('NP_SkinFiles');
39
40
41 // array with skins to install. skins must be present under the skins/ directory with
42 // a subdirectory having the same name that contains a skinbackup.xml file
43 //
44 // example:
45 //     array('base','rsd')
46 $aConfSkinsToImport = array('default');
47
48 /*
49         -- End Of Configurable Part --
50 */
51
52 // don't give warnings for uninitialized vars
53 error_reporting(E_ERROR | E_WARNING | E_PARSE);
54
55 // make sure there's no unnecessary escaping:
56 set_magic_quotes_runtime(0);
57
58 // if there are some plugins or skins to import, do not include vars
59 // in globalfunctions.php again... so set a flag
60 if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {
61         global $CONF;
62         $CONF['installscript'] = 1;
63 }
64
65 if (phpversion() >= '4.1.0') {
66         include_once('nucleus/libs/vars4.1.0.php');
67 } else {
68         include_once('nucleus/libs/vars4.0.6.php');
69 }
70
71 include_once('nucleus/libs/mysql.php');
72
73 // check if mysql support is installed
74         if (!function_exists('mysql_query') ) {
75                 _doError('Your PHP version does not have support for MySQL :(');
76         }
77
78         if (postVar('action') == 'go') {
79                 doInstall();
80         } else {
81                 showInstallForm();
82         }
83
84         exit;
85
86 function showInstallForm() {
87         // 0. pre check if all necessary files exist
88         doCheckFiles();
89
90         ?>
91         <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
92         <html xmlns="http://www.w3.org/1999/xhtml">
93         <head>
94                 <meta http-equiv="content-type" content="application/xhtml+xml; charset=EUC-JP" />
95                 <title>Nucleus¤Î¥¤¥ó¥¹¥È¡¼¥ë</title>
96                 <style type="text/css"><!--
97                         @import url('nucleus/documentation/styles/manual.css');
98                 --></style>
99                 <script type="text/javascript"><!--
100                         var submitcount = 0;
101
102                         // function to make sure the submit button only gets pressed once
103                         function checkSubmit() {
104                                 if (submitcount == 0) {
105                                         submitcount++;
106                                         return true;
107                                 } else {
108                                         return false;
109                                 }
110                         }
111                 --></script>
112         </head>
113         <body>
114                 <div style="text-align:center"><img src="./nucleus/styles/logo.gif" /></div> <!-- Nucleus logo -->
115                 <form method="post" action="install.php">
116
117                 <h1>Install Nucleus</h1>
118
119                 <p>¤³¤Î¥¹¥¯¥ê¥×¥È¤ÏNucleus¤Î¥¤¥ó¥¹¥È¡¼¥ë¤ò¼ê½õ¤±¤·¤Þ¤¹¡£MySQL¥Æ¡¼¥Ö¥ë¤Î¥»¥Ã¥È¥¢¥Ã¥×¤È¡¢<i>config.php</i>¤ËÆþÎϤ¹¤ë¤¿¤á¤Î¾ðÊó¤òɽ¼¨¤·¤Þ¤¹¡Êconfig.php¤Î¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤ò0666¤Ë¤·¤Æ¤ª¤±¤Ð¡¢¸å¼Ô¤Îºî¶È¤Ï¼«Æ°Åª¤Ë¹Ô¤ï¤ì¤Þ¤¹¡Ë¡£¤³¤ì¤ò¤Ê¤¹°Ù¤Ë¡¢¤¤¤¯¤Ä¤«¤Î¾ðÊó¤òÆþÎϤ¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£</p>
120
121                 <p>¤¹¤Ù¤Æ¤ÎÍó¤ÎÆþÎϤ¬É¬ÍפǤ¹¡£¥ª¥×¥·¥ç¥ó¾ðÊó¤Ï¥¤¥ó¥¹¥È¡¼¥ë¤¬´°Î»¤·¤¿¤é¡¢Nucleus¤Î´ÉÍýÎΰ褫¤éÀßÄê²Äǽ¤Ç¤¹¡£</p>
122
123                 <h1>PHP &amp; MySQL Versions</h1>
124
125                 <p>°Ê²¼¤Ï¤¢¤Ê¤¿¤Î¥¦¥§¥Ö¥Û¥¹¥È¤Ë¤ª¤±¤ëPHP¥¤¥ó¥¿¡¼¥×¥ê¥¿¡¼¤ÈMySQL¥µ¡¼¥Ð¡¼¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤¹¡£Nucleus¤Î¥µ¥Ý¡¼¥È¥Õ¥©¡¼¥é¥à¤ËÌäÂê¤òÊó¹ð¤¹¤ë¤È¤­¤Ï¡¢¤³¤Î¾ðÊó¤ò½ñ¤­Åº¤¨¤Æ¤¯¤À¤µ¤¤¡£</p>
126
127                 <ul>
128                         <li>PHP:
129
130 <?php
131         echo phpversion();
132         $minVersion = '4.0.6';
133
134         if (phpversion() < $minVersion) {
135                 echo ' <span class="warning">Ãí°Õ: Nucleus¤ÎÆ°ºî¤Ë¤Ï¾¯¤Ê¤¯¤È¤â¥Ð¡¼¥¸¥ç¥ó ',$minVersion,' ¤¬É¬ÍפȤµ¤ì¤Þ¤¹</span>';
136         }
137 ?>
138
139                         </li>
140                         <li>MySQL:
141
142 <?php
143         // note: this piece of code is taken from phpMyAdmin
144         $result = @mysql_query('SELECT VERSION() AS version');
145
146         if ($result != FALSE && @mysql_num_rows($result) > 0) {
147                 $row = mysql_fetch_array($result);
148                 $match = explode('.', $row['version']);
149         } else {
150                 $result = @mysql_query('SHOW VARIABLES LIKE \'version\'');
151
152                 if ($result != FALSE && @mysql_num_rows($result) > 0) {
153                         $row = mysql_fetch_row($result);
154                         $match = explode('.', $row[1]);
155                 } else {
156                         $match[0] = '?';
157                         $match[1] = '?';
158                         $match[2] = '?';
159                 }
160         }
161
162         if (!isset($match) || !isset($match[0]) ) {
163                 $match[0] = 3;
164         }
165
166         if (!isset($match[1]) ) {
167                 $match[1] = 21;
168         }
169
170         if (!isset($match[2]) ) {
171                 $match[2] = 0;
172         }
173
174         if ($match[0] != '?') {
175                 $match[0] = intval($match[0]);
176                 $match[1] = intval($match[1]);
177         }
178
179         $mysqlVersion = implode($match, '.');
180         $minVersion = '3.23';
181
182         echo $mysqlVersion;
183
184         if ($mysqlVersion < $minVersion) {
185                 echo ' <span class="warning">Ãí°Õ: Nucleus¤ÎÆ°ºî¤Ë¤Ï¾¯¤Ê¤¯¤È¤â¥Ð¡¼¥¸¥ç¥ó ',$minVersion,' ¤¬É¬ÍפȤµ¤ì¤Þ¤¹</span>';
186         }
187 ?>
188
189                         </li>
190                 </ul>
191
192 <?php
193         // tell people how they can have their config file filled out automatically
194         if (@file_exists('config.php') && @!is_writable('config.php') ) {
195 ?>
196
197                 <h1><i>config.php</i>¤Î¼«Æ°¥¢¥Ã¥×¥Ç¡¼¥È</h1>
198
199                 <p>¤â¤·<em>config.php</em>¤ò¼«Æ°Åª¤Ë¹¹¿·¤¹¤ë¤è¤¦¤Ë¤·¤¿¤¤¤Ê¤é¡¢½ñ¤­¹þ¤ß²Äǽ¤Ë¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£<em>config.php</em>¤Î¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤ò<strong>666</strong>¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£Nucleus¤Î¥¤¥ó¥¹¥È¡¼¥ëÀ®¸ù¸å¤Ë¡¢¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤ò<strong>444</strong>¤ËÌᤵ¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡Ê<a href="nucleus/documentation/tips.html#filepermissions">¥Ñ¡¼¥ß¥Ã¥·¥ç¥óÊѹ¹¤Î´Ê°×¥¬¥¤¥É</a>¡Ë¡£</p>
200
201                 <p>¤â¤·¥Õ¥¡¥¤¥ë¤Ë½ñ¤­¹þ¤Þ¤Ê¤¤¤È¤¤¤¦ÁªÂò¤ò¤·¤¿¡Ê¤¢¤ë¤¤¤Ï¹Ô¤¨¤Ê¤¤¡Ë¾ì¹ç¡§¤´¿´Çۤʤ¯¡£¥¤¥ó¥¹¥È¡¼¥ë¤Î²áÄø¤Ç<em>config.php</em>¤ÎÃæ¿È¤¬Ä󶡤µ¤ì¤Þ¤¹¡£¤Ç¤¹¤«¤é¡¢¤½¤ì¤ò¤´¼«¿È¤Ç¥¢¥Ã¥×¥í¡¼¥É¤·¤Æ¤¯¤À¤µ¤¤¡£</p>
202
203 <?php } ?>
204
205                 <h1>MySQL¤Î¥í¥°¥¤¥ó¥Ç¡¼¥¿</h1>
206
207                 <p>MySQL¤Î¥Ç¡¼¥¿¤ò°Ê²¼¤ËÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£¤½¤ì¤é¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¡¦¥Æ¡¼¥Ö¥ë¤òºîÀ®¤·¾ðÊó¤òÆþÎϤ¹¤ë¤¿¤á¤ËɬÍפʤâ¤Î¤Ç¤¹¡£¸å¤Ç¡¢<i>config.php</i>¤Ë¤âµ­Æþ¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡Ê¾åµ­¤Î¼«Æ°¥¢¥Ã¥×¥Ç¡¼¥È¤òÍøÍѤ¹¤ë¾ì¹ç¡¢¤½¤Î¼ê½ç¤Ï¾Êά¤µ¤ì¤Þ¤¹¡Ë¡£</p>
208
209                 <p>¤â¤·¤³¤Î¾ðÊ󤬤狼¤é¤Ê¤±¤ì¤Ð¡¢¥·¥¹¥Æ¥à´ÉÍý¼Ô¤«¥Û¥¹¥Æ¥£¥ó¥°¸µ¤ËÏ¢Íí¤ò¤È¤Ã¤Æ¤¯¤À¤µ¤¤¡£¤Û¤È¤ó¤É¤Î¾ì¹ç¡¢¥Û¥¹¥È̾¤Ï'localhost'¤Ç¤¹¡£¤â¤·Nucleus¤¬¤¢¤Ê¤¿¤Î¥µ¡¼¥Ð¤ÎPHPÀßÄ꤫¤é'default MySQL host'¤ò¸¡ÃΤ·¤¿¤Ê¤é¡¢'¥Û¥¹¥È̾'¤Ë´û¤Ëµ­Æþ¤µ¤ì¤Æ¤¤¤ë¤Ï¤º¤Ç¤¹¡£¤â¤Ã¤È¤â¡¢¤³¤Î¾ðÊó¤¬Àµ³Î¤Ç¤¢¤ë¤È¤¤¤¦ÊݾڤϤ¢¤ê¤Þ¤»¤ó¡£</p>
210
211                 <fieldset>
212                         <legend>´ðËܤΥǡ¼¥¿¥Ù¡¼¥¹ÀßÄê</legend>
213                         <table>
214                                 <tr>
215                                         <td>¥Û¥¹¥È̾¡§</td>
216                                         <td><input name="mySQL_host" value="<?php echo htmlspecialchars(@ini_get('mysql.default_host') )?>" /></td>
217                                 </tr>
218                                 <tr>
219                                         <td>¥æ¡¼¥¶¡¼Ì¾¡§</td>
220                                         <td><input name="mySQL_user" /></td>
221                                 </tr>
222                                 <tr>
223                                         <td>¥Ñ¥¹¥ï¡¼¥É¡§</td>
224                                         <td><input name="mySQL_password" type="password" /></td>
225                                 </tr>
226                                 <tr>
227                                         <td>¥Ç¡¼¥¿¥Ù¡¼¥¹Ì¾¡§</td>
228                                         <td><input name="mySQL_database" /> (<input name="mySQL_create" value="1" type="checkbox" id="mySQL_create"><label for="mySQL_create" />¥Ç¡¼¥¿¥Ù¡¼¥¹¤òºîÀ®¤¹¤ëɬÍפ¬¤¢¤ë</label>)</td>
229                                 </tr>
230                         </table>
231                 </fieldset>
232
233                 <fieldset>
234                         <legend>¹âÅù¤Ê¥Ç¡¼¥¿¥Ù¡¼¥¹ÀßÄê</legend>
235                         <table>
236                                 <tr>
237                                         <td><input name="mySQL_usePrefix" value="1" type="checkbox" id="mySQL_usePrefix"><label for="mySQL_usePrefix" />¥Æ¡¼¥Ö¥ë¡¦¥×¥ê¥Õ¥£¥Ã¥¯¥¹¤òÍøÍÑ</label></td>
238                                         <td><input name="mySQL_tablePrefix" value="" /></td>
239                                 </tr>
240                         </table>
241
242                         <p>°ì¤Ä¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤ËÊ£¿ô¤ÎNucleus¤ò¥¤¥ó¥¹¥È¡¼¥ë¤·¤Æ¤ª¤ê¡¢¼«Ê¬¤¬²¿¤ò¤ä¤Ã¤Æ¤¤¤ë¤Î¤«Íý²ò¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤ò½ü¤¤¤Æ¤Ï¡¢<strong>¤³¤ì¤òÊѹ¹¤¹¤ëɬÍפϤ¢¤ê¤Þ¤»¤ó</strong>¡£</p>
243                         <p>Nucleus¤Ë¤è¤Ã¤ÆÀ¸À®¤µ¤ì¤¿¤¹¤Ù¤Æ¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¥Æ¡¼¥Ö¥ë¤Ï¡¢¤³¤Î¥×¥ê¥Õ¥£¥Ã¥¯¥¹¤¬Æ¬¤Ë¤Ä¤­¤Þ¤¹¡£</p>
244                 </fieldset>
245
246         <h1>¥Ç¥£¥ì¥¯¥È¥ê¤ÈURL</h1>
247
248         <p>¤³¤Î¥¤¥ó¥¹¥È¡¼¥ë¥¹¥¯¥ê¥×¥È¤ÏNucleus¤¬¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤ë¥Ç¥£¥ì¥¯¥È¥ê¤ÈURL¤ò¸«¤Ä¤±¤è¤¦¤È¤·¤Þ¤·¤¿¡£²¼¤ÎÃͤò¥Á¥§¥Ã¥¯¤·¤ÆɬÍפʤéÄûÀµ¤·¤Æ¤¯¤À¤µ¤¤¡£¥Õ¥¡¥¤¥ë¤Ø¤Î¥Ñ¥¹¤ÈURL¤Ï¥¹¥é¥Ã¥·¥å'/'¤Ç½ª¤ï¤é¤Ê¤¯¤Æ¤Ï¤Ê¤ê¤Þ¤»¤ó¡£</p>
249
250 <?php
251
252         // no need to this all! dirname(__FILE__) is all we need -- moraes
253         /*
254         // discover full path
255         $fullPath = serverVar('PATH_TRANSLATED');
256
257         if ($fullPath == '') {
258                 $fullPath = serverVar('SCRIPT_FILENAME');
259         }
260
261         $basePath = str_replace('install.php', '', $fullPath);
262         $basePath = replaceDoubleBackslash($basePath);
263         $basePath = replaceDoubleBackslash($basePath);
264
265         // add slash at end if necessary
266         if (!endsWithSlash($basePath) ) {
267                 $basePath .= '/';
268         }
269         */
270
271         $basePath = dirname(__FILE__) . '/';
272 ?>
273
274                 <fieldset>
275                         <legend>URLs and directories</legend>
276                         <table>
277                                 <tr>
278                                         <td>Site <strong>URL</strong>:</td>
279                                         <td><input name="IndexURL" size="60" value="<?php
280                                                 $url = 'http://' . serverVar('HTTP_HOST') . serverVar('PHP_SELF');
281                                                 $url = str_replace('install.php', '', $url);
282                                                 $url = replaceDoubleBackslash($url);
283
284                                                 // add slash at end if necessary
285                                                 if (!endsWithSlash($url) ) {
286                                                         $url .= '/';
287                                                 }
288
289                                                 echo $url; ?>" /></td>
290                                 </tr>
291                                 <tr>
292                                         <td>Admin-area <strong>URL</strong>:</td>
293                                         <td><input name="AdminURL" size="60" value="<?php
294                                                 if ($url) {
295                                                         echo $url, 'nucleus/';
296                                                 } ?>" /></td>
297                                 </tr>
298                                 <tr>
299                                         <td>Admin-area <strong>path</strong>:</td>
300                                         <td><input name="AdminPath" size="60" value="<?php
301                                                 if($basePath) {
302                                                         echo $basePath, 'nucleus/';
303                                                 } ?>" /></td>
304                                 </tr>
305                                 <tr>
306                                         <td>Media files <strong>URL</strong>:</td>
307                                         <td><input name="MediaURL" size="60" value="<?php
308                                                 if ($url) {
309                                                         echo $url, 'media/';
310                                                 } ?>" /></td>
311                                 </tr>
312                                 <tr>
313                                         <td>Media directory <strong>path</strong>:</td>
314                                         <td><input name="MediaPath" size="60" value="<?php
315                                                 if ($basePath) {
316                                                         echo $basePath, 'media/';
317                                                 } ?>" /></td>
318                                 </tr>
319                                 <tr>
320                                         <td>Extra skin files <strong>URL</strong>:</td>
321                                         <td><input name="SkinsURL" size="60" value="<?php
322                                                 if ($url) {
323                                                         echo $url, 'skins/';
324                                                 } ?>" />
325                                                 <br />(¥¤¥ó¥Ý¡¼¥È¤µ¤ì¤¿¥¹¥­¥ó¤¬»ÈÍÑ)
326                                         </td>
327                                 </tr>
328                                 <tr>
329                                         <td>Extra skin files directory <strong>path</strong>:</td>
330                                         <td><input name="SkinsPath" size="60" value="<?php
331                                                 if ($basePath) {
332                                                         echo $basePath, 'skins/';
333                                                 } ?>" />
334                                                 <br />(¥¤¥ó¥Ý¡¼¥È¤µ¤ì¤¿¥¹¥­¥ó¤Î¥Õ¥¡¥¤¥ëÎà¤òÃÖ¤¯¾ì½ê)
335                                         </td>
336                                 </tr>
337                                 <tr>
338                                         <td>Plugin files <strong>URL</strong>:</td>
339                                         <td><input name="PluginURL" size="60" value="<?php
340                                                 if ($url) {
341                                                         echo $url, 'nucleus/plugins/';
342                                                 } ?>" /></td>
343                                 </tr>
344                                 <tr>
345                                         <td>Action <strong>URL</strong>:</td>
346                                         <td><input name="ActionURL" size="60" value="<?php
347                                                 if ($url) {
348                                                         echo $url, 'action.php';
349                                                 } ?>" />
350                                                 <br />(<tt>action.php</tt>¤Ø¤Îhttp://¤«¤é»Ï¤Þ¤ëURL)
351                                         </td>
352                                 </tr>
353                         </table>
354                 </fieldset>
355
356                 <p class="note"><strong>ÉÕµ­:</strong> ÁêÂХѥ¹¤Ç¤Ï¤Ê¤¯<strong>ÀäÂХѥ¹¤ò»È¤Ã¤Æ¤¯¤À¤µ¤¤</strong>¡£Ä̾ÀäÂХѥ¹¤Ï<tt>/home/username/public_html/</tt>¤Î¤è¤¦¤Ê·Á¤ò¤È¤ê¤Þ¤¹¡£Unix¥·¥¹¥Æ¥à¡Ê¤Û¤È¤ó¤É¤Î¥µ¡¼¥Ð¡¼¤¬¤½¤¦¤Ç¤¹¡Ë¤Ë¤ª¤¤¤Æ¡¢¥Ñ¥¹¤Ï¥¹¥é¥Ã¥·¥å¤«¤é»Ï¤Þ¤ê¤Þ¤¹¡£¤â¤·¤³¤ì¤é¤Î¾ðÊóÆþÎϤËÌäÂ꤬À¸¤¸¤¿¤é¡¢¤¢¤Ê¤¿¤Î¥µ¡¼¥Ð´ÉÍý¼Ô¤Ë¤¿¤º¤Í¤ë¤Ù¤­¤Ç¤¹¡£</p>
357
358                 <h1>´ÉÍý¸¢¸Â¤ò¤â¤Ä¥æ¡¼¥¶¡¼</h1>
359
360                 <p>°Ê²¼¤Ë¡¢¥µ¥¤¥È¤ÎºÇ½é¤Î¥æ¡¼¥¶¡¼¤òºîÀ®¤¹¤ë¤¿¤á¤Î¤¤¤¯¤Ä¤«¤Î¾ðÊó¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£</p>
361
362                 <fieldset>
363                         <legend>´ÉÍý¸¢¸Â¤ò»ý¤Ä¥æ¡¼¥¶¡¼</legend>
364                         <table>
365                                 <tr>
366                                         <td>ɽ¼¨¤µ¤ì¤ë̾Á°¡§</td>
367                                         <td><input name="User_name" value="" /> <small>(µö²Ä¤µ¤ì¤ëʸ»ú¡§a-z ¤È 0-9¡¢ºÇ½é¤ÈºÇ¸å°Ê³°¤Î¥¹¥Ú¡¼¥¹)</small></td>
368                                 </tr>
369                                 <tr>
370                                         <td>ËÜ̾¡Ê¥Ï¥ó¥É¥ë̾¡Ë¡§</td>
371                                         <td><input name="User_realname" value="" /></td>
372                                 </tr>
373                                 <tr>
374                                         <td>¥Ñ¥¹¥ï¡¼¥É¡§</td>
375                                         <td><input name="User_password" type="password" value="" /></td>
376                                 </tr>
377                                 <tr>
378                                         <td>¥Ñ¥¹¥ï¡¼¥É¤Î³Îǧ¡§</td>
379                                         <td><input name="User_password2" type="password" value="" /></td>
380                                 </tr>
381                                 <tr>
382                                         <td>¥á¡¼¥ë¥¢¥É¥ì¥¹¡§</td>
383                                         <td><input name="User_email" value="" /> <small>(ÍøÍѲÄǽ¤Ê¥á¡¼¥ë¥¢¥É¥ì¥¹¤òÆþ¤ì¤Æ¤¯¤À¤µ¤¤)</small></td>
384                                 </tr>
385                         </table>
386                 </fieldset>
387
388                 <h1>¥¦¥§¥Ö¥í¥°¤Î¥Ç¡¼¥¿</h1>
389
390                 <p>°Ê²¼¤Ë¡¢¥Ç¥Õ¥©¥ë¥È¤Îweblog¤òºîÀ®¤¹¤ë¤¿¤á¤Ë¤¤¤¯¤Ä¤«¤Î¾ðÊó¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£¤³¤Îweblog¤Î̾Á°¤Ï¡¢¥µ¥¤¥È̾¤È¤·¤Æ¤âÍøÍѤµ¤ì¤Þ¤¹¡£</p>
391
392                 <fieldset>
393                         <legend>¥¦¥§¥Ö¥í¥°¤Î¥Ç¡¼¥¿</legend>
394                         <table>
395                                 <tr>
396                                         <td>Blog̾¡§</td>
397                                         <td><input name="Blog_name" size="60" value="My Nucleus CMS" /></td>
398                                 </tr>
399                                 <tr>
400                                         <td>Blog¤Îû½Ì̾¡§</td>
401                                         <td><input name="Blog_shortname" value="mynucleuscms" /> <small>(µö²Ä¤µ¤ì¤ëʸ»ú¡§a-z ¤È 0-9¡¢¥¹¥Ú¡¼¥¹¤ÏÉÔ²Ä)</small></td>
402                                 </tr>
403                         </table>
404                 </fieldset>
405
406                 <h1>¥Ç¡¼¥¿¤ÎÁ÷¿®</h1>
407
408                 <p>¾å¤Ë½ñ¤¤¤Æ¤­¤¿¥Ç¡¼¥¿¤¬Àµ¤·¤¤¤«³Î¤«¤á¤Æ¤¯¤À¤µ¤¤¡£¤è¤±¤ì¤Ð¥Ç¡¼¥¿¥Ù¡¼¥¹¡¦¥Æ¡¼¥Ö¥ë¤ÈºÇ½é¤Î¥Ç¡¼¥¿¤òÀßÄꤹ¤ë¤¿¤á¤Ë²¼¤Î¥Ü¥¿¥ó¤ò²¡¤·¤Æ¤¯¤À¤µ¤¤¡£¾¯¤·»þ´Ö¤¬¤«¤«¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¤¬¤´¿ÉÊú¤ò¡£<b>¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤Î¤Ï°ì²ó¤À¤±¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£</b></p>
409
410                 <p><input name="action" value="go" type="hidden" /> <input type="submit" value="Nucleus CMS¤Î¥¤¥ó¥¹¥È¡¼¥ë" onclick="return checkSubmit();" /></p>
411
412                 </form>
413         </body>
414 </html>
415
416 <?php }
417
418 function tableName($unPrefixed) {
419         global $mysql_usePrefix, $mysql_prefix;
420
421         if ($mysql_usePrefix == 1) {
422                 return $mysql_prefix . $unPrefixed;
423         } else {
424                 return $unPrefixed;
425         }
426 }
427
428 function doInstall() {
429         global $mysql_usePrefix, $mysql_prefix;
430
431         // 0. put all POST-vars into vars
432         $mysql_host = postVar('mySQL_host');
433         $mysql_user = postVar('mySQL_user');
434         $mysql_password = postVar('mySQL_password');
435         $mysql_database = postVar('mySQL_database');
436         $mysql_create = postVar('mySQL_create');
437         $mysql_usePrefix = postVar('mySQL_usePrefix');
438         $mysql_prefix = postVar('mySQL_tablePrefix');
439         $config_indexurl = postVar('IndexURL');
440         $config_adminurl = postVar('AdminURL');
441         $config_adminpath = postVar('AdminPath');
442         $config_mediaurl = postVar('MediaURL');
443         $config_skinsurl = postVar('SkinsURL');
444         $config_pluginurl = postVar('PluginURL');
445         $config_actionurl = postVar('ActionURL');
446         $config_mediapath = postVar('MediaPath');
447         $config_skinspath = postVar('SkinsPath');
448         $user_name = postVar('User_name');
449         $user_realname = postVar('User_realname');
450         $user_password = postVar('User_password');
451         $user_password2 = postVar('User_password2');
452         $user_email = postVar('User_email');
453         $blog_name = postVar('Blog_name');
454         $blog_shortname = postVar('Blog_shortname');
455         $config_adminemail = $user_email;
456         $config_sitename = $blog_name;
457
458         $config_indexurl = replaceDoubleBackslash($config_indexurl);
459         $config_adminurl = replaceDoubleBackslash($config_adminurl);
460         $config_mediaurl = replaceDoubleBackslash($config_mediaurl);
461         $config_skinsurl = replaceDoubleBackslash($config_skinsurl);
462         $config_pluginurl = replaceDoubleBackslash($config_pluginurl);
463         $config_actionurl = replaceDoubleBackslash($config_actionurl);
464         $config_adminpath = replaceDoubleBackslash($config_adminpath);
465         $config_skinspath = replaceDoubleBackslash($config_skinspath);
466         $config_mediapath = replaceDoubleBackslash($config_mediapath);
467
468         // 1. check all the data
469         $errors = array();
470
471         if (!$mysql_database) {
472                 array_push($errors, 'mySQL database name missing');
473         }
474
475         if (($mysql_usePrefix == 1) && (strlen($mysql_prefix) == 0) ) {
476                 array_push($errors, 'mySQL prefix was selected, but prefix is empty');
477         }
478
479         if (($mysql_usePrefix == 1) && (!eregi('^[a-zA-Z0-9_]+$', $mysql_prefix) ) ) {
480                 array_push($errors, 'mySQL prefix should only contain characters from the ranges A-Z, a-z, 0-9 or underscores');
481         }
482
483         // TODO: add action.php check
484         if (!endsWithSlash($config_indexurl) || !endsWithSlash($config_adminurl) || !endsWithSlash($config_mediaurl) || !endsWithSlash($config_pluginurl) || !endsWithSlash($config_skinsurl) ) {
485                 array_push($errors, 'One of the URLs does not end with a slash, or action url does not end with \'action.php\'');
486         }
487
488         if (!endsWithSlash($config_adminpath) ) {
489                 array_push($errors, 'The path of the administration area does not end with a slash');
490         }
491
492         if (!endsWithSlash($config_mediapath) ) {
493                 array_push($errors, 'The media path does not end with a slash');
494         }
495
496         if (!endsWithSlash($config_skinspath) ) {
497                 array_push($errors, 'The skins path does not end with a slash');
498         }
499
500         if (!is_dir($config_adminpath) ) {
501                 array_push($errors, 'The path of the administration area does not exist on your server');
502         }
503
504         if (!_isValidMailAddress($user_email) ) {
505                 array_push($errors, 'Invalid e-mail address given for user');
506         }
507
508         if (!_isValidDisplayName($user_name) ) {
509                 array_push($errors, 'User name is not a valid display name (allowed chars: a-zA-Z0-9 and spaces)');
510         }
511
512         if (!$user_password || !$user_password2) {
513                 array_push($errors, 'User password is empty');
514         }
515
516         if ($user_password != $user_password2) {
517                 array_push($errors, 'User password do not match');
518         }
519
520         if (!_isValidShortName($blog_shortname) ) {
521                 array_push($errors, 'Invalid short name given for blog (allowed chars: a-z0-9, no spaces)');
522         }
523
524         if (sizeof($errors) > 0) {
525                 showErrorMessages($errors);
526         }
527
528         // 2. try to log in to mySQL
529         global $MYSQL_CONN;
530         $MYSQL_CONN = @mysql_connect($mysql_host, $mysql_user, $mysql_password);
531
532         if ($MYSQL_CONN == false) {
533                 _doError('Could not connect to mySQL server: ' . mysql_error() );
534         }
535
536         // 3. try to create database (if needed)
537         if ($mysql_create == 1) {
538                 mysql_query('CREATE DATABASE ' . $mysql_database) or _doError('Could not create database. Make sure you have the rights to do so. SQL error was: ' . mysql_error() );
539         }
540
541         // 4. try to select database
542         mysql_select_db($mysql_database) or _doError('Could not select database. Make sure it exists');
543
544         // 5. execute queries
545         $filename = 'install.sql';
546         $fd = fopen($filename, 'r');
547         $queries = fread($fd, filesize($filename) );
548         fclose($fd);
549
550         $queries = split("(;\n|;\r)", $queries);
551
552         $aTableNames = array(
553                 'nucleus_actionlog',
554                 'nucleus_ban',
555                 'nucleus_blog',
556                 'nucleus_category',
557                 'nucleus_comment',
558                 'nucleus_config',
559                 'nucleus_item',
560                 'nucleus_karma',
561                 'nucleus_member',
562                 'nucleus_plugin',
563                 'nucleus_skin',
564                 'nucleus_template',
565                 'nucleus_team',
566                 'nucleus_activation',
567                 'nucleus_tickets'
568                 );
569 // these are unneeded (one of the replacements above takes care of them)
570 //                      'nucleus_plugin_event',
571 //                      'nucleus_plugin_option',
572 //                      'nucleus_plugin_option_desc',
573 //                      'nucleus_skin_desc',
574 //                      'nucleus_template_desc',
575
576         $aTableNamesPrefixed = array(
577                 $mysql_prefix . 'nucleus_actionlog',
578                 $mysql_prefix . 'nucleus_ban',
579                 $mysql_prefix . 'nucleus_blog',
580                 $mysql_prefix . 'nucleus_category',
581                 $mysql_prefix . 'nucleus_comment',
582                 $mysql_prefix . 'nucleus_config',
583                 $mysql_prefix . 'nucleus_item',
584                 $mysql_prefix . 'nucleus_karma',
585                 $mysql_prefix . 'nucleus_member',
586                 $mysql_prefix . 'nucleus_plugin',
587                 $mysql_prefix . 'nucleus_skin',
588                 $mysql_prefix . 'nucleus_template',
589                 $mysql_prefix . 'nucleus_team',
590                 $mysql_prefix . 'nucleus_activation',
591                 $mysql_prefix . 'nucleus_tickets'
592                 );
593 // these are unneeded (one of the replacements above takes care of them)
594 //                      $mysql_prefix . 'nucleus_plugin_event',
595 //                      $mysql_prefix . 'nucleus_plugin_option',
596 //                      $mysql_prefix . 'nucleus_plugin_option_desc',
597 //                      $mysql_prefix . 'nucleus_skin_desc',
598 //                      $mysql_prefix . 'nucleus_template_desc',
599
600         $count = count($queries);
601
602         for ($idx = 0; $idx < $count; $idx++) {
603                 $query = trim($queries[$idx]);
604                 // echo "QUERY = <small>" . htmlspecialchars($query) . "</small><p>";
605
606                 if ($query) {
607
608                         if ($mysql_usePrefix == 1) {
609                                         $query = str_replace($aTableNames, $aTableNamesPrefixed, $query);
610                         }
611
612                         mysql_query($query) or _doError('Error while executing query (<small>' . htmlspecialchars($query) . '</small>): ' . mysql_error() );
613                 }
614         }
615
616         // 6. update global settings
617         updateConfig('IndexURL', $config_indexurl);
618         updateConfig('AdminURL', $config_adminurl);
619         updateConfig('MediaURL', $config_mediaurl);
620         updateConfig('SkinsURL', $config_skinsurl);
621         updateConfig('PluginURL', $config_pluginurl);
622         updateConfig('ActionURL', $config_actionurl);
623         updateConfig('AdminEmail', $config_adminemail);
624         updateConfig('SiteName', $config_sitename);
625
626         // 7. update GOD member
627         $query = 'UPDATE ' . tableName('nucleus_member')
628                         . " SET mname='" . addslashes($user_name) . "',"
629                         . " mrealname='" . addslashes($user_realname) . "',"
630                         . " mpassword='" . md5(addslashes($user_password) ) . "',"
631                         . " murl='" . addslashes($config_indexurl) . "',"
632                         . " memail='" . addslashes($user_email) . "',"
633                         . " madmin=1, mcanlogin=1"
634                         . " WHERE mnumber=1";
635
636         mysql_query($query) or _doError('Error while setting member settings: ' . mysql_error() );
637
638         // 8. update weblog settings
639         $query = 'UPDATE ' . tableName('nucleus_blog')
640                         . " SET bname='" . addslashes($blog_name) . "',"
641                         . " bshortname='" . addslashes($blog_shortname) . "',"
642                         . " burl='" . addslashes($config_indexurl) . "'"
643                         . " WHERE bnumber=1";
644
645         mysql_query($query) or _doError('Error while setting weblog settings: ' . mysql_error() );
646
647         // 9. update item date
648         $query = 'UPDATE ' . tableName('nucleus_item')
649                         . " SET itime='" . date('Y-m-d H:i:s', time() ) ."'"
650                         . " WHERE inumber=1";
651
652         mysql_query($query) or _doError('Error with query: ' . mysql_error() );
653
654         global $aConfPlugsToInstall, $aConfSkinsToImport;
655         $aSkinErrors = array();
656         $aPlugErrors = array();
657
658         if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {
659                 // 10. set global variables
660                 global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX;
661
662                 $MYSQL_HOST = $mysql_host;
663                 $MYSQL_USER = $mysql_user;
664                 $MYSQL_PASSWORD = $mysql_password;
665                 $MYSQL_DATABASE = $mysql_database;
666                 $MYSQL_PREFIX = ($mysql_usePrefix == 1)?$mysql_prefix:'';
667
668                 global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS;
669
670                 $DIR_NUCLEUS = $config_adminpath;
671                 $DIR_MEDIA = $config_mediapath;
672                 $DIR_SKINS = $config_skinspath;
673                 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
674                 $DIR_LANG = $DIR_NUCLEUS . 'language/';
675                 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
676
677                 // close database connection (needs to be closed if we want to include globalfunctions.php)
678                 mysql_close();
679
680                 $manager = '';
681                 include_once($DIR_LIBS . 'globalfunctions.php');
682
683                 // 11. install custom skins
684                 $aSkinErrors = installCustomSkins($manager);
685
686                 // 12. install custom plugins
687                 $aPlugErrors = installCustomPlugs($manager);
688         }
689
690         // 12. Write config file ourselves (if possible)
691         $bConfigWritten = 0;
692
693         if (@file_exists('config.php') && is_writable('config.php') && $fp = @fopen('config.php', 'w') ) {
694                 $config_data = '<' . '?php' . "\n\n";
695                 //$config_data .= "\n"; (extraneous, just added extra \n to previous line
696                 $config_data .= "       // mySQL connection information\n";
697                 $config_data .= "       \$MYSQL_HOST = '" . $mysql_host . "';\n";
698                 $config_data .= "       \$MYSQL_USER = '" . $mysql_user . "';\n";
699                 $config_data .= "       \$MYSQL_PASSWORD = '" . $mysql_password . "';\n";
700                 $config_data .= "       \$MYSQL_DATABASE = '" . $mysql_database . "';\n";
701                 $config_data .= "       \$MYSQL_PREFIX = '" . (($mysql_usePrefix == 1)?$mysql_prefix:'') . "';\n";
702                 $config_data .= "\n";
703                 $config_data .= "       // main nucleus directory\n";
704                 $config_data .= "       \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";
705                 $config_data .= "\n";
706                 $config_data .= "       // path to media dir\n";
707                 $config_data .= "       \$DIR_MEDIA = '" . $config_mediapath . "';\n";
708                 $config_data .= "\n";
709                 $config_data .= "       // extra skin files for imported skins\n";
710                 $config_data .= "       \$DIR_SKINS = '" . $config_skinspath . "';\n";
711                 $config_data .= "\n";
712                 $config_data .= "       // these dirs are normally sub dirs of the nucleus dir, but \n";
713                 $config_data .= "       // you can redefine them if you wish\n";
714                 $config_data .= "       \$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n";
715                 $config_data .= "       \$DIR_LANG = \$DIR_NUCLEUS . 'language/';\n";
716                 $config_data .= "       \$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n";
717                 $config_data .= "\n";
718                 $config_data .= "       // include libs\n";
719                 $config_data .= "       include(\$DIR_LIBS.'globalfunctions.php');\n";
720                 $config_data .= "       if (!extension_loaded('mbstring')) {\n";
721                 $config_data .= "       include(\$DIR_LIBS.'mb_emulator/mb-emulator.php');\n";
722                 $config_data .= "       }\n";
723                 $config_data .= "?" . ">";
724
725                 $result = @fputs($fp, $config_data, strlen($config_data) );
726                 fclose($fp);
727
728                 if ($result) {
729                         $bConfigWritten = 1;
730                 }
731         }
732
733 ?>
734 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
735 <html xmlns="http://www.w3.org/1999/xhtml">
736 <head>
737         <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP" />
738         <title>Nucleus¤Î¥¤¥ó¥¹¥È¡¼¥ë</title>
739         <style>@import url('nucleus/styles/manual.css');</style>
740 </head>
741 <body>
742         <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
743
744 <?php
745         $aAllErrors = array_merge($aSkinErrors, $aPlugErrors);
746
747         if (count($aAllErrors) > 0) {
748                 echo '<h1>Skin/Plugin Install errors</h1>';
749                 echo '<ul><li>' . implode('</li><li>', $aAllErrors) . '</li></ul>';
750         }
751
752         if (!$bConfigWritten) { ?>
753                 <h1>¥¤¥ó¥¹¥È¡¼¥ë¤Ï¤Û¤Ü´°Î»¤·¤Þ¤·¤¿¡ª</h1>
754
755                 <p>¥Ç¡¼¥¿¥Ù¡¼¥¹¥Æ¡¼¥Ö¥ë¤Î½é´üÃÍÆþÎϤ¬À®¸ù¤·¤Þ¤·¤¿¡£¸å¤Ï<i>config.php</i>¤ò½ñ¤­´¹¤¨¤ë¤À¤±¤Ç¤¹¡£°Ê²¼¤Ë½ñ¤­´¹¤¨¤ë¤Ù¤­ÆâÍƤòɽ¼¨¤·¤Þ¤¹¡Êmysql¤Î¥Ñ¥¹¥ï¡¼¥É¤Ï¥Þ¥¹¥¯¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¤³¤³¤Ï¼ÂºÝ¤Î¤â¤Î¤Ë½ñ¤­´¹¤¨¤Æ¤¯¤À¤µ¤¤¡Ë</p>
756
757                 <pre><code>&lt;?php
758         // mySQL connection information
759         $MYSQL_HOST = '<b><?php echo $mysql_host?></b>';
760         $MYSQL_USER = '<b><?php echo $mysql_user?></b>';
761         $MYSQL_PASSWORD = '<i><b>xxxxxxxxxxx</b></i>';
762         $MYSQL_DATABASE = '<b><?php echo $mysql_database?></b>';
763         $MYSQL_PREFIX = '<b><?php echo ($mysql_usePrefix == 1)?$mysql_prefix:''?></b>';
764
765         // main nucleus directory
766         $DIR_NUCLEUS = '<b><?php echo $config_adminpath?></b>';
767
768         // path to media dir
769         $DIR_MEDIA = '<b><?php echo $config_mediapath?></b>';
770
771         // extra skin files for imported skins
772         $DIR_SKINS = '<b><?php echo $config_skinspath?></b>';
773
774         // these dirs are normally sub dirs of the nucleus dir, but
775         // you can redefine them if you wish
776         $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
777         $DIR_LANG = $DIR_NUCLEUS . 'language/';
778         $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
779
780         // include libs
781         include($DIR_LIBS.'globalfunctions.php');
782         if (!extension_loaded('mbstring')) {
783                 include($DIR_LIBS.'mb_emulator/mb-emulator.php');
784         }
785 ?&gt;</code></pre>
786
787         <p>¤¢¤Ê¤¿¤Î¥³¥ó¥Ô¥å¡¼¥¿¾å¤Î¥Õ¥¡¥¤¥ë¤ò½ñ¤­´¹¤¨¤¿¤é¡¢FTP¤ò»È¤Ã¤Æ¥¦¥§¥Ö¥µ¡¼¥Ð¤Ë¥¢¥Ã¥×¥í¡¼¥É¤·¤Æ¤¯¤À¤µ¤¤¡£ASCII¥â¡¼¥É¤ÇÁ÷¿®¤·¤Æ¥Õ¥¡¥¤¥ë¤ò¾å½ñ¤­¤·¤Þ¤¹¡£</p>
788
789         <div class="note">
790                 <b>ÉÕµ­:</b> <i>config.php</i>¤ÎºÇ½é¤ä½ª¤ï¤ê¤Ë¥¹¥Ú¡¼¥¹¤ò¶õ¤±¤Ê¤¤¤è¤¦¤Ë¤·¤Þ¤·¤ç¤¦¡£¼Â¹Ô»þ¤Ë¥¨¥é¡¼¤ò°ú¤­µ¯¤³¤¹¸¶°ø¤È¤Ê¤ê¤Þ¤¹¡£<br />
791                 ¤·¤¿¤¬¤Ã¤Æ¡¢config.php¤ÎºÇ½é¤Îʸ»ú¤Ï "&lt;"¤ÇºÇ¸å¤Îʸ»ú¤Ï"&gt;"¤È¤·¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£
792         </div>
793
794 <?php } else { ?>
795
796         <h1>¥¤¥ó¥¹¥È¡¼¥ë¤Ï´°Î»¤·¤Þ¤·¤¿¡ª</h1>
797
798         <p>Nucleus¤Ï¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¡¢<code>config.php</code>¤Ï¥¢¥Ã¥×¥Ç¡¼¥È¤µ¤ì¤Þ¤·¤¿¡£</p>
799
800         <p>¥»¥­¥å¥ê¥Æ¥£¤Î¤¿¤á<code>config.php</code>¤Î¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤ò444¤ËÌ᤹¤³¤È¤ò˺¤ì¤Ê¤¤¤Ç¤¯¤À¤µ¤¤(<a href="nucleus/documentation/tips.html#filepermissions">¥Ñ¡¼¥ß¥Ã¥·¥ç¥óÊѹ¹¤Î´Ê°×¥¬¥¤¥É</a>)¡£</p>
801
802 <?php } ?>
803
804         <h1>¥¤¥ó¥¹¥È¡¼¥ë¥Õ¥¡¥¤¥ë¤Îºï½ü</h1>
805
806         <p>¥¦¥§¥Ö¥µ¡¼¥Ð¤«¤é¼¡¤Î¥Õ¥¡¥¤¥ë¤òºï½ü¤·¤Æ¤¯¤À¤µ¤¤¡§</p>
807
808         <ul>
809                 <li><b>install.sql</b>¡§¥Æ¡¼¥Ö¥ë¤Î¹½Â¤¤òÆâÊñ¤¹¤ë¥Õ¥¡¥¤¥ë</li>
810                 <li><b>install.php</b>¡§¤³¤Î¥Õ¥¡¥¤¥ë</li>
811         </ul>
812
813         <p>¤â¤·¤³¤ì¤é¤Î¥Õ¥¡¥¤¥ë¤òºï½ü¤·¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢´ÉÍýÎΰè¤ò³«¤¯¤³¤È¤¬½ÐÍè¤Þ¤»¤ó¡£</p>
814
815         <h1>¥¦¥§¥Ö¥µ¥¤¥È¤Î³Îǧ</h1>
816
817         <p>¥¦¥§¥Ö¥µ¥¤¥È¤ò»È¤¦½àÈ÷¤¬À°¤¤¤Þ¤·¤¿¡£
818                 <ul>
819                         <li><a href="<?php echo $config_adminurl?>">´ÉÍýÎΰè¤Ë¥í¥°¥¤¥ó¤·¤Æ¥µ¥¤¥È¤ÎÀßÄê¤ò¹Ô¤¦</a></li>
820                         <li><a href="<?php echo $config_indexurl?>">¤¹¤°¤Ë¥µ¥¤¥È¤Ø¹Ô¤Ã¤Æ¤ß¤ë</a></li>
821                 </ul>
822         </p>
823
824 </body>
825 </html>
826
827 <?php
828 }
829
830 function installCustomPlugs(&$manager) {
831         global $aConfPlugsToInstall, $DIR_LIBS;
832
833         $aErrors = array();
834
835         if (count($aConfPlugsToInstall) == 0) {
836                 return $aErrors;
837         }
838
839         $res = sql_query('SELECT * FROM ' . sql_table('plugin') );
840         $numCurrent = mysql_num_rows($res);
841
842         foreach ($aConfPlugsToInstall as $plugName) {
843                 // do this before calling getPlugin (in case the plugin id is used there)
844                 $query = 'INSERT INTO ' . sql_table('plugin') . ' (porder, pfile) VALUES (' . (++$numCurrent) . ', "' . addslashes($plugName) . '")';
845                 sql_query($query);
846
847                 // get and install the plugin
848                 $plugin =& $manager->getPlugin($plugName);
849
850                 if (!$plugin) {
851                         sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pfile=\'' . addslashes($plugName) . '\'');
852                         $numCurrent--;
853                         array_push($aErrors, 'Unable to install plugin ' . $plugName);
854                         continue;
855                 }
856
857                 $plugin->install();
858         }
859
860         // SYNC PLUGIN EVENT LIST
861         sql_query('DELETE FROM ' . sql_table('plugin_event') );
862
863         // loop over all installed plugins
864         $res = sql_query('SELECT pid, pfile FROM ' . sql_table('plugin') );
865
866         while($o = mysql_fetch_object($res) ) {
867                 $pid = $o->pid;
868                 $plug =& $manager->getPlugin($o->pfile);
869
870                 if ($plug) {
871                         $eventList = $plug->getEventList();
872
873                         foreach ($eventList as $eventName) {
874                                 sql_query('INSERT INTO ' . sql_table('plugin_event') . ' (pid, event) VALUES (' . $pid . ', \'' . $eventName . '\')');
875                         }
876                 }
877         }
878
879         return $aErrors;
880 }
881
882 function installCustomSkins(&$manager) {
883         global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;
884
885         $aErrors = array();
886
887         if (count($aConfSkinsToImport) == 0) {
888                 return $aErrors;
889         }
890
891         // load skinie class
892         include_once($DIR_LIBS . 'skinie.php');
893
894         $importer = new SKINIMPORT();
895
896         foreach ($aConfSkinsToImport as $skinName) {
897                 $importer->reset();
898                 $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml';
899
900                 if (!@file_exists($skinFile) ) {
901                         array_push($aErrors, 'Unable to import ' . $skinFile . ' : file does not exist');
902                         continue;
903                 }
904
905                 $error = $importer->readFile($skinFile);
906
907                 if ($error) {
908                         array_push($aErrors, 'Unable to import ' . $skinName . ' : ' . $error);
909                         continue;
910                 }
911
912                 $error = $importer->writeToDatabase(1);
913
914                 if ($error) {
915                         array_push($aErrors, 'Unable to import ' . $skinName . ' : ' . $error);
916                         continue;
917                 }
918         }
919
920         return $aErrors;
921 }
922
923 // give an error if one or more nucleus are not accessible
924 function doCheckFiles() {
925         $missingfiles = array();
926         $files = array(
927                 'install.sql',
928                 'index.php',
929                 'action.php',
930                 'nucleus/index.php',
931                 'nucleus/libs/globalfunctions.php',
932                 'nucleus/libs/ADMIN.php',
933                 'nucleus/libs/BLOG.php',
934                 'nucleus/libs/COMMENT.php',
935                 'nucleus/libs/COMMENTS.php',
936                 'nucleus/libs/ITEM.php',
937                 'nucleus/libs/MEMBER.php',
938                 'nucleus/libs/SKIN.php',
939                 'nucleus/libs/TEMPLATE.php',
940                 'nucleus/libs/MEDIA.php',
941                 'nucleus/libs/ACTIONLOG.php',
942                 'nucleus/media.php'
943                 );
944
945         $count = count($files);
946
947         for ($i = 0; $i < $count; $i++) {
948                 if (!is_readable($files[$i]) ) {
949                         array_push($missingfiles, 'File <b>' . $files[$i] . '</b> is missing or not readable.');
950                 }
951         }
952
953 // The above code replaces several if statements of the form:
954
955 //      if (!is_readable('install.sql') ) {
956 //              array_push($missingfiles, 'File <b>install.sql</b> is missing or not readable');
957 //      }
958
959         if (count($missingfiles) > 0) {
960                 showErrorMessages($missingfiles);
961         }
962 }
963
964 function updateConfig($name, $val) {
965         $name = addslashes($name);
966         $val = trim(addslashes($val) );
967
968         $query = 'UPDATE ' . tableName('nucleus_config')
969                         . " SET value='$val'"
970                         . " WHERE name='$name'";
971
972         mysql_query($query) or _doError('Query error while trying to update config: ' . mysql_error() );
973         return mysql_insert_id();
974 }
975
976 function replaceDoubleBackslash($input) {
977         return str_replace('\\', '/', $input);
978 }
979
980 function endsWithSlash($s) {
981         return (strrpos($s, '/') == strlen($s) - 1);
982 }
983
984 /**
985  * Checks if email address is valid
986  */
987 function _isValidMailAddress($address) {
988         if (preg_match("/^[a-zA-Z0-9\._-]+@+[A-Za-z0-9\._-]+\.+[A-Za-z]{2,4}$/", $address) ) {
989                 return 1;
990         } else {
991                 return 0;
992         }
993 }
994
995 // returns true if the given string is a valid shortname
996 // (to check short blog names and nicknames)
997 // logic: starts and ends with a non space, can contain spaces in between
998 //        min 2 chars
999 function _isValidShortName($name) {
1000         if (eregi("^[a-z0-9]+$", $name) ) {
1001                 return 1;
1002         } else {
1003                 return 0;
1004         }
1005 }
1006
1007
1008
1009 // returns true if the given string is a valid display name
1010 // (to check nicknames)
1011 function _isValidDisplayName($name) {
1012         if (eregi("^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$", $name) ) {
1013                 return 1;
1014         } else {
1015                 return 0;
1016         }
1017 }
1018
1019 function _doError($msg) {
1020         ?>
1021 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1022 <html xmlns="http://www.w3.org/1999/xhtml">
1023 <head>
1024         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
1025         <title>Nucleus Install</title>
1026         <style>@import url('nucleus/styles/manual.css');</style>
1027 </head>
1028 <body>
1029         <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
1030         <h1>Error!</h1>
1031
1032         <p>Error message was: "<?php echo $msg?>";</p>
1033
1034         <p><a href="install.php" onclick="history.back();return false;">Go Back</a></p>
1035 </body>
1036 </html>
1037
1038 <?php
1039         exit;
1040 }
1041
1042 function showErrorMessages($errors) {
1043         ?>
1044 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1045 <html xmlns="http://www.w3.org/1999/xhtml">
1046 <head>
1047         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
1048         <title>Nucleus Install</title>
1049         <style>@import url('nucleus/styles/manual.css');</style>
1050 </head>
1051 <body>
1052         <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
1053         <h1>Errors!</h1>
1054
1055         <p>Errors were found:</p>
1056
1057         <ul>
1058
1059 <?php
1060         while($msg = array_shift($errors) ) {
1061                 echo '<li>', $msg, '</li>';
1062         }
1063 ?>
1064
1065         </ul>
1066
1067         <p><a href="install.php" onclick="history.back();return false;">Go Back</a></p>
1068 </body>
1069 </html>
1070
1071 <?php
1072         exit;
1073 }
1074
1075 /* for the non-php systems that decide to show the contents:
1076 ?></div><?php   */
1077
1078 ?>