OSDN Git Service

Allow pluguins to authenticate before calling ticketForPlugin() function
[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.5 2007-04-04 07:52:04 kimitake Exp $
22  * $NucleusJP: install.php,v 1.7 2007/02/04 06:28:44 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
467         // 1. check all the data
468         $errors = array();
469
470         if (!$mysql_database) {
471                 array_push($errors, 'mySQL database name missing');
472         }
473
474         if (($mysql_usePrefix == 1) && (strlen($mysql_prefix) == 0) ) {
475                 array_push($errors, 'mySQL prefix was selected, but prefix is empty');
476         }
477
478         if (($mysql_usePrefix == 1) && (!eregi('^[a-zA-Z0-9_]+$', $mysql_prefix) ) ) {
479                 array_push($errors, 'mySQL prefix should only contain characters from the ranges A-Z, a-z, 0-9 or underscores');
480         }
481
482         // TODO: add action.php check
483         if (!endsWithSlash($config_indexurl) || !endsWithSlash($config_adminurl) || !endsWithSlash($config_mediaurl) || !endsWithSlash($config_pluginurl) || !endsWithSlash($config_skinsurl) ) {
484                 array_push($errors, 'One of the URLs does not end with a slash, or action url does not end with \'action.php\'');
485         }
486
487         if (!endsWithSlash($config_adminpath) ) {
488                 array_push($errors, 'The path of the administration area does not end with a slash');
489         }
490
491         if (!endsWithSlash($config_mediapath) ) {
492                 array_push($errors, 'The media path does not end with a slash');
493         }
494
495         if (!endsWithSlash($config_skinspath) ) {
496                 array_push($errors, 'The skins path does not end with a slash');
497         }
498
499         if (!is_dir($config_adminpath) ) {
500                 array_push($errors, 'The path of the administration area does not exist on your server');
501         }
502
503         if (!_isValidMailAddress($user_email) ) {
504                 array_push($errors, 'Invalid e-mail address given for user');
505         }
506
507         if (!_isValidDisplayName($user_name) ) {
508                 array_push($errors, 'User name is not a valid display name (allowed chars: a-zA-Z0-9 and spaces)');
509         }
510
511         if (!$user_password || !$user_password2) {
512                 array_push($errors, 'User password is empty');
513         }
514
515         if ($user_password != $user_password2) {
516                 array_push($errors, 'User password do not match');
517         }
518
519         if (!_isValidShortName($blog_shortname) ) {
520                 array_push($errors, 'Invalid short name given for blog (allowed chars: a-z0-9, no spaces)');
521         }
522
523         if (sizeof($errors) > 0) {
524                 showErrorMessages($errors);
525         }
526
527         // 2. try to log in to mySQL
528         global $MYSQL_CONN;
529         $MYSQL_CONN = @mysql_connect($mysql_host, $mysql_user, $mysql_password);
530
531         if ($MYSQL_CONN == false) {
532                 _doError('Could not connect to mySQL server: ' . mysql_error() );
533         }
534
535         // 3. try to create database (if needed)
536         if ($mysql_create == 1) {
537                 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() );
538         }
539
540         // 4. try to select database
541         mysql_select_db($mysql_database) or _doError('Could not select database. Make sure it exists');
542
543         // 5. execute queries
544         $filename = 'install.sql';
545         $fd = fopen($filename, 'r');
546         $queries = fread($fd, filesize($filename) );
547         fclose($fd);
548
549         $queries = split("(;\n|;\r)", $queries);
550
551         $aTableNames = array(
552                 'nucleus_actionlog',
553                 'nucleus_ban',
554                 'nucleus_blog',
555                 'nucleus_category',
556                 'nucleus_comment',
557                 'nucleus_config',
558                 'nucleus_item',
559                 'nucleus_karma',
560                 'nucleus_member',
561                 'nucleus_plugin',
562                 'nucleus_skin',
563                 'nucleus_template',
564                 'nucleus_team',
565                 'nucleus_activation',
566                 'nucleus_tickets'
567                 );
568 // these are unneeded (one of the replacements above takes care of them)
569 //                      'nucleus_plugin_event',
570 //                      'nucleus_plugin_option',
571 //                      'nucleus_plugin_option_desc',
572 //                      'nucleus_skin_desc',
573 //                      'nucleus_template_desc',
574
575         $aTableNamesPrefixed = array(
576                 $mysql_prefix . 'nucleus_actionlog',
577                 $mysql_prefix . 'nucleus_ban',
578                 $mysql_prefix . 'nucleus_blog',
579                 $mysql_prefix . 'nucleus_category',
580                 $mysql_prefix . 'nucleus_comment',
581                 $mysql_prefix . 'nucleus_config',
582                 $mysql_prefix . 'nucleus_item',
583                 $mysql_prefix . 'nucleus_karma',
584                 $mysql_prefix . 'nucleus_member',
585                 $mysql_prefix . 'nucleus_plugin',
586                 $mysql_prefix . 'nucleus_skin',
587                 $mysql_prefix . 'nucleus_template',
588                 $mysql_prefix . 'nucleus_team',
589                 $mysql_prefix . 'nucleus_activation',
590                 $mysql_prefix . 'nucleus_tickets'
591                 );
592 // these are unneeded (one of the replacements above takes care of them)
593 //                      $mysql_prefix . 'nucleus_plugin_event',
594 //                      $mysql_prefix . 'nucleus_plugin_option',
595 //                      $mysql_prefix . 'nucleus_plugin_option_desc',
596 //                      $mysql_prefix . 'nucleus_skin_desc',
597 //                      $mysql_prefix . 'nucleus_template_desc',
598
599         $count = count($queries);
600
601         for ($idx = 0; $idx < $count; $idx++) {
602                 $query = trim($queries[$idx]);
603                 // echo "QUERY = <small>" . htmlspecialchars($query) . "</small><p>";
604
605                 if ($query) {
606
607                         if ($mysql_usePrefix == 1) {
608                                         $query = str_replace($aTableNames, $aTableNamesPrefixed, $query);
609                         }
610
611                         mysql_query($query) or _doError('Error while executing query (<small>' . htmlspecialchars($query) . '</small>): ' . mysql_error() );
612                 }
613         }
614
615         // 6. update global settings
616         updateConfig('IndexURL', $config_indexurl);
617         updateConfig('AdminURL', $config_adminurl);
618         updateConfig('MediaURL', $config_mediaurl);
619         updateConfig('SkinsURL', $config_skinsurl);
620         updateConfig('PluginURL', $config_pluginurl);
621         updateConfig('ActionURL', $config_actionurl);
622         updateConfig('AdminEmail', $config_adminemail);
623         updateConfig('SiteName', $config_sitename);
624
625         // 7. update GOD member
626         $query = 'UPDATE ' . tableName('nucleus_member')
627                         . " SET mname='" . addslashes($user_name) . "',"
628                         . " mrealname='" . addslashes($user_realname) . "',"
629                         . " mpassword='" . md5(addslashes($user_password) ) . "',"
630                         . " murl='" . addslashes($config_indexurl) . "',"
631                         . " memail='" . addslashes($user_email) . "',"
632                         . " madmin=1, mcanlogin=1"
633                         . " WHERE mnumber=1";
634
635         mysql_query($query) or _doError('Error while setting member settings: ' . mysql_error() );
636
637         // 8. update weblog settings
638         $query = 'UPDATE ' . tableName('nucleus_blog')
639                         . " SET bname='" . addslashes($blog_name) . "',"
640                         . " bshortname='" . addslashes($blog_shortname) . "',"
641                         . " burl='" . addslashes($config_indexurl) . "'"
642                         . " WHERE bnumber=1";
643
644         mysql_query($query) or _doError('Error while setting weblog settings: ' . mysql_error() );
645
646         // 9. update item date
647         $query = 'UPDATE ' . tableName('nucleus_item')
648                         . " SET itime='" . date('Y-m-d H:i:s', time() ) ."'"
649                         . " WHERE inumber=1";
650
651         mysql_query($query) or _doError('Error with query: ' . mysql_error() );
652
653         global $aConfPlugsToInstall, $aConfSkinsToImport;
654         $aSkinErrors = array();
655         $aPlugErrors = array();
656
657         if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {
658                 // 10. set global variables
659                 global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX;
660
661                 $MYSQL_HOST = $mysql_host;
662                 $MYSQL_USER = $mysql_user;
663                 $MYSQL_PASSWORD = $mysql_password;
664                 $MYSQL_DATABASE = $mysql_database;
665                 $MYSQL_PREFIX = ($mysql_usePrefix == 1)?$mysql_prefix:'';
666
667                 global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS;
668
669                 $DIR_NUCLEUS = $config_adminpath;
670                 $DIR_MEDIA = $config_mediapath;
671                 $DIR_SKINS = $config_skinspath;
672                 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
673                 $DIR_LANG = $DIR_NUCLEUS . 'language/';
674                 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
675
676                 // close database connection (needs to be closed if we want to include globalfunctions.php)
677                 mysql_close();
678
679                 $manager = '';
680                 include_once($DIR_LIBS . 'globalfunctions.php');
681
682                 // 11. install custom skins
683                 $aSkinErrors = installCustomSkins($manager);
684
685                 // 12. install custom plugins
686                 $aPlugErrors = installCustomPlugs($manager);
687         }
688
689         // 12. Write config file ourselves (if possible)
690         $bConfigWritten = 0;
691
692         if (@file_exists('config.php') && is_writable('config.php') && $fp = @fopen('config.php', 'w') ) {
693                 $config_data = '<' . '?php' . "\n\n";
694                 //$config_data .= "\n"; (extraneous, just added extra \n to previous line
695                 $config_data .= "       // mySQL connection information\n";
696                 $config_data .= "       \$MYSQL_HOST = '" . $mysql_host . "';\n";
697                 $config_data .= "       \$MYSQL_USER = '" . $mysql_user . "';\n";
698                 $config_data .= "       \$MYSQL_PASSWORD = '" . $mysql_password . "';\n";
699                 $config_data .= "       \$MYSQL_DATABASE = '" . $mysql_database . "';\n";
700                 $config_data .= "       \$MYSQL_PREFIX = '" . (($mysql_usePrefix == 1)?$mysql_prefix:'') . "';\n";
701                 $config_data .= "\n";
702                 $config_data .= "       // main nucleus directory\n";
703                 $config_data .= "       \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";
704                 $config_data .= "\n";
705                 $config_data .= "       // path to media dir\n";
706                 $config_data .= "       \$DIR_MEDIA = '" . $config_mediapath . "';\n";
707                 $config_data .= "\n";
708                 $config_data .= "       // extra skin files for imported skins\n";
709                 $config_data .= "       \$DIR_SKINS = '" . $config_skinspath . "';\n";
710                 $config_data .= "\n";
711                 $config_data .= "       // these dirs are normally sub dirs of the nucleus dir, but \n";
712                 $config_data .= "       // you can redefine them if you wish\n";
713                 $config_data .= "       \$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n";
714                 $config_data .= "       \$DIR_LANG = \$DIR_NUCLEUS . 'language/';\n";
715                 $config_data .= "       \$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n";
716                 $config_data .= "\n";
717                 $config_data .= "       // include libs\n";
718                 $config_data .= "       include(\$DIR_LIBS.'globalfunctions.php');\n";
719                 $config_data .= "       if (!extension_loaded('mbstring')) {\n";
720                 $config_data .= "       include(\$DIR_LIBS.'mb_emulator/mb-emulator.php');\n";
721                 $config_data .= "       }\n";
722                 $config_data .= "?" . ">";
723
724                 $result = @fputs($fp, $config_data, strlen($config_data) );
725                 fclose($fp);
726
727                 if ($result) {
728                         $bConfigWritten = 1;
729                 }
730         }
731
732 ?>
733 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
734 <html xmlns="http://www.w3.org/1999/xhtml">
735 <head>
736         <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP" />
737         <title>Nucleus¤Î¥¤¥ó¥¹¥È¡¼¥ë</title>
738         <style>@import url('nucleus/styles/manual.css');</style>
739 </head>
740 <body>
741         <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
742
743 <?php
744         $aAllErrors = array_merge($aSkinErrors, $aPlugErrors);
745
746         if (count($aAllErrors) > 0) {
747                 echo '<h1>Skin/Plugin Install errors</h1>';
748                 echo '<ul><li>' . implode('</li><li>', $aAllErrors) . '</li></ul>';
749         }
750
751         if (!$bConfigWritten) { ?>
752                 <h1>¥¤¥ó¥¹¥È¡¼¥ë¤Ï¤Û¤Ü´°Î»¤·¤Þ¤·¤¿¡ª</h1>
753
754                 <p>¥Ç¡¼¥¿¥Ù¡¼¥¹¥Æ¡¼¥Ö¥ë¤Î½é´üÃÍÆþÎϤ¬À®¸ù¤·¤Þ¤·¤¿¡£¸å¤Ï<i>config.php</i>¤ò½ñ¤­´¹¤¨¤ë¤À¤±¤Ç¤¹¡£°Ê²¼¤Ë½ñ¤­´¹¤¨¤ë¤Ù¤­ÆâÍƤòɽ¼¨¤·¤Þ¤¹¡Êmysql¤Î¥Ñ¥¹¥ï¡¼¥É¤Ï¥Þ¥¹¥¯¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¤³¤³¤Ï¼ÂºÝ¤Î¤â¤Î¤Ë½ñ¤­´¹¤¨¤Æ¤¯¤À¤µ¤¤¡Ë</p>
755
756                 <pre><code>&lt;?php
757         // mySQL connection information
758         $MYSQL_HOST = '<b><?php echo $mysql_host?></b>';
759         $MYSQL_USER = '<b><?php echo $mysql_user?></b>';
760         $MYSQL_PASSWORD = '<i><b>xxxxxxxxxxx</b></i>';
761         $MYSQL_DATABASE = '<b><?php echo $mysql_database?></b>';
762         $MYSQL_PREFIX = '<b><?php echo ($mysql_usePrefix == 1)?$mysql_prefix:''?></b>';
763
764         // main nucleus directory
765         $DIR_NUCLEUS = '<b><?php echo $config_adminpath?></b>';
766
767         // path to media dir
768         $DIR_MEDIA = '<b><?php echo $config_mediapath?></b>';
769
770         // extra skin files for imported skins
771         $DIR_SKINS = '<b><?php echo $config_skinspath?></b>';
772
773         // these dirs are normally sub dirs of the nucleus dir, but
774         // you can redefine them if you wish
775         $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
776         $DIR_LANG = $DIR_NUCLEUS . 'language/';
777         $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
778
779         // include libs
780         include($DIR_LIBS.'globalfunctions.php');
781         if (!extension_loaded('mbstring')) {
782                 include($DIR_LIBS.'mb_emulator/mb-emulator.php');
783         }
784 ?&gt;</code></pre>
785
786         <p>¤¢¤Ê¤¿¤Î¥³¥ó¥Ô¥å¡¼¥¿¾å¤Î¥Õ¥¡¥¤¥ë¤ò½ñ¤­´¹¤¨¤¿¤é¡¢FTP¤ò»È¤Ã¤Æ¥¦¥§¥Ö¥µ¡¼¥Ð¤Ë¥¢¥Ã¥×¥í¡¼¥É¤·¤Æ¤¯¤À¤µ¤¤¡£ASCII¥â¡¼¥É¤ÇÁ÷¿®¤·¤Æ¥Õ¥¡¥¤¥ë¤ò¾å½ñ¤­¤·¤Þ¤¹¡£</p>
787
788         <div class="note">
789                 <b>ÉÕµ­:</b> <i>config.php</i>¤ÎºÇ½é¤ä½ª¤ï¤ê¤Ë¥¹¥Ú¡¼¥¹¤ò¶õ¤±¤Ê¤¤¤è¤¦¤Ë¤·¤Þ¤·¤ç¤¦¡£¼Â¹Ô»þ¤Ë¥¨¥é¡¼¤ò°ú¤­µ¯¤³¤¹¸¶°ø¤È¤Ê¤ê¤Þ¤¹¡£<br />
790                 ¤·¤¿¤¬¤Ã¤Æ¡¢config.php¤ÎºÇ½é¤Îʸ»ú¤Ï "&lt;"¤ÇºÇ¸å¤Îʸ»ú¤Ï"&gt;"¤È¤·¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£
791         </div>
792
793 <?php } else { ?>
794
795         <h1>¥¤¥ó¥¹¥È¡¼¥ë¤Ï´°Î»¤·¤Þ¤·¤¿¡ª</h1>
796
797         <p>Nucleus¤Ï¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¡¢<code>config.php</code>¤Ï¥¢¥Ã¥×¥Ç¡¼¥È¤µ¤ì¤Þ¤·¤¿¡£</p>
798
799         <p>¥»¥­¥å¥ê¥Æ¥£¤Î¤¿¤á<code>config.php</code>¤Î¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤ò444¤ËÌ᤹¤³¤È¤ò˺¤ì¤Ê¤¤¤Ç¤¯¤À¤µ¤¤(<a href="nucleus/documentation/tips.html#filepermissions">¥Ñ¡¼¥ß¥Ã¥·¥ç¥óÊѹ¹¤Î´Ê°×¥¬¥¤¥É</a>)¡£</p>
800
801 <?php } ?>
802
803         <h1>¥¤¥ó¥¹¥È¡¼¥ë¥Õ¥¡¥¤¥ë¤Îºï½ü</h1>
804
805         <p>¥¦¥§¥Ö¥µ¡¼¥Ð¤«¤é¼¡¤Î¥Õ¥¡¥¤¥ë¤òºï½ü¤·¤Æ¤¯¤À¤µ¤¤¡§</p>
806
807         <ul>
808                 <li><b>install.sql</b>¡§¥Æ¡¼¥Ö¥ë¤Î¹½Â¤¤òÆâÊñ¤¹¤ë¥Õ¥¡¥¤¥ë</li>
809                 <li><b>install.php</b>¡§¤³¤Î¥Õ¥¡¥¤¥ë</li>
810         </ul>
811
812         <p>¤â¤·¤³¤ì¤é¤Î¥Õ¥¡¥¤¥ë¤òºï½ü¤·¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢´ÉÍýÎΰè¤ò³«¤¯¤³¤È¤¬½ÐÍè¤Þ¤»¤ó¡£</p>
813
814         <h1>¥¦¥§¥Ö¥µ¥¤¥È¤Î³Îǧ</h1>
815
816         <p>¥¦¥§¥Ö¥µ¥¤¥È¤ò»È¤¦½àÈ÷¤¬À°¤¤¤Þ¤·¤¿¡£
817                 <ul>
818                         <li><a href="<?php echo $config_adminurl?>">´ÉÍýÎΰè¤Ë¥í¥°¥¤¥ó¤·¤Æ¥µ¥¤¥È¤ÎÀßÄê¤ò¹Ô¤¦</a></li>
819                         <li><a href="<?php echo $config_indexurl?>">¤¹¤°¤Ë¥µ¥¤¥È¤Ø¹Ô¤Ã¤Æ¤ß¤ë</a></li>
820                 </ul>
821         </p>
822
823 </body>
824 </html>
825
826 <?php
827 }
828
829 function installCustomPlugs(&$manager) {
830         global $aConfPlugsToInstall, $DIR_LIBS;
831
832         $aErrors = array();
833
834         if (count($aConfPlugsToInstall) == 0) {
835                 return $aErrors;
836         }
837
838         $res = sql_query('SELECT * FROM ' . sql_table('plugin') );
839         $numCurrent = mysql_num_rows($res);
840
841         foreach ($aConfPlugsToInstall as $plugName) {
842                 // do this before calling getPlugin (in case the plugin id is used there)
843                 $query = 'INSERT INTO ' . sql_table('plugin') . ' (porder, pfile) VALUES (' . (++$numCurrent) . ', "' . addslashes($plugName) . '")';
844                 sql_query($query);
845
846                 // get and install the plugin
847                 $plugin =& $manager->getPlugin($plugName);
848
849                 if (!$plugin) {
850                         sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pfile=\'' . addslashes($plugName) . '\'');
851                         $numCurrent--;
852                         array_push($aErrors, 'Unable to install plugin ' . $plugName);
853                         continue;
854                 }
855
856                 $plugin->install();
857         }
858
859         // SYNC PLUGIN EVENT LIST
860         sql_query('DELETE FROM ' . sql_table('plugin_event') );
861
862         // loop over all installed plugins
863         $res = sql_query('SELECT pid, pfile FROM ' . sql_table('plugin') );
864
865         while($o = mysql_fetch_object($res) ) {
866                 $pid = $o->pid;
867                 $plug =& $manager->getPlugin($o->pfile);
868
869                 if ($plug) {
870                         $eventList = $plug->getEventList();
871
872                         foreach ($eventList as $eventName) {
873                                 sql_query('INSERT INTO ' . sql_table('plugin_event') . ' (pid, event) VALUES (' . $pid . ', \'' . $eventName . '\')');
874                         }
875                 }
876         }
877
878         return $aErrors;
879 }
880
881 function installCustomSkins(&$manager) {
882         global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;
883
884         $aErrors = array();
885
886         if (count($aConfSkinsToImport) == 0) {
887                 return $aErrors;
888         }
889
890         // load skinie class
891         include_once($DIR_LIBS . 'skinie.php');
892
893         $importer = new SKINIMPORT();
894
895         foreach ($aConfSkinsToImport as $skinName) {
896                 $importer->reset();
897                 $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml';
898
899                 if (!@file_exists($skinFile) ) {
900                         array_push($aErrors, 'Unable to import ' . $skinFile . ' : file does not exist');
901                         continue;
902                 }
903
904                 $error = $importer->readFile($skinFile);
905
906                 if ($error) {
907                         array_push($aErrors, 'Unable to import ' . $skinName . ' : ' . $error);
908                         continue;
909                 }
910
911                 $error = $importer->writeToDatabase(1);
912
913                 if ($error) {
914                         array_push($aErrors, 'Unable to import ' . $skinName . ' : ' . $error);
915                         continue;
916                 }
917         }
918
919         return $aErrors;
920 }
921
922 // give an error if one or more nucleus are not accessible
923 function doCheckFiles() {
924         $missingfiles = array();
925         $files = array(
926                 'install.sql',
927                 'index.php',
928                 'action.php',
929                 'nucleus/index.php',
930                 'nucleus/libs/globalfunctions.php',
931                 'nucleus/libs/ADMIN.php',
932                 'nucleus/libs/BLOG.php',
933                 'nucleus/libs/COMMENT.php',
934                 'nucleus/libs/COMMENTS.php',
935                 'nucleus/libs/ITEM.php',
936                 'nucleus/libs/MEMBER.php',
937                 'nucleus/libs/SKIN.php',
938                 'nucleus/libs/TEMPLATE.php',
939                 'nucleus/libs/MEDIA.php',
940                 'nucleus/libs/ACTIONLOG.php',
941                 'nucleus/media.php'
942                 );
943
944         $count = count($files);
945
946         for ($i = 0; $i < $count; $i++) {
947                 if (!is_readable($files[$i]) ) {
948                         array_push($missingfiles, 'File <b>' . $files[$i] . '</b> is missing or not readable.');
949                 }
950         }
951
952 // The above code replaces several if statements of the form:
953
954 //      if (!is_readable('install.sql') ) {
955 //              array_push($missingfiles, 'File <b>install.sql</b> is missing or not readable');
956 //      }
957
958         if (count($missingfiles) > 0) {
959                 showErrorMessages($missingfiles);
960         }
961 }
962
963 function updateConfig($name, $val) {
964         $name = addslashes($name);
965         $val = trim(addslashes($val) );
966
967         $query = 'UPDATE ' . tableName('nucleus_config')
968                         . " SET value='$val'"
969                         . " WHERE name='$name'";
970
971         mysql_query($query) or _doError('Query error while trying to update config: ' . mysql_error() );
972         return mysql_insert_id();
973 }
974
975 function replaceDoubleBackslash($input) {
976         return str_replace('\\', '/', $input);
977 }
978
979 function endsWithSlash($s) {
980         return (strrpos($s, '/') == strlen($s) - 1);
981 }
982
983 /**
984  * Checks if email address is valid
985  */
986 function _isValidMailAddress($address) {
987         if (preg_match("/^[a-zA-Z0-9\._-]+@+[A-Za-z0-9\._-]+\.+[A-Za-z]{2,4}$/", $address) ) {
988                 return 1;
989         } else {
990                 return 0;
991         }
992 }
993
994 // returns true if the given string is a valid shortname
995 // (to check short blog names and nicknames)
996 // logic: starts and ends with a non space, can contain spaces in between
997 //        min 2 chars
998 function _isValidShortName($name) {
999         if (eregi("^[a-z0-9]+$", $name) ) {
1000                 return 1;
1001         } else {
1002                 return 0;
1003         }
1004 }
1005
1006
1007
1008 // returns true if the given string is a valid display name
1009 // (to check nicknames)
1010 function _isValidDisplayName($name) {
1011         if (eregi("^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$", $name) ) {
1012                 return 1;
1013         } else {
1014                 return 0;
1015         }
1016 }
1017
1018 function _doError($msg) {
1019         ?>
1020 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1021 <html xmlns="http://www.w3.org/1999/xhtml">
1022 <head>
1023         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
1024         <title>Nucleus Install</title>
1025         <style>@import url('nucleus/styles/manual.css');</style>
1026 </head>
1027 <body>
1028         <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
1029         <h1>Error!</h1>
1030
1031         <p>Error message was: "<?php echo $msg?>";</p>
1032
1033         <p><a href="install.php" onclick="history.back();return false;">Go Back</a></p>
1034 </body>
1035 </html>
1036
1037 <?php
1038         exit;
1039 }
1040
1041 function showErrorMessages($errors) {
1042         ?>
1043 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1044 <html xmlns="http://www.w3.org/1999/xhtml">
1045 <head>
1046         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
1047         <title>Nucleus Install</title>
1048         <style>@import url('nucleus/styles/manual.css');</style>
1049 </head>
1050 <body>
1051         <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
1052         <h1>Errors!</h1>
1053
1054         <p>Errors were found:</p>
1055
1056         <ul>
1057
1058 <?php
1059         while($msg = array_shift($errors) ) {
1060                 echo '<li>', $msg, '</li>';
1061         }
1062 ?>
1063
1064         </ul>
1065
1066         <p><a href="install.php" onclick="history.back();return false;">Go Back</a></p>
1067 </body>
1068 </html>
1069
1070 <?php
1071         exit;
1072 }
1073
1074 /* for the non-php systems that decide to show the contents:
1075 ?></div><?php   */
1076
1077 ?>